diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-05-23 08:18:28 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-05-23 08:18:28 +0000 |
commit | 39dcd561255d9c1b438c618c9810a1b39eeb3d65 (patch) | |
tree | dcb67742d4f052c7f614c11cedc45bfef85a0af1 /connectivity | |
parent | c6431349f002d326d811070c29534e12efbe53de (diff) |
#86528# disable exception in some files
Diffstat (limited to 'connectivity')
57 files changed, 3727 insertions, 4283 deletions
diff --git a/connectivity/inc/connectivity/DateConversion.hxx b/connectivity/inc/connectivity/DateConversion.hxx index 100a45923913..63be082b7975 100644 --- a/connectivity/inc/connectivity/DateConversion.hxx +++ b/connectivity/inc/connectivity/DateConversion.hxx @@ -2,9 +2,9 @@ * * $RCSfile: DateConversion.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2000-09-29 14:53:23 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:15:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -77,16 +77,56 @@ namespace connectivity class DateConversion { public: - static sal_Int32 toINT32(const ::com::sun::star::util::Date& rVal); - static sal_Int32 toINT32(const ::com::sun::star::util::Time& rVal); - static sal_Int64 toINT64(const ::com::sun::star::util::DateTime& rVal); - static sal_Int32 getMsFromTime(const ::com::sun::star::util::Time& rVal); - static double toDouble(const ::com::sun::star::util::Date& rVal); - static double toDouble(const ::com::sun::star::util::Time& rVal); - static double toDouble(const ::com::sun::star::util::DateTime& rVal); - static ::com::sun::star::util::Date toDate(double dVal,const ::com::sun::star::util::Date& _rSTANDARD_DB_DATE=::com::sun::star::util::Date(01,01,1900)); - static ::com::sun::star::util::Time toTime(double dVal); - static ::com::sun::star::util::DateTime toDateTime(double dVal,const ::com::sun::star::util::Date& _rSTANDARD_DB_DATE=::com::sun::star::util::Date(01,01,1900)); + static sal_Int32 toINT32(const ::com::sun::star::util::Date& rVal) + { + OSL_ENSURE(0,"Please use DBConversion instead!"); + return 0; + } + static sal_Int32 toINT32(const ::com::sun::star::util::Time& rVal) + { + OSL_ENSURE(0,"Please use DBConversion instead!"); + return 0; + } + static sal_Int64 toINT64(const ::com::sun::star::util::DateTime& rVal) + { + OSL_ENSURE(0,"Please use DBConversion instead!"); + return 0; + } + static sal_Int32 getMsFromTime(const ::com::sun::star::util::Time& rVal) + { + OSL_ENSURE(0,"Please use DBConversion instead!"); + return 0; + } + static double toDouble(const ::com::sun::star::util::Date& rVal) + { + OSL_ENSURE(0,"Please use DBConversion instead!"); + return 0; + } + static double toDouble(const ::com::sun::star::util::Time& rVal) + { + OSL_ENSURE(0,"Please use DBConversion instead!"); + return 0; + } + static double toDouble(const ::com::sun::star::util::DateTime& rVal) + { + OSL_ENSURE(0,"Please use DBConversion instead!"); + return 0; + } + static ::com::sun::star::util::Date toDate(double dVal,const ::com::sun::star::util::Date& _rSTANDARD_DB_DATE=::com::sun::star::util::Date(01,01,1900)) + { + OSL_ENSURE(0,"Please use DBConversion instead!"); + return ::com::sun::star::util::Date(); + } + static ::com::sun::star::util::Time toTime(double dVal) + { + OSL_ENSURE(0,"Please use DBConversion instead!"); + return ::com::sun::star::util::Time(); + } + static ::com::sun::star::util::DateTime toDateTime(double dVal,const ::com::sun::star::util::Date& _rSTANDARD_DB_DATE=::com::sun::star::util::Date(01,01,1900)) + { + OSL_ENSURE(0,"Please use DBConversion instead!"); + return ::com::sun::star::util::DateTime(); + } }; } #endif // _CONNECTIVITY_DATECONVERSION_HXX_ diff --git a/connectivity/inc/connectivity/sdbcx/VKey.hxx b/connectivity/inc/connectivity/sdbcx/VKey.hxx index af28d9e1709a..86b5306419ef 100644 --- a/connectivity/inc/connectivity/sdbcx/VKey.hxx +++ b/connectivity/inc/connectivity/sdbcx/VKey.hxx @@ -2,9 +2,9 @@ * * $RCSfile: VKey.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-04-30 10:13:37 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:15:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -141,7 +141,7 @@ namespace connectivity virtual void construct(); // ::cppu::OComponentHelper - virtual void SAL_CALL disposing(void); + virtual void SAL_CALL disposing(); // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); // XColumnsSupplier diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index 9a605e360e7f..6d3433b5d4ce 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -2,9 +2,9 @@ * * $RCSfile: sqlnode.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: jl $ $Date: 2001-03-20 16:46:48 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:15:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -389,6 +389,7 @@ namespace connectivity ::rtl::OUString convertDateTimeString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const; ::rtl::OUString convertDateString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const; ::rtl::OUString convertTimeString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const; + void parseLeaf(::rtl::OUString & rString, const SQLParseNodeParameter& rParam) const; }; //----------------------------------------------------------------------------- diff --git a/connectivity/source/commontools/CommonTools.cxx b/connectivity/source/commontools/CommonTools.cxx index 535e4c8fe76e..caa388e13afb 100644 --- a/connectivity/source/commontools/CommonTools.cxx +++ b/connectivity/source/commontools/CommonTools.cxx @@ -2,9 +2,9 @@ * * $RCSfile: CommonTools.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:50:43 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:15:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,6 +64,9 @@ #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ #include "connectivity/CommonTools.hxx" #endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include "connectivity/dbtools.hxx" +#endif #ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ #include <com/sun/star/util/Date.hpp> #endif @@ -85,9 +88,6 @@ #ifndef _CPPUHELPER_INTERFACECONTAINER_H_ #include <cppuhelper/interfacecontainer.h> #endif -#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ -#include <com/sun/star/lang/DisposedException.hpp> -#endif #ifndef CONNECTIVITY_CONNECTION_HXX #include "TConnection.hxx" #endif @@ -265,82 +265,79 @@ namespace connectivity } return aRes; } - // ------------------------------------------------------------------------- - OSQLColumns::const_iterator find( OSQLColumns::const_iterator __first, - OSQLColumns::const_iterator __last, - 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; - } - // ------------------------------------------------------------------------- - OSQLColumns::const_iterator findRealName( OSQLColumns::const_iterator __first, - OSQLColumns::const_iterator __last, - 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; - } - // ------------------------------------------------------------------------- - OSQLColumns::const_iterator find( OSQLColumns::const_iterator __first, - OSQLColumns::const_iterator __last, - const ::rtl::OUString& _rProp, - const ::rtl::OUString& _rVal, - const ::comphelper::UStringMixEqual& _rCase) - { - while (__first != __last && !_rCase(getString(Reference<XPropertySet>((*__first),UNO_QUERY)->getPropertyValue(_rProp)),_rVal)) - ++__first; - return __first; - } - void release(oslInterlockedCount& _refCount, - ::cppu::OBroadcastHelper& rBHelper, - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface, - ::com::sun::star::lang::XComponent* _pObject) - { - if (osl_decrementInterlockedCount( &_refCount ) == 0) - { - osl_incrementInterlockedCount( &_refCount ); - if (!rBHelper.bDisposed && !rBHelper.bInDispose) - { - // remember the parent - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xParent; - { - ::osl::MutexGuard aGuard( rBHelper.rMutex ); - xParent = _xInterface; - _xInterface = NULL; - } - // First dispose - _pObject->dispose(); +} + +#include <ctype.h> //isdigit +namespace dbtools +{ +sal_Bool isCharOk(char c,const ::rtl::OUString& _rSpecials); - // only the alive ref holds the object - OSL_ASSERT( _refCount == 1 ); +//------------------------------------------------------------------------------ +sal_Bool isValidSQLName(const ::rtl::OUString& rName,const ::rtl::OUString& _rSpecials) +{ + // berprfung auf korrekte Namensgebung im SQL Sinne + // Dieses ist wichtig fr Tabellennamen beispielsweise + ::rtl::OString aName(rName,rName.getLength(),RTL_TEXTENCODING_ASCII_US); + const char* pStr = aName.getStr(); + if (isdigit(*pStr)) + return sal_False; - // release the parent in the ~ - if (xParent.is()) - { - ::osl::MutexGuard aGuard( rBHelper.rMutex ); - _xInterface = xParent; - } + for (; *pStr; ++pStr ) + if(!isCharOk(*pStr,_rSpecials)) + return sal_False; -// // destroy the object if xHoldAlive decrement the refcount to 0 -// m_pDerivedImplementation->WEAK::release(); - } - } - else - osl_incrementInterlockedCount( &_refCount ); - } + if ( rName.getLength() + && ( (rName.toChar() == '_') + || ( (rName.toChar() >= '0') + && (rName.toChar() <= '9') + ) + ) + ) + return sal_False; + // the SQL-Standard requires the first character to be an alphabetic character, which + // isn't easy to decide in UniCode ... + // So we just prohibit the characters which already lead to problems .... + // 11.04.00 - 74902 - FS - void checkDisposed(sal_Bool _bThrow) throw ( DisposedException ) - { - if (_bThrow) - throw DisposedException(); + return sal_True; +} +//------------------------------------------------------------------ +sal_Bool isCharOk(char c,const ::rtl::OUString& _rSpecials) +{ - } + if ( ((c >= 97) && (c <= 122)) || ((c >= 65) && (c <= 90)) || ((c >= 48) && (c <= 57)) || + c == '_' || _rSpecials.indexOf(c) != -1) + return sal_True; + else + return sal_False; +} +//------------------------------------------------------------------ +// Erzeugt einen neuen Namen falls noetig +::rtl::OUString convertName2SQLName(const ::rtl::OUString& rName,const ::rtl::OUString& _rSpecials) +{ + if(isValidSQLName(rName,_rSpecials)) + return rName; + ::rtl::OUString aNewName(rName); + const sal_Unicode* pStr = rName.getStr(); + sal_Bool bValid(!isdigit(*pStr)); + for (; bValid && *pStr; pStr++ ) + if(!isCharOk(*pStr,_rSpecials)) + aNewName.replace(*pStr,'_'); + + return aNewName; } +//------------------------------------------------------------------------------ +::rtl::OUString quoteName(const ::rtl::OUString& _rQuote, const ::rtl::OUString& _rName) +{ + ::rtl::OUString sName = _rName; + if(_rQuote.getLength() && _rQuote.toChar() != ' ') + sName = _rQuote + _rName + _rQuote; + return sName; +} +// ----------------------------------------------------------------------------- + + +}
\ No newline at end of file diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx index 63beb8e81830..2a78e47786fe 100644 --- a/connectivity/source/commontools/DateConversion.cxx +++ b/connectivity/source/commontools/DateConversion.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DateConversion.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jl $ $Date: 2001-03-27 12:19:34 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:15:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,307 +68,4 @@ using namespace ::com::sun::star::util; using namespace ::com::sun::star::uno; -const double fMilliSecondsPerDay = 86400000.0; -const Date STANDARD_DB_DATE(1,1,1900); -static sal_Int32 aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30, - 31, 31, 30, 31, 30, 31 }; - -#define MAX_DAYS 3636532 -//------------------------------------------------------------------------------ -sal_Int32 DateConversion::toINT32(const Date& rVal) -{ - return ((sal_Int32)(rVal.Day%100)) + - (((sal_Int32)(rVal.Month%100))*100) + - (((sal_Int32) rVal.Year%10000)*10000); -} - -//------------------------------------------------------------------------------ -sal_Int32 DateConversion::toINT32(const Time& rVal) -{ - // Zeit normalisieren - sal_Int32 nSeconds = rVal.Seconds + rVal.HundredthSeconds / 100; - sal_Int32 nHundredthSeconds = rVal.HundredthSeconds % 100; - sal_Int32 nMinutes = rVal.Minutes + nSeconds / 60; - nSeconds = nSeconds % 60; - sal_Int32 nHours = rVal.Hours + nMinutes / 60; - nMinutes = nMinutes % 60; - - // Zeit zusammenbauen - return (sal_Int32)(nHundredthSeconds + (nSeconds*100) + (nMinutes*10000) + (nHours*1000000)); -} -//------------------------------------------------------------------------------ -sal_Int64 DateConversion::toINT64(const DateTime& rVal) -{ - // Zeit normalisieren - sal_Int32 nSeconds = rVal.Seconds + rVal.HundredthSeconds / 100; - sal_Int32 nHundredthSeconds = rVal.HundredthSeconds % 100; - sal_Int32 nMinutes = rVal.Minutes + nSeconds / 60; - nSeconds = nSeconds % 60; - sal_Int32 nHours = rVal.Hours + nMinutes / 60; - nMinutes = nMinutes % 60; - - // Zeit zusammenbauen - sal_Int32 nTime = (sal_Int32)(nHundredthSeconds + (nSeconds*100) + (nMinutes*10000) + (nHours*1000000)); - sal_Int32 nDate = ((sal_Int32)(rVal.Day%100)) + (((sal_Int32)(rVal.Month%100))*100) + (((sal_Int32) rVal.Year%10000)*10000); - sal_Int64 nRet; - - nRet = (sal_Int64) nTime; - nRet <<= 32; - nRet += nDate; - - return nRet; -} -//------------------------------------------------------------------------------ -sal_Int32 DateConversion::getMsFromTime(const Time& rVal) -{ - sal_Int16 nSign = (toINT32(rVal) >= 0) ? +1 : -1; - sal_Int32 nHour = rVal.Hours; - sal_Int32 nMin = rVal.Minutes; - sal_Int32 nSec = rVal.Seconds; - sal_Int32 n100Sec = rVal.HundredthSeconds; - - return (((nHour*3600000)+(nMin*60000)+(nSec*1000)+(n100Sec*10))*nSign); -} -//------------------------------------------------------------------------------ -double DateConversion::toDouble(const Date& rVal) -{ - return (double)toINT32(rVal); -} -//------------------------------------------------------------------------------ -double DateConversion::toDouble(const Time& rVal) -{ - return (double)getMsFromTime(rVal) / fMilliSecondsPerDay; -} -//------------------------------------------------------------------------------ -double DateConversion::toDouble(const DateTime& rVal) -{ - sal_Int64 nTime = toINT64(rVal); - sal_Int16 nSign = (nTime >= 0) ? +1 : -1; - sal_Int32 nHour = rVal.Hours; - sal_Int32 nMin = rVal.Minutes; - sal_Int32 nSec = rVal.Seconds; - sal_Int32 n100Sec = rVal.HundredthSeconds; - - double nVal = (((nHour*3600000)+(nMin*60000)+(nSec*1000)+(n100Sec*10))*nSign); - - return ((double)nTime) + (nVal * (1/fMilliSecondsPerDay)); -} -// ------------------------------------------------------------------------- -inline sal_Bool ImpIsLeapYear( sal_uInt16 nYear ) -{ - return (((nYear % 4) == 0) && ((nYear % 100) != 0) || ((nYear % 400) == 0)); -} -// ------------------------------------------------------------------------- -inline sal_uInt16 DaysInMonth( sal_uInt16 nMonth, sal_uInt16 nYear ) -{ - if ( nMonth != 2 ) - return aDaysInMonth[nMonth-1]; - else - { - if ( ((nYear % 4) == 0) && ((nYear % 100) != 0) || - ((nYear % 400) == 0) ) - return aDaysInMonth[nMonth-1] + 1; - else - return aDaysInMonth[nMonth-1]; - } -} -//------------------------------------------------------------------------------ -static void DaysToDate( sal_Int32 nDays, - sal_uInt16& rDay, sal_uInt16& rMonth, sal_uInt16& rYear ) -{ - sal_Int32 nTempDays; - sal_Int32 i = 0; - sal_Bool bCalc; - - do - { - nTempDays = nDays; - rYear = ((nTempDays / 365) - i); - nTempDays -= (rYear-1) * 365; - nTempDays -= ((rYear-1) / 4) - ((rYear-1) / 100) + ((rYear-1) / 400); - bCalc = sal_False; - if ( nTempDays < 1 ) - { - i++; - bCalc = sal_True; - } - else - { - if ( nTempDays > 365 ) - { - if ( (nTempDays != 366) || !ImpIsLeapYear( rYear ) ) - { - i--; - bCalc = sal_True; - } - } - } - } - while ( bCalc ); - - rMonth = 1; - while ( nTempDays > DaysInMonth( rMonth, rYear ) ) - { - nTempDays -= DaysInMonth( rMonth, rYear ); - rMonth++; - } - rDay = nTempDays; -} -// ------------------------------------------------------------------------- -static sal_Int32 DateToDays( sal_uInt16 nDay, sal_uInt16 nMonth, sal_uInt16 nYear ) -{ - sal_Int32 nDays; - - nDays = ((sal_Int32)nYear-1) * 365; - nDays += ((nYear-1) / 4) - ((nYear-1) / 100) + ((nYear-1) / 400); - for( sal_uInt16 i = 1; i < nMonth; i++ ) - nDays += DaysInMonth(i,nYear); - nDays += nDay; - return nDays; -} -// ------------------------------------------------------------------------- -static void addDays( sal_Int32 nDays ,Date& _rDate) -{ - sal_Int32 nTempDays = DateToDays( _rDate.Day, _rDate.Month, _rDate.Year ); - - nTempDays += nDays; - if ( nTempDays > MAX_DAYS ) - { - _rDate.Day = 31; - _rDate.Month = 12; - _rDate.Year = 9999; - } - else if ( nTempDays <= 0 ) - { - _rDate.Day = 1; - _rDate.Month = 1; - _rDate.Year = 00; - } - else - DaysToDate( nTempDays, _rDate.Day, _rDate.Month, _rDate.Year ); -} - -// ----------------------------------------------------------------------- - -static void subDays( sal_Int32 nDays,Date& _rDate ) -{ - sal_Int32 nTempDays = DateToDays( _rDate.Day, _rDate.Month, _rDate.Year ); - - nTempDays -= nDays; - if ( nTempDays > MAX_DAYS ) - { - _rDate.Day = 31; - _rDate.Month = 12; - _rDate.Year = 9999; - } - else if ( nTempDays <= 0 ) - { - _rDate.Day = 1; - _rDate.Month = 1; - _rDate.Year = 00; - } - else - DaysToDate( nTempDays, _rDate.Day, _rDate.Month, _rDate.Year ); -} - -// ------------------------------------------------------------------------- -Date DateConversion::toDate(double dVal,const Date& _rSTANDARD_DB_DATE) -{ - Date aRet = _rSTANDARD_DB_DATE; - // DaysToDate((sal_Int32)dVal,aRet.Day,aRet.Month,aRet.Year); - - if (dVal >= 0) - addDays((sal_Int32)dVal,aRet); - else - subDays((sal_uInt32)(-dVal),aRet); - // x -= (sal_uInt32)(-nDays); - - return aRet; -} -//------------------------------------------------------------------------------ -void MakeTimeFromMS( sal_Int32 nMS ) -{ - sal_uInt16 nSign; - if ( nMS < 0 ) - { - nMS *= -1; - nSign = -1; - } - else - nSign = 1; - - // Zeit normalisieren - sal_uInt16 n100Sec = nMS/10; - sal_uInt16 nSec = n100Sec / 100; - n100Sec = n100Sec % 100; - sal_uInt16 nMin = nSec / 60; - nSec = nSec % 60; - sal_uInt16 nHour = nMin / 60; - nMin = nMin % 60; - - // Zeit zusammenbauen - sal_Int32 nTime = (sal_Int32)(n100Sec + (nSec*100) + (nMin*10000) + (nHour*1000000)) * nSign; - - -} -// ------------------------------------------------------------------------- -Time DateConversion::toTime(double dVal) -{ - sal_Int32 nDays = (sal_Int32)dVal; - sal_Int32 nMS = sal_Int32((dVal - (double)nDays) * fMilliSecondsPerDay + 0.5); - - sal_uInt16 nSign; - if ( nMS < 0 ) - { - nMS *= -1; - nSign = -1; - } - else - nSign = 1; - - Time xRet; - // Zeit normalisieren - xRet.HundredthSeconds = nMS/10; - xRet.Seconds = xRet.HundredthSeconds / 100; - xRet.HundredthSeconds = xRet.HundredthSeconds % 100; - xRet.Minutes = xRet.Seconds / 60; - xRet.Seconds = xRet.Seconds % 60; - xRet.Hours = xRet.Minutes / 60; - xRet.Minutes = xRet.Minutes % 60; - - // Zeit zusammenbauen - sal_Int32 nTime = (sal_Int32)(xRet.HundredthSeconds + (xRet.Seconds*100) + (xRet.Minutes*10000) + (xRet.Hours*1000000)) * nSign; - - if(nTime < 0) - { - xRet.HundredthSeconds = 99; - xRet.Minutes = 59; - xRet.Seconds = 59; - xRet.Hours = 23; - } - return xRet; - -} -//------------------------------------------------------------------------------ -DateTime DateConversion::toDateTime(double dVal,const Date& _rSTANDARD_DB_DATE) -{ - Date aDate = DateConversion::toDate(dVal,_rSTANDARD_DB_DATE); - Time aTime = DateConversion::toTime(dVal); - - - DateTime xRet; - - xRet.Day = aDate.Day; - xRet.Month = aDate.Month; - xRet.Year = aDate.Year; - - xRet.HundredthSeconds = aTime.HundredthSeconds; - xRet.Minutes = aTime.Minutes; - xRet.Seconds = aTime.Seconds; - xRet.Hours = aTime.Hours; - - - return xRet; -} -//------------------------------------------------------------------------------ diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx index b216e8d627c6..a90071cc4706 100644 --- a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx +++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FDatabaseMetaDataResultSet.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: oj $ $Date: 2001-05-17 07:27:04 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:15:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -208,6 +208,12 @@ sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const ::rtl::OUString break; return i; } +// ----------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException) +{ + if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) + ::dbtools::throwInvalidIndexException(*this); +} // ------------------------------------------------------------------------- Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { @@ -217,8 +223,8 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResult if(m_aRowsIter == m_aRows.end()) return NULL; - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; return NULL; @@ -233,8 +239,8 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResult if(m_aRowsIter == m_aRows.end()) return NULL; - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; return NULL; @@ -249,8 +255,8 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex if(m_aRowsIter == m_aRows.end()) return sal_False; - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; return (*m_aRowsIter)[columnIndex]; } @@ -264,8 +270,8 @@ sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) t if(m_aRowsIter == m_aRows.end()) return 0; - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; return (*m_aRowsIter)[columnIndex]; @@ -280,8 +286,8 @@ Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 co if(m_aRowsIter == m_aRows.end()) return Sequence< sal_Int8 >(); - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; ; @@ -297,8 +303,8 @@ Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 co if(m_aRowsIter == m_aRows.end()) return ::com::sun::star::util::Date(0,0,0); - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; ; @@ -314,8 +320,8 @@ double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) t if(m_aRowsIter == m_aRows.end()) return 0.0; - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; ; @@ -332,8 +338,8 @@ float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) thr if(m_aRowsIter == m_aRows.end()) return 0.0; - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; ; @@ -350,8 +356,8 @@ sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) t if(m_aRowsIter == m_aRows.end()) return 0; - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; ; @@ -378,8 +384,8 @@ sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex ) if(m_aRowsIter == m_aRows.end()) return sal_Int64(); - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; ; @@ -407,8 +413,8 @@ Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 col if(m_aRowsIter == m_aRows.end()) return NULL; - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; return NULL; @@ -424,8 +430,8 @@ Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 colum if(m_aRowsIter == m_aRows.end()) return NULL; - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; return NULL; @@ -439,8 +445,8 @@ Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 colum if(m_aRowsIter == m_aRows.end()) return NULL; - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; return NULL; @@ -455,8 +461,8 @@ Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 columnI if(m_aRowsIter == m_aRows.end()) return NULL; - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; return NULL; @@ -471,8 +477,8 @@ Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const if(m_aRowsIter == m_aRows.end()) return Any(); - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; return (*m_aRowsIter)[columnIndex].makeAny(); } @@ -486,8 +492,8 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) if(m_aRowsIter == m_aRows.end()) return 0; - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; return (*m_aRowsIter)[columnIndex]; @@ -503,8 +509,8 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) if(m_aRowsIter == m_aRows.end()) return ::rtl::OUString(); - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; @@ -523,8 +529,8 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) if(m_aRowsIter == m_aRows.end()) return ::com::sun::star::util::Time(0,0,0,0); - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; ; @@ -543,8 +549,8 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) if(m_aRowsIter == m_aRows.end()) return ::com::sun::star::util::DateTime(0,0,0,0,0,0,0); - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) - ::dbtools::throwInvalidIndexException(*this); + checkIndex(columnIndex ); + m_nColPos = columnIndex; ; diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 660550286329..8879047fa21d 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dbtools.cxx,v $ * - * $Revision: 1.27 $ + * $Revision: 1.28 $ * - * last change: $Author: oj $ $Date: 2001-05-21 09:06:17 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:15:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -166,6 +166,13 @@ #ifndef CONNECTIVITY_CONNECTION_HXX #include "TConnection.hxx" #endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + using namespace ::comphelper; using namespace ::com::sun::star::uno; @@ -544,16 +551,6 @@ SQLContext prependContextInfo(SQLException& _rException, const Reference< XInter SQLContext aContextDescription(_rContextDescription, _rxContext, ::rtl::OUString(), 0, aInfo.get(), _rContextDetails); return aContextDescription; } - -//------------------------------------------------------------------------------ -::rtl::OUString quoteName(const ::rtl::OUString& _rQuote, const ::rtl::OUString& _rName) -{ - ::rtl::OUString sName = _rName; - if(_rQuote.getLength() && _rQuote.toChar() != ' ') - sName = _rQuote + _rName + _rQuote; - return sName; -} - //------------------------------------------------------------------------------ ::rtl::OUString quoteTableName(const Reference< XDatabaseMetaData>& _rxMeta, const ::rtl::OUString& _rName) { @@ -1130,63 +1127,6 @@ sal_Int32 getSearchColumnFlag( const Reference< XConnection>& _rxConn,sal_Int32 } return sName; } -sal_Bool isCharOk(char c,const ::rtl::OUString& _rSpecials); -#include <ctype.h> //isdigit -//------------------------------------------------------------------------------ -sal_Bool isValidSQLName(const ::rtl::OUString& rName,const ::rtl::OUString& _rSpecials) -{ - // berprfung auf korrekte Namensgebung im SQL Sinne - // Dieses ist wichtig fr Tabellennamen beispielsweise - ::rtl::OString aName(rName,rName.getLength(),RTL_TEXTENCODING_ASCII_US); - const char* pStr = aName.getStr(); - if (isdigit(*pStr)) - return sal_False; - - for (; *pStr; ++pStr ) - if(!isCharOk(*pStr,_rSpecials)) - return sal_False; - - if ( rName.getLength() - && ( (rName.toChar() == '_') - || ( (rName.toChar() >= '0') - && (rName.toChar() <= '9') - ) - ) - ) - return sal_False; - // the SQL-Standard requires the first character to be an alphabetic character, which - // isn't easy to decide in UniCode ... - // So we just prohibit the characters which already lead to problems .... - // 11.04.00 - 74902 - FS - - return sal_True; -} -//------------------------------------------------------------------ -sal_Bool isCharOk(char c,const ::rtl::OUString& _rSpecials) -{ - - if ( ((c >= 97) && (c <= 122)) || ((c >= 65) && (c <= 90)) || ((c >= 48) && (c <= 57)) || - c == '_' || _rSpecials.indexOf(c) != -1) - return sal_True; - else - return sal_False; -} -//------------------------------------------------------------------ -// Erzeugt einen neuen Namen falls noetig -::rtl::OUString convertName2SQLName(const ::rtl::OUString& rName,const ::rtl::OUString& _rSpecials) -{ - if(isValidSQLName(rName,_rSpecials)) - return rName; - ::rtl::OUString aNewName(rName); - const sal_Unicode* pStr = rName.getStr(); - sal_Bool bValid(!isdigit(*pStr)); - for (; bValid && *pStr; pStr++ ) - if(!isCharOk(*pStr,_rSpecials)) - aNewName.replace(*pStr,'_'); - - return aNewName; -} - // ----------------------------------------------------------------------------- void showError(const SQLExceptionInfo& _rInfo, const Reference< XWindow>& _xParent, @@ -1212,15 +1152,98 @@ void showError(const SQLExceptionInfo& _rInfo, } } } - //......................................................................... } // namespace dbtools //......................................................................... +namespace connectivity +{ +void release(oslInterlockedCount& _refCount, + ::cppu::OBroadcastHelper& rBHelper, + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface, + ::com::sun::star::lang::XComponent* _pObject) +{ + if (osl_decrementInterlockedCount( &_refCount ) == 0) + { + osl_incrementInterlockedCount( &_refCount ); + if (!rBHelper.bDisposed && !rBHelper.bInDispose) + { + // remember the parent + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xParent; + { + ::osl::MutexGuard aGuard( rBHelper.rMutex ); + xParent = _xInterface; + _xInterface = NULL; + } + + // First dispose + _pObject->dispose(); + + // only the alive ref holds the object + OSL_ASSERT( _refCount == 1 ); + + // release the parent in the ~ + if (xParent.is()) + { + ::osl::MutexGuard aGuard( rBHelper.rMutex ); + _xInterface = xParent; + } + +// // destroy the object if xHoldAlive decrement the refcount to 0 +// m_pDerivedImplementation->WEAK::release(); + } + } + else + osl_incrementInterlockedCount( &_refCount ); +} + +void checkDisposed(sal_Bool _bThrow) throw ( DisposedException ) +{ + if (_bThrow) + throw DisposedException(); + +} +// ------------------------------------------------------------------------- + OSQLColumns::const_iterator find( OSQLColumns::const_iterator __first, + OSQLColumns::const_iterator __last, + 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; + } + // ------------------------------------------------------------------------- + OSQLColumns::const_iterator findRealName( OSQLColumns::const_iterator __first, + OSQLColumns::const_iterator __last, + 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; + } + // ------------------------------------------------------------------------- + OSQLColumns::const_iterator find( OSQLColumns::const_iterator __first, + OSQLColumns::const_iterator __last, + const ::rtl::OUString& _rProp, + const ::rtl::OUString& _rVal, + const ::comphelper::UStringMixEqual& _rCase) + { + while (__first != __last && !_rCase(getString(Reference<XPropertySet>((*__first),UNO_QUERY)->getPropertyValue(_rProp)),_rVal)) + ++__first; + return __first; + } +// ----------------------------------------------------------------------------- +} //namespace connexctivity +// ----------------------------------------------------------------------------- /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.27 2001/05/21 09:06:17 oj + * #87050# composeTableName corrected + * * Revision 1.26 2001/05/17 07:27:04 oj * #86528# size changes * diff --git a/connectivity/source/commontools/makefile.mk b/connectivity/source/commontools/makefile.mk index 35e73a8f1543..59a309869be3 100644 --- a/connectivity/source/commontools/makefile.mk +++ b/connectivity/source/commontools/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.13 $ +# $Revision: 1.14 $ # -# last change: $Author: oj $ $Date: 2001-04-27 10:08:34 $ +# last change: $Author: oj $ $Date: 2001-05-23 09:15:42 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -86,9 +86,19 @@ SLOFILES=\ $(SLO)$/FDatabaseMetaDataResultSetMetaData.obj \ $(SLO)$/FDatabaseMetaDataResultSet.obj \ $(SLO)$/FValue.obj \ - $(SLO)$/DateConversion.obj \ $(SLO)$/TDatabaseMetaDataBase.obj +EXCEPTIONSFILES=\ + $(SLO)$/TConnection.obj \ + $(SLO)$/conncleanup.obj \ + $(SLO)$/emptymetadata.obj \ + $(SLO)$/dbtools.obj \ + $(SLO)$/dbexception.obj \ + $(SLO)$/dbconversion.obj \ + $(SLO)$/FDatabaseMetaDataResultSet.obj \ + $(SLO)$/TDatabaseMetaDataBase.obj + + .IF "$(COM)"=="GCC" NOOPTFILES= \ $(SLO)$/dbexception.obj diff --git a/connectivity/source/drivers/ado/ADatabaseMetaData.cxx b/connectivity/source/drivers/ado/ADatabaseMetaData.cxx index 31052e3e5ab1..4bb4c1fb971e 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.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:48:07 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:15:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -99,65 +99,6 @@ using namespace com::sun::star::beans; using namespace com::sun::star::sdbc; -const int JET_ENGINETYPE_UNKNOWN = 0; -const int JET_ENGINETYPE_JET10 = 1; -const int JET_ENGINETYPE_JET11 = 2; -const int JET_ENGINETYPE_JET20 = 3; -const int JET_ENGINETYPE_JET3X = 4; -const int JET_ENGINETYPE_JET4X = 5; -const int JET_ENGINETYPE_DBASE3 = 10; -const int JET_ENGINETYPE_DBASE4 = 11; -const int JET_ENGINETYPE_DBASE5 = 12; -const int JET_ENGINETYPE_EXCEL30 = 20; -const int JET_ENGINETYPE_EXCEL40 = 21; -const int JET_ENGINETYPE_EXCEL50 = 22; -const int JET_ENGINETYPE_EXCEL80 = 23; -const int JET_ENGINETYPE_EXCEL90 = 24; -const int JET_ENGINETYPE_EXCHANGE4 = 30; -const int JET_ENGINETYPE_LOTUSWK1 = 40; -const int JET_ENGINETYPE_LOTUSWK3 = 41; -const int JET_ENGINETYPE_LOTUSWK4 = 42; -const int JET_ENGINETYPE_PARADOX3X = 50; -const int JET_ENGINETYPE_PARADOX4X = 51; -const int JET_ENGINETYPE_PARADOX5X = 52; -const int JET_ENGINETYPE_PARADOX7X = 53; -const int JET_ENGINETYPE_TEXT1X = 60; -const int JET_ENGINETYPE_HTML1X = 70; - -sal_Bool isJetEngine(sal_Int32 _nEngineType) -{ - sal_Bool bRet = sal_False; - switch(_nEngineType) - { - case JET_ENGINETYPE_UNKNOWN: - case JET_ENGINETYPE_JET10: - case JET_ENGINETYPE_JET11: - case JET_ENGINETYPE_JET20: - case JET_ENGINETYPE_JET3X: - case JET_ENGINETYPE_JET4X: - case JET_ENGINETYPE_DBASE3: - case JET_ENGINETYPE_DBASE4: - case JET_ENGINETYPE_DBASE5: - case JET_ENGINETYPE_EXCEL30: - case JET_ENGINETYPE_EXCEL40: - case JET_ENGINETYPE_EXCEL50: - case JET_ENGINETYPE_EXCEL80: - case JET_ENGINETYPE_EXCEL90: - case JET_ENGINETYPE_EXCHANGE4: - case JET_ENGINETYPE_LOTUSWK1: - case JET_ENGINETYPE_LOTUSWK3: - case JET_ENGINETYPE_LOTUSWK4: - case JET_ENGINETYPE_PARADOX3X: - case JET_ENGINETYPE_PARADOX4X: - case JET_ENGINETYPE_PARADOX5X: - case JET_ENGINETYPE_PARADOX7X: - case JET_ENGINETYPE_TEXT1X: - case JET_ENGINETYPE_HTML1X: - bRet = sal_True; - break; - } - return bRet; -} // using namespace connectivity; ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon) @@ -167,77 +108,7 @@ ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon) { } // ------------------------------------------------------------------------- -void ODatabaseMetaData::fillLiterals() throw(SQLException, RuntimeException) -{ - ADORecordset *pRecordset = NULL; - OLEVariant vtEmpty; - vtEmpty.setNoArg(); - m_pADOConnection->OpenSchema(adSchemaDBInfoLiterals,vtEmpty,vtEmpty,&pRecordset); - - ADOS::ThrowException(*m_pADOConnection,*this); - - OSL_ENSURE(pRecordset,"getMaxSize no resultset!"); - WpADORecordset aRecordset(pRecordset); - - aRecordset.MoveFirst(); - OLEVariant aValue; - sal_Int32 nRet = 0; - LiteralInfo aInfo; - while(!aRecordset.IsAtEOF()) - { - WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(aRecordset.GetFields()); - WpADOField aField(aFields.GetItem(1)); - aInfo.pwszLiteralValue = aField.get_Value(); - aField = aFields.GetItem(5); - aInfo.fSupported = aField.get_Value(); - aField = aFields.GetItem(6); - aInfo.cchMaxLen = aField.get_Value().getUInt32(); - - aField = aFields.GetItem(4); - sal_uInt32 nId = aField.get_Value().getUInt32(); - m_aLiteralInfo[nId] = aInfo; - - aRecordset.MoveNext(); - } - aRecordset.Close(); -} -// ------------------------------------------------------------------------- -sal_Int32 ODatabaseMetaData::getMaxSize(sal_uInt32 _nId) throw(SQLException, RuntimeException) -{ - if(!m_aLiteralInfo.size()) - fillLiterals(); - - sal_Int32 nSize = 0; - ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId); - if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported) - nSize = ((*aIter).second.cchMaxLen == (-1)) ? 0 : (*aIter).second.cchMaxLen; - return nSize; -} -// ------------------------------------------------------------------------- -sal_Bool ODatabaseMetaData::isCapable(sal_uInt32 _nId) throw(SQLException, RuntimeException) -{ - if(!m_aLiteralInfo.size()) - fillLiterals(); - sal_Bool bSupported = sal_False; - ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId); - if(aIter != m_aLiteralInfo.end()) - bSupported = (*aIter).second.fSupported; - return bSupported; -} - -// ------------------------------------------------------------------------- -::rtl::OUString ODatabaseMetaData::getLiteral(sal_uInt32 _nId) throw(SQLException, RuntimeException) -{ - if(!m_aLiteralInfo.size()) - fillLiterals(); - ::rtl::OUString sStr; - ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId); - if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported) - sStr = (*aIter).second.pwszLiteralValue; - return sStr; -} -// ------------------------------------------------------------------------- -sal_Int32 ODatabaseMetaData::getInt32Property(const ::rtl::OUString& _aProperty) throw(SQLException, RuntimeException) +sal_Int32 ODatabaseMetaData::getInt32Property(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { WpOLEAppendCollection<ADOProperties, ADOProperty, WpADOProperty> aProps(m_pADOConnection->get_Properties()); // ADOS::ThrowException(*m_pADOConnection,*this); @@ -250,7 +121,7 @@ sal_Int32 ODatabaseMetaData::getInt32Property(const ::rtl::OUString& _aProperty) } // ------------------------------------------------------------------------- -sal_Bool ODatabaseMetaData::getBoolProperty(const ::rtl::OUString& _aProperty) throw(SQLException, RuntimeException) +sal_Bool ODatabaseMetaData::getBoolProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { WpOLEAppendCollection<ADOProperties, ADOProperty, WpADOProperty> aProps(m_pADOConnection->get_Properties()); ADOS::ThrowException(*m_pADOConnection,*this); @@ -259,7 +130,7 @@ sal_Bool ODatabaseMetaData::getBoolProperty(const ::rtl::OUString& _aProperty) t return (!aVar.isNull() && !aVar.isEmpty() ? aVar.getBool() : sal_False); } // ------------------------------------------------------------------------- -::rtl::OUString ODatabaseMetaData::getStringProperty(const ::rtl::OUString& _aProperty) throw(SQLException, RuntimeException) +::rtl::OUString ODatabaseMetaData::getStringProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { WpOLEAppendCollection<ADOProperties, ADOProperty, WpADOProperty> aProps(m_pADOConnection->get_Properties()); ADOS::ThrowException(*m_pADOConnection,*this); @@ -272,36 +143,13 @@ sal_Bool ODatabaseMetaData::getBoolProperty(const ::rtl::OUString& _aProperty) t return aValue; } - // ------------------------------------------------------------------------- Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException) { - HRESULT hr = S_OK; - // Create elements used in the array - OLEVariant varCriteria[2]; - const int nCrit = sizeof varCriteria / sizeof varCriteria[0]; - // Create SafeArray Bounds and initialize the array - SAFEARRAYBOUND rgsabound[1]; - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = nCrit; - SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); - - sal_Int32 nPos = 0; - SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++; - SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++; - - // Initialize and fill the SafeArray - OLEVariant vsa; - vsa.setArray(psa,VT_VARIANT); - - OLEVariant aEmpty; - aEmpty.setNoArg(); - - ADORecordset *pRec=NULL; - m_pADOConnection->OpenSchema(adSchemaProviderTypes,vsa,aEmpty,&pRec); + ADORecordset *pRecordset = m_pADOConnection->getTypeInfo(); // ADOS::ThrowException(*m_pADOConnection,*this); - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRec); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); pResult->setTypeInfoMap(); Reference< XResultSet > xRef = pResult; return xRef; @@ -351,41 +199,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges( const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) { - // Create elements used in the array - HRESULT hr = S_OK; - SAFEARRAYBOUND rgsabound[1]; - SAFEARRAY *psa = NULL; - OLEVariant varCriteria[4]; - - // Create SafeArray Bounds and initialize the array - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; - psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); - - sal_Int32 nPos=0; - if(catalog.hasValue()) - varCriteria[nPos].setString(getString(catalog)); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - if(schema.toChar() != '%') - varCriteria[nPos].setString(schema); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - - varCriteria[nPos].setString(table); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - varCriteria[nPos].setString(columnNamePattern); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME - - OLEVariant vtEmpty; - vtEmpty.setNoArg(); - - // Initialize and fill the SafeArray - OLEVariant vsa; - vsa.setArray(psa,VT_VARIANT); - - ADORecordset *pRecordset = NULL; - m_pADOConnection->OpenSchema(adSchemaColumnPrivileges,vsa,vtEmpty,&pRecordset); + ADORecordset *pRecordset = m_pADOConnection->getColumnPrivileges(catalog,schema,table,columnNamePattern); ADOS::ThrowException(*m_pADOConnection,*this); Reference< XResultSet > xRef = NULL; @@ -400,42 +214,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) { - // Create elements used in the array - HRESULT hr = S_OK; - SAFEARRAYBOUND rgsabound[1]; - SAFEARRAY *psa = NULL; - OLEVariant varCriteria[4]; - - // Create SafeArray Bounds and initialize the array - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; - psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); - - sal_Int32 nPos=0; - if(catalog.hasValue()) - varCriteria[nPos].setString(getString(catalog)); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - if(schemaPattern.toChar() != '%') - varCriteria[nPos].setString(schemaPattern); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - - if(tableNamePattern.toChar() != '%') - varCriteria[nPos].setString(tableNamePattern); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - varCriteria[nPos].setString(columnNamePattern); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME - - OLEVariant vtEmpty; - vtEmpty.setNoArg(); - - // Initialize and fill the SafeArray - OLEVariant vsa; - vsa.setArray(psa,VT_VARIANT); - - ADORecordset *pRecordset = NULL; - m_pADOConnection->OpenSchema(adSchemaColumns,vsa,vtEmpty,&pRecordset); + ADORecordset *pRecordset = m_pADOConnection->getColumns(catalog,schemaPattern,tableNamePattern,columnNamePattern); ADOS::ThrowException(*m_pADOConnection,*this); Reference< XResultSet > xRef = NULL; @@ -451,52 +230,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException) { - // Create elements used in the array - HRESULT hr = S_OK; - SAFEARRAYBOUND rgsabound[1]; - SAFEARRAY *psa = NULL; - OLEVariant varCriteria[4]; - - // Create SafeArray Bounds and initialize the array - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; - psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); - - sal_Int32 nPos=0; - if(catalog.hasValue()) - varCriteria[nPos].setString(getString(catalog)); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - if(schemaPattern.toChar() != '%') - varCriteria[nPos].setString(schemaPattern); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - if(tableNamePattern.toChar() != '%') - varCriteria[nPos].setString(tableNamePattern); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - ::rtl::OUString aTypes,aComma = ::rtl::OUString::createFromAscii(","); - const ::rtl::OUString* pBegin = types.getConstArray(); - const ::rtl::OUString* pEnd = pBegin + types.getLength(); - for(;pBegin != pEnd;++pBegin) - aTypes = aTypes + *pBegin + aComma; - - if(aTypes.getLength()) - varCriteria[nPos].setString(aTypes); - // else - // varCriteria[nPos].setString(::rtl::OUString::createFromAscii("TABLE")); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_TYPE - - OLEVariant vtEmpty; - vtEmpty.setNoArg(); - - // Initialize and fill the SafeArray - OLEVariant vsa; - vsa.setArray(psa,VT_VARIANT); - - ADORecordset *pRecordset = NULL; - m_pADOConnection->OpenSchema(adSchemaTables,vsa,vtEmpty,&pRecordset); + ADORecordset *pRecordset = m_pADOConnection->getTables(catalog,schemaPattern,tableNamePattern,types); ADOS::ThrowException(*m_pADOConnection,*this); Reference< XResultSet > xRef = NULL; @@ -512,43 +246,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) { - // Create elements used in the array - HRESULT hr = S_OK; - SAFEARRAYBOUND rgsabound[1]; - SAFEARRAY *psa = NULL; - OLEVariant varCriteria[4]; - - // Create SafeArray Bounds and initialize the array - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; - psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); - - sal_Int32 nPos=0; - if(catalog.hasValue()) - varCriteria[nPos].setString(getString(catalog)); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - if(schemaPattern.toChar() != '%') - varCriteria[nPos].setString(schemaPattern); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - - if(procedureNamePattern.toChar() != '%') - varCriteria[nPos].setString(procedureNamePattern); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - if(columnNamePattern.toChar() != '%') - varCriteria[nPos].setString(columnNamePattern); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME - - OLEVariant vtEmpty; - vtEmpty.setNoArg(); - - // Initialize and fill the SafeArray - OLEVariant vsa; - vsa.setArray(psa,VT_VARIANT); - - ADORecordset *pRecordset = NULL; - m_pADOConnection->OpenSchema(adSchemaProcedureParameters,vsa,vtEmpty,&pRecordset); + ADORecordset *pRecordset = m_pADOConnection->getProcedureColumns(catalog,schemaPattern,procedureNamePattern,columnNamePattern); ADOS::ThrowException(*m_pADOConnection,*this); Reference< XResultSet > xRef = NULL; @@ -565,38 +263,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures( const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException) { // Create elements used in the array - HRESULT hr = S_OK; - SAFEARRAYBOUND rgsabound[1]; - SAFEARRAY *psa = NULL; - OLEVariant varCriteria[3]; - - // Create SafeArray Bounds and initialize the array - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; - psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); - - sal_Int32 nPos=0; - if(catalog.hasValue()) - varCriteria[nPos].setString(getString(catalog)); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - if(schemaPattern.toChar() != '%') - varCriteria[nPos].setString(schemaPattern); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - - if(procedureNamePattern.toChar() != '%') - varCriteria[nPos].setString(procedureNamePattern); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - OLEVariant vtEmpty; - vtEmpty.setNoArg(); - - // Initialize and fill the SafeArray - OLEVariant vsa; - vsa.setArray(psa,VT_VARIANT); - - ADORecordset *pRecordset = NULL; - m_pADOConnection->OpenSchema(adSchemaProcedures,vsa,vtEmpty,&pRecordset); + ADORecordset *pRecordset = m_pADOConnection->getProcedures(catalog,schemaPattern,procedureNamePattern); ADOS::ThrowException(*m_pADOConnection,*this); Reference< XResultSet > xRef = NULL; @@ -678,46 +345,10 @@ sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTablesInSelect( ) throw(SQLExceptio Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys( const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) { - // Create elements used in the array - HRESULT hr = S_OK; - SAFEARRAYBOUND rgsabound[1]; - SAFEARRAY *psa = NULL; - OLEVariant varCriteria[6]; - - // Create SafeArray Bounds and initialize the array - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; - psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); - - sal_Int32 nPos=0; - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - if(catalog.hasValue()) - varCriteria[nPos].setString(getString(catalog)); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - if(schema.toChar() != '%') - varCriteria[nPos].setString(schema); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - - varCriteria[nPos].setString(table); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - OLEVariant vtEmpty; - vtEmpty.setNoArg(); - - // Initialize and fill the SafeArray - OLEVariant vsa; - vsa.setArray(psa,VT_VARIANT); - - ADORecordset *pRecordset = NULL; - m_pADOConnection->OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset); + ADORecordset *pRecordset = m_pADOConnection->getExportedKeys(catalog,schema,table); ADOS::ThrowException(*m_pADOConnection,*this); Reference< XResultSet > xRef = NULL; - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); pResult->setCrossReferenceMap(); xRef = pResult; @@ -728,42 +359,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys( Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys( const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) { - // Create elements used in the array - HRESULT hr = S_OK; - SAFEARRAYBOUND rgsabound[1]; - SAFEARRAY *psa = NULL; - OLEVariant varCriteria[6]; - - // Create SafeArray Bounds and initialize the array - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; - psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); - - sal_Int32 nPos=0; - if(catalog.hasValue()) - varCriteria[nPos].setString(getString(catalog)); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - if(schema.toChar() != '%') - varCriteria[nPos].setString(schema); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - - varCriteria[nPos].setString(table); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - OLEVariant vtEmpty; - vtEmpty.setNoArg(); - - // Initialize and fill the SafeArray - OLEVariant vsa; - vsa.setArray(psa,VT_VARIANT); - - ADORecordset *pRecordset = NULL; - m_pADOConnection->OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset); + ADORecordset *pRecordset = m_pADOConnection->getImportedKeys(catalog,schema,table); ADOS::ThrowException(*m_pADOConnection,*this); Reference< XResultSet > xRef = NULL; @@ -778,39 +374,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys( Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys( const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) { - // Create elements used in the array - HRESULT hr = S_OK; - SAFEARRAYBOUND rgsabound[1]; - SAFEARRAY *psa = NULL; - OLEVariant varCriteria[3]; - - // Create SafeArray Bounds and initialize the array - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; - psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); - - sal_Int32 nPos=0; - if(catalog.hasValue()) - varCriteria[nPos].setString(getString(catalog)); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - if(schema.toChar() != '%') - varCriteria[nPos].setString(schema); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - - varCriteria[nPos].setString(table); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - - OLEVariant vtEmpty; - vtEmpty.setNoArg(); - - // Initialize and fill the SafeArray - OLEVariant vsa; - vsa.setArray(psa,VT_VARIANT); - - ADORecordset *pRecordset = NULL; - m_pADOConnection->OpenSchema(adSchemaPrimaryKeys,vsa,vtEmpty,&pRecordset); + ADORecordset *pRecordset = m_pADOConnection->getPrimaryKeys(catalog,schema,table); ADOS::ThrowException(*m_pADOConnection,*this); Reference< XResultSet > xRef = NULL; @@ -826,42 +390,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo( const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException) { - // Create elements used in the array - HRESULT hr = S_OK; - SAFEARRAYBOUND rgsabound[1]; - SAFEARRAY *psa = NULL; - OLEVariant varCriteria[5]; - - // Create SafeArray Bounds and initialize the array - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; - psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); - - sal_Int32 nPos=0; - if(catalog.hasValue()) - varCriteria[nPos].setString(getString(catalog)); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - if(schema.toChar() != '%') - varCriteria[nPos].setString(schema); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// INDEX_NAME - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TYPE - - varCriteria[nPos].setString(table); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - OLEVariant vtEmpty; - vtEmpty.setNoArg(); - - // Initialize and fill the SafeArray - OLEVariant vsa; - vsa.setArray(psa,VT_VARIANT); - - ADORecordset *pRecordset = NULL; - m_pADOConnection->OpenSchema(adSchemaIndexes,vsa,vtEmpty,&pRecordset); + ADORecordset *pRecordset = m_pADOConnection->getIndexInfo(catalog,schema,table,unique,approximate); ADOS::ThrowException(*m_pADOConnection,*this); Reference< XResultSet > xRef = NULL; @@ -890,44 +419,11 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( sal_Int32 nEngineType = getInt32Property(::rtl::OUString::createFromAscii("Jet OLEDB:Engine Type")); Reference< XResultSet > xRef = NULL; - if(!isJetEngine(nEngineType)) + if(!ADOS::isJetEngine(nEngineType)) { // the jet provider doesn't support this method // Create elements used in the array - HRESULT hr = S_OK; - SAFEARRAYBOUND rgsabound[1]; - SAFEARRAY *psa = NULL; - OLEVariant varCriteria[5]; - - // Create SafeArray Bounds and initialize the array - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; - psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); - - sal_Int32 nPos=0; - if(catalog.hasValue()) - varCriteria[nPos].setString(getString(catalog)); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - if(schemaPattern.toChar() != '%') - varCriteria[nPos].setString(schemaPattern); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - - if(tableNamePattern.toChar() != '%') - varCriteria[nPos].setString(tableNamePattern); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTOR - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTEE - OLEVariant vtEmpty; - vtEmpty.setNoArg(); - - // Initialize and fill the SafeArray - OLEVariant vsa; - vsa.setArray(psa,VT_VARIANT); - - ADORecordset *pRecordset = NULL; - m_pADOConnection->OpenSchema(adSchemaTablePrivileges,vsa,vtEmpty,&pRecordset); + ADORecordset *pRecordset = m_pADOConnection->getTablePrivileges(catalog,schemaPattern,tableNamePattern); ADOS::ThrowException(*m_pADOConnection,*this); ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); @@ -979,49 +475,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference( const ::rtl::OUString& primaryTable, const Any& foreignCatalog, const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException) { - // Create elements used in the array - HRESULT hr = S_OK; - SAFEARRAYBOUND rgsabound[1]; - SAFEARRAY *psa = NULL; - OLEVariant varCriteria[6]; - - // Create SafeArray Bounds and initialize the array - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; - psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); - - sal_Int32 nPos=0; - if(primaryCatalog.hasValue()) - varCriteria[nPos].setString(getString(primaryCatalog)); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - if(primarySchema.toChar() != '%') - varCriteria[nPos].setString(primarySchema); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - - varCriteria[nPos].setString(primaryTable); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - if(foreignCatalog.hasValue()) - varCriteria[nPos].setString(getString(foreignCatalog)); - - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG - if(foreignSchema.toChar() != '%') - varCriteria[nPos].setString(foreignSchema); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA - - varCriteria[nPos].setString(foreignTable); - hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME - - OLEVariant vtEmpty; - vtEmpty.setNoArg(); - - // Initialize and fill the SafeArray - OLEVariant vsa; - vsa.setArray(psa,VT_VARIANT); - - ADORecordset *pRecordset = NULL; - m_pADOConnection->OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset); + ADORecordset *pRecordset = m_pADOConnection->getCrossReference(primaryCatalog,primarySchema,primaryTable,foreignCatalog,foreignSchema,foreignTable); ADOS::ThrowException(*m_pADOConnection,*this); Reference< XResultSet > xRef = NULL; diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx new file mode 100644 index 000000000000..7dc1b13bc875 --- /dev/null +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx @@ -0,0 +1,688 @@ +/************************************************************************* + * + * $RCSfile: ADatabaseMetaDataImpl.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-05-23 09:16:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADO_ADATABASEMETADATA_HXX_ +#include "ado/ADatabaseMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSETMETADATA_HXX_ +#include "ado/ADatabaseMetaDataResultSetMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_ +#include "ado/Awrapado.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_GROUP_HXX_ +#include "ado/AGroup.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ADOIMP_HXX_ +#include "ado/adoimp.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_INDEX_HXX_ +#include "ado/AIndex.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_KEY_HXX_ +#include "ado/AKey.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_TABLE_HXX_ +#include "ado/ATable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_PROCEDURERESULT_HPP_ +#include <com/sun/star/sdbc/ProcedureResult.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifdef DELETE +#undef DELETE +#endif +#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ +#include <com/sun/star/sdbcx/Privilege.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGEOBJECT_HPP_ +#include <com/sun/star/sdbcx/PrivilegeObject.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ +#include <com/sun/star/sdbcx/KeyType.hpp> +#endif + +using namespace connectivity; +using namespace connectivity::ado; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::uno; + +// ------------------------------------------------------------------------- +void ODatabaseMetaData::fillLiterals() +{ + ADORecordset *pRecordset = NULL; + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + m_pADOConnection->OpenSchema(adSchemaDBInfoLiterals,vtEmpty,vtEmpty,&pRecordset); + + ADOS::ThrowException(*m_pADOConnection,*this); + + OSL_ENSURE(pRecordset,"getMaxSize no resultset!"); + WpADORecordset aRecordset(pRecordset); + + aRecordset.MoveFirst(); + OLEVariant aValue; + sal_Int32 nRet = 0; + LiteralInfo aInfo; + while(!aRecordset.IsAtEOF()) + { + WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(aRecordset.GetFields()); + WpADOField aField(aFields.GetItem(1)); + aInfo.pwszLiteralValue = aField.get_Value(); + aField = aFields.GetItem(5); + aInfo.fSupported = aField.get_Value(); + aField = aFields.GetItem(6); + aInfo.cchMaxLen = aField.get_Value().getUInt32(); + + aField = aFields.GetItem(4); + sal_uInt32 nId = aField.get_Value().getUInt32(); + m_aLiteralInfo[nId] = aInfo; + + aRecordset.MoveNext(); + } + aRecordset.Close(); +} +// ------------------------------------------------------------------------- +sal_Int32 ODatabaseMetaData::getMaxSize(sal_uInt32 _nId) +{ + if(!m_aLiteralInfo.size()) + fillLiterals(); + + sal_Int32 nSize = 0; + ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId); + if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported) + nSize = ((*aIter).second.cchMaxLen == (-1)) ? 0 : (*aIter).second.cchMaxLen; + return nSize; +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::isCapable(sal_uInt32 _nId) +{ + if(!m_aLiteralInfo.size()) + fillLiterals(); + sal_Bool bSupported = sal_False; + ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId); + if(aIter != m_aLiteralInfo.end()) + bSupported = (*aIter).second.fSupported; + return bSupported; +} + +// ------------------------------------------------------------------------- +::rtl::OUString ODatabaseMetaData::getLiteral(sal_uInt32 _nId) +{ + if(!m_aLiteralInfo.size()) + fillLiterals(); + ::rtl::OUString sStr; + ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId); + if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported) + sStr = (*aIter).second.pwszLiteralValue; + return sStr; +} +// ----------------------------------------------------------------------------- +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setColumnPrivilegesMap() +{ + m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"), + ColumnValue::NULLABLE, + 3,3,0, + DataType::VARCHAR); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setColumnsMap() +{ + m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TYPE_NAME"), + ColumnValue::NO_NULLS, + 0,0,0, + DataType::VARCHAR); + m_mColumns[11] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); + m_mColumns[13] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_DEF"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); + m_mColumns[14] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATA_TYPE"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[15] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATETIME_SUB"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[16] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("CHAR_OCTET_LENGTH"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setTablesMap() +{ + m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setProcedureColumnsMap() +{ + m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setPrimaryKeysMap() +{ + m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PK_NAME"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setIndexInfoMap() +{ + m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NON_UNIQUE"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::BIT); + m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("INDEX_QUALIFIER"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); + m_mColumns[10] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("ASC_OR_DESC"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setTablePrivilegesMap() +{ + m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRIVILEGE"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); + m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setCrossReferenceMap() +{ + m_mColumns[9] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setTypeInfoMap() +{ + m_mColumns[3] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRECISION"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("AUTO_INCREMENT"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::BIT); + m_mColumns[16] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATA_TYPE"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[17] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATETIME_SUB"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[18] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NUM_PREC_RADIX"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setProceduresMap() +{ + m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isSearchable(); + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isAutoIncrement(); + return sal_False; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getColumnServiceName(); + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getTableName(); + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getCatalogName(); + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getColumnTypeName(); + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isCaseSensitive(); + return sal_True; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getSchemaName(); + return ::rtl::OUString(); +} +// ----------------------------------------------------------------------------- +// ------------------------------------------------------------------------- +ObjectTypeEnum OAdoGroup::MapObjectType(sal_Int32 _ObjType) +{ + ObjectTypeEnum eNumType= adPermObjTable; + switch(_ObjType) + { + case PrivilegeObject::TABLE: + break; + case PrivilegeObject::VIEW: + eNumType = adPermObjView; + break; + case PrivilegeObject::COLUMN: + eNumType = adPermObjColumn; + break; + } + return eNumType; +} +// ------------------------------------------------------------------------- +sal_Int32 OAdoGroup::MapRight(RightsEnum _eNum) +{ + sal_Int32 nRight = 0; + if(_eNum & adRightRead) + nRight |= Privilege::SELECT; + if(_eNum & adRightInsert) + nRight |= Privilege::INSERT; + if(_eNum & adRightUpdate) + nRight |= Privilege::UPDATE; + if(_eNum & adRightDelete) + nRight |= Privilege::DELETE; + if(_eNum & adRightReadDesign) + nRight |= Privilege::READ; + if(_eNum & adRightCreate) + nRight |= Privilege::CREATE; + if(_eNum & adRightWriteDesign) + nRight |= Privilege::ALTER; + if(_eNum & adRightReference) + nRight |= Privilege::REFERENCE; + if(_eNum & adRightDrop) + nRight |= Privilege::DROP; + + return nRight; +} +// ------------------------------------------------------------------------- +RightsEnum OAdoGroup::Map2Right(sal_Int32 _eNum) +{ + sal_Int32 nRight = adRightNone; + if(_eNum & Privilege::SELECT) + nRight |= adRightRead; + + if(_eNum & Privilege::INSERT) + nRight |= adRightInsert; + + if(_eNum & Privilege::UPDATE) + nRight |= adRightUpdate; + + if(_eNum & Privilege::DELETE) + nRight |= adRightDelete; + + if(_eNum & Privilege::READ) + nRight |= adRightReadDesign; + + if(_eNum & Privilege::CREATE) + nRight |= adRightCreate; + + if(_eNum & Privilege::ALTER) + nRight |= adRightWriteDesign; + + if(_eNum & Privilege::REFERENCE) + nRight |= adRightReference; + + if(_eNum & Privilege::DROP) + nRight |= adRightDrop; + + return (RightsEnum)nRight; +} +// ------------------------------------------------------------------------- +void WpADOIndex::Create() +{ + IClassFactory2* pIUnknown = NULL; + IUnknown *pOuter = NULL; + HRESULT hr = -1; + _ADOIndex* pCommand; + hr = CoCreateInstance(ADOS::CLSID_ADOINDEX_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOINDEX_25, + (void**)&pCommand ); + + + if( !FAILED( hr ) ) + operator=(pCommand); +} +// ------------------------------------------------------------------------- +void OAdoIndex::fillPropertyValues() +{ + if(m_aIndex.IsValid()) + { + m_Name = m_aIndex.get_Name(); + m_IsUnique = m_aIndex.get_Unique(); + m_IsPrimaryKeyIndex = m_aIndex.get_PrimaryKey(); + m_IsClustered = m_aIndex.get_Clustered(); + } +} +// ----------------------------------------------------------------------------- +void WpADOKey::Create() +{ + IClassFactory2* pIUnknown = NULL; + IUnknown *pOuter = NULL; + HRESULT hr = -1; + _ADOKey* pCommand; + hr = CoCreateInstance(ADOS::CLSID_ADOKEY_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOKEY_25, + (void**)&pCommand ); + + + if( !FAILED( hr ) ) + operator=(pCommand); +} +// ------------------------------------------------------------------------- +void OAdoKey::fillPropertyValues() +{ + if(m_aKey.IsValid()) + { + m_Type = MapKeyRule(m_aKey.get_Type()); + m_Name = m_aKey.get_Name(); + m_ReferencedTable = m_aKey.get_RelatedTable(); + m_UpdateRule = MapRule(m_aKey.get_UpdateRule()); + m_DeleteRule = MapRule(m_aKey.get_DeleteRule()); + } +} +// ------------------------------------------------------------------------- +sal_Int32 OAdoKey::MapRule(const RuleEnum& _eNum) const +{ + sal_Int32 eNum = KeyRule::NO_ACTION; + switch(_eNum) + { + case adRICascade: + eNum = KeyRule::CASCADE; + break; + case adRISetNull: + eNum = KeyRule::SET_NULL; + break; + case adRINone: + eNum = KeyRule::NO_ACTION; + break; + case adRISetDefault: + eNum = KeyRule::SET_DEFAULT; + break; + } + return eNum; +} +// ------------------------------------------------------------------------- +RuleEnum OAdoKey::Map2Rule(const sal_Int32& _eNum) const +{ + RuleEnum eNum = adRINone; + switch(_eNum) + { + case KeyRule::CASCADE: + eNum = adRICascade; + break; + case KeyRule::SET_NULL: + eNum = adRISetNull; + break; + case KeyRule::NO_ACTION: + eNum = adRINone; + break; + case KeyRule::SET_DEFAULT: + eNum = adRISetDefault; + break; + } + return eNum; +} +// ------------------------------------------------------------------------- +sal_Int32 OAdoKey::MapKeyRule(const KeyTypeEnum& _eNum) const +{ + sal_Int32 nKeyType = KeyType::PRIMARY; + switch(_eNum) + { + case adKeyPrimary: + nKeyType = KeyType::PRIMARY; + break; + case adKeyForeign: + nKeyType = KeyType::FOREIGN; + break; + case adKeyUnique: + nKeyType = KeyType::UNIQUE; + break; + } + return nKeyType; +} +// ------------------------------------------------------------------------- +KeyTypeEnum OAdoKey::Map2KeyRule(const sal_Int32& _eNum) const +{ + KeyTypeEnum eNum; + switch(_eNum) + { + case KeyType::PRIMARY: + eNum = adKeyPrimary; + break; + case KeyType::FOREIGN: + eNum = adKeyForeign; + break; + case KeyType::UNIQUE: + eNum = adKeyUnique; + break; + } + return eNum; +} +// ----------------------------------------------------------------------------- +void WpADOTable::Create() +{ + IClassFactory2* pIUnknown = NULL; + IUnknown *pOuter = NULL; + HRESULT hr = -1; + _ADOTable* pCommand; + hr = CoCreateInstance(ADOS::CLSID_ADOTABLE_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOTABLE_25, + (void**)&pCommand ); + + + if( !FAILED( hr ) ) + operator=(pCommand); +} +// ------------------------------------------------------------------------- +::rtl::OUString WpADOCatalog::GetObjectOwner(const ::rtl::OUString& _rName, ObjectTypeEnum _eNum) +{ + OLEVariant _rVar; + _rVar.setNoArg(); + OLEString aBSTR; + OLEString sStr1(_rName); + pInterface->GetObjectOwner(sStr1,_eNum,_rVar,&aBSTR); + return aBSTR; +} +// ----------------------------------------------------------------------------- +void OAdoTable::fillPropertyValues() +{ + if(m_aTable.IsValid()) + { + m_Name = m_aTable.get_Name(); + m_Type = m_aTable.get_Type(); + { + WpADOCatalog aCat(m_aTable.get_ParentCatalog()); + if(aCat.IsValid()) + m_CatalogName = aCat.GetObjectOwner(m_aTable.get_Name(),adPermObjTable); + } + { + ADOProperties* pProps = m_aTable.get_Properties(); + if(pProps) + { + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Description")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + m_Description = aProp.GetValue(); + pProps->Release(); + } + } + } +} +// ----------------------------------------------------------------------------- +void WpADOUser::Create() +{ + IClassFactory2* pIUnknown = NULL; + IUnknown *pOuter = NULL; + HRESULT hr = -1; + _ADOUser* pCommand; + hr = CoCreateInstance(ADOS::CLSID_ADOUSER_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOUSER_25, + (void**)&pCommand ); + + + if( !FAILED( hr ) ) + operator=(pCommand); +} +// ------------------------------------------------------------------------- +void WpADOView::Create() +{ + IClassFactory2* pIUnknown = NULL; + IUnknown *pOuter = NULL; + HRESULT hr = -1; + ADOView* pCommand; + hr = CoCreateInstance(ADOS::CLSID_ADOVIEW_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOVIEW_25, + (void**)&pCommand ); + + + if( !FAILED( hr ) ) + operator=(pCommand); +} + +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx index 5682feae54da..01cf482a94ee 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.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2001-05-17 09:13:23 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:15:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -176,6 +176,12 @@ Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) th return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes()); } +// ----------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::checkRecordSet() throw(SQLException) +{ + if(!m_pRecordSet) + throwFunctionSequenceException(*this); +} // ------------------------------------------------------------------------- sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException) @@ -204,8 +210,8 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResult ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -247,8 +253,8 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResult ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); return NULL; @@ -260,8 +266,8 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -277,8 +283,8 @@ sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) t ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -299,8 +305,8 @@ Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 co ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -316,8 +322,8 @@ Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 co ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -333,8 +339,8 @@ double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) t ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -350,8 +356,8 @@ float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) thr ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -367,8 +373,8 @@ sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) t ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -390,8 +396,8 @@ sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) throw(SQLException, Ru ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + return 0; } @@ -402,8 +408,8 @@ sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex ) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -416,8 +422,8 @@ Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + if(!m_xMetaData.is()) m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); @@ -430,8 +436,8 @@ Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 col ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); return NULL; @@ -444,8 +450,8 @@ Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 colum ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); return NULL; @@ -456,8 +462,8 @@ Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 colum ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); return NULL; @@ -469,8 +475,8 @@ Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 columnI ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); return NULL; @@ -482,8 +488,8 @@ Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); return Any(); @@ -495,8 +501,8 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -518,8 +524,8 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -540,8 +546,8 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -558,8 +564,8 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + columnIndex = mapColumn(columnIndex); ADO_GETFIELD(columnIndex); @@ -575,8 +581,8 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( ) throw(SQLException ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + VARIANT_BOOL bIsAtEOF; m_pRecordSet->get_EOF(&bIsAtEOF); @@ -588,8 +594,8 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException, Ru ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + return m_nRowPos == 1; } @@ -599,8 +605,8 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) throw(SQLException, Run ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + return sal_True; } @@ -610,8 +616,8 @@ void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException, Ru ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + if(first()) previous(); @@ -622,8 +628,8 @@ void SAL_CALL ODatabaseMetaDataResultSet::afterLast( ) throw(SQLException, Runt ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + if(last()) next(); @@ -728,8 +734,8 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException, ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + RecordStatusEnum eRec; m_pRecordSet->get_Status((sal_Int32*)&eRec); @@ -740,8 +746,8 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException { ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + RecordStatusEnum eRec; m_pRecordSet->get_Status((sal_Int32*)&eRec); @@ -753,8 +759,8 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException, ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + RecordStatusEnum eRec; m_pRecordSet->get_Status((sal_Int32*)&eRec); @@ -801,8 +807,8 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException, Ru ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + return m_aValue.isNull(); } @@ -812,8 +818,8 @@ void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException, Run ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + m_pRecordSet->Resync(adAffectCurrent,adResyncAllValues); } @@ -824,8 +830,8 @@ void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - if(!m_pRecordSet) - throwFunctionSequenceException(*this); + checkRecordSet(); + m_pRecordSet->Cancel(); } diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx index 5f5c6ddc5ae2..4a2d9f1fd749 100644 --- a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ADatabaseMetaDataResultSetMetaData.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-05-17 07:26:59 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,16 +63,6 @@ #include "ado/ADatabaseMetaDataResultSetMetaData.hxx" #endif -#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ -#include <com/sun/star/sdbc/DataType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_PROCEDURERESULT_HPP_ -#include <com/sun/star/sdbc/ProcedureResult.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ -#include <com/sun/star/sdbc/ColumnValue.hpp> -#endif - #ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_ #include "ado/Awrapado.hxx" #endif @@ -141,22 +131,6 @@ sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnCount( ) throw( } // ------------------------------------------------------------------------- -sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) - return (*m_mColumnsIter).second.isCaseSensitive(); - return sal_True; -} -// ------------------------------------------------------------------------- - -::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) - return (*m_mColumnsIter).second.getSchemaName(); - return ::rtl::OUString(); -} -// ------------------------------------------------------------------------- - ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException) { if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) @@ -170,27 +144,6 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCaseSensitive( sal_Int32 return ::rtl::OUString(); } // ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) - return (*m_mColumnsIter).second.getTableName(); - return ::rtl::OUString(); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) - return (*m_mColumnsIter).second.getCatalogName(); - return ::rtl::OUString(); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) - return (*m_mColumnsIter).second.getColumnTypeName(); - return ::rtl::OUString(); -} -// ------------------------------------------------------------------------- ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException) { if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) @@ -198,13 +151,6 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCaseSensitive( sal_Int32 return getColumnName(column); } // ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) - return (*m_mColumnsIter).second.getColumnServiceName(); - return ::rtl::OUString(); -} -// ------------------------------------------------------------------------- sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException) { @@ -221,14 +167,6 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCurrency( sal_Int32 colu } // ------------------------------------------------------------------------- -sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) - return (*m_mColumnsIter).second.isAutoIncrement(); - return sal_False; -} -// ------------------------------------------------------------------------- - sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException) { @@ -288,14 +226,6 @@ sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::isNullable( sal_Int32 col } // ------------------------------------------------------------------------- -sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) - return (*m_mColumnsIter).second.isSearchable(); - return sal_True; -} -// ------------------------------------------------------------------------- - sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException) { if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) @@ -336,145 +266,6 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isWritable( sal_Int32 colu return (*m_mColumnsIter).second.isWritable(); return isDefinitelyWritable(column); } -// ------------------------------------------------------------------------- -void ODatabaseMetaDataResultSetMetaData::setColumnPrivilegesMap() -{ - m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"), - ColumnValue::NULLABLE, - 3,3,0, - DataType::VARCHAR); -} -// ------------------------------------------------------------------------- -void ODatabaseMetaDataResultSetMetaData::setColumnsMap() -{ - m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TYPE_NAME"), - ColumnValue::NO_NULLS, - 0,0,0, - DataType::VARCHAR); - m_mColumns[11] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::INTEGER); - m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"), - ColumnValue::NULLABLE, - 0,0,0, - DataType::VARCHAR); - m_mColumns[13] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_DEF"), - ColumnValue::NULLABLE, - 0,0,0, - DataType::VARCHAR); - m_mColumns[14] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATA_TYPE"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::INTEGER); - m_mColumns[15] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATETIME_SUB"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::INTEGER); - m_mColumns[16] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("CHAR_OCTET_LENGTH"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::INTEGER); -} -// ------------------------------------------------------------------------- -void ODatabaseMetaDataResultSetMetaData::setTablesMap() -{ - m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"), - ColumnValue::NULLABLE, - 0,0,0, - DataType::VARCHAR); -} -// ------------------------------------------------------------------------- -void ODatabaseMetaDataResultSetMetaData::setProcedureColumnsMap() -{ - m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::INTEGER); -} -// ------------------------------------------------------------------------- -void ODatabaseMetaDataResultSetMetaData::setPrimaryKeysMap() -{ - m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::INTEGER); - m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PK_NAME"), - ColumnValue::NULLABLE, - 0,0,0, - DataType::VARCHAR); -} -// ------------------------------------------------------------------------- -void ODatabaseMetaDataResultSetMetaData::setIndexInfoMap() -{ - m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NON_UNIQUE"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::BIT); - m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("INDEX_QUALIFIER"), - ColumnValue::NULLABLE, - 0,0,0, - DataType::VARCHAR); - m_mColumns[10] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("ASC_OR_DESC"), - ColumnValue::NULLABLE, - 0,0,0, - DataType::VARCHAR); -} -// ------------------------------------------------------------------------- -void ODatabaseMetaDataResultSetMetaData::setTablePrivilegesMap() -{ - m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRIVILEGE"), - ColumnValue::NULLABLE, - 0,0,0, - DataType::VARCHAR); - m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"), - ColumnValue::NULLABLE, - 0,0,0, - DataType::VARCHAR); -} -// ------------------------------------------------------------------------- -void ODatabaseMetaDataResultSetMetaData::setCrossReferenceMap() -{ - m_mColumns[9] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::INTEGER); -} -// ------------------------------------------------------------------------- -void ODatabaseMetaDataResultSetMetaData::setTypeInfoMap() -{ - m_mColumns[3] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRECISION"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::INTEGER); - m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::INTEGER); - m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("AUTO_INCREMENT"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::BIT); - m_mColumns[16] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATA_TYPE"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::INTEGER); - m_mColumns[17] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATETIME_SUB"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::INTEGER); - m_mColumns[18] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NUM_PREC_RADIX"), - ColumnValue::NO_NULLS, - 1,1,0, - DataType::INTEGER); -} -// ------------------------------------------------------------------------- -void ODatabaseMetaDataResultSetMetaData::setProceduresMap() -{ - m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"), - ColumnValue::NULLABLE, - 0,0,0, - DataType::VARCHAR); -} -// ------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/ado/ADriver.cxx b/connectivity/source/drivers/ado/ADriver.cxx index 2105a20075c2..75b017c2b2d6 100644 --- a/connectivity/source/drivers/ado/ADriver.cxx +++ b/connectivity/source/drivers/ado/ADriver.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ADriver.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-05-22 07:40:32 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -175,11 +175,7 @@ Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url ) throw(SQLException, RuntimeException) { - if(!url.compareTo(::rtl::OUString::createFromAscii("sdbc:ado:"),9)) - { - return sal_True; - } - return sal_False; + return (!url.compareTo(::rtl::OUString::createFromAscii("sdbc:ado:"),9)); } // -------------------------------------------------------------------------------- Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) @@ -240,30 +236,65 @@ Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByURL( const ::r return getDataDefinitionByConnection(connect(url,info)); } -//#include <tools/prewin.h> -//namespace test__rr__ -//{ -// -//#import "c:\Program Files\Common Files\system\ado\msadox.dll" -// -//} -//#include <tools/postwin.h> +// ----------------------------------------------------------------------------- +void OLEVariant::ChangeType(VARTYPE vartype, const OLEVariant* pSrc) +{ + // + // If pDest is NULL, convert type in place + // + if (pSrc == NULL) + pSrc = this; -void WpADOCatalog::Create() + if ((this != pSrc) || (vartype != V_VT(this))) + { + if(FAILED(::VariantChangeType(static_cast<VARIANT*>(this), + const_cast<VARIANT*>(static_cast<const VARIANT*>(pSrc)), + 0, vartype))) + throw ::com::sun::star::sdbc::SQLException(::rtl::OUString::createFromAscii("Could convert type!"),NULL,::rtl::OUString(),1000,::com::sun::star::uno::Any()); + } +} +// ----------------------------------------------------------------------------- +void ADOS::ThrowException(ADOConnection* _pAdoCon,const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException) { - IClassFactory2* pIUnknown = NULL; - IUnknown *pOuter = NULL; - HRESULT hr = -1; - _ADOCatalog* pCommand; - hr = CoCreateInstance(ADOS::CLSID_ADOCATALOG_25, - NULL, - CLSCTX_INPROC_SERVER, - ADOS::IID_ADOCATALOG_25, - (void**)&pCommand ); + ADOErrors *pErrors = NULL; + _pAdoCon->get_Errors(&pErrors); + if(!pErrors) + return; // no error found + pErrors->AddRef( ); - if( !FAILED( hr ) ) - operator=(pCommand); + // alle aufgelaufenen Fehler auslesen und ausgeben + sal_Int32 nLen; + pErrors->get_Count(&nLen); + if (nLen) + { + ::rtl::OUString sError; + ::rtl::OUString aSQLState; + SQLException aException; + for (sal_Int32 i = nLen-1; i>=0; i--) + { + ADOError *pError = NULL; + pErrors->get_Item(OLEVariant(i),&pError); + WpADOError aErr(pError); + OSL_ENSURE(pError,"No error in collection found! BAD!"); + if(pError) + { + if(i==nLen-1) + aException = SQLException(aErr.GetDescription(),_xInterface,aErr.GetSQLState(),aErr.GetNumber(),Any()); + else + { + SQLException aTemp = SQLException(aErr.GetDescription(), + _xInterface,aErr.GetSQLState(),aErr.GetNumber(),makeAny(aException)); + aTemp.NextException <<= aException; + aException = aTemp; + } + } + } + pErrors->Clear(); + pErrors->Release(); + throw aException; + } + pErrors->Release(); } diff --git a/connectivity/source/drivers/ado/AGroup.cxx b/connectivity/source/drivers/ado/AGroup.cxx index 06cb5f050802..dd9e8aa55265 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.9 $ + * $Revision: 1.10 $ * - * last change: $Author: oj $ $Date: 2001-05-22 07:40:32 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,15 +71,6 @@ #ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> #endif -#ifdef DELETE -#undef DELETE -#endif -#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ -#include <com/sun/star/sdbcx/Privilege.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGEOBJECT_HPP_ -#include <com/sun/star/sdbcx/PrivilegeObject.hpp> -#endif #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ #include <com/sun/star/sdbc/XRow.hpp> @@ -247,81 +238,7 @@ void SAL_CALL OAdoGroup::revokePrivileges( const ::rtl::OUString& objName, sal_I { m_aGroup.SetPermissions(objName,MapObjectType(objType),adAccessDeny,Map2Right(objPrivileges)); } -// ------------------------------------------------------------------------- -ObjectTypeEnum OAdoGroup::MapObjectType(sal_Int32 _ObjType) -{ - ObjectTypeEnum eNumType= adPermObjTable; - switch(_ObjType) - { - case PrivilegeObject::TABLE: - break; - case PrivilegeObject::VIEW: - eNumType = adPermObjView; - break; - case PrivilegeObject::COLUMN: - eNumType = adPermObjColumn; - break; - } - return eNumType; -} -// ------------------------------------------------------------------------- -sal_Int32 OAdoGroup::MapRight(RightsEnum _eNum) -{ - sal_Int32 nRight = 0; - if(_eNum & adRightRead) - nRight |= Privilege::SELECT; - if(_eNum & adRightInsert) - nRight |= Privilege::INSERT; - if(_eNum & adRightUpdate) - nRight |= Privilege::UPDATE; - if(_eNum & adRightDelete) - nRight |= Privilege::DELETE; - if(_eNum & adRightReadDesign) - nRight |= Privilege::READ; - if(_eNum & adRightCreate) - nRight |= Privilege::CREATE; - if(_eNum & adRightWriteDesign) - nRight |= Privilege::ALTER; - if(_eNum & adRightReference) - nRight |= Privilege::REFERENCE; - if(_eNum & adRightDrop) - nRight |= Privilege::DROP; - return nRight; -} -// ------------------------------------------------------------------------- -RightsEnum OAdoGroup::Map2Right(sal_Int32 _eNum) -{ - sal_Int32 nRight = adRightNone; - if(_eNum & Privilege::SELECT) - nRight |= adRightRead; - - if(_eNum & Privilege::INSERT) - nRight |= adRightInsert; - - if(_eNum & Privilege::UPDATE) - nRight |= adRightUpdate; - - if(_eNum & Privilege::DELETE) - nRight |= adRightDelete; - - if(_eNum & Privilege::READ) - nRight |= adRightReadDesign; - - if(_eNum & Privilege::CREATE) - nRight |= adRightCreate; - - if(_eNum & Privilege::ALTER) - nRight |= adRightWriteDesign; - - if(_eNum & Privilege::REFERENCE) - nRight |= adRightReference; - - if(_eNum & Privilege::DROP) - nRight |= adRightDrop; - - return (RightsEnum)nRight; -} // ----------------------------------------------------------------------------- void SAL_CALL OAdoGroup::acquire() throw(::com::sun::star::uno::RuntimeException) { diff --git a/connectivity/source/drivers/ado/AIndex.cxx b/connectivity/source/drivers/ado/AIndex.cxx index 3fe4f16ab95a..43547254534a 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.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2001-05-22 07:40:32 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,23 +96,6 @@ using namespace com::sun::star::beans; using namespace com::sun::star::sdbc; // ------------------------------------------------------------------------- -void WpADOIndex::Create() -{ - IClassFactory2* pIUnknown = NULL; - IUnknown *pOuter = NULL; - HRESULT hr = -1; - _ADOIndex* pCommand; - hr = CoCreateInstance(ADOS::CLSID_ADOINDEX_25, - NULL, - CLSCTX_INPROC_SERVER, - ADOS::IID_ADOINDEX_25, - (void**)&pCommand ); - - - if( !FAILED( hr ) ) - operator=(pCommand); -} -// ------------------------------------------------------------------------- OAdoIndex::OAdoIndex(sal_Bool _bCase,OConnection* _pConnection,ADOIndex* _pIndex) : OIndex_ADO(::rtl::OUString(),::rtl::OUString(),sal_False,sal_False,sal_False,_bCase) ,m_pConnection(_pConnection) @@ -223,18 +206,6 @@ void SAL_CALL OAdoIndex::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,cons } OIndex_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue); } -// ------------------------------------------------------------------------- -void OAdoIndex::fillPropertyValues() -{ - if(m_aIndex.IsValid()) - { - m_Name = m_aIndex.get_Name(); - m_IsUnique = m_aIndex.get_Unique(); - m_IsPrimaryKeyIndex = m_aIndex.get_PrimaryKey(); - m_IsClustered = m_aIndex.get_Clustered(); - } -} -// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- void SAL_CALL OAdoIndex::acquire() throw(::com::sun::star::uno::RuntimeException) { diff --git a/connectivity/source/drivers/ado/AKey.cxx b/connectivity/source/drivers/ado/AKey.cxx index e6c7b3cae9e8..20dd3cb487bd 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.11 $ + * $Revision: 1.12 $ * - * last change: $Author: oj $ $Date: 2001-05-22 07:40:32 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,12 +74,6 @@ #ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> #endif -#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ -#include <com/sun/star/sdbc/KeyRule.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ -#include <com/sun/star/sdbcx/KeyType.hpp> -#endif #ifndef _CONNECTIVITY_ADO_COLUMNS_HXX_ #include "ado/AColumns.hxx" #endif @@ -95,23 +89,6 @@ using namespace com::sun::star::sdbc; using namespace com::sun::star::sdbcx; // ------------------------------------------------------------------------- -void WpADOKey::Create() -{ - IClassFactory2* pIUnknown = NULL; - IUnknown *pOuter = NULL; - HRESULT hr = -1; - _ADOKey* pCommand; - hr = CoCreateInstance(ADOS::CLSID_ADOKEY_25, - NULL, - CLSCTX_INPROC_SERVER, - ADOS::IID_ADOKEY_25, - (void**)&pCommand ); - - - if( !FAILED( hr ) ) - operator=(pCommand); -} -// ------------------------------------------------------------------------- OAdoKey::OAdoKey(sal_Bool _bCase,OConnection* _pConnection, ADOKey* _pKey) : OKey_ADO(_bCase) ,m_pConnection(_pConnection) @@ -232,96 +209,6 @@ void OAdoKey::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rVal OKey_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue); } // ------------------------------------------------------------------------- -void OAdoKey::fillPropertyValues() -{ - if(m_aKey.IsValid()) - { - m_Type = MapKeyRule(m_aKey.get_Type()); - m_Name = m_aKey.get_Name(); - m_ReferencedTable = m_aKey.get_RelatedTable(); - m_UpdateRule = MapRule(m_aKey.get_UpdateRule()); - m_DeleteRule = MapRule(m_aKey.get_DeleteRule()); - } -} -// ------------------------------------------------------------------------- -sal_Int32 OAdoKey::MapRule(const RuleEnum& _eNum) const -{ - sal_Int32 eNum = KeyRule::NO_ACTION; - switch(_eNum) - { - case adRICascade: - eNum = KeyRule::CASCADE; - break; - case adRISetNull: - eNum = KeyRule::SET_NULL; - break; - case adRINone: - eNum = KeyRule::NO_ACTION; - break; - case adRISetDefault: - eNum = KeyRule::SET_DEFAULT; - break; - } - return eNum; -} -// ------------------------------------------------------------------------- -RuleEnum OAdoKey::Map2Rule(const sal_Int32& _eNum) const -{ - RuleEnum eNum = adRINone; - switch(_eNum) - { - case KeyRule::CASCADE: - eNum = adRICascade; - break; - case KeyRule::SET_NULL: - eNum = adRISetNull; - break; - case KeyRule::NO_ACTION: - eNum = adRINone; - break; - case KeyRule::SET_DEFAULT: - eNum = adRISetDefault; - break; - } - return eNum; -} -// ------------------------------------------------------------------------- -sal_Int32 OAdoKey::MapKeyRule(const KeyTypeEnum& _eNum) const -{ - sal_Int32 nKeyType = KeyType::PRIMARY; - switch(_eNum) - { - case adKeyPrimary: - nKeyType = KeyType::PRIMARY; - break; - case adKeyForeign: - nKeyType = KeyType::FOREIGN; - break; - case adKeyUnique: - nKeyType = KeyType::UNIQUE; - break; - } - return nKeyType; -} -// ------------------------------------------------------------------------- -KeyTypeEnum OAdoKey::Map2KeyRule(const sal_Int32& _eNum) const -{ - KeyTypeEnum eNum; - switch(_eNum) - { - case KeyType::PRIMARY: - eNum = adKeyPrimary; - break; - case KeyType::FOREIGN: - eNum = adKeyForeign; - break; - case KeyType::UNIQUE: - eNum = adKeyUnique; - break; - } - return eNum; -} -// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- void SAL_CALL OAdoKey::acquire() throw(::com::sun::star::uno::RuntimeException) { diff --git a/connectivity/source/drivers/ado/ATable.cxx b/connectivity/source/drivers/ado/ATable.cxx index cd53938246a6..1cc53e17ea4f 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.15 $ + * $Revision: 1.16 $ * - * last change: $Author: oj $ $Date: 2001-05-22 07:40:32 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -120,23 +120,6 @@ using namespace com::sun::star::container; using namespace com::sun::star::lang; // ------------------------------------------------------------------------- -void WpADOTable::Create() -{ - IClassFactory2* pIUnknown = NULL; - IUnknown *pOuter = NULL; - HRESULT hr = -1; - _ADOTable* pCommand; - hr = CoCreateInstance(ADOS::CLSID_ADOTABLE_25, - NULL, - CLSCTX_INPROC_SERVER, - ADOS::IID_ADOTABLE_25, - (void**)&pCommand ); - - - if( !FAILED( hr ) ) - operator=(pCommand); -} -// ------------------------------------------------------------------------- OAdoTable::OAdoTable(sal_Bool _bCase,OCatalog* _pCatalog,_ADOTable* _pTable) : OTable_TYPEDEF(_bCase,::rtl::OUString(),::rtl::OUString()) ,m_pCatalog(_pCatalog) @@ -362,44 +345,6 @@ void OAdoTable::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rV OTable_TYPEDEF::setFastPropertyValue_NoBroadcast(nHandle,rValue); } // ------------------------------------------------------------------------- -void OAdoTable::fillPropertyValues() -{ - if(m_aTable.IsValid()) - { - m_Name = m_aTable.get_Name(); - m_Type = m_aTable.get_Type(); - { - WpADOCatalog aCat(m_aTable.get_ParentCatalog()); - if(aCat.IsValid()) - m_CatalogName = aCat.GetObjectOwner(m_aTable.get_Name(),adPermObjTable); - } - { - ADOProperties* pProps = m_aTable.get_Properties(); - if(pProps) - { - pProps->AddRef(); - ADOProperty* pProp = NULL; - pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Description")),&pProp); - WpADOProperty aProp(pProp); - if(pProp) - m_Description = aProp.GetValue(); - pProps->Release(); - } - } - } -} -// ------------------------------------------------------------------------- -::rtl::OUString WpADOCatalog::GetObjectOwner(const ::rtl::OUString& _rName, ObjectTypeEnum _eNum) -{ - OLEVariant _rVar; - _rVar.setNoArg(); - OLEString aBSTR; - OLEString sStr1(_rName); - pInterface->GetObjectOwner(sStr1,_eNum,_rVar,&aBSTR); - return aBSTR; -} -// ----------------------------------------------------------------------------- -// ----------------------------------------------------------------------------- void SAL_CALL OAdoTable::acquire() throw(::com::sun::star::uno::RuntimeException) { OTable_TYPEDEF::acquire(); diff --git a/connectivity/source/drivers/ado/AUser.cxx b/connectivity/source/drivers/ado/AUser.cxx index 073618e965ae..2138adea9d93 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.9 $ + * $Revision: 1.10 $ * - * last change: $Author: oj $ $Date: 2001-05-22 07:40:32 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -88,23 +88,6 @@ using namespace com::sun::star::beans; using namespace com::sun::star::sdbc; // ------------------------------------------------------------------------- -void WpADOUser::Create() -{ - IClassFactory2* pIUnknown = NULL; - IUnknown *pOuter = NULL; - HRESULT hr = -1; - _ADOUser* pCommand; - hr = CoCreateInstance(ADOS::CLSID_ADOUSER_25, - NULL, - CLSCTX_INPROC_SERVER, - ADOS::IID_ADOUSER_25, - (void**)&pCommand ); - - - if( !FAILED( hr ) ) - operator=(pCommand); -} -// ------------------------------------------------------------------------- OAdoUser::OAdoUser(sal_Bool _bCase, ADOUser* _pUser) : OUser_TYPEDEF(_bCase) { construct(); diff --git a/connectivity/source/drivers/ado/AView.cxx b/connectivity/source/drivers/ado/AView.cxx index 943b86f3bc33..e26125a84c57 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.9 $ + * $Revision: 1.10 $ * - * last change: $Author: oj $ $Date: 2001-05-22 07:40:32 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,24 +89,6 @@ using namespace com::sun::star::sdbc; // IMPLEMENT_SERVICE_INFO(OAdoView,"com.sun.star.sdbcx.AView","com.sun.star.sdbcx.View"); // ------------------------------------------------------------------------- -void WpADOView::Create() -{ - IClassFactory2* pIUnknown = NULL; - IUnknown *pOuter = NULL; - HRESULT hr = -1; - ADOView* pCommand; - hr = CoCreateInstance(ADOS::CLSID_ADOVIEW_25, - NULL, - CLSCTX_INPROC_SERVER, - ADOS::IID_ADOVIEW_25, - (void**)&pCommand ); - - - if( !FAILED( hr ) ) - operator=(pCommand); -} - -// ------------------------------------------------------------------------- OAdoView::OAdoView(sal_Bool _bCase,ADOView* _pView) : OView_ADO(_bCase,NULL) { construct(); diff --git a/connectivity/source/drivers/ado/Aolevariant.cxx b/connectivity/source/drivers/ado/Aolevariant.cxx index 9ab9092d4b0a..65b8349e0a1c 100644 --- a/connectivity/source/drivers/ado/Aolevariant.cxx +++ b/connectivity/source/drivers/ado/Aolevariant.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Aolevariant.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:48:07 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -523,21 +523,3 @@ SAFEARRAY* OLEVariant::getUI1SAFEARRAYPtr() const // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- -// ----------------------------------------------------------------------------- -void OLEVariant::ChangeType(VARTYPE vartype, const OLEVariant* pSrc) -{ - // - // If pDest is NULL, convert type in place - // - if (pSrc == NULL) - pSrc = this; - - if ((this != pSrc) || (vartype != V_VT(this))) - { - if(FAILED(::VariantChangeType(static_cast<VARIANT*>(this), - const_cast<VARIANT*>(static_cast<const VARIANT*>(pSrc)), - 0, vartype))) - throw ::com::sun::star::sdbc::SQLException(::rtl::OUString::createFromAscii("Could convert type!"),NULL,::rtl::OUString(),1000,::com::sun::star::uno::Any()); - } -} - diff --git a/connectivity/source/drivers/ado/Awrapado.cxx b/connectivity/source/drivers/ado/Awrapado.cxx index 1b4982433dbd..6f92a6e05943 100644 --- a/connectivity/source/drivers/ado/Awrapado.cxx +++ b/connectivity/source/drivers/ado/Awrapado.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Awrapado.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-05-22 07:40:32 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,8 +64,37 @@ #ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ #include "ado/Awrapadox.hxx" #endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif using namespace connectivity::ado; +//#include <tools/prewin.h> +//namespace test__rr__ +//{ +// +//#import "c:\Program Files\Common Files\system\ado\msadox.dll" +// +//} +//#include <tools/postwin.h> + +void WpADOCatalog::Create() +{ + IClassFactory2* pIUnknown = NULL; + IUnknown *pOuter = NULL; + HRESULT hr = -1; + _ADOCatalog* pCommand; + hr = CoCreateInstance(ADOS::CLSID_ADOCATALOG_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOCATALOG_25, + (void**)&pCommand ); + + + if( !FAILED( hr ) ) + operator=(pCommand); +} + ADOProperties* WpADOConnection::get_Properties() const { @@ -1560,5 +1589,527 @@ WpBase::operator IDispatch*() return pIUnknown; } +ADORecordset* WpADOConnection::getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[6]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schema.toChar() != '%') + varCriteria[nPos].setString(schema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + varCriteria[nPos].setString(table); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[6]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schema.toChar() != '%') + varCriteria[nPos].setString(schema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + varCriteria[nPos].setString(table); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset); + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[3]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schema.toChar() != '%') + varCriteria[nPos].setString(schema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + varCriteria[nPos].setString(table); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaPrimaryKeys,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getIndexInfo( + const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, + sal_Bool unique, sal_Bool approximate ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[5]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schema.toChar() != '%') + varCriteria[nPos].setString(schema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// INDEX_NAME + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TYPE + + varCriteria[nPos].setString(table); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaIndexes,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getTablePrivileges( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern ) +{ + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[5]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schemaPattern.toChar() != '%') + varCriteria[nPos].setString(schemaPattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + if(tableNamePattern.toChar() != '%') + varCriteria[nPos].setString(tableNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTOR + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTEE + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaTablePrivileges,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog, + const ::rtl::OUString& primarySchema, + const ::rtl::OUString& primaryTable, + const ::com::sun::star::uno::Any& foreignCatalog, + const ::rtl::OUString& foreignSchema, + const ::rtl::OUString& foreignTable) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[6]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(primaryCatalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(primaryCatalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(primarySchema.toChar() != '%') + varCriteria[nPos].setString(primarySchema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + varCriteria[nPos].setString(primaryTable); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + if(foreignCatalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(foreignCatalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(foreignSchema.toChar() != '%') + varCriteria[nPos].setString(foreignSchema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + varCriteria[nPos].setString(foreignTable); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getProcedures( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern ) +{ + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[3]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schemaPattern.toChar() != '%') + varCriteria[nPos].setString(schemaPattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + if(procedureNamePattern.toChar() != '%') + varCriteria[nPos].setString(procedureNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaProcedures,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getProcedureColumns( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern, + const ::rtl::OUString& columnNamePattern ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[4]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schemaPattern.toChar() != '%') + varCriteria[nPos].setString(schemaPattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + if(procedureNamePattern.toChar() != '%') + varCriteria[nPos].setString(procedureNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + if(columnNamePattern.toChar() != '%') + varCriteria[nPos].setString(columnNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaProcedureParameters,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::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 ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[4]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schemaPattern.toChar() != '%') + varCriteria[nPos].setString(schemaPattern); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + if(tableNamePattern.toChar() != '%') + varCriteria[nPos].setString(tableNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + ::rtl::OUString aTypes,aComma = ::rtl::OUString::createFromAscii(","); + const ::rtl::OUString* pBegin = types.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + types.getLength(); + for(;pBegin != pEnd;++pBegin) + aTypes = aTypes + *pBegin + aComma; + + if(aTypes.getLength()) + varCriteria[nPos].setString(aTypes); + // else + // varCriteria[nPos].setString(::rtl::OUString::createFromAscii("TABLE")); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_TYPE + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaTables,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getColumns( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern, + const ::rtl::OUString& columnNamePattern ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[4]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schemaPattern.toChar() != '%') + varCriteria[nPos].setString(schemaPattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + if(tableNamePattern.toChar() != '%') + varCriteria[nPos].setString(tableNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + varCriteria[nPos].setString(columnNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaColumns,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schema, + const ::rtl::OUString& table, + const ::rtl::OUString& columnNamePattern ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[4]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schema.toChar() != '%') + varCriteria[nPos].setString(schema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + varCriteria[nPos].setString(table); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + varCriteria[nPos].setString(columnNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaColumnPrivileges,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getTypeInfo( ) +{ + HRESULT hr = S_OK; + // Create elements used in the array + OLEVariant varCriteria[2]; + const int nCrit = sizeof varCriteria / sizeof varCriteria[0]; + // Create SafeArray Bounds and initialize the array + SAFEARRAYBOUND rgsabound[1]; + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = nCrit; + SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos = 0; + SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++; + SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++; + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + OLEVariant aEmpty; + aEmpty.setNoArg(); + + ADORecordset *pRec=NULL; + OpenSchema(adSchemaProviderTypes,vsa,aEmpty,&pRec); + + return pRec; +} + diff --git a/connectivity/source/drivers/ado/adoimp.cxx b/connectivity/source/drivers/ado/adoimp.cxx index 3ac6b888ff11..633f29285ce1 100644 --- a/connectivity/source/drivers/ado/adoimp.cxx +++ b/connectivity/source/drivers/ado/adoimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: adoimp.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: kz $ $Date: 2001-04-24 08:21:49 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -114,49 +114,6 @@ const IID ADOS::IID_ADOUSER_25 = MYADOID(0x00000619); const CLSID ADOS::CLSID_ADOVIEW_25 = MYADOID(0x00000612); const IID ADOS::IID_ADOVIEW_25 = MYADOID(0x00000613); -void ADOS::ThrowException(ADOConnection* _pAdoCon,const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException) -{ - ADOErrors *pErrors = NULL; - _pAdoCon->get_Errors(&pErrors); - if(!pErrors) - return; // no error found - - pErrors->AddRef( ); - - // alle aufgelaufenen Fehler auslesen und ausgeben - sal_Int32 nLen; - pErrors->get_Count(&nLen); - if (nLen) - { - ::rtl::OUString sError; - ::rtl::OUString aSQLState; - SQLException aException; - for (sal_Int32 i = nLen-1; i>=0; i--) - { - ADOError *pError = NULL; - pErrors->get_Item(OLEVariant(i),&pError); - WpADOError aErr(pError); - OSL_ENSURE(pError,"No error in collection found! BAD!"); - if(pError) - { - if(i==nLen-1) - aException = SQLException(aErr.GetDescription(),_xInterface,aErr.GetSQLState(),aErr.GetNumber(),Any()); - else - { - SQLException aTemp = SQLException(aErr.GetDescription(), - _xInterface,aErr.GetSQLState(),aErr.GetNumber(),makeAny(aException)); - aTemp.NextException <<= aException; - aException = aTemp; - } - } - } - pErrors->Clear(); - pErrors->Release(); - throw aException; - } - pErrors->Release(); -} - // ------------------------------------------------------------------------- sal_Int32 ADOS::MapADOType2Jdbc(DataTypeEnum eType) { @@ -240,6 +197,65 @@ DataTypeEnum ADOS::MapJdbc2ADOType(sal_Int32 _nType) return adEmpty; } // ----------------------------------------------------------------------------- +const int JET_ENGINETYPE_UNKNOWN = 0; +const int JET_ENGINETYPE_JET10 = 1; +const int JET_ENGINETYPE_JET11 = 2; +const int JET_ENGINETYPE_JET20 = 3; +const int JET_ENGINETYPE_JET3X = 4; +const int JET_ENGINETYPE_JET4X = 5; +const int JET_ENGINETYPE_DBASE3 = 10; +const int JET_ENGINETYPE_DBASE4 = 11; +const int JET_ENGINETYPE_DBASE5 = 12; +const int JET_ENGINETYPE_EXCEL30 = 20; +const int JET_ENGINETYPE_EXCEL40 = 21; +const int JET_ENGINETYPE_EXCEL50 = 22; +const int JET_ENGINETYPE_EXCEL80 = 23; +const int JET_ENGINETYPE_EXCEL90 = 24; +const int JET_ENGINETYPE_EXCHANGE4 = 30; +const int JET_ENGINETYPE_LOTUSWK1 = 40; +const int JET_ENGINETYPE_LOTUSWK3 = 41; +const int JET_ENGINETYPE_LOTUSWK4 = 42; +const int JET_ENGINETYPE_PARADOX3X = 50; +const int JET_ENGINETYPE_PARADOX4X = 51; +const int JET_ENGINETYPE_PARADOX5X = 52; +const int JET_ENGINETYPE_PARADOX7X = 53; +const int JET_ENGINETYPE_TEXT1X = 60; +const int JET_ENGINETYPE_HTML1X = 70; + +sal_Bool ADOS::isJetEngine(sal_Int32 _nEngineType) +{ + sal_Bool bRet = sal_False; + switch(_nEngineType) + { + case JET_ENGINETYPE_UNKNOWN: + case JET_ENGINETYPE_JET10: + case JET_ENGINETYPE_JET11: + case JET_ENGINETYPE_JET20: + case JET_ENGINETYPE_JET3X: + case JET_ENGINETYPE_JET4X: + case JET_ENGINETYPE_DBASE3: + case JET_ENGINETYPE_DBASE4: + case JET_ENGINETYPE_DBASE5: + case JET_ENGINETYPE_EXCEL30: + case JET_ENGINETYPE_EXCEL40: + case JET_ENGINETYPE_EXCEL50: + case JET_ENGINETYPE_EXCEL80: + case JET_ENGINETYPE_EXCEL90: + case JET_ENGINETYPE_EXCHANGE4: + case JET_ENGINETYPE_LOTUSWK1: + case JET_ENGINETYPE_LOTUSWK3: + case JET_ENGINETYPE_LOTUSWK4: + case JET_ENGINETYPE_PARADOX3X: + case JET_ENGINETYPE_PARADOX4X: + case JET_ENGINETYPE_PARADOX5X: + case JET_ENGINETYPE_PARADOX7X: + case JET_ENGINETYPE_TEXT1X: + case JET_ENGINETYPE_HTML1X: + bRet = sal_True; + break; + } + return bRet; +} diff --git a/connectivity/source/drivers/ado/makefile.mk b/connectivity/source/drivers/ado/makefile.mk index 145653fa4817..80f4eabf197a 100644 --- a/connectivity/source/drivers/ado/makefile.mk +++ b/connectivity/source/drivers/ado/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.7 $ +# $Revision: 1.8 $ # -# last change: $Author: oj $ $Date: 2001-05-17 09:13:23 $ +# last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -66,7 +66,7 @@ PRJINC=..$/.. PRJNAME=connectivity TARGET=ado -ENABLE_EXCEPTIONS=TRUE +# ENABLE_EXCEPTIONS=TRUE # --- Settings ---------------------------------- .IF "$(DBGUTIL_OJ)"!="" @@ -80,6 +80,7 @@ ENVCFLAGS+=/FR$(SLO)$/ # --- Files ------------------------------------- SLOFILES=\ + $(SLO)$/ADatabaseMetaDataImpl.obj \ $(SLO)$/Aolevariant.obj \ $(SLO)$/Awrapado.obj \ $(SLO)$/ADatabaseMetaData.obj \ @@ -110,6 +111,33 @@ SLOFILES=\ $(SLO)$/Aservices.obj \ $(SLO)$/adoimp.obj +EXCEPTIONSFILES= \ + $(SLO)$/ADatabaseMetaData.obj \ + $(SLO)$/AColumn.obj \ + $(SLO)$/AColumns.obj \ + $(SLO)$/AIndex.obj \ + $(SLO)$/AIndexes.obj \ + $(SLO)$/AKey.obj \ + $(SLO)$/AKeys.obj \ + $(SLO)$/AUser.obj \ + $(SLO)$/AUsers.obj \ + $(SLO)$/AGroup.obj \ + $(SLO)$/AGroups.obj \ + $(SLO)$/ACatalog.obj \ + $(SLO)$/AView.obj \ + $(SLO)$/AViews.obj \ + $(SLO)$/ATable.obj \ + $(SLO)$/ATables.obj \ + $(SLO)$/ACallableStatement.obj \ + $(SLO)$/ADatabaseMetaDataResultSetMetaData.obj \ + $(SLO)$/ADatabaseMetaDataResultSet.obj \ + $(SLO)$/AResultSet.obj \ + $(SLO)$/AConnection.obj \ + $(SLO)$/AStatement.obj \ + $(SLO)$/APreparedStatement.obj \ + $(SLO)$/AResultSetMetaData.obj \ + $(SLO)$/ADriver.obj \ + $(SLO)$/Aservices.obj # --- Library ----------------------------------- diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx index 7e621143fd5e..193f4aa2d3c3 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.11 $ + * $Revision: 1.12 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:40:01 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -128,9 +128,6 @@ #ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> #endif -#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ -#include "connectivity/DateConversion.hxx" -#endif #ifndef _INTN_HXX //autogen #include <tools/intn.hxx> #endif diff --git a/connectivity/source/drivers/calc/makefile.mk b/connectivity/source/drivers/calc/makefile.mk index 3e3dcff38d8d..d597fcd948a7 100644 --- a/connectivity/source/drivers/calc/makefile.mk +++ b/connectivity/source/drivers/calc/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.6 $ +# $Revision: 1.7 $ # -# last change: $Author: oj $ $Date: 2001-05-14 11:40:01 $ +# last change: $Author: oj $ $Date: 2001-05-23 09:13:10 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -115,9 +115,9 @@ SHL1STDLIBS=\ $(COMPHELPERLIB) -.IF "$(DBFILELIB)" == "" -SHL1STDLIBS+= ifile$(UPD).lib -.ENDIF +#.IF "$(DBFILELIB)" == "" +#SHL1STDLIBS+= ifile$(UPD).lib +#.ENDIF SHL1DEPN= SHL1IMPLIB= i$(TARGET) diff --git a/connectivity/source/drivers/dbase/DCode.cxx b/connectivity/source/drivers/dbase/DCode.cxx index 544c0817990b..a4cc70d1e0d7 100644 --- a/connectivity/source/drivers/dbase/DCode.cxx +++ b/connectivity/source/drivers/dbase/DCode.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DCode.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:39:59 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -86,7 +86,7 @@ OOperandAttr* OFILEAnalyzer::createOperandAttr(sal_Int32 _nPos, const Reference< XPropertySet>& _xCol, const Reference< XNameAccess>& _xIndexes) { - return new OFILEOperandAttr(_nPos,_xCol,_xIndexes); + return new OFILEOperandAttr((sal_uInt16)_nPos,_xCol,_xIndexes); } //------------------------------------------------------------------ diff --git a/connectivity/source/drivers/dbase/DNoException.cxx b/connectivity/source/drivers/dbase/DNoException.cxx new file mode 100644 index 000000000000..89ea25f92048 --- /dev/null +++ b/connectivity/source/drivers/dbase/DNoException.cxx @@ -0,0 +1,805 @@ +/************************************************************************* + * + * $RCSfile: DNoException.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-05-23 09:18:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_DBASE_TABLE_HXX_ +#include "dbase/DTable.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_INDEX_HXX_ +#include "dbase/DIndex.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_INDEXNODE_HXX_ +#include "dbase/dindexnode.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +using namespace connectivity; +using namespace connectivity::dbase; +using namespace com::sun::star::uno; +using namespace com::sun::star::sdbc; +//------------------------------------------------------------------ +sal_Bool ODbaseTable::seekRow(FilePosition eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) +{ + // ---------------------------------------------------------- + // Positionierung vorbereiten: + + sal_uInt32 nNumberOfRecords = (sal_uInt32)m_aHeader.db_anz; + sal_uInt32 nTempPos = m_nFilePos; + m_nFilePos = nCurPos; + + switch(eCursorPosition) + { + case FILE_NEXT: + m_nFilePos++; + break; + case FILE_PRIOR: + if (m_nFilePos > 0) + m_nFilePos--; + break; + case FILE_FIRST: + m_nFilePos = 1; + break; + case FILE_LAST: + m_nFilePos = nNumberOfRecords; + break; + case FILE_RELATIVE: + m_nFilePos = (((sal_Int32)m_nFilePos) + nOffset < 0) ? 0L + : (sal_uInt32)(((sal_Int32)m_nFilePos) + nOffset); + break; + case FILE_ABSOLUTE: + case FILE_BOOKMARK: + m_nFilePos = (sal_uInt32)nOffset; + break; + } + + if (m_nFilePos > (sal_Int32)nNumberOfRecords) + m_nFilePos = (sal_Int32)nNumberOfRecords + 1; + + if (m_nFilePos == 0 || m_nFilePos == (sal_Int32)nNumberOfRecords + 1) + goto Error; + else + { + sal_uInt16 nEntryLen = m_aHeader.db_slng; + + OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position"); + sal_Int32 nPos = m_aHeader.db_kopf + (sal_Int32)(m_nFilePos-1) * nEntryLen; + + ULONG nLen = m_pFileStream->Seek(nPos); + if (m_pFileStream->GetError() != ERRCODE_NONE) + goto Error; + + nLen = m_pFileStream->Read((char*)m_pBuffer, nEntryLen); + if (m_pFileStream->GetError() != ERRCODE_NONE) + goto Error; + } + goto End; + +Error: + switch(eCursorPosition) + { + case FILE_PRIOR: + case FILE_FIRST: + m_nFilePos = 0; + break; + case FILE_LAST: + case FILE_NEXT: + case FILE_ABSOLUTE: + case FILE_RELATIVE: + if (nOffset > 0) + m_nFilePos = nNumberOfRecords + 1; + else if (nOffset < 0) + m_nFilePos = 0; + break; + case FILE_BOOKMARK: + m_nFilePos = nTempPos; // vorherige Position + } + // aStatus.Set(SDB_STAT_NO_DATA_FOUND); + return sal_False; + +End: + nCurPos = m_nFilePos; + return sal_True; +} +// ----------------------------------------------------------------------------- +BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable) +{ + BOOL bIsText = TRUE; + // SdbConnection* pConnection = GetConnection(); + + m_pMemoStream->Seek(nBlockNo * m_aMemoHeader.db_size); + switch (m_aMemoHeader.db_typ) + { + case MemodBaseIII: // dBase III-Memofeld, endet mit Ctrl-Z + { + const char cEOF = (char) 0x1a; + ByteString aBStr; + static char aBuf[514]; + aBuf[512] = 0; // sonst kann der Zufall uebel mitspielen + BOOL bReady = sal_False; + + do + { + m_pMemoStream->Read(&aBuf,512); + + USHORT i = 0; + while (aBuf[i] != cEOF && ++i < 512) + ; + bReady = aBuf[i] == cEOF; + + aBuf[i] = 0; + aBStr += aBuf; + + } while (!bReady && !m_pMemoStream->IsEof() && aBStr.Len() < STRING_MAXLEN); + + ::rtl::OUString aStr(aBStr.GetBuffer(), aBStr.Len(),getConnection()->getTextEncoding()); + aVariable = Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aStr.getStr()),sizeof(sal_Unicode)*aStr.getLength()); + + } break; + case MemoFoxPro: + case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe + { + char sHeader[4]; + m_pMemoStream->Read(sHeader,4); + // Foxpro stores text and binary data + if (m_aMemoHeader.db_typ == MemoFoxPro) + { + if (((BYTE)sHeader[0]) != 0 || ((BYTE)sHeader[1]) != 0 || ((BYTE)sHeader[2]) != 0) + { +// String aText = String(SdbResId(STR_STAT_FILE_INVALID)); +// aText.SearchAndReplace(String::CreateFromAscii("%%d"),m_pMemoStream->GetFileName()); +// aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO)); +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(aText), +// 0, String() ); + return sal_False; + } + + bIsText = sHeader[3] != 0; + } + else if (((BYTE)sHeader[0]) != 0xFF || ((BYTE)sHeader[1]) != 0xFF || ((BYTE)sHeader[2]) != 0x08) + { +// String aText = String(SdbResId(STR_STAT_FILE_INVALID)); +// aText.SearchAndReplace(String::CreateFromAscii("%%d"),m_pMemoStream->GetFileName()); +// aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO)); +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(aText), +// 0, String() ); + return sal_False; + } + + ULONG nLength; + (*m_pMemoStream) >> nLength; + + if (m_aMemoHeader.db_typ == MemodBaseIV) + nLength -= 8; + + // char cChar; + if (nLength < STRING_MAXLEN && bIsText) + { + ByteString aBStr; + aBStr.Expand(USHORT (nLength)); + m_pMemoStream->Read(aBStr.AllocBuffer((USHORT)nLength),nLength); + aBStr.ReleaseBufferAccess(); + ::rtl::OUString aStr(aBStr.GetBuffer(),aBStr.Len(), getConnection()->getTextEncoding()); + aVariable = Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aStr.getStr()),sizeof(sal_Unicode)*aStr.getLength()); + } + else + { + Sequence<sal_Int8> aText(nLength); + sal_Int8* pData = aText.getArray(); + sal_Char cChar; + for (ULONG i = 0; i < nLength; i++) + { + m_pMemoStream->Read(&cChar,1); + (*pData++) = cChar; + } + aVariable = aText; + // return sal_False; + } + } + } + return sal_True; +} +// ----------------------------------------------------------------------------- +BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr) +{ + // wird die BlockNr 0 vorgegeben, wird der block ans Ende gehaengt + char cChar = 0; + BOOL bIsText = TRUE; + // SdbConnection* pConnection = GetConnection(); + + ULONG nSize = 0; + ULONG nStreamSize; + BYTE nHeader[4]; + + ByteString aStr; + // ::Sequence<sal_Int8>* pData = NULL; +// if (aVariable.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence< sal_Int8 > *)0)) +// { +// pData = (::Sequence<sal_Int8>*)aVariable.get(); +// nSize = pData->getLength(); +// } +// else +// { + aStr = ByteString(String(aVariable.getString()), getConnection()->getTextEncoding()); + nSize = aStr.Len(); + // } + + // Anhaengen oder ueberschreiben + BOOL bAppend = rBlockNr == 0; + + if (!bAppend) + { + switch (m_aMemoHeader.db_typ) + { + case MemodBaseIII: // dBase III-Memofeld, endet mit 2 * Ctrl-Z + bAppend = nSize > (512 - 2); + break; + case MemoFoxPro: + case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe + { + char sHeader[4]; + m_pMemoStream->Seek(rBlockNr * m_aMemoHeader.db_size); + m_pMemoStream->SeekRel(4L); + m_pMemoStream->Read(sHeader,4); + + ULONG nOldSize; + if (m_aMemoHeader.db_typ == MemoFoxPro) + nOldSize = ((((unsigned char)sHeader[0]) * 256 + + (unsigned char)sHeader[1]) * 256 + + (unsigned char)sHeader[2]) * 256 + + (unsigned char)sHeader[3]; + else + nOldSize = ((((unsigned char)sHeader[3]) * 256 + + (unsigned char)sHeader[2]) * 256 + + (unsigned char)sHeader[1]) * 256 + + (unsigned char)sHeader[0] - 8; + + // passt die neue Laenge in die belegten Bloecke + ULONG nUsedBlocks = ((nSize + 8) / m_aMemoHeader.db_size) + (((nSize + 8) % m_aMemoHeader.db_size > 0) ? 1 : 0), + nOldUsedBlocks = ((nOldSize + 8) / m_aMemoHeader.db_size) + (((nOldSize + 8) % m_aMemoHeader.db_size > 0) ? 1 : 0); + bAppend = nUsedBlocks > nOldUsedBlocks; + } + } + } + + if (bAppend) + { + ULONG nStreamSize; + nStreamSize = m_pMemoStream->Seek(STREAM_SEEK_TO_END); + // letzten block auffuellen + rBlockNr = (nStreamSize / m_aMemoHeader.db_size) + ((nStreamSize % m_aMemoHeader.db_size) > 0 ? 1 : 0); + + m_pMemoStream->SetStreamSize(rBlockNr * m_aMemoHeader.db_size); + m_pMemoStream->Seek(STREAM_SEEK_TO_END); + } + else + { + m_pMemoStream->Seek(rBlockNr * m_aMemoHeader.db_size); + } + + switch (m_aMemoHeader.db_typ) + { + case MemodBaseIII: // dBase III-Memofeld, endet mit Ctrl-Z + { + const char cEOF = (char) 0x1a; + nSize++; + +// if (pData) +// { +// m_pMemoStream->Write((const char*) pData->getConstArray(), pData->getLength()); +// } +// else +// { + m_pMemoStream->Write(aStr.GetBuffer(), aStr.Len()); + // } + + (*m_pMemoStream) << cEOF << cEOF; + } break; + case MemoFoxPro: + case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe + { + (*m_pMemoStream) << (BYTE)0xFF + << (BYTE)0xFF + << (BYTE)0x08; + + UINT32 nWriteSize = nSize; + if (m_aMemoHeader.db_typ == MemoFoxPro) + { + (*m_pMemoStream) << (BYTE) 0x01; // ((pData = NULL) ? 0x01 : 0x00); + for (int i = 4; i > 0; nWriteSize >>= 8) + nHeader[--i] = (BYTE) (nWriteSize % 256); + } + else + { + (*m_pMemoStream) << (BYTE) 0x00; + nWriteSize += 8; + for (int i = 0; i < 4; nWriteSize >>= 8) + nHeader[i++] = (BYTE) (nWriteSize % 256); + } + + m_pMemoStream->Write(nHeader,4); +// if (pData) +// { +// m_pMemoStream->Write((const char*) pData->getConstArray(), pData->getLength()); +// } +// else +// { + m_pMemoStream->Write(aStr.GetBuffer(), aStr.Len()); + // } + m_pMemoStream->Flush(); + } + } + + + // Schreiben der neuen Blocknummer + if (bAppend) + { + nStreamSize = m_pMemoStream->Seek(STREAM_SEEK_TO_END); + m_aMemoHeader.db_next = (nStreamSize / m_aMemoHeader.db_size) + ((nStreamSize % m_aMemoHeader.db_size) > 0 ? 1 : 0); + + // Schreiben der neuen Blocknummer + m_pMemoStream->Seek(0L); + (*m_pMemoStream) << m_aMemoHeader.db_next; + m_pMemoStream->Flush(); + } + return sal_True; +} +// ----------------------------------------------------------------------------- +void ODbaseTable::AllocBuffer() +{ + UINT16 nSize = m_aHeader.db_slng; + OSL_ENSURE(nSize > 0, "Size too small"); + + if (m_nBufferSize != nSize) + { + delete m_pBuffer; + m_pBuffer = NULL; + } + + // Falls noch kein Puffer vorhanden: allozieren: + if (m_pBuffer == NULL && nSize) + { + m_nBufferSize = nSize; + m_pBuffer = new BYTE[m_nBufferSize+1]; + } +} +// ----------------------------------------------------------------------------- +BOOL ODbaseTable::WriteBuffer() +{ + OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position"); + + // Auf gewuenschten Record positionieren: + long nPos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng; + m_pFileStream->Seek(nPos); + return m_pFileStream->Write((char*) m_pBuffer, m_aHeader.db_slng) > 0; +} +// ----------------------------------------------------------------------------- +sal_Int32 ODbaseTable::getCurrentLastPos() const +{ + return m_aHeader.db_anz; +} +// ----------------------------------------------------------------------------- +//================================================================== +// ONDXNode +//================================================================== + +//------------------------------------------------------------------ +void ONDXNode::Read(SvStream &rStream, ODbaseIndex& rIndex) +{ + rStream >> (sal_uInt32)aKey.nRecord; // schluessel + if (rIndex.getHeader().db_keytype) + { + double aDbl; + rStream >> aDbl; + aKey = ONDXKey(aDbl,aKey.nRecord); + } + else + { + ByteString aBuf; + USHORT nLen = rIndex.getHeader().db_keylen; + char* pStr = aBuf.AllocBuffer(nLen+1); + + rStream.Read(pStr,nLen); + pStr[nLen] = 0; + aBuf.ReleaseBufferAccess(); + aBuf.EraseTrailingChars(); + + // aKey = ONDXKey((aBuf,rIndex.GetDBFConnection()->GetCharacterSet()) ,aKey.nRecord); + aKey = ONDXKey(::rtl::OUString(aBuf.GetBuffer(),aBuf.Len(),rIndex.m_pTable->getConnection()->getTextEncoding()) ,aKey.nRecord); + } + rStream >> aChild; +} + +union +{ + double aDbl; + char aData[128]; +} aNodeData; +//------------------------------------------------------------------ +void ONDXNode::Write(SvStream &rStream, const ONDXPage& rPage) const +{ + const ODbaseIndex& rIndex = rPage.GetIndex(); + if (!rIndex.isUnique() || rPage.IsLeaf()) + rStream << (sal_uInt32)aKey.nRecord; // schluessel + else + rStream << (sal_uInt32)0; // schluessel + + if (rIndex.getHeader().db_keytype) // double + { + if (aKey.getValue().isNull()) + { + memset(aNodeData.aData,0,rIndex.getHeader().db_keylen); + rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen); + } + else + rStream << (double) aKey.getValue(); + } + else + { + memset(aNodeData.aData,0x20,rIndex.getHeader().db_keylen); + if (!aKey.getValue().isNull()) + { + ::rtl::OUString sValue = aKey.getValue(); + ByteString aText(sValue.getStr(), rIndex.m_pTable->getConnection()->getTextEncoding()); + strncpy(aNodeData.aData,aText.GetBuffer(),min(rIndex.getHeader().db_keylen, aText.Len())); + } + rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen); + } + rStream << aChild; +} + + +//------------------------------------------------------------------ +ONDXPagePtr& ONDXNode::GetChild(ODbaseIndex* pIndex, ONDXPage* pParent) +{ + if (!aChild.Is() && pIndex) + { + aChild = pIndex->CreatePage(aChild.GetPagePos(),pParent,aChild.HasPage()); + } + return aChild; +} + +//================================================================== +// ONDXKey +//================================================================== +//------------------------------------------------------------------ +BOOL ONDXKey::IsText(sal_Int32 eType) +{ + return eType == DataType::VARCHAR || eType == DataType::CHAR; +} + +//------------------------------------------------------------------ +StringCompare ONDXKey::Compare(const ONDXKey& rKey) const +{ + // DBG_ASSERT(is(), "Falscher Indexzugriff"); + StringCompare eResult; + + if (getValue().isNull()) + { + if (rKey.getValue().isNull() || (rKey.IsText(getDBType()) && !rKey.getValue().getString().getLength())) + eResult = COMPARE_EQUAL; + else + eResult = COMPARE_LESS; + } + else if (rKey.getValue().isNull()) + { + if (getValue().isNull() || (IsText(getDBType()) && !getValue().getString().getLength())) + eResult = COMPARE_EQUAL; + else + eResult = COMPARE_GREATER; + } + else if (IsText(getDBType())) + { + INT32 nRes = getValue().getString().compareTo(rKey.getValue()); + eResult = (nRes > 0) ? COMPARE_GREATER : (nRes == 0) ? COMPARE_EQUAL : COMPARE_LESS; + } + else + { + double m = getValue(),n = rKey.getValue(); + eResult = (m > n) ? COMPARE_GREATER : (n == m) ? COMPARE_EQUAL : COMPARE_LESS; + } + + // Record vergleich, wenn Index !Unique + if (eResult == COMPARE_EQUAL && nRecord && rKey.nRecord) + eResult = (nRecord > rKey.nRecord) ? COMPARE_GREATER : + (nRecord == rKey.nRecord) ? COMPARE_EQUAL : COMPARE_LESS; + + return eResult; +} +// ----------------------------------------------------------------------------- +void ONDXKey::setValue(const ORowSetValue& _rVal) +{ + xValue = _rVal; +} +// ----------------------------------------------------------------------------- +const ORowSetValue& ONDXKey::getValue() const +{ + return xValue; +} +// ----------------------------------------------------------------------------- +SvStream& connectivity::dbase::operator >> (SvStream &rStream, ONDXPagePtr& rPage) +{ + rStream >> rPage.nPagePos; + return rStream; +} +// ----------------------------------------------------------------------------- +SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPagePtr& rPage) +{ + rStream << rPage.nPagePos; + return rStream; +} +// ----------------------------------------------------------------------------- +//================================================================== +// ONDXPagePtr +//================================================================== +//------------------------------------------------------------------ +ONDXPagePtr::ONDXPagePtr(const ONDXPagePtr& rRef) + :ONDXPageRef(rRef) + ,nPagePos(rRef.nPagePos) +{ +} + +//------------------------------------------------------------------ +ONDXPagePtr::ONDXPagePtr(ONDXPage* pRefPage) + :ONDXPageRef(pRefPage) + ,nPagePos(0) +{ + if (pRefPage) + nPagePos = pRefPage->GetPagePos(); +} +//------------------------------------------------------------------ +ONDXPagePtr& ONDXPagePtr::operator=(const ONDXPagePtr& rRef) +{ + ONDXPageRef::operator=(rRef); + nPagePos = rRef.nPagePos; + return *this; +} + +//------------------------------------------------------------------ +ONDXPagePtr& ONDXPagePtr::operator= (ONDXPage* pRef) +{ + ONDXPageRef::operator=(pRef); + nPagePos = (pRef) ? pRef->GetPagePos() : 0; + return *this; +} +// ----------------------------------------------------------------------------- +static UINT32 nValue; +//------------------------------------------------------------------ +SvStream& connectivity::dbase::operator >> (SvStream &rStream, ONDXPage& rPage) +{ + rStream.Seek(rPage.GetPagePos() * 512); + rStream >> nValue >> rPage.aChild; + rPage.nCount = USHORT(nValue); + +// DBG_ASSERT(rPage.nCount && rPage.nCount < rPage.GetIndex().GetMaxNodes(), "Falscher Count"); + for (USHORT i = 0; i < rPage.nCount; i++) + rPage[i].Read(rStream, rPage.GetIndex()); + return rStream; +} + +//------------------------------------------------------------------ +SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& rPage) +{ + // Seite existiert noch nicht + ULONG nSize = (rPage.GetPagePos() + 1) * 512; + if (nSize > rStream.Seek(STREAM_SEEK_TO_END)) + { + rStream.SetStreamSize(nSize); + rStream.Seek(rPage.GetPagePos() * 512); + + char aEmptyData[512]; + memset(aEmptyData,0x00,512); + rStream.Write((BYTE*)aEmptyData,512); + } + ULONG nCurrentPos = rStream.Seek(rPage.GetPagePos() * 512); + + nValue = rPage.nCount; + rStream << nValue << rPage.aChild; + + USHORT i = 0; + for (; i < rPage.nCount; i++) + rPage[i].Write(rStream, rPage); + + // check if we have to fill the stream with '\0' + if(i < rPage.rIndex.getHeader().db_maxkeys) + { + ULONG nTell = rStream.Tell() % 512; + USHORT nBufferSize = rStream.GetBufferSize(); + ULONG nSize = nBufferSize - nTell; + char* pEmptyData = new char[nSize]; + memset(pEmptyData,0x00,nSize); + rStream.Write((BYTE*)pEmptyData,nSize); + rStream.Seek(nTell); + delete pEmptyData; + } + return rStream; +} +// ----------------------------------------------------------------------------- +#ifdef DEBUG +//------------------------------------------------------------------ +void ONDXPage::PrintPage() +{ + DBG_TRACE4("\nSDB: -----------Page: %d Parent: %d Count: %d Child: %d-----", + nPagePos, HasParent() ? aParent->GetPagePos() : 0 ,nCount, aChild.GetPagePos()); + + for (USHORT i = 0; i < nCount; i++) + { + ONDXNode rNode = (*this)[i]; + ONDXKey& rKey = rNode.GetKey(); + if (!IsLeaf()) + rNode.GetChild(&rIndex, this); + + if (rKey.getValue().isNull()) + { + DBG_TRACE2("SDB: [%d,NULL,%d]",rKey.GetRecord(), rNode.GetChild().GetPagePos()); + } + else if (rIndex.getHeader().db_keytype) + { + DBG_TRACE3("SDB: [%d,%f,%d]",rKey.GetRecord(), rKey.getValue().getDouble(),rNode.GetChild().GetPagePos()); + } + else + { + DBG_TRACE3("SDB: [%d,%s,%d]",rKey.GetRecord(), (const char* )ByteString(rKey.getValue().getString().getStr(), rIndex.m_pTable->getConnection()->getTextEncoding()).GetBuffer(),rNode.GetChild().GetPagePos()); + } + } + DBG_TRACE("SDB: -----------------------------------------------\n"); + if (!IsLeaf()) + { + GetChild(&rIndex)->PrintPage(); + for (USHORT i = 0; i < nCount; i++) + { + ONDXNode rNode = (*this)[i]; + rNode.GetChild(&rIndex,this)->PrintPage(); + } + } + DBG_TRACE("SDB: ===============================================\n"); +} +#endif +// ----------------------------------------------------------------------------- +BOOL ONDXPage::IsFull() const +{ + return Count() == rIndex.getHeader().db_maxkeys; +} +// ----------------------------------------------------------------------------- +//------------------------------------------------------------------ +USHORT ONDXPage::Search(const ONDXKey& rSearch) +{ + // binare Suche spaeter + USHORT i = 0xFFFF; + while (++i < Count()) + if ((*this)[i].GetKey() == rSearch) + break; + + return (i < Count()) ? i : NODE_NOTFOUND; +} + +//------------------------------------------------------------------ +USHORT ONDXPage::Search(const ONDXPage* pPage) +{ + USHORT i = 0xFFFF; + while (++i < Count()) + if (((*this)[i]).GetChild() == pPage) + break; + + // wenn nicht gefunden, dann wird davon ausgegangen, dass die Seite selbst + // auf die Page zeigt + return (i < Count()) ? i : NODE_NOTFOUND; +} +// ----------------------------------------------------------------------------- +// laeuft rekursiv +void ONDXPage::SearchAndReplace(const ONDXKey& rSearch, + ONDXKey& rReplace) +{ + if (rSearch == rReplace) + return; + + USHORT nPos = NODE_NOTFOUND; + ONDXPage* pPage = this; + + while (pPage && (nPos = pPage->Search(rSearch)) == NODE_NOTFOUND) + pPage = pPage->aParent; + + if (pPage) + { + (*pPage)[nPos].GetKey() = rReplace; + pPage->SetModified(TRUE); + } +} +// ----------------------------------------------------------------------------- +ONDXNode& ONDXPage::operator[] (USHORT nPos) +{ + DBG_ASSERT(nCount > nPos, "falscher Indexzugriff"); + return ppNodes[nPos]; +} + +//------------------------------------------------------------------ +const ONDXNode& ONDXPage::operator[] (USHORT nPos) const +{ + DBG_ASSERT(nCount > nPos, "falscher Indexzugriff"); + return ppNodes[nPos]; +} +// ----------------------------------------------------------------------------- +void ONDXPage::Remove(USHORT nPos) +{ + DBG_ASSERT(nCount > nPos, "falscher Indexzugriff"); + + for (USHORT i = nPos; i < (nCount-1); i++) + (*this)[i] = (*this)[i+1]; + + nCount--; + bModified = TRUE; +} +// ----------------------------------------------------------------------------- + + + + + + + + + + + diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index bdc78d093456..ead94acd45dc 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DTable.cxx,v $ * - * $Revision: 1.46 $ + * $Revision: 1.47 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:48:08 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -98,9 +98,6 @@ #ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> #endif -#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ -#include "connectivity/DateConversion.hxx" -#endif #ifndef _INTN_HXX //autogen #include <tools/intn.hxx> #endif @@ -609,89 +606,6 @@ sal_Int64 ODbaseTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (R return ODbaseTable_BASE::getSomething(rId); } //------------------------------------------------------------------ -sal_Bool ODbaseTable::seekRow(FilePosition eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) -{ - // ---------------------------------------------------------- - // Positionierung vorbereiten: - - sal_uInt32 nNumberOfRecords = (sal_uInt32)m_aHeader.db_anz; - sal_uInt32 nTempPos = m_nFilePos; - m_nFilePos = nCurPos; - - switch(eCursorPosition) - { - case FILE_NEXT: - m_nFilePos++; - break; - case FILE_PRIOR: - if (m_nFilePos > 0) - m_nFilePos--; - break; - case FILE_FIRST: - m_nFilePos = 1; - break; - case FILE_LAST: - m_nFilePos = nNumberOfRecords; - break; - case FILE_RELATIVE: - m_nFilePos = (((sal_Int32)m_nFilePos) + nOffset < 0) ? 0L - : (sal_uInt32)(((sal_Int32)m_nFilePos) + nOffset); - break; - case FILE_ABSOLUTE: - case FILE_BOOKMARK: - m_nFilePos = (sal_uInt32)nOffset; - break; - } - - if (m_nFilePos > (sal_Int32)nNumberOfRecords) - m_nFilePos = (sal_Int32)nNumberOfRecords + 1; - - if (m_nFilePos == 0 || m_nFilePos == (sal_Int32)nNumberOfRecords + 1) - goto Error; - else - { - sal_uInt16 nEntryLen = m_aHeader.db_slng; - - OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position"); - sal_Int32 nPos = m_aHeader.db_kopf + (sal_Int32)(m_nFilePos-1) * nEntryLen; - - ULONG nLen = m_pFileStream->Seek(nPos); - if (m_pFileStream->GetError() != ERRCODE_NONE) - goto Error; - - nLen = m_pFileStream->Read((char*)m_pBuffer, nEntryLen); - if (m_pFileStream->GetError() != ERRCODE_NONE) - goto Error; - } - goto End; - -Error: - switch(eCursorPosition) - { - case FILE_PRIOR: - case FILE_FIRST: - m_nFilePos = 0; - break; - case FILE_LAST: - case FILE_NEXT: - case FILE_ABSOLUTE: - case FILE_RELATIVE: - if (nOffset > 0) - m_nFilePos = nNumberOfRecords + 1; - else if (nOffset < 0) - m_nFilePos = 0; - break; - case FILE_BOOKMARK: - m_nFilePos = nTempPos; // vorherige Position - } - // aStatus.Set(SDB_STAT_NO_DATA_FOUND); - return sal_False; - -End: - nCurPos = m_nFilePos; - return sal_True; -} -//------------------------------------------------------------------ sal_Bool ODbaseTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols, sal_Bool _bUseTableDefs,sal_Bool bRetrieveData) { // Einlesen der Daten @@ -856,107 +770,6 @@ sal_Bool ODbaseTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols, sal_B return sal_True; } //------------------------------------------------------------------ -BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable) -{ - BOOL bIsText = TRUE; - // SdbConnection* pConnection = GetConnection(); - - m_pMemoStream->Seek(nBlockNo * m_aMemoHeader.db_size); - switch (m_aMemoHeader.db_typ) - { - case MemodBaseIII: // dBase III-Memofeld, endet mit Ctrl-Z - { - const char cEOF = (char) 0x1a; - ByteString aBStr; - static char aBuf[514]; - aBuf[512] = 0; // sonst kann der Zufall uebel mitspielen - BOOL bReady = sal_False; - - do - { - m_pMemoStream->Read(&aBuf,512); - - USHORT i = 0; - while (aBuf[i] != cEOF && ++i < 512) - ; - bReady = aBuf[i] == cEOF; - - aBuf[i] = 0; - aBStr += aBuf; - - } while (!bReady && !m_pMemoStream->IsEof() && aBStr.Len() < STRING_MAXLEN); - - ::rtl::OUString aStr(aBStr.GetBuffer(), aBStr.Len(),getConnection()->getTextEncoding()); - aVariable = Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aStr.getStr()),sizeof(sal_Unicode)*aStr.getLength()); - - } break; - case MemoFoxPro: - case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe - { - char sHeader[4]; - m_pMemoStream->Read(sHeader,4); - // Foxpro stores text and binary data - if (m_aMemoHeader.db_typ == MemoFoxPro) - { - if (((BYTE)sHeader[0]) != 0 || ((BYTE)sHeader[1]) != 0 || ((BYTE)sHeader[2]) != 0) - { -// String aText = String(SdbResId(STR_STAT_FILE_INVALID)); -// aText.SearchAndReplace(String::CreateFromAscii("%%d"),m_pMemoStream->GetFileName()); -// aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO)); -// aStatus.Set(SDB_STAT_ERROR, -// String::CreateFromAscii("01000"), -// aStatus.CreateErrorMessage(aText), -// 0, String() ); - return sal_False; - } - - bIsText = sHeader[3] != 0; - } - else if (((BYTE)sHeader[0]) != 0xFF || ((BYTE)sHeader[1]) != 0xFF || ((BYTE)sHeader[2]) != 0x08) - { -// String aText = String(SdbResId(STR_STAT_FILE_INVALID)); -// aText.SearchAndReplace(String::CreateFromAscii("%%d"),m_pMemoStream->GetFileName()); -// aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO)); -// aStatus.Set(SDB_STAT_ERROR, -// String::CreateFromAscii("01000"), -// aStatus.CreateErrorMessage(aText), -// 0, String() ); - return sal_False; - } - - ULONG nLength; - (*m_pMemoStream) >> nLength; - - if (m_aMemoHeader.db_typ == MemodBaseIV) - nLength -= 8; - - // char cChar; - if (nLength < STRING_MAXLEN && bIsText) - { - ByteString aBStr; - aBStr.Expand(USHORT (nLength)); - m_pMemoStream->Read(aBStr.AllocBuffer((USHORT)nLength),nLength); - aBStr.ReleaseBufferAccess(); - ::rtl::OUString aStr(aBStr.GetBuffer(),aBStr.Len(), getConnection()->getTextEncoding()); - aVariable = Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aStr.getStr()),sizeof(sal_Unicode)*aStr.getLength()); - } - else - { - Sequence<sal_Int8> aText(nLength); - sal_Int8* pData = aText.getArray(); - sal_Char cChar; - for (ULONG i = 0; i < nLength; i++) - { - m_pMemoStream->Read(&cChar,1); - (*pData++) = cChar; - } - aVariable = aText; - // return sal_False; - } - } - } - return sal_True; -} // ------------------------------------------------------------------------- void ODbaseTable::FileClose() { @@ -1464,171 +1277,6 @@ BOOL ODbaseTable::DeleteRow(const OSQLColumns& _rCols) m_pFileStream->Flush(); return sal_True;; } - -//------------------------------------------------------------------ -BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr) -{ - // wird die BlockNr 0 vorgegeben, wird der block ans Ende gehaengt - char cChar = 0; - BOOL bIsText = TRUE; - // SdbConnection* pConnection = GetConnection(); - - ULONG nSize = 0; - ULONG nStreamSize; - BYTE nHeader[4]; - - ByteString aStr; - // ::Sequence<sal_Int8>* pData = NULL; -// if (aVariable.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence< sal_Int8 > *)0)) -// { -// pData = (::Sequence<sal_Int8>*)aVariable.get(); -// nSize = pData->getLength(); -// } -// else -// { - aStr = ByteString(String(aVariable.getString()), getConnection()->getTextEncoding()); - nSize = aStr.Len(); - // } - - // Anhaengen oder ueberschreiben - BOOL bAppend = rBlockNr == 0; - - if (!bAppend) - { - switch (m_aMemoHeader.db_typ) - { - case MemodBaseIII: // dBase III-Memofeld, endet mit 2 * Ctrl-Z - bAppend = nSize > (512 - 2); - break; - case MemoFoxPro: - case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe - { - char sHeader[4]; - m_pMemoStream->Seek(rBlockNr * m_aMemoHeader.db_size); - m_pMemoStream->SeekRel(4L); - m_pMemoStream->Read(sHeader,4); - - ULONG nOldSize; - if (m_aMemoHeader.db_typ == MemoFoxPro) - nOldSize = ((((unsigned char)sHeader[0]) * 256 + - (unsigned char)sHeader[1]) * 256 + - (unsigned char)sHeader[2]) * 256 + - (unsigned char)sHeader[3]; - else - nOldSize = ((((unsigned char)sHeader[3]) * 256 + - (unsigned char)sHeader[2]) * 256 + - (unsigned char)sHeader[1]) * 256 + - (unsigned char)sHeader[0] - 8; - - // passt die neue Laenge in die belegten Bloecke - ULONG nUsedBlocks = ((nSize + 8) / m_aMemoHeader.db_size) + (((nSize + 8) % m_aMemoHeader.db_size > 0) ? 1 : 0), - nOldUsedBlocks = ((nOldSize + 8) / m_aMemoHeader.db_size) + (((nOldSize + 8) % m_aMemoHeader.db_size > 0) ? 1 : 0); - bAppend = nUsedBlocks > nOldUsedBlocks; - } - } - } - - if (bAppend) - { - ULONG nStreamSize; - nStreamSize = m_pMemoStream->Seek(STREAM_SEEK_TO_END); - // letzten block auffuellen - rBlockNr = (nStreamSize / m_aMemoHeader.db_size) + ((nStreamSize % m_aMemoHeader.db_size) > 0 ? 1 : 0); - - m_pMemoStream->SetStreamSize(rBlockNr * m_aMemoHeader.db_size); - m_pMemoStream->Seek(STREAM_SEEK_TO_END); - } - else - { - m_pMemoStream->Seek(rBlockNr * m_aMemoHeader.db_size); - } - - switch (m_aMemoHeader.db_typ) - { - case MemodBaseIII: // dBase III-Memofeld, endet mit Ctrl-Z - { - const char cEOF = (char) 0x1a; - nSize++; - -// if (pData) -// { -// m_pMemoStream->Write((const char*) pData->getConstArray(), pData->getLength()); -// } -// else -// { - m_pMemoStream->Write(aStr.GetBuffer(), aStr.Len()); - // } - - (*m_pMemoStream) << cEOF << cEOF; - } break; - case MemoFoxPro: - case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe - { - (*m_pMemoStream) << (BYTE)0xFF - << (BYTE)0xFF - << (BYTE)0x08; - - UINT32 nWriteSize = nSize; - if (m_aMemoHeader.db_typ == MemoFoxPro) - { - (*m_pMemoStream) << (BYTE) 0x01; // ((pData = NULL) ? 0x01 : 0x00); - for (int i = 4; i > 0; nWriteSize >>= 8) - nHeader[--i] = (BYTE) (nWriteSize % 256); - } - else - { - (*m_pMemoStream) << (BYTE) 0x00; - nWriteSize += 8; - for (int i = 0; i < 4; nWriteSize >>= 8) - nHeader[i++] = (BYTE) (nWriteSize % 256); - } - - m_pMemoStream->Write(nHeader,4); -// if (pData) -// { -// m_pMemoStream->Write((const char*) pData->getConstArray(), pData->getLength()); -// } -// else -// { - m_pMemoStream->Write(aStr.GetBuffer(), aStr.Len()); - // } - m_pMemoStream->Flush(); - } - } - - - // Schreiben der neuen Blocknummer - if (bAppend) - { - nStreamSize = m_pMemoStream->Seek(STREAM_SEEK_TO_END); - m_aMemoHeader.db_next = (nStreamSize / m_aMemoHeader.db_size) + ((nStreamSize % m_aMemoHeader.db_size) > 0 ? 1 : 0); - - // Schreiben der neuen Blocknummer - m_pMemoStream->Seek(0L); - (*m_pMemoStream) << m_aMemoHeader.db_next; - m_pMemoStream->Flush(); - } - return sal_True; -} -//------------------------------------------------------------------ -void ODbaseTable::AllocBuffer() -{ - UINT16 nSize = m_aHeader.db_slng; - OSL_ENSURE(nSize > 0, "Size too small"); - - if (m_nBufferSize != nSize) - { - delete m_pBuffer; - m_pBuffer = NULL; - } - - // Falls noch kein Puffer vorhanden: allozieren: - if (m_pBuffer == NULL && nSize) - { - m_nBufferSize = nSize; - m_pBuffer = new BYTE[m_nBufferSize+1]; - } -} // ------------------------------------------------------------------------- Reference<XPropertySet> ODbaseTable::isUniqueByColumnName(const ::rtl::OUString& _rColName) { @@ -1895,18 +1543,6 @@ BOOL ODbaseTable::UpdateBuffer(OValueVector& rRow, OValueRow pOrgRow,const Refer } return sal_True; } - - -//------------------------------------------------------------------ -BOOL ODbaseTable::WriteBuffer() -{ - OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position"); - - // Auf gewuenschten Record positionieren: - long nPos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng; - m_pFileStream->Seek(nPos); - return m_pFileStream->Write((char*) m_pBuffer, m_aHeader.db_slng) > 0; -} // ----------------------------------------------------------------------------- // XAlterTable void SAL_CALL ODbaseTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException) @@ -2167,7 +1803,4 @@ void ODbaseTable::copyData(ODbaseTable* _pNewTable) } } // ----------------------------------------------------------------------------- -sal_Int32 ODbaseTable::getCurrentLastPos() const -{ - return m_aHeader.db_anz; -} + diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx index c1ae7aebc2ed..56aa81ce2330 100644 --- a/connectivity/source/drivers/dbase/dindexnode.cxx +++ b/connectivity/source/drivers/dbase/dindexnode.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dindexnode.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: oj $ $Date: 2001-05-10 14:30:43 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -381,19 +381,6 @@ BOOL ONDXPage::Append(ONDXNode& rNode) DBG_ASSERT(!IsFull(), "kein Append moeglich"); return Insert(nCount, rNode); } - -//------------------------------------------------------------------ -void ONDXPage::Remove(USHORT nPos) -{ - DBG_ASSERT(nCount > nPos, "falscher Indexzugriff"); - - for (USHORT i = nPos; i < (nCount-1); i++) - (*this)[i] = (*this)[i+1]; - - nCount--; - bModified = TRUE; -} - //------------------------------------------------------------------ void ONDXPage::Release(BOOL bSave) { @@ -430,68 +417,6 @@ void ONDXPage::ReleaseFull(BOOL bSave) aTempParent->GetChild().Clear(); } } - - -//------------------------------------------------------------------ -ONDXNode& ONDXPage::operator[] (USHORT nPos) -{ - DBG_ASSERT(nCount > nPos, "falscher Indexzugriff"); - return ppNodes[nPos]; -} - -//------------------------------------------------------------------ -const ONDXNode& ONDXPage::operator[] (USHORT nPos) const -{ - DBG_ASSERT(nCount > nPos, "falscher Indexzugriff"); - return ppNodes[nPos]; -} - -//------------------------------------------------------------------ -// laeuft rekursiv -void ONDXPage::SearchAndReplace(const ONDXKey& rSearch, - ONDXKey& rReplace) -{ - if (rSearch == rReplace) - return; - - USHORT nPos = NODE_NOTFOUND; - ONDXPage* pPage = this; - - while (pPage && (nPos = pPage->Search(rSearch)) == NODE_NOTFOUND) - pPage = pPage->aParent; - - if (pPage) - { - (*pPage)[nPos].GetKey() = rReplace; - pPage->SetModified(TRUE); - } -} - -//------------------------------------------------------------------ -USHORT ONDXPage::Search(const ONDXKey& rSearch) -{ - // binare Suche spaeter - USHORT i = 0xFFFF; - while (++i < Count()) - if ((*this)[i].GetKey() == rSearch) - break; - - return (i < Count()) ? i : NODE_NOTFOUND; -} - -//------------------------------------------------------------------ -USHORT ONDXPage::Search(const ONDXPage* pPage) -{ - USHORT i = 0xFFFF; - while (++i < Count()) - if (((*this)[i]).GetChild() == pPage) - break; - - // wenn nicht gefunden, dann wird davon ausgegangen, dass die Seite selbst - // auf die Page zeigt - return (i < Count()) ? i : NODE_NOTFOUND; -} - //------------------------------------------------------------------ BOOL ONDXPage::Delete(USHORT nNodePos) { @@ -812,242 +737,9 @@ void ONDXPage::Merge(USHORT nParentNodePos, ONDXPagePtr xPage) } } // ------------------------------------------------------------------------- -BOOL ONDXPage::IsFull() const -{ - return Count() == rIndex.getHeader().db_maxkeys; -} - -#ifdef DEBUG -//------------------------------------------------------------------ -void ONDXPage::PrintPage() -{ - DBG_TRACE4("\nSDB: -----------Page: %d Parent: %d Count: %d Child: %d-----", - nPagePos, HasParent() ? aParent->GetPagePos() : 0 ,nCount, aChild.GetPagePos()); - - for (USHORT i = 0; i < nCount; i++) - { - ONDXNode rNode = (*this)[i]; - ONDXKey& rKey = rNode.GetKey(); - if (!IsLeaf()) - rNode.GetChild(&rIndex, this); - - if (rKey.getValue().isNull()) - { - DBG_TRACE2("SDB: [%d,NULL,%d]",rKey.GetRecord(), rNode.GetChild().GetPagePos()); - } - else if (rIndex.getHeader().db_keytype) - { - DBG_TRACE3("SDB: [%d,%f,%d]",rKey.GetRecord(), rKey.getValue().getDouble(),rNode.GetChild().GetPagePos()); - } - else - { - DBG_TRACE3("SDB: [%d,%s,%d]",rKey.GetRecord(), (const char* )ByteString(rKey.getValue().getString().getStr(), rIndex.m_pTable->getConnection()->getTextEncoding()).GetBuffer(),rNode.GetChild().GetPagePos()); - } - } - DBG_TRACE("SDB: -----------------------------------------------\n"); - if (!IsLeaf()) - { - GetChild(&rIndex)->PrintPage(); - for (USHORT i = 0; i < nCount; i++) - { - ONDXNode rNode = (*this)[i]; - rNode.GetChild(&rIndex,this)->PrintPage(); - } - } - DBG_TRACE("SDB: ===============================================\n"); -} -#endif - - -static UINT32 nValue; -//------------------------------------------------------------------ -SvStream& connectivity::dbase::operator >> (SvStream &rStream, ONDXPage& rPage) -{ - rStream.Seek(rPage.GetPagePos() * 512); - rStream >> nValue >> rPage.aChild; - rPage.nCount = USHORT(nValue); - -// DBG_ASSERT(rPage.nCount && rPage.nCount < rPage.GetIndex().GetMaxNodes(), "Falscher Count"); - for (USHORT i = 0; i < rPage.nCount; i++) - rPage[i].Read(rStream, rPage.GetIndex()); - return rStream; -} - -//------------------------------------------------------------------ -SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& rPage) -{ - // Seite existiert noch nicht - ULONG nSize = (rPage.GetPagePos() + 1) * 512; - if (nSize > rStream.Seek(STREAM_SEEK_TO_END)) - { - rStream.SetStreamSize(nSize); - rStream.Seek(rPage.GetPagePos() * 512); - - char aEmptyData[512]; - memset(aEmptyData,0x00,512); - rStream.Write((BYTE*)aEmptyData,512); - } - ULONG nCurrentPos = rStream.Seek(rPage.GetPagePos() * 512); - - nValue = rPage.nCount; - rStream << nValue << rPage.aChild; - - USHORT i = 0; - for (; i < rPage.nCount; i++) - rPage[i].Write(rStream, rPage); - - // check if we have to fill the stream with '\0' - if(i < rPage.rIndex.getHeader().db_maxkeys) - { - ULONG nTell = rStream.Tell() % 512; - USHORT nBufferSize = rStream.GetBufferSize(); - ULONG nSize = nBufferSize - nTell; - char* pEmptyData = new char[nSize]; - memset(pEmptyData,0x00,nSize); - rStream.Write((BYTE*)pEmptyData,nSize); - rStream.Seek(nTell); - delete pEmptyData; - } - return rStream; -} - -//================================================================== -// ONDXNode -//================================================================== - -//------------------------------------------------------------------ -void ONDXNode::Read(SvStream &rStream, ODbaseIndex& rIndex) -{ - rStream >> (sal_uInt32)aKey.nRecord; // schluessel - if (rIndex.getHeader().db_keytype) - { - double aDbl; - rStream >> aDbl; - aKey = ONDXKey(aDbl,aKey.nRecord); - } - else - { - ByteString aBuf; - USHORT nLen = rIndex.getHeader().db_keylen; - char* pStr = aBuf.AllocBuffer(nLen+1); - - rStream.Read(pStr,nLen); - pStr[nLen] = 0; - aBuf.ReleaseBufferAccess(); - aBuf.EraseTrailingChars(); - - // aKey = ONDXKey((aBuf,rIndex.GetDBFConnection()->GetCharacterSet()) ,aKey.nRecord); - aKey = ONDXKey(::rtl::OUString(aBuf.GetBuffer(),aBuf.Len(),rIndex.m_pTable->getConnection()->getTextEncoding()) ,aKey.nRecord); - } - rStream >> aChild; -} - -union -{ - double aDbl; - char aData[128]; -} aNodeData; -//------------------------------------------------------------------ -void ONDXNode::Write(SvStream &rStream, const ONDXPage& rPage) const -{ - const ODbaseIndex& rIndex = rPage.GetIndex(); - if (!rIndex.isUnique() || rPage.IsLeaf()) - rStream << (sal_uInt32)aKey.nRecord; // schluessel - else - rStream << (sal_uInt32)0; // schluessel - - if (rIndex.getHeader().db_keytype) // double - { - if (aKey.getValue().isNull()) - { - memset(aNodeData.aData,0,rIndex.getHeader().db_keylen); - rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen); - } - else - rStream << (double) aKey.getValue(); - } - else - { - memset(aNodeData.aData,0x20,rIndex.getHeader().db_keylen); - if (!aKey.getValue().isNull()) - { - ::rtl::OUString sValue = aKey.getValue(); - ByteString aText(sValue.getStr(), rIndex.m_pTable->getConnection()->getTextEncoding()); - strncpy(aNodeData.aData,aText.GetBuffer(),min(rIndex.getHeader().db_keylen, aText.Len())); - } - rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen); - } - rStream << aChild; -} - - -//------------------------------------------------------------------ -ONDXPagePtr& ONDXNode::GetChild(ODbaseIndex* pIndex, ONDXPage* pParent) -{ - if (!aChild.Is() && pIndex) - { - aChild = pIndex->CreatePage(aChild.GetPagePos(),pParent,aChild.HasPage()); - } - return aChild; -} - -//================================================================== -// ONDXKey -//================================================================== -//------------------------------------------------------------------ -BOOL ONDXKey::IsText(sal_Int32 eType) -{ - return eType == DataType::VARCHAR || eType == DataType::CHAR; -} - -//------------------------------------------------------------------ -StringCompare ONDXKey::Compare(const ONDXKey& rKey) const -{ - // DBG_ASSERT(is(), "Falscher Indexzugriff"); - StringCompare eResult; - if (getValue().isNull()) - { - if (rKey.getValue().isNull() || (rKey.IsText(getDBType()) && !rKey.getValue().getString().getLength())) - eResult = COMPARE_EQUAL; - else - eResult = COMPARE_LESS; - } - else if (rKey.getValue().isNull()) - { - if (getValue().isNull() || (IsText(getDBType()) && !getValue().getString().getLength())) - eResult = COMPARE_EQUAL; - else - eResult = COMPARE_GREATER; - } - else if (IsText(getDBType())) - { - INT32 nRes = getValue().getString().compareTo(rKey.getValue()); - eResult = (nRes > 0) ? COMPARE_GREATER : (nRes == 0) ? COMPARE_EQUAL : COMPARE_LESS; - } - else - { - double m = getValue(),n = rKey.getValue(); - eResult = (m > n) ? COMPARE_GREATER : (n == m) ? COMPARE_EQUAL : COMPARE_LESS; - } - // Record vergleich, wenn Index !Unique - if (eResult == COMPARE_EQUAL && nRecord && rKey.nRecord) - eResult = (nRecord > rKey.nRecord) ? COMPARE_GREATER : - (nRecord == rKey.nRecord) ? COMPARE_EQUAL : COMPARE_LESS; - return eResult; -} -// ----------------------------------------------------------------------------- -void ONDXKey::setValue(const ORowSetValue& _rVal) -{ - xValue = _rVal; -} -// ----------------------------------------------------------------------------- -const ORowSetValue& ONDXKey::getValue() const -{ - return xValue; -} // ----------------------------------------------------------------------------- //namespace connectivity //{ @@ -1056,52 +748,5 @@ const ORowSetValue& ONDXKey::getValue() const // SV_IMPL_REF(ONDXPage); // } //} -//================================================================== -// ONDXPagePtr -//================================================================== -//------------------------------------------------------------------ -SvStream& connectivity::dbase::operator >> (SvStream &rStream, ONDXPagePtr& rPage) -{ - rStream >> rPage.nPagePos; - return rStream; -} - -//------------------------------------------------------------------ -SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPagePtr& rPage) -{ - rStream << rPage.nPagePos; - return rStream; -} -//------------------------------------------------------------------ -ONDXPagePtr::ONDXPagePtr(const ONDXPagePtr& rRef) - :ONDXPageRef(rRef) - ,nPagePos(rRef.nPagePos) -{ -} - -//------------------------------------------------------------------ -ONDXPagePtr::ONDXPagePtr(ONDXPage* pRefPage) - :ONDXPageRef(pRefPage) - ,nPagePos(0) -{ - if (pRefPage) - nPagePos = pRefPage->GetPagePos(); -} -//------------------------------------------------------------------ -ONDXPagePtr& ONDXPagePtr::operator=(const ONDXPagePtr& rRef) -{ - ONDXPageRef::operator=(rRef); - nPagePos = rRef.nPagePos; - return *this; -} - -//------------------------------------------------------------------ -ONDXPagePtr& ONDXPagePtr::operator= (ONDXPage* pRef) -{ - ONDXPageRef::operator=(pRef); - nPagePos = (pRef) ? pRef->GetPagePos() : 0; - return *this; -} -// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/dbase/makefile.mk b/connectivity/source/drivers/dbase/makefile.mk index 8c77904c86bf..b9334fe7911d 100644 --- a/connectivity/source/drivers/dbase/makefile.mk +++ b/connectivity/source/drivers/dbase/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.16 $ +# $Revision: 1.17 $ # -# last change: $Author: oj $ $Date: 2001-05-14 11:37:37 $ +# last change: $Author: oj $ $Date: 2001-05-23 09:13:10 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -65,8 +65,6 @@ PRJINC=..$/.. PRJNAME=connectivity TARGET=dbase -ENABLE_EXCEPTIONS=TRUE - # --- Settings ---------------------------------- .IF "$(DBGUTIL_OJ)"!="" ENVCFLAGS+=/FR$(SLO)$/ @@ -78,6 +76,7 @@ ENVCFLAGS+=/FR$(SLO)$/ # --- Files ------------------------------------- SLOFILES=\ + $(SLO)$/DNoException.obj \ $(SLO)$/DCode.obj \ $(SLO)$/DResultSet.obj \ $(SLO)$/DStatement.obj \ @@ -97,6 +96,27 @@ SLOFILES=\ $(SLO)$/Dservices.obj \ $(SLO)$/DDriver.obj +EXCEPTIONSFILES=\ + $(SLO)$/DCode.obj \ + $(SLO)$/DResultSet.obj \ + $(SLO)$/DStatement.obj \ + $(SLO)$/DPreparedStatement.obj \ + $(SLO)$/dindexnode.obj \ + $(SLO)$/DIndexPage.obj \ + $(SLO)$/DIndexIter.obj \ + $(SLO)$/DDatabaseMetaData.obj \ + $(SLO)$/DCatalog.obj \ + $(SLO)$/DColumns.obj \ + $(SLO)$/DIndexColumns.obj \ + $(SLO)$/DIndex.obj \ + $(SLO)$/DIndexes.obj \ + $(SLO)$/DTable.obj \ + $(SLO)$/DTables.obj \ + $(SLO)$/DConnection.obj \ + $(SLO)$/Dservices.obj \ + $(SLO)$/DDriver.obj + + .IF "$(OS)"=="MACOSX" #SHL1VERSIONMAP=$(TARGET).$(DLLPOSTFIX).map .ELSE diff --git a/connectivity/source/drivers/file/FCatalog.cxx b/connectivity/source/drivers/file/FCatalog.cxx index 0f60ead02f37..0566d51d415d 100644 --- a/connectivity/source/drivers/file/FCatalog.cxx +++ b/connectivity/source/drivers/file/FCatalog.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FCatalog.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-05-02 12:54:56 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -116,6 +116,8 @@ void OFileCatalog::refreshTables() aVector.push_back(xRow->getString(3)); } if(m_pTables) + m_pTables->reFill(aVector); + else delete m_pTables; m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector); } @@ -153,8 +155,4 @@ Sequence< Type > SAL_CALL OFileCatalog::getTypes( ) throw(RuntimeException) } return aRet; } -// ----------------------------------------------------------------------------- -void OFileCatalog::refreshViews(){} -void OFileCatalog::refreshGroups(){} -void OFileCatalog::refreshUsers(){} diff --git a/connectivity/source/drivers/file/FDriver.cxx b/connectivity/source/drivers/file/FDriver.cxx index 5f7688603102..a9b037a072c1 100644 --- a/connectivity/source/drivers/file/FDriver.cxx +++ b/connectivity/source/drivers/file/FDriver.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FDriver.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-05-17 09:13:20 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,9 +65,15 @@ #ifndef _CONNECTIVITY_FILE_OCONNECTION_HXX_ #include "file/FConnection.hxx" #endif +#ifndef _CONNECTIVITY_FILE_FCODE_HXX_ +#include "file/fcode.hxx" +#endif #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ #include <com/sun/star/lang/DisposedException.hpp> #endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif using namespace connectivity::file; using namespace com::sun::star::uno; @@ -213,6 +219,36 @@ Reference< XTablesSupplier > SAL_CALL OFileDriver::getDataDefinitionByURL( const return getDataDefinitionByConnection(connect(url,info)); } // ----------------------------------------------------------------------------- +void OOperandParam::describe(const Reference< XPropertySet>& rColumn, ::vos::ORef<connectivity::OSQLColumns> rParameterColumns) +{ + // den alten namen beibehalten + + Reference< XPropertySet> xColumn = (*rParameterColumns)[getRowPos()]; + + try + { + xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))); + xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))); + xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))); + xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))); + xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))); + xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))); + xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT))); + } + catch(const Exception&) + { + } + + m_eDBType = ::comphelper::getINT32(rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))); +} +// ----------------------------------------------------------------------------- +OOperandAttr::OOperandAttr(sal_uInt16 _nPos,const Reference< XPropertySet>& _xColumn) + : OOperandRow(_nPos,::comphelper::getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))) + , m_xColumn(_xColumn) +{ +} +// ----------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/file/FNoException.cxx b/connectivity/source/drivers/file/FNoException.cxx new file mode 100644 index 000000000000..540914620d9e --- /dev/null +++ b/connectivity/source/drivers/file/FNoException.cxx @@ -0,0 +1,425 @@ +/************************************************************************* + * + * $RCSfile: FNoException.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-05-23 09:17:04 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CONNECTIVITY_FILE_CATALOG_HXX_ +#include "file/FCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_FCOMP_HXX_ +#include "file/fcomp.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_FANALYZER_HXX_ +#include "file/fanalyzer.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_FRESULTSET_HXX_ +#include "file/FResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_VALUE_HXX_ +#include "FValue.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +using namespace connectivity; +using namespace connectivity::file; +// ----------------------------------------------------------------------------- +void OFileCatalog::refreshViews() +{} +void OFileCatalog::refreshGroups() +{} +void OFileCatalog::refreshUsers() +{ +} +// ----------------------------------------------------------------------------- +OPredicateInterpreter::~OPredicateInterpreter() +{ + while(!m_aStack.empty()) + { + delete m_aStack.top(); + m_aStack.pop(); + } + // m_aStack.clear(); +} +// ----------------------------------------------------------------------------- +void OPredicateCompiler::Clean() +{ + for(OCodeList::reverse_iterator aIter = m_aCodeList.rbegin(); aIter != m_aCodeList.rend();++aIter) + { + delete *aIter; + m_aCodeList.pop_back(); + } + // m_aCodeList.clear(); +} +// ----------------------------------------------------------------------------- +void OSQLAnalyzer::clean() +{ + m_aCompiler.Clean(); +} +// ----------------------------------------------------------------------------- +void OSQLAnalyzer::bindParameterRow(OValueRow _pRow) +{ + OCodeList& rCodeList = m_aCompiler.m_aCodeList; + for(OCodeList::iterator aIter = rCodeList.begin(); aIter != rCodeList.end();++aIter) + { + OOperandParam* pParam = PTR_CAST(OOperandParam,(*aIter)); + if (pParam) + pParam->bindValue(_pRow); + } +} +// ----------------------------------------------------------------------------- +sal_Bool OResultSet::isCount() const +{ + return (m_pParseTree && + m_pParseTree->count() > 2 && + SQL_ISRULE(m_pParseTree->getChild(2),scalar_exp_commalist) && + SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0),derived_column) && + SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0)->getChild(0),general_set_fct) + ); +} +// ----------------------------------------------------------------------------- +void OResultSet::scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes) +{ + DBG_ASSERT(pParseNode != NULL,"OResultSet: interner Fehler: ungueltiger ParseNode"); + + // Parameter Name-Regel gefunden? + if (SQL_ISRULE(pParseNode,parameter)) + { + DBG_ASSERT(pParseNode->count() >= 1,"OResultSet: Parse Tree fehlerhaft"); + DBG_ASSERT(pParseNode->getChild(0)->getNodeType() == SQL_NODE_PUNCTUATION,"OResultSet: Parse Tree fehlerhaft"); + + _rParaNodes.push_back(pParseNode); + // Weiterer Abstieg nicht erforderlich + return; + } + + // Weiter absteigen im Parse Tree + for (UINT32 i = 0; i < pParseNode->count(); i++) + scanParameter(pParseNode->getChild(i),_rParaNodes); +} +// ----------------------------------------------------------------------------- +//------------------------------------------------------------------ +int +#if defined(WIN) || defined(WNT) +__cdecl +#endif +#if defined(ICC) && defined(OS2) +_Optlink +#endif +connectivity::file::OFILEKeyCompare(const void * elem1, const void * elem2) +{ + const OFILESortIndex * pIndex = OFILESortIndex::pCurrentIndex; + const OFILEKeyValue * pKeyValue1 = (OFILEKeyValue *) * (OFILEKeyValue **) elem1; + const OFILEKeyValue * pKeyValue2 = (OFILEKeyValue *) * (OFILEKeyValue **) elem2; + + // Ueber die (max.) drei ORDER BY-Columns iterieren. Abbruch des Vergleiches, wenn Ungleichheit erkannt + // 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 nLess = - nGreater; + + // Vergleich (je nach Datentyp): + switch (pIndex->eKeyType[i]) + { + case SQL_ORDERBYKEY_STRING: + { + INT32 nRes = pKeyValue1->GetKeyString(i)->compareTo(*pKeyValue2->GetKeyString(i)); + if (nRes < 0) + return nLess; + else if (nRes > 0) + return nGreater; + } + break; + case SQL_ORDERBYKEY_DOUBLE: + { + double d1 = pKeyValue1->GetKeyDouble(i); + double d2 = pKeyValue2->GetKeyDouble(i); + + if (d1 < d2) + return nLess; + else if (d1 > d2) + return nGreater; + } + break; + } + } + + // Wenn wir bis hierher gekommen sind, waren alle Werte gleich: + return 0; +} +// ----------------------------------------------------------------------------- +//------------------------------------------------------------------ +OKeySet* OFILESortIndex::CreateKeySet() +{ + + OSL_ENSURE(! bFrozen,"OFILESortIndex::Freeze: already frozen!"); + + // Kritischer Bereich: Hinterlegung von this in statischer Variable. + // Zugriff auf diese Variable von der OFILECompare-Funktion aus. + // Da dies NUR waehrend der Ausfuehrung der qsort-Funktion stattfindet, + // ist dies aber unkritisch: unter Windows 3.x ist diese Ausfuehrung + // UNUNTERBRECHBAR; unter NT, OS/2, Unix, ... hat jede DLL ihr + // eigenes Datensegment. + pCurrentIndex = this; + eCurrentCharSet = eCharSet; + + // Sortierung: + if (eKeyType[0] != SQL_ORDERBYKEY_NONE) + // Sortierung, wenn mindestens nach dem ersten Key sortiert werden soll: + qsort(ppKeyValueArray,nCount,sizeof(void *),&OFILEKeyCompare); + + + // Ende des kritischen Bereiches + pCurrentIndex = NULL; + + + OKeySet* pKeySet = new OKeySet(nCount); + OKeySet::iterator aIter = pKeySet->begin(); + for (INT32 i = 0; i < nCount; i++,++aIter) + { + OFILEKeyValuePtr pKeyValue = ppKeyValueArray[i]; + + OSL_ENSURE(pKeyValue != NULL,"OFILESortIndex::Freeze: pKeyValue == NULL"); + (*aIter) = pKeyValue->GetValue(); // Wert holen ... + + // Strings in KeyValue freigeben! + for (int j = 0; j < SQL_ORDERBYKEYS; j++) + { + if (eKeyType[j] == SQL_ORDERBYKEY_STRING) + delete pKeyValue->GetKeyString(j); + } + delete pKeyValue; + } + bFrozen = TRUE; + pKeySet->setFrozen(); + return pKeySet; +} +// ----------------------------------------------------------------------------- +OFILESortIndex * OFILESortIndex::pCurrentIndex; +CharSet OFILESortIndex::eCurrentCharSet; +//------------------------------------------------------------------ +OFILESortIndex::OFILESortIndex(const OKeyType eKeyType2[], // Genau 3 Eintraege! + const BOOL bAscending2[], // Genau 3 Eintraege! + INT32 nMaxNumberOfRows, rtl_TextEncoding eSet) // Obere Schranke fuer die Anzahl indizierbarer Zeilen + : nMaxCount(nMaxNumberOfRows), + nCount(0), + bFrozen(FALSE), eCharSet(eSet) +{ + for (int j = 0; j < SQL_ORDERBYKEYS; j++) + { + eKeyType[j] = eKeyType2[j]; + bAscending[j] = bAscending2[j]; + } + +#if defined MAX_KEYSET_SIZE + // Zur Sicherheit Maximalgroesse nochmal pruefen: + if (nMaxCount > MAX_KEYSET_SIZE) + { + DBG_WARNING("OFILESortIndex::OFILESortIndex: nMaxNumberOfRows zur Zeit auf <16K beschraenkt!"); + nMaxCount = MAX_KEYSET_SIZE; + } +#endif + if (nMaxCount <= 0) + nMaxCount = USHORT(-1); + + ppKeyValueArray = new OFILEKeyValuePtr[nMaxCount]; + + for (INT32 i = 0; i < nMaxCount; i++) + ppKeyValueArray[i] = NULL; +} + +//------------------------------------------------------------------ +OFILESortIndex::~OFILESortIndex() +{ + __DELETE(nMaxCount) ppKeyValueArray; +} + + +//------------------------------------------------------------------ +BOOL OFILESortIndex::AddKeyValue(OFILEKeyValue * pKeyValue) +{ + if (nCount < nMaxCount) + { + if (bFrozen) // wenn der Index schon eingefroren + // dann wird der Key einfach ans Ende gehaengt + { + OSL_ENSURE(pKeyValue != NULL,"OFILESortIndex::Freeze: pKeyValue == NULL"); + INT32 nValue = pKeyValue->GetValue(); // Wert holen ... + + // Strings in KeyValue freigeben! + for (int j = 0; j < SQL_ORDERBYKEYS; j++) + { + if (eKeyType[j] == SQL_ORDERBYKEY_STRING) + delete pKeyValue->GetKeyString(j); + } + delete pKeyValue; + ppKeyValueArray[nCount++] = (OFILEKeyValuePtr) nValue; + } + else + ppKeyValueArray[nCount++] = pKeyValue; + return TRUE; + } + else + return FALSE; +} + + +//------------------------------------------------------------------ +void OFILESortIndex::Freeze() +{ + OSL_ENSURE(! bFrozen,"OFILESortIndex::Freeze: already frozen!"); + + // Kritischer Bereich: Hinterlegung von this in statischer Variable. + // Zugriff auf diese Variable von der OFILECompare-Funktion aus. + // Da dies NUR waehrend der Ausfuehrung der qsort-Funktion stattfindet, + // ist dies aber unkritisch: unter Windows 3.x ist diese Ausfuehrung + // UNUNTERBRECHBAR; unter NT, OS/2, Unix, ... hat jede DLL ihr + // eigenes Datensegment. + pCurrentIndex = this; + eCurrentCharSet = eCharSet; + + // Sortierung: + if (eKeyType[0] != SQL_ORDERBYKEY_NONE) + // Sortierung, wenn mindestens nach dem ersten Key sortiert werden soll: + qsort(ppKeyValueArray,nCount,sizeof(void *),&OFILEKeyCompare); + + + // Ende des kritischen Bereiches + pCurrentIndex = NULL; + + // Wert auslesen, KeyValue loeschen und in den void * den Value + // reinschreiben (uebler Trick mit Typecast!) + for (INT32 i = 0; i < nCount; i++) + { + OFILEKeyValuePtr pKeyValue = ppKeyValueArray[i]; + + OSL_ENSURE(pKeyValue != NULL,"OFILESortIndex::Freeze: pKeyValue == NULL"); + INT32 nValue = pKeyValue->GetValue(); // Wert holen ... + + // Strings in KeyValue freigeben! + for (int j = 0; j < SQL_ORDERBYKEYS; j++) + { + if (eKeyType[j] == SQL_ORDERBYKEY_STRING) + delete pKeyValue->GetKeyString(j); + } + delete pKeyValue; + ppKeyValueArray[i] = (OFILEKeyValuePtr) nValue; + } + + bFrozen = TRUE; +} + +//------------------------------------------------------------------ +INT32 OFILESortIndex::GetValue(INT32 nPos) const +{ + OSL_ENSURE(nPos > 0,"OFILESortIndex::GetValue: nPos == 0"); + OSL_ENSURE(nPos <= nCount,"OFILESortIndex::GetValue: Zugriff ausserhalb der Array-Grenzen"); + +// OSL_ENSURE(ppKeyValueArray[nPos-1] != NULL,"OFILESortIndex::GetValue: interner Fehler: kein KeyValue an dieser Stelle"); +// return ppKeyValueArray[nPos-1]->GetValue(); + + if (!bFrozen) + { + if (eKeyType[0] == SQL_ORDERBYKEY_NONE) // wenn keine Sortierung vorliegt + // darf auf die Values schon vorher zugegriffen werden + return ppKeyValueArray[nPos-1]->GetValue(); + else + { + OSL_ASSERT("OFILESortIndex::GetValue: Invalid use of index!"); + return 0; + } + } + else + return (INT32) ppKeyValueArray[nPos-1]; // Trick: nach Freeze sind hier nur noch Values, keine KeyValue-Strukturen mehr! + +} +// ----------------------------------------------------------------------------- +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++) + { + if (m_nOrderbyColumnNumber[i] == SQL_COLUMN_NOTFOUND) break; + + ORowSetValue xKey = (*_rRow)[m_nOrderbyColumnNumber[i]]; + switch (xKey.getTypeKind()) + { + case ::com::sun::star::sdbc::DataType::VARCHAR: + case ::com::sun::star::sdbc::DataType::CHAR: + pKeyValue->SetKey(i,(rtl::OUString)xKey); + break; + default: + pKeyValue->SetKey(i,(double)xKey); + break; + } + } + return pKeyValue; +} +// ----------------------------------------------------------------------------- + + + + + + + + diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx index c86db187edda..5e0eb1ee81b2 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.17 $ + * $Revision: 1.18 $ * - * last change: $Author: oj $ $Date: 2001-05-17 06:46:53 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,9 +79,6 @@ #ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> #endif -#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ -#include "connectivity/DateConversion.hxx" -#endif #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ #include <com/sun/star/lang/DisposedException.hpp> #endif diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx index 74030a8a11f0..d5aaf1846cf5 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.55 $ + * $Revision: 1.56 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:48:05 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -287,6 +287,12 @@ sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) t break; return i; } +// ----------------------------------------------------------------------------- +void OResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException) +{ + if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) + ::dbtools::throwInvalidIndexException(*this); +} // ------------------------------------------------------------------------- Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { @@ -294,8 +300,8 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getBinarySt checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); return NULL; } @@ -306,8 +312,8 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getCharacte checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); return NULL; } @@ -319,8 +325,8 @@ sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLExcep checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); m_bWasNull = (*m_aRow)[columnIndex].isNull(); return (*m_aRow)[columnIndex]; @@ -333,8 +339,8 @@ sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLExceptio checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); m_bWasNull = (*m_aRow)[columnIndex].isNull(); return (*m_aRow)[columnIndex]; @@ -347,8 +353,8 @@ Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) thro checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); m_bWasNull = (*m_aRow)[columnIndex].isNull(); // it could happen that values are updated as string and then called for as getBytes @@ -369,8 +375,8 @@ Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) thro checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); m_bWasNull = (*m_aRow)[columnIndex].isNull(); @@ -384,8 +390,8 @@ double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLExceptio checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); m_bWasNull = (*m_aRow)[columnIndex].isNull(); return (*m_aRow)[columnIndex]; @@ -398,8 +404,8 @@ float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); m_bWasNull = (*m_aRow)[columnIndex].isNull(); return (*m_aRow)[columnIndex]; @@ -412,8 +418,8 @@ sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLExceptio checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); m_bWasNull = (*m_aRow)[columnIndex].isNull(); return (*m_aRow)[columnIndex]; @@ -441,8 +447,8 @@ sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLExcepti ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); return sal_Int64(); @@ -466,8 +472,8 @@ Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 columnIndex ) throw checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); return NULL; } @@ -480,8 +486,8 @@ Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) throw(S checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); return NULL; } @@ -492,8 +498,8 @@ Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex ) throw(S checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); return NULL; } @@ -505,8 +511,8 @@ Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 columnIndex ) throw(SQL checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); return NULL; } @@ -529,8 +535,8 @@ sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLExcept checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); m_bWasNull = (*m_aRow)[columnIndex].isNull(); return (*m_aRow)[columnIndex]; @@ -544,8 +550,8 @@ sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLExcept checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); m_bWasNull = (*m_aRow)[columnIndex].isNull(); return (*m_aRow)[columnIndex]; @@ -560,8 +566,8 @@ sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLExcept checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); return (*m_aRow)[columnIndex]; @@ -575,8 +581,8 @@ sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLExcept checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); return (*m_aRow)[columnIndex]; } @@ -928,8 +934,8 @@ void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -944,8 +950,8 @@ void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) thr checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -958,8 +964,8 @@ void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw( checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -973,8 +979,8 @@ void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) thro checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -987,8 +993,8 @@ void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw( checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -997,8 +1003,8 @@ void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw( // ------------------------------------------------------------------------- void SAL_CALL OResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException) { - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); throw RuntimeException(); } @@ -1009,8 +1015,8 @@ void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQ checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -1024,8 +1030,8 @@ void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw( checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -1038,8 +1044,8 @@ void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUSt checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -1052,8 +1058,8 @@ void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sa checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -1066,8 +1072,8 @@ void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::s checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -1081,8 +1087,8 @@ void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::s checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -1096,8 +1102,8 @@ void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::s checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -1113,8 +1119,8 @@ void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Refer if(!x.is()) ::dbtools::throwFunctionSequenceException(*this); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); Sequence<sal_Int8> aSeq; x->readSomeBytes(aSeq,length); @@ -1130,8 +1136,8 @@ void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Re if(!x.is()) ::dbtools::throwFunctionSequenceException(*this); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); Sequence<sal_Int8> aSeq; x->readSomeBytes(aSeq,length); @@ -1152,8 +1158,8 @@ void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) th checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); (*m_aInsertRow)[columnIndex].setBound(sal_True); @@ -1166,8 +1172,8 @@ void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->size()) - throwInvalidIndexException(*this); + checkIndex(columnIndex ); + columnIndex = mapColumn(columnIndex); OSL_ENSURE(0,"OResultSet::updateNumericObject: NYI"); } @@ -1700,266 +1706,6 @@ sal_Bool OResultSet::moveAbsolute(sal_Int32 _nOffset,sal_Bool _bRetrieveData) return bDataFound; } // ------------------------------------------------------------------------- -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++) - { - if (m_nOrderbyColumnNumber[i] == SQL_COLUMN_NOTFOUND) break; - - ORowSetValue xKey = (*_rRow)[m_nOrderbyColumnNumber[i]]; - switch (xKey.getTypeKind()) - { - case ::com::sun::star::sdbc::DataType::VARCHAR: - case ::com::sun::star::sdbc::DataType::CHAR: - pKeyValue->SetKey(i,(rtl::OUString)xKey); - break; - default: - pKeyValue->SetKey(i,(double)xKey); - break; - } - } - return pKeyValue; -} -OFILESortIndex * OFILESortIndex::pCurrentIndex; -CharSet OFILESortIndex::eCurrentCharSet; -//------------------------------------------------------------------ -OFILESortIndex::OFILESortIndex(const OKeyType eKeyType2[], // Genau 3 Eintraege! - const BOOL bAscending2[], // Genau 3 Eintraege! - INT32 nMaxNumberOfRows, rtl_TextEncoding eSet) // Obere Schranke fuer die Anzahl indizierbarer Zeilen - : nMaxCount(nMaxNumberOfRows), - nCount(0), - bFrozen(FALSE), eCharSet(eSet) -{ - for (int j = 0; j < SQL_ORDERBYKEYS; j++) - { - eKeyType[j] = eKeyType2[j]; - bAscending[j] = bAscending2[j]; - } - -#if defined MAX_KEYSET_SIZE - // Zur Sicherheit Maximalgroesse nochmal pruefen: - if (nMaxCount > MAX_KEYSET_SIZE) - { - DBG_WARNING("OFILESortIndex::OFILESortIndex: nMaxNumberOfRows zur Zeit auf <16K beschraenkt!"); - nMaxCount = MAX_KEYSET_SIZE; - } -#endif - if (nMaxCount <= 0) - nMaxCount = USHORT(-1); - - ppKeyValueArray = new OFILEKeyValuePtr[nMaxCount]; - - for (INT32 i = 0; i < nMaxCount; i++) - ppKeyValueArray[i] = NULL; -} - -//------------------------------------------------------------------ -OFILESortIndex::~OFILESortIndex() -{ - __DELETE(nMaxCount) ppKeyValueArray; -} - - -//------------------------------------------------------------------ -BOOL OFILESortIndex::AddKeyValue(OFILEKeyValue * pKeyValue) -{ - if (nCount < nMaxCount) - { - if (bFrozen) // wenn der Index schon eingefroren - // dann wird der Key einfach ans Ende gehaengt - { - OSL_ENSURE(pKeyValue != NULL,"OFILESortIndex::Freeze: pKeyValue == NULL"); - INT32 nValue = pKeyValue->GetValue(); // Wert holen ... - - // Strings in KeyValue freigeben! - for (int j = 0; j < SQL_ORDERBYKEYS; j++) - { - if (eKeyType[j] == SQL_ORDERBYKEY_STRING) - delete pKeyValue->GetKeyString(j); - } - delete pKeyValue; - ppKeyValueArray[nCount++] = (OFILEKeyValuePtr) nValue; - } - else - ppKeyValueArray[nCount++] = pKeyValue; - return TRUE; - } - else - return FALSE; -} - - -//------------------------------------------------------------------ -void OFILESortIndex::Freeze() -{ - OSL_ENSURE(! bFrozen,"OFILESortIndex::Freeze: already frozen!"); - - // Kritischer Bereich: Hinterlegung von this in statischer Variable. - // Zugriff auf diese Variable von der OFILECompare-Funktion aus. - // Da dies NUR waehrend der Ausfuehrung der qsort-Funktion stattfindet, - // ist dies aber unkritisch: unter Windows 3.x ist diese Ausfuehrung - // UNUNTERBRECHBAR; unter NT, OS/2, Unix, ... hat jede DLL ihr - // eigenes Datensegment. - pCurrentIndex = this; - eCurrentCharSet = eCharSet; - - // Sortierung: - if (eKeyType[0] != SQL_ORDERBYKEY_NONE) - // Sortierung, wenn mindestens nach dem ersten Key sortiert werden soll: - qsort(ppKeyValueArray,nCount,sizeof(void *),&OFILEKeyCompare); - - - // Ende des kritischen Bereiches - pCurrentIndex = NULL; - - // Wert auslesen, KeyValue loeschen und in den void * den Value - // reinschreiben (uebler Trick mit Typecast!) - for (INT32 i = 0; i < nCount; i++) - { - OFILEKeyValuePtr pKeyValue = ppKeyValueArray[i]; - - OSL_ENSURE(pKeyValue != NULL,"OFILESortIndex::Freeze: pKeyValue == NULL"); - INT32 nValue = pKeyValue->GetValue(); // Wert holen ... - - // Strings in KeyValue freigeben! - for (int j = 0; j < SQL_ORDERBYKEYS; j++) - { - if (eKeyType[j] == SQL_ORDERBYKEY_STRING) - delete pKeyValue->GetKeyString(j); - } - delete pKeyValue; - ppKeyValueArray[i] = (OFILEKeyValuePtr) nValue; - } - - bFrozen = TRUE; -} - -//------------------------------------------------------------------ -INT32 OFILESortIndex::GetValue(INT32 nPos) const -{ - OSL_ENSURE(nPos > 0,"OFILESortIndex::GetValue: nPos == 0"); - OSL_ENSURE(nPos <= nCount,"OFILESortIndex::GetValue: Zugriff ausserhalb der Array-Grenzen"); - -// OSL_ENSURE(ppKeyValueArray[nPos-1] != NULL,"OFILESortIndex::GetValue: interner Fehler: kein KeyValue an dieser Stelle"); -// return ppKeyValueArray[nPos-1]->GetValue(); - - if (!bFrozen) - { - if (eKeyType[0] == SQL_ORDERBYKEY_NONE) // wenn keine Sortierung vorliegt - // darf auf die Values schon vorher zugegriffen werden - return ppKeyValueArray[nPos-1]->GetValue(); - else - { - OSL_ASSERT("OFILESortIndex::GetValue: Invalid use of index!"); - return 0; - } - } - else - return (INT32) ppKeyValueArray[nPos-1]; // Trick: nach Freeze sind hier nur noch Values, keine KeyValue-Strukturen mehr! - -} - -//------------------------------------------------------------------ -OKeySet* OFILESortIndex::CreateKeySet() -{ - - OSL_ENSURE(! bFrozen,"OFILESortIndex::Freeze: already frozen!"); - - // Kritischer Bereich: Hinterlegung von this in statischer Variable. - // Zugriff auf diese Variable von der OFILECompare-Funktion aus. - // Da dies NUR waehrend der Ausfuehrung der qsort-Funktion stattfindet, - // ist dies aber unkritisch: unter Windows 3.x ist diese Ausfuehrung - // UNUNTERBRECHBAR; unter NT, OS/2, Unix, ... hat jede DLL ihr - // eigenes Datensegment. - pCurrentIndex = this; - eCurrentCharSet = eCharSet; - - // Sortierung: - if (eKeyType[0] != SQL_ORDERBYKEY_NONE) - // Sortierung, wenn mindestens nach dem ersten Key sortiert werden soll: - qsort(ppKeyValueArray,nCount,sizeof(void *),&OFILEKeyCompare); - - - // Ende des kritischen Bereiches - pCurrentIndex = NULL; - - - OKeySet* pKeySet = new OKeySet(nCount); - OKeySet::iterator aIter = pKeySet->begin(); - for (INT32 i = 0; i < nCount; i++,++aIter) - { - OFILEKeyValuePtr pKeyValue = ppKeyValueArray[i]; - - OSL_ENSURE(pKeyValue != NULL,"OFILESortIndex::Freeze: pKeyValue == NULL"); - (*aIter) = pKeyValue->GetValue(); // Wert holen ... - - // Strings in KeyValue freigeben! - for (int j = 0; j < SQL_ORDERBYKEYS; j++) - { - if (eKeyType[j] == SQL_ORDERBYKEY_STRING) - delete pKeyValue->GetKeyString(j); - } - delete pKeyValue; - } - bFrozen = TRUE; - pKeySet->setFrozen(); - return pKeySet; -} - -//------------------------------------------------------------------ -int -#if defined(WIN) || defined(WNT) -__cdecl -#endif -#if defined(ICC) && defined(OS2) -_Optlink -#endif -connectivity::file::OFILEKeyCompare(const void * elem1, const void * elem2) -{ - const OFILESortIndex * pIndex = OFILESortIndex::pCurrentIndex; - const OFILEKeyValue * pKeyValue1 = (OFILEKeyValue *) * (OFILEKeyValue **) elem1; - const OFILEKeyValue * pKeyValue2 = (OFILEKeyValue *) * (OFILEKeyValue **) elem2; - - // Ueber die (max.) drei ORDER BY-Columns iterieren. Abbruch des Vergleiches, wenn Ungleichheit erkannt - // 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 nLess = - nGreater; - - // Vergleich (je nach Datentyp): - switch (pIndex->eKeyType[i]) - { - case SQL_ORDERBYKEY_STRING: - { - INT32 nRes = pKeyValue1->GetKeyString(i)->compareTo(*pKeyValue2->GetKeyString(i)); - if (nRes < 0) - return nLess; - else if (nRes > 0) - return nGreater; - } - break; - case SQL_ORDERBYKEY_DOUBLE: - { - double d1 = pKeyValue1->GetKeyDouble(i); - double d2 = pKeyValue2->GetKeyDouble(i); - - if (d1 < d2) - return nLess; - else if (d1 > d2) - return nGreater; - } - break; - } - } - - // Wenn wir bis hierher gekommen sind, waren alle Werte gleich: - return 0; -} -//------------------------------------------------------------------ BOOL OResultSet::OpenImpl() { m_pSQLAnalyzer = createAnalyzer(); @@ -2917,36 +2663,6 @@ void OResultSet::describeParameter() // } } } -//------------------------------------------------------------------ -void OResultSet::scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes) -{ - DBG_ASSERT(pParseNode != NULL,"OResultSet: interner Fehler: ungueltiger ParseNode"); - - // Parameter Name-Regel gefunden? - if (SQL_ISRULE(pParseNode,parameter)) - { - DBG_ASSERT(pParseNode->count() >= 1,"OResultSet: Parse Tree fehlerhaft"); - DBG_ASSERT(pParseNode->getChild(0)->getNodeType() == SQL_NODE_PUNCTUATION,"OResultSet: Parse Tree fehlerhaft"); - - _rParaNodes.push_back(pParseNode); - // Weiterer Abstieg nicht erforderlich - return; - } - - // Weiter absteigen im Parse Tree - for (UINT32 i = 0; i < pParseNode->count(); i++) - scanParameter(pParseNode->getChild(i),_rParaNodes); -} -// ----------------------------------------------------------------------------- -sal_Bool OResultSet::isCount() const -{ - return (m_pParseTree && - m_pParseTree->count() > 2 && - SQL_ISRULE(m_pParseTree->getChild(2),scalar_exp_commalist) && - SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0),derived_column) && - SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0)->getChild(0),general_set_fct) - ); -} // ----------------------------------------------------------------------------- void OResultSet::setBoundedColumns(const OValueRow& _rRow, const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns, diff --git a/connectivity/source/drivers/file/fanalyzer.cxx b/connectivity/source/drivers/file/fanalyzer.cxx index 71fc7d90ef46..edf8014855bf 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.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-05-08 13:26:37 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -233,19 +233,6 @@ void OSQLAnalyzer::start(OSQLParseNode* pSQLParseNode) } //------------------------------------------------------------------ -void OSQLAnalyzer::bindParameterRow(OValueRow _pRow) -{ - OCodeList& rCodeList = m_aCompiler.m_aCodeList; - for(OCodeList::iterator aIter = rCodeList.begin(); aIter != rCodeList.end();++aIter) - { - OOperandParam* pParam = PTR_CAST(OOperandParam,(*aIter)); - if (pParam) - pParam->bindValue(_pRow); - } -} - - -//------------------------------------------------------------------ void OSQLAnalyzer::describeParam(::vos::ORef<OSQLColumns> rParameterColumns) { OCodeList& rCodeList = m_aCompiler.m_aCodeList; @@ -305,11 +292,6 @@ void OSQLAnalyzer::describeParam(::vos::ORef<OSQLColumns> rParameterColumns) m_aCompiler.setParameterColumns(rParameterColumns); } -//------------------------------------------------------------------ -void OSQLAnalyzer::clean() -{ - m_aCompiler.Clean(); -} // ----------------------------------------------------------------------------- OOperandAttr* OSQLAnalyzer::createOperandAttr(sal_Int32 _nPos, const Reference< XPropertySet>& _xCol, diff --git a/connectivity/source/drivers/file/fcode.cxx b/connectivity/source/drivers/file/fcode.cxx index d38d778ce544..1ede34390eb6 100644 --- a/connectivity/source/drivers/file/fcode.cxx +++ b/connectivity/source/drivers/file/fcode.cxx @@ -2,9 +2,9 @@ * * $RCSfile: fcode.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:31:20 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -77,9 +77,6 @@ #ifndef _SV_SVAPP_HXX #include <vcl/svapp.hxx> #endif -#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ -#include <com/sun/star/container/XIndexAccess.hpp> -#endif #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> #endif @@ -94,12 +91,12 @@ using namespace ::comphelper; using namespace connectivity; using namespace connectivity::file; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; +//using namespace ::com::sun::star::uno; +//using namespace ::com::sun::star::lang; using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; +//using namespace ::com::sun::star::container; +//using namespace ::com::sun::star::beans; +//using namespace ::com::sun::star::sdbcx; TYPEINIT0(OCode); TYPEINIT1(OOperand, OCode); @@ -169,12 +166,6 @@ void OOperandValue::setValue(const ORowSetValue& _rVal) { m_aValue = _rVal; } -//------------------------------------------------------------------ -OOperandAttr::OOperandAttr(sal_uInt16 _nPos,const Reference< XPropertySet>& _xColumn) - : OOperandRow(_nPos,getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))) - , m_xColumn(_xColumn) -{ -} // ------------------------------------------------------------------------- sal_Bool OOperandAttr::isIndexed() const { @@ -213,30 +204,6 @@ OOperandParam::OOperandParam(OSQLParseNode* pNode, sal_Int32 _nPos) //------------------------------------------------------------------ -void OOperandParam::describe(const Reference< XPropertySet>& rColumn, ::vos::ORef<connectivity::OSQLColumns> rParameterColumns) -{ - // den alten namen beibehalten - - Reference< XPropertySet> xColumn = (*rParameterColumns)[getRowPos()]; - - try - { - xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))); - xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))); - xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))); - xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))); - xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))); - xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))); - xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT))); - } - catch(const Exception&) - { - } - - m_eDBType = getINT32(rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))); -} - -//------------------------------------------------------------------ const ORowSetValue& OOperandValue::getValue() const { return m_aValue; @@ -301,8 +268,10 @@ void OBoolOperator::Exec(OCodeStack& rCodeStack) rCodeStack.pop(); rCodeStack.push(new OOperandResultBOOL(operate(pLeft, pRight))); - if (IS_TYPE(OOperandResult,pLeft)) delete pLeft; - if (IS_TYPE(OOperandResult,pRight)) delete pRight; + if (IS_TYPE(OOperandResult,pLeft)) + delete pLeft; + if (IS_TYPE(OOperandResult,pRight)) + delete pRight; } //------------------------------------------------------------------ @@ -327,7 +296,8 @@ void OOp_ISNULL::Exec(OCodeStack& rCodeStack) rCodeStack.pop(); rCodeStack.push(new OOperandResultBOOL(operate(pOperand))); - if (IS_TYPE(OOperandResult,pOperand)) delete pOperand; + if (IS_TYPE(OOperandResult,pOperand)) + delete pOperand; } //------------------------------------------------------------------ diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx index 4d5731762a88..4f8a420f0f38 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.13 $ + * $Revision: 1.14 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:37:36 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -116,17 +116,6 @@ void OPredicateCompiler::dispose() //------------------------------------------------------------------ // inline OCursor& OPredicateCompiler::Cursor() const {return m_rCursor;} //------------------------------------------------------------------ -void OPredicateCompiler::Clean() -{ - for(OCodeList::reverse_iterator aIter = m_aCodeList.rbegin(); aIter != m_aCodeList.rend();++aIter) - { - delete *aIter; - m_aCodeList.pop_back(); - } - // m_aCodeList.clear(); -} - -//------------------------------------------------------------------ void OPredicateCompiler::start(OSQLParseNode* pSQLParseNode) { if (!pSQLParseNode) @@ -540,19 +529,6 @@ OOperand* OPredicateCompiler::execute_Operand(OSQLParseNode* pPredicateNode) thr } //////////////////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------ -OPredicateInterpreter::~OPredicateInterpreter() -{ - while(!m_aStack.empty()) - { - delete m_aStack.top(); - m_aStack.pop(); - } - // m_aStack.clear(); -} - -//------------------------------------------------------------------ sal_Bool OPredicateInterpreter::evaluate(OCodeList& rCodeList) { static sal_Bool bResult; diff --git a/connectivity/source/drivers/file/makefile.mk b/connectivity/source/drivers/file/makefile.mk index e50fb81f47b0..a5ece3244a64 100644 --- a/connectivity/source/drivers/file/makefile.mk +++ b/connectivity/source/drivers/file/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.8 $ +# $Revision: 1.9 $ # -# last change: $Author: vg $ $Date: 2001-05-16 15:31:48 $ +# last change: $Author: oj $ $Date: 2001-05-23 09:10:30 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -67,7 +67,6 @@ TARGET=file USE_LDUMP2=TRUE USE_DEFFILE=TRUE -ENABLE_EXCEPTIONS=TRUE LDUMP=ldump2.exe # --- Settings ---------------------------------- @@ -81,6 +80,7 @@ ENVCFLAGS+=/FR$(SLO)$/ # --- Files ------------------------------------- SLOFILES=\ + $(SLO)$/FNoException.obj \ $(SLO)$/FConnection.obj \ $(SLO)$/FResultSetMetaData.obj \ $(SLO)$/FColumns.obj \ @@ -96,6 +96,21 @@ SLOFILES=\ $(SLO)$/fcode.obj \ $(SLO)$/fcomp.obj +EXCEPTIONSFILES=\ + $(SLO)$/FConnection.obj \ + $(SLO)$/FResultSetMetaData.obj \ + $(SLO)$/FColumns.obj \ + $(SLO)$/FTables.obj \ + $(SLO)$/FTable.obj \ + $(SLO)$/FCatalog.obj \ + $(SLO)$/FResultSet.obj \ + $(SLO)$/FStatement.obj \ + $(SLO)$/FPreparedStatement.obj \ + $(SLO)$/FDatabaseMetaData.obj \ + $(SLO)$/FDriver.obj \ + $(SLO)$/fanalyzer.obj \ + $(SLO)$/fcomp.obj + .IF "$(OS)"=="MACOSX" #SHL1VERSIONMAP=$(TARGET).$(DLLPOSTFIX).map .ELSE diff --git a/connectivity/source/drivers/flat/ENoException.cxx b/connectivity/source/drivers/flat/ENoException.cxx new file mode 100644 index 000000000000..899fdb5e32b8 --- /dev/null +++ b/connectivity/source/drivers/flat/ENoException.cxx @@ -0,0 +1,368 @@ +/************************************************************************* + * + * $RCSfile: ENoException.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-05-23 09:17:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CONNECTIVITY_FLAT_TABLE_HXX_ +#include "flat/ETable.hxx" +#endif +#ifndef _CONNECTIVITY_FLAT_ECONNECTION_HXX_ +#include "flat/EConnection.hxx" +#endif + +using namespace connectivity::flat; + +//------------------------------------------------------------------ +xub_StrLen OFlatString::GetTokenCount( sal_uInt8 cTok, sal_uInt8 cStrDel ) const +{ + if ( !Len() ) + return 0; + + xub_StrLen nTokCount = 1; + BOOL bStart = TRUE; // Stehen wir auf dem ersten Zeichen im Token? + BOOL bInString = FALSE; // Befinden wir uns INNERHALB eines (cStrDel delimited) String? + + // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen + for( xub_StrLen i = 0; i < Len(); i++ ) + { + 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! + } + } + + if (bInString) { + // Wenn jetzt das String-Delimiter-Zeichen auftritt ... + if ( (*this).GetChar(i) == cStrDel ) + { + if ((i+1 < Len()) && ((*this).GetChar(i+1) == cStrDel)) + { + // Verdoppeltes String-Delimiter-Zeichen: + i++; // kein String-Ende, naechstes Zeichen ueberlesen. + } + else + { + // String-Ende + bInString = FALSE; + } + } + } else { + // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount + if ( (*this).GetChar(i) == cTok ) + { + nTokCount++; + bStart = TRUE; + } + } + } + + return nTokCount; +} + +//------------------------------------------------------------------ +ByteString OFlatString::GetToken( xub_StrLen nToken, 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++ ) + { + 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! + } + } + + if (bInString) { + // Wenn jetzt das String-Delimiter-Zeichen auftritt ... + if ( (*this).GetChar(i) == cStrDel ) { + if ((i+1 < Len()) && ((*this).GetChar(i+1) == cStrDel)) + { + // Verdoppeltes String-Delimiter-Zeichen: + i++; // kein String-Ende, naechstes Zeichen ueberlesen. + + if (nTok == nToken) + { + aResult += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String + } + } + else + { + // String-Ende + bInString = FALSE; + } + } else { + if (nTok == nToken) { + aResult += (*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 ) + { + // Vorzeitiger Abbruch der Schleife moeglich, denn + // wir haben, was wir wollten. + return aResult; + } + } else { + if (nTok == nToken) { + aResult += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String + } + } + } + } + + return aResult; +} +// ----------------------------------------------------------------------------- +void OFlatTable::refreshIndexes() +{ +} +// ----------------------------------------------------------------------------- +sal_Bool OFlatTable::checkHeaderLine() +{ + OFlatConnection* pConnection = (OFlatConnection*)m_pConnection; + if (m_nFilePos == 0 && pConnection->isHeaderLine()) + { + BOOL bRead2; + do + { + bRead2 = m_pFileStream->ReadLine(m_aCurrentLine); + } + while(bRead2 && !m_aCurrentLine.Len()); + + m_nFilePos = m_pFileStream->Tell(); + if (m_pFileStream->IsEof()) + return sal_False; + } + return sal_True; +} +//------------------------------------------------------------------ +sal_Bool OFlatTable::seekRow(FilePosition eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) +{ + OFlatConnection* pConnection = (OFlatConnection*)m_pConnection; + // ---------------------------------------------------------- + // Positionierung vorbereiten: + + sal_uInt32 nTempPos = m_nFilePos; + m_nFilePos = nCurPos; + + switch(eCursorPosition) + { + case FILE_FIRST: + m_nFilePos = 0; + m_nRowPos = 1; + // run through + case FILE_NEXT: + if(eCursorPosition != FILE_FIRST) + ++m_nRowPos; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + { + m_nMaxRowCount = m_nRowPos; + return sal_False; + } + + m_aRowToFilePos[m_nRowPos] = m_nFilePos; + + m_pFileStream->ReadLine(m_aCurrentLine); + if (m_pFileStream->IsEof()) + { + m_nMaxRowCount = m_nRowPos; + return sal_False; + } + nCurPos = m_pFileStream->Tell(); + break; + case FILE_PRIOR: + --m_nRowPos; + if(m_nRowPos > 0) + { + m_nFilePos = m_aRowToFilePos.find(m_nRowPos)->second; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadLine(m_aCurrentLine); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + else + m_nRowPos = 0; + + break; + + break; + case FILE_LAST: + if(m_nMaxRowCount) + { + m_nFilePos = m_aRowToFilePos.rbegin()->second; + m_nRowPos = m_aRowToFilePos.rbegin()->first; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadLine(m_aCurrentLine); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + else + { + while(seekRow(FILE_NEXT,1,nCurPos)) ; // run through after last row + // now I know all + seekRow(FILE_PRIOR,1,nCurPos); + } + break; + case FILE_RELATIVE: + if(nOffset > 0) + { + for(sal_Int32 i = 0;i<nOffset;++i) + seekRow(FILE_NEXT,1,nCurPos); + } + else if(nOffset < 0) + { + for(sal_Int32 i = nOffset;i;++i) + seekRow(FILE_PRIOR,1,nCurPos); + } + break; + case FILE_ABSOLUTE: + { + if(nOffset < 0) + nOffset = m_nRowPos + nOffset; + ::std::map<sal_Int32,sal_Int32>::const_iterator aIter = m_aRowToFilePos.find(nOffset); + if(aIter != m_aRowToFilePos.end()) + { + m_nFilePos = aIter->second; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadLine(m_aCurrentLine); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + else if(m_nMaxRowCount && nOffset > m_nMaxRowCount) // offset is outside the table + { + m_nRowPos = m_nMaxRowCount; + return sal_False; + } + else + { + aIter = m_aRowToFilePos.upper_bound(nOffset); + if(aIter == m_aRowToFilePos.end()) + { + m_nRowPos = m_aRowToFilePos.rbegin()->first; + nCurPos = m_nFilePos = m_aRowToFilePos.rbegin()->second; + while(m_nRowPos != nOffset) + seekRow(FILE_NEXT,1,nCurPos); + } + else + { + --aIter; + m_nRowPos = aIter->first; + m_nFilePos = aIter->second; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadLine(m_aCurrentLine); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + } + } + + break; + case FILE_BOOKMARK: + m_pFileStream->Seek(nOffset); + if (m_pFileStream->IsEof()) + return sal_False; + + m_nFilePos = m_pFileStream->Tell(); // Byte-Position in der Datei merken (am ZeilenANFANG) + m_pFileStream->ReadLine(m_aCurrentLine); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + break; + } + + + return sal_True; +} +// ----------------------------------------------------------------------------- + + + diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx index 7a59bc2085b0..467891a6541a 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.28 $ + * $Revision: 1.29 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:31:19 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:10:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -94,9 +94,6 @@ #ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> #endif -#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ -#include "connectivity/DateConversion.hxx" -#endif #ifndef _INTN_HXX //autogen #include <tools/intn.hxx> #endif @@ -154,127 +151,6 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; double toDouble(const ByteString& rString,rtl_TextEncoding _nrTextEncoding); -//------------------------------------------------------------------ -xub_StrLen OFlatString::GetTokenCount( sal_uInt8 cTok, sal_uInt8 cStrDel ) const -{ - if ( !Len() ) - return 0; - - xub_StrLen nTokCount = 1; - BOOL bStart = TRUE; // Stehen wir auf dem ersten Zeichen im Token? - BOOL bInString = FALSE; // Befinden wir uns INNERHALB eines (cStrDel delimited) String? - - // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen - for( xub_StrLen i = 0; i < Len(); i++ ) - { - 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! - } - } - - if (bInString) { - // Wenn jetzt das String-Delimiter-Zeichen auftritt ... - if ( (*this).GetChar(i) == cStrDel ) - { - if ((i+1 < Len()) && ((*this).GetChar(i+1) == cStrDel)) - { - // Verdoppeltes String-Delimiter-Zeichen: - i++; // kein String-Ende, naechstes Zeichen ueberlesen. - } - else - { - // String-Ende - bInString = FALSE; - } - } - } else { - // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount - if ( (*this).GetChar(i) == cTok ) - { - nTokCount++; - bStart = TRUE; - } - } - } - - return nTokCount; -} - -//------------------------------------------------------------------ -ByteString OFlatString::GetToken( xub_StrLen nToken, 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++ ) - { - 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! - } - } - - if (bInString) { - // Wenn jetzt das String-Delimiter-Zeichen auftritt ... - if ( (*this).GetChar(i) == cStrDel ) { - if ((i+1 < Len()) && ((*this).GetChar(i+1) == cStrDel)) - { - // Verdoppeltes String-Delimiter-Zeichen: - i++; // kein String-Ende, naechstes Zeichen ueberlesen. - - if (nTok == nToken) - { - aResult += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String - } - } - else - { - // String-Ende - bInString = FALSE; - } - } else { - if (nTok == nToken) { - aResult += (*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 ) - { - // Vorzeitiger Abbruch der Schleife moeglich, denn - // wir haben, was wir wollten. - return aResult; - } - } else { - if (nTok == nToken) { - aResult += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String - } - } - } - } - - return aResult; -} // ------------------------------------------------------------------------- void OFlatTable::fillColumns() @@ -589,10 +465,6 @@ void OFlatTable::refreshColumns() else m_pColumns = new OFlatColumns(this,m_aMutex,aVector); } -// ------------------------------------------------------------------------- -void OFlatTable::refreshIndexes() -{ -} // ------------------------------------------------------------------------- void SAL_CALL OFlatTable::disposing(void) @@ -665,176 +537,6 @@ sal_Int64 OFlatTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (Ru return OFlatTable_BASE::getSomething(rId); } -// ------------------------------------------------------------------------- -sal_Bool OFlatTable::checkHeaderLine() -{ - OFlatConnection* pConnection = (OFlatConnection*)m_pConnection; - if (m_nFilePos == 0 && pConnection->isHeaderLine()) - { - BOOL bRead2; - do - { - bRead2 = m_pFileStream->ReadLine(m_aCurrentLine); - } - while(bRead2 && !m_aCurrentLine.Len()); - - m_nFilePos = m_pFileStream->Tell(); - if (m_pFileStream->IsEof()) - return sal_False; - } - return sal_True; -} -//------------------------------------------------------------------ -sal_Bool OFlatTable::seekRow(FilePosition eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) -{ - OFlatConnection* pConnection = (OFlatConnection*)m_pConnection; - // ---------------------------------------------------------- - // Positionierung vorbereiten: - - sal_uInt32 nTempPos = m_nFilePos; - m_nFilePos = nCurPos; - - switch(eCursorPosition) - { - case FILE_FIRST: - m_nFilePos = 0; - m_nRowPos = 1; - // run through - case FILE_NEXT: - if(eCursorPosition != FILE_FIRST) - ++m_nRowPos; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - { - m_nMaxRowCount = m_nRowPos; - return sal_False; - } - - m_aRowToFilePos[m_nRowPos] = m_nFilePos; - - m_pFileStream->ReadLine(m_aCurrentLine); - if (m_pFileStream->IsEof()) - { - m_nMaxRowCount = m_nRowPos; - return sal_False; - } - nCurPos = m_pFileStream->Tell(); - break; - case FILE_PRIOR: - --m_nRowPos; - if(m_nRowPos > 0) - { - m_nFilePos = m_aRowToFilePos.find(m_nRowPos)->second; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - return sal_False; - m_pFileStream->ReadLine(m_aCurrentLine); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - } - else - m_nRowPos = 0; - - break; - - break; - case FILE_LAST: - if(m_nMaxRowCount) - { - m_nFilePos = m_aRowToFilePos.rbegin()->second; - m_nRowPos = m_aRowToFilePos.rbegin()->first; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - return sal_False; - m_pFileStream->ReadLine(m_aCurrentLine); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - } - else - { - while(seekRow(FILE_NEXT,1,nCurPos)) ; // run through after last row - // now I know all - seekRow(FILE_PRIOR,1,nCurPos); - } - break; - case FILE_RELATIVE: - if(nOffset > 0) - { - for(sal_Int32 i = 0;i<nOffset;++i) - seekRow(FILE_NEXT,1,nCurPos); - } - else if(nOffset < 0) - { - for(sal_Int32 i = nOffset;i;++i) - seekRow(FILE_PRIOR,1,nCurPos); - } - break; - case FILE_ABSOLUTE: - { - if(nOffset < 0) - nOffset = m_nRowPos + nOffset; - ::std::map<sal_Int32,sal_Int32>::const_iterator aIter = m_aRowToFilePos.find(nOffset); - if(aIter != m_aRowToFilePos.end()) - { - m_nFilePos = aIter->second; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - return sal_False; - m_pFileStream->ReadLine(m_aCurrentLine); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - } - else if(m_nMaxRowCount && nOffset > m_nMaxRowCount) // offset is outside the table - { - m_nRowPos = m_nMaxRowCount; - return sal_False; - } - else - { - aIter = m_aRowToFilePos.upper_bound(nOffset); - if(aIter == m_aRowToFilePos.end()) - { - m_nRowPos = m_aRowToFilePos.rbegin()->first; - nCurPos = m_nFilePos = m_aRowToFilePos.rbegin()->second; - while(m_nRowPos != nOffset) - seekRow(FILE_NEXT,1,nCurPos); - } - else - { - --aIter; - m_nRowPos = aIter->first; - m_nFilePos = aIter->second; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - return sal_False; - m_pFileStream->ReadLine(m_aCurrentLine); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - } - } - } - - break; - case FILE_BOOKMARK: - m_pFileStream->Seek(nOffset); - if (m_pFileStream->IsEof()) - return sal_False; - - m_nFilePos = m_pFileStream->Tell(); // Byte-Position in der Datei merken (am ZeilenANFANG) - m_pFileStream->ReadLine(m_aCurrentLine); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - break; - } - - - return sal_True; -} //------------------------------------------------------------------ sal_Bool OFlatTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols,sal_Bool bIsTable,sal_Bool bRetrieveData) { @@ -877,13 +579,13 @@ sal_Bool OFlatTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols,sal_Boo switch(nType) { case DataType::DATE: - (*_rRow)[i] = ::dbtools::DBTypeConversion::toDouble(DateConversion::toDate(nRes,aDate)); + (*_rRow)[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(nRes,aDate)); break; case DataType::TIMESTAMP: - (*_rRow)[i] = ::dbtools::DBTypeConversion::toDouble(DateConversion::toDateTime(nRes,aDate)); + (*_rRow)[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(nRes,aDate)); break; default: - (*_rRow)[i] = ::dbtools::DBTypeConversion::toDouble(DateConversion::toTime(nRes)); + (*_rRow)[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(nRes)); } } catch(Exception&) diff --git a/connectivity/source/drivers/flat/makefile.mk b/connectivity/source/drivers/flat/makefile.mk index 7de72345e2d3..8092c5aba3df 100644 --- a/connectivity/source/drivers/flat/makefile.mk +++ b/connectivity/source/drivers/flat/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.12 $ +# $Revision: 1.13 $ # -# last change: $Author: oj $ $Date: 2001-05-17 06:46:52 $ +# last change: $Author: oj $ $Date: 2001-05-23 09:13:11 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -65,8 +65,6 @@ PRJINC=..$/.. PRJNAME=connectivity TARGET=flat -ENABLE_EXCEPTIONS=TRUE - # --- Settings ---------------------------------- .IF "$(DBGUTIL_OJ)"!="" ENVCFLAGS+=/FR$(SLO)$/ @@ -79,6 +77,20 @@ ENVCFLAGS+=/FR$(SLO)$/ # --- Files ------------------------------------- SLOFILES=\ + $(SLO)$/ENoException.obj \ + $(SLO)$/EResultSet.obj \ + $(SLO)$/EStatement.obj \ + $(SLO)$/EPreparedStatement.obj \ + $(SLO)$/ETable.obj \ + $(SLO)$/EDatabaseMetaData.obj \ + $(SLO)$/ECatalog.obj \ + $(SLO)$/EColumns.obj \ + $(SLO)$/ETables.obj \ + $(SLO)$/EConnection.obj \ + $(SLO)$/Eservices.obj \ + $(SLO)$/EDriver.obj + +EXCEPTIONSFILES=\ $(SLO)$/EResultSet.obj \ $(SLO)$/EStatement.obj \ $(SLO)$/EPreparedStatement.obj \ @@ -91,6 +103,7 @@ SLOFILES=\ $(SLO)$/Eservices.obj \ $(SLO)$/EDriver.obj + .IF "$(OS)"=="MACOSX" #SHL1VERSIONMAP=$(TARGET).$(DLLPOSTFIX).map .ELSE diff --git a/connectivity/source/drivers/jdbc/Date.cxx b/connectivity/source/drivers/jdbc/Date.cxx index 35304e184136..93c3e5e14895 100644 --- a/connectivity/source/drivers/jdbc/Date.cxx +++ b/connectivity/source/drivers/jdbc/Date.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Date.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2000-09-29 15:04:24 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:13:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,10 +66,9 @@ #ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ #include "java/tools.hxx" #endif -#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ -#include "connectivity/DateConversion.hxx" +#ifndef _DBHELPER_DBCONVERSION_HXX_ +#include "connectivity/dbconversion.hxx" #endif - using namespace connectivity; //************************************************************** //************ Class: java.util.Date @@ -84,7 +83,7 @@ java_util_Date::java_util_Date( const ::com::sun::star::util::Date& _rOut ) //: return; jvalue args[1]; // Parameter konvertieren - args[0].j = DateConversion::toINT32(_rOut); + args[0].j = ::dbtools::DBTypeConversion::toINT32(_rOut); // Java-Call fuer den Konstruktor absetzen // temporaere Variable initialisieren char * cSignature = "(J)V"; diff --git a/connectivity/source/drivers/jdbc/Timestamp.cxx b/connectivity/source/drivers/jdbc/Timestamp.cxx index 9565ffb7882c..cdc675af95d5 100644 --- a/connectivity/source/drivers/jdbc/Timestamp.cxx +++ b/connectivity/source/drivers/jdbc/Timestamp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Timestamp.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:31:18 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:10:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,12 +65,12 @@ #ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ #include "java/tools.hxx" #endif -#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ -#include "connectivity/DateConversion.hxx" -#endif #ifndef _COMPHELPER_TYPES_HXX_ #include <comphelper/types.hxx> #endif +#ifndef _DBHELPER_DBCONVERSION_HXX_ +#include "connectivity/dbconversion.hxx" +#endif using namespace ::comphelper; using namespace connectivity; @@ -143,7 +143,7 @@ java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_ return; jvalue args[1]; // Parameter konvertieren - args[0].j = DateConversion::toINT32(_rOut); + args[0].j = ::dbtools::DBTypeConversion::toINT32(_rOut); // Java-Call fuer den Konstruktor absetzen // temporaere Variable initialisieren char * cSignature = "(J)V"; @@ -194,7 +194,7 @@ java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _ return; jvalue args[1]; // Parameter konvertieren - args[0].j = (jlong)DateConversion::toINT64(_rOut); + args[0].j = (jlong)::dbtools::DBTypeConversion::toINT64(_rOut); // Java-Call fuer den Konstruktor absetzen // temporaere Variable initialisieren char * cSignature = "(J)V"; diff --git a/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx b/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx index 8b7519a88533..29e0a69beb1a 100644 --- a/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx +++ b/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx @@ -2,9 +2,9 @@ * * $RCSfile: FDatabaseMetaDataResultSet.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-04-30 10:13:39 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:15:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -147,6 +147,7 @@ namespace connectivity sal_Bool m_bBOF; void construct(); + void checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException); protected: diff --git a/connectivity/source/inc/ado/ADatabaseMetaData.hxx b/connectivity/source/inc/ado/ADatabaseMetaData.hxx index 4441d68f9a66..e662a3010455 100644 --- a/connectivity/source/inc/ado/ADatabaseMetaData.hxx +++ b/connectivity/source/inc/ado/ADatabaseMetaData.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ADatabaseMetaData.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2000-11-03 13:44:21 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:15:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,11 +93,11 @@ namespace connectivity WpADOConnection* m_pADOConnection; OConnection* m_pConnection; - void fillLiterals() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void fillLiterals(); // get information out of rowset - sal_Int32 getMaxSize(sal_uInt32 _nId) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - sal_Bool isCapable(sal_uInt32 _nId) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - ::rtl::OUString getLiteral(sal_uInt32 _nProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getMaxSize(sal_uInt32 _nId); + sal_Bool isCapable(sal_uInt32 _nId); + ::rtl::OUString getLiteral(sal_uInt32 _nProperty); // get info out of propertyst ::rtl::OUString getStringProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); diff --git a/connectivity/source/inc/ado/ADatabaseMetaDataResultSet.hxx b/connectivity/source/inc/ado/ADatabaseMetaDataResultSet.hxx index 2f15854e6637..ef7fd022fb83 100644 --- a/connectivity/source/inc/ado/ADatabaseMetaDataResultSet.hxx +++ b/connectivity/source/inc/ado/ADatabaseMetaDataResultSet.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ADatabaseMetaDataResultSet.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-05-17 06:46:50 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:10:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -160,6 +160,7 @@ namespace connectivity inline sal_Int32 mapColumn (sal_Int32 column); + void checkRecordSet() throw(::com::sun::star::sdbc::SQLException); protected: diff --git a/connectivity/source/inc/ado/Awrapado.hxx b/connectivity/source/inc/ado/Awrapado.hxx index dbee80f7b69e..47f2a1d7a0ed 100644 --- a/connectivity/source/inc/ado/Awrapado.hxx +++ b/connectivity/source/inc/ado/Awrapado.hxx @@ -2,9 +2,9 @@ * * $RCSfile: Awrapado.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:34:10 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:10:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -169,6 +169,41 @@ namespace connectivity sal_Bool OpenSchema(SchemaEnum eNum,OLEVariant& Restrictions,OLEVariant& SchemaID,ADORecordset**pprset); ::rtl::OUString get_Version() const; + + // special methods + ADORecordset* getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ); + ADORecordset* getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ); + ADORecordset* getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ); + ADORecordset* getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ); + ADORecordset* getTablePrivileges( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern ); + ADORecordset* getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog, + const ::rtl::OUString& primarySchema, + const ::rtl::OUString& primaryTable, + const ::com::sun::star::uno::Any& foreignCatalog, + const ::rtl::OUString& foreignSchema, + const ::rtl::OUString& foreignTable); + ADORecordset* getProcedures( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern ); + ADORecordset* getProcedureColumns( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern, + const ::rtl::OUString& columnNamePattern ); + ADORecordset* 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 ); + ADORecordset* getColumns( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern, + const ::rtl::OUString& columnNamePattern ); + ADORecordset* getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& table, + const ::rtl::OUString& columnNamePattern ); + ADORecordset* getTypeInfo( ); }; //------------------------------------------------------------------------ diff --git a/connectivity/source/inc/ado/adoimp.hxx b/connectivity/source/inc/ado/adoimp.hxx index 92c4c702685a..e02d3a47e3d0 100644 --- a/connectivity/source/inc/ado/adoimp.hxx +++ b/connectivity/source/inc/ado/adoimp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: adoimp.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:34:10 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:10:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -117,6 +117,7 @@ namespace connectivity static void ThrowException(ADOConnection* _pAdoCon,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); static sal_Int32 MapADOType2Jdbc(DataTypeEnum eType); static DataTypeEnum MapJdbc2ADOType(sal_Int32 _nType); + static sal_Bool isJetEngine(sal_Int32 _nEngineType); }; diff --git a/connectivity/source/inc/file/FResultSet.hxx b/connectivity/source/inc/file/FResultSet.hxx index 63bdac2a5233..b6f34bd66739 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.18 $ + * $Revision: 1.19 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:31:17 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:10:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -343,6 +343,7 @@ OFILEKeyCompare(const void * elem1, const void * elem2); sal_Bool moveAbsolute(sal_Int32 _nOffset,sal_Bool _bRetrieveData); // return true when the select statement is "select count(*) from table" sal_Bool isCount() const; + void checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException); protected: using OResultSet_BASE::rBHelper; diff --git a/connectivity/source/inc/file/fcomp.hxx b/connectivity/source/inc/file/fcomp.hxx index 5486f23041ab..d45670d32c7c 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.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-05-07 10:37:53 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:10:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,7 +89,6 @@ namespace connectivity ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xIndexes; sal_Int32 m_nParamCounter; sal_Bool m_bORCondition; - public: OPredicateCompiler(OSQLAnalyzer* pAnalyzer); diff --git a/connectivity/source/inc/java/sql/Timestamp.hxx b/connectivity/source/inc/java/sql/Timestamp.hxx index 7729d38f71ed..7331632590c8 100644 --- a/connectivity/source/inc/java/sql/Timestamp.hxx +++ b/connectivity/source/inc/java/sql/Timestamp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: Timestamp.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:10:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,7 +93,7 @@ namespace connectivity java_sql_Date( const ::com::sun::star::util::Date& _rOut ) : java_util_Date(_rOut) {} operator ::com::sun::star::util::Date() { - return ::com::sun::star::util::Date(getYear(),getMonth(),getDate()); + return ::com::sun::star::util::Date((sal_uInt16)getYear(),(sal_uInt16)getMonth(),(sal_uInt16)getDate()); } }; @@ -117,7 +117,7 @@ namespace connectivity java_sql_Time( const ::com::sun::star::util::Time& _rOut ); operator ::com::sun::star::util::Time() { - return ::com::sun::star::util::Time(0,getSeconds(),getMinutes(),getHours()); + return ::com::sun::star::util::Time(0,(sal_uInt16)getSeconds(),(sal_uInt16)getMinutes(),(sal_uInt16)getHours()); } }; @@ -139,8 +139,8 @@ namespace connectivity java_sql_Timestamp( const ::com::sun::star::util::DateTime& _rOut); operator ::com::sun::star::util::DateTime() { - return ::com::sun::star::util::DateTime(getYear(),getMonth(),getDate(), - getHours(),getMinutes(),getSeconds(),getNanos()); + return ::com::sun::star::util::DateTime((sal_uInt16)getYear(),(sal_uInt16)getMonth(),(sal_uInt16)getDate(), + (sal_uInt16)getHours(),(sal_uInt16)getMinutes(),(sal_uInt16)getSeconds(),(sal_uInt16)getNanos()); } sal_Int32 getNanos(); diff --git a/connectivity/source/parse/PColumn.cxx b/connectivity/source/parse/PColumn.cxx index 3c8d852fad15..dba86d0ce611 100644 --- a/connectivity/source/parse/PColumn.cxx +++ b/connectivity/source/parse/PColumn.cxx @@ -2,9 +2,9 @@ * * $RCSfile: PColumn.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:31:16 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:10:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -130,10 +130,10 @@ void OParseColumn::construct() { sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION), PROPERTY_ID_FUNCTION, nAttrib,&m_bFunction, ::getCppuType(reinterpret_cast< sal_Bool*>(NULL))); - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME), PROPERTY_ID_TABLENAME, nAttrib,&m_aTableName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME), PROPERTY_ID_REALNAME, nAttrib,&m_aRealName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DBASEPRECISIONCHANGED), PROPERTY_ID_DBASEPRECISIONCHANGED, nAttrib,&m_bDbasePrecisionChanged, ::getCppuType(reinterpret_cast<sal_Bool*>(NULL))); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION), PROPERTY_ID_FUNCTION, 0,&m_bFunction, ::getCppuType(reinterpret_cast< sal_Bool*>(NULL))); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME), PROPERTY_ID_TABLENAME, nAttrib,&m_aTableName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME), PROPERTY_ID_REALNAME, 0,&m_aRealName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DBASEPRECISIONCHANGED), PROPERTY_ID_DBASEPRECISIONCHANGED, nAttrib,&m_bDbasePrecisionChanged, ::getCppuType(reinterpret_cast<sal_Bool*>(NULL))); } // ----------------------------------------------------------------------------- diff --git a/connectivity/source/parse/makefile.mk b/connectivity/source/parse/makefile.mk index 36c4422ee2b7..da654f7a1391 100644 --- a/connectivity/source/parse/makefile.mk +++ b/connectivity/source/parse/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.3 $ +# $Revision: 1.4 $ # -# last change: $Author: oj $ $Date: 2001-02-01 14:01:27 $ +# last change: $Author: oj $ $Date: 2001-05-23 09:10:28 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -64,7 +64,7 @@ PRJ=..$/.. PRJNAME=connectivity TARGET=sql -ENABLE_EXCEPTIONS=TRUE + # --- Settings ----------------------------------------------------- .INCLUDE : svpre.mk @@ -74,6 +74,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Files -------------------------------------------------------- SLOFILES = \ + $(SLO)$/sqlNoException.obj \ $(SLO)$/sqlbison.obj \ $(SLO)$/sqlflex.obj \ $(SLO)$/PColumn.obj \ @@ -81,6 +82,13 @@ SLOFILES = \ $(SLO)$/sqlnode.obj \ $(SLO)$/internalnode.obj +EXCEPTIONSFILES = \ + $(SLO)$/sqlbison.obj \ + $(SLO)$/sqlflex.obj \ + $(SLO)$/PColumn.obj \ + $(SLO)$/sqliterator.obj \ + $(SLO)$/sqlnode.obj \ + $(SLO)$/internalnode.obj all: \ $(MISC)$/sqlflex.cxx \ diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 9d4181a06173..f051476179ff 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sqlnode.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: pl $ $Date: 2001-05-11 17:51:47 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:10:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,9 +79,6 @@ #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> #endif -#ifndef __SGI_STL_ROPE -#include <rope> -#endif #ifndef _DBHELPER_DBCONVERSION_HXX_ #include "connectivity/dbconversion.hxx" @@ -95,6 +92,9 @@ #ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ #include <com/sun/star/util/Date.hpp> #endif +#ifndef CONNECTIVITY_CONNECTION_HXX +#include "TConnection.hxx" +#endif using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::util; @@ -127,48 +127,17 @@ OSQLParseNode::SQLParseNodeParameter::SQLParseNodeParameter(const ::rtl::OUStrin { } -//------------------------------------------------------------------ -::rtl::OUString SetQuotation(const ::rtl::OUString& rValue, const ::rtl::OUString& rQuot, const ::rtl::OUString& rQuotToReplace) -{ - ::rtl::OUString rNewValue = rQuot; - rNewValue += rValue; - sal_Int32 nIndex = (sal_Int32)-1; // Quotes durch zweifache Quotes ersetzen, sonst kriegt der Parser Probleme - - if (rQuot.getLength()) - { - do - { - nIndex += 2; - nIndex = rNewValue.indexOf(rQuot,nIndex); - if(nIndex != -1) - rNewValue = rNewValue.replaceAt(nIndex,rQuot.getLength(),rQuotToReplace); - } while (nIndex != -1); - } - - rNewValue += rQuot; - return rNewValue; -} -// ------------------------------------------------------------------------- -sal_Int32 getToken(const ::rtl::OUString& _rValue,const ::rtl::OUString& _rToken,sal_uInt32 _nPos) -{ - sal_Int32 nLen = _rValue.getLength(); - sal_Int32 nFirstIndex = 0; - sal_Int32 nSecondIndex = _rValue.indexOf(::rtl::OUString::createFromAscii("-"), nFirstIndex); - while(_nPos--) - { - nFirstIndex = nSecondIndex; - nSecondIndex = _rValue.indexOf(::rtl::OUString::createFromAscii("-"), nFirstIndex); - } - - return _rValue.copy(nFirstIndex,nSecondIndex-1).toInt32(); -} +::rtl::OUString SetQuotation(const ::rtl::OUString& rValue, const ::rtl::OUString& rQuot, const ::rtl::OUString& rQuotToReplace); +sal_Int32 getToken(const ::rtl::OUString& _rValue,const ::rtl::OUString& _rToken,sal_uInt32 _nPos); //----------------------------------------------------------------------------- ::rtl::OUString OSQLParseNode::convertDateString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const { // get the token out of a string - sal_Int32 nYear = getToken(rString,::rtl::OUString::createFromAscii("-"),0); - sal_Int32 nMonth = getToken(rString,::rtl::OUString::createFromAscii("-"),1); - sal_Int32 nDay = getToken(rString,::rtl::OUString::createFromAscii("-"),2); + static ::rtl::OUString sDateSep = ::rtl::OUString::createFromAscii("-"); + + sal_Int32 nYear = getToken(rString,sDateSep,0); + sal_Int32 nMonth = getToken(rString,sDateSep,1); + sal_Int32 nDay = getToken(rString,sDateSep,2); Date aDate(nDay,nMonth,nYear); Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier()); @@ -182,12 +151,15 @@ sal_Int32 getToken(const ::rtl::OUString& _rValue,const ::rtl::OUString& _rToken //----------------------------------------------------------------------------- ::rtl::OUString OSQLParseNode::convertDateTimeString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const { - sal_Int32 nYear = getToken(rString,::rtl::OUString::createFromAscii("-"),0); - sal_Int32 nMonth = getToken(rString,::rtl::OUString::createFromAscii("-"),1); - sal_Int32 nDay = getToken(rString,::rtl::OUString::createFromAscii("-"),2); - sal_Int32 nHour = getToken(rString,::rtl::OUString::createFromAscii(":"),0); - sal_Int32 nMinute = getToken(rString,::rtl::OUString::createFromAscii(":"),1); - sal_Int32 nSecond = getToken(rString,::rtl::OUString::createFromAscii(":"),2); + static ::rtl::OUString sDateSep = ::rtl::OUString::createFromAscii("-"); + static ::rtl::OUString sTimeSep = ::rtl::OUString::createFromAscii(":"); + + sal_Int32 nYear = getToken(rString,sDateSep,0); + sal_Int32 nMonth = getToken(rString,sDateSep,1); + sal_Int32 nDay = getToken(rString,sDateSep,2); + sal_Int32 nHour = getToken(rString,sTimeSep,0); + sal_Int32 nMinute = getToken(rString,sTimeSep,1); + sal_Int32 nSecond = getToken(rString,sTimeSep,2); DateTime aDate(0,nSecond,nMinute,nHour,nDay,nMonth,nYear); Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier()); @@ -201,9 +173,11 @@ sal_Int32 getToken(const ::rtl::OUString& _rValue,const ::rtl::OUString& _rToken //----------------------------------------------------------------------------- ::rtl::OUString OSQLParseNode::convertTimeString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const { - sal_Int32 nHour = getToken(rString,::rtl::OUString::createFromAscii(":"),0); - sal_Int32 nMinute = getToken(rString,::rtl::OUString::createFromAscii(":"),1); - sal_Int32 nSecond = getToken(rString,::rtl::OUString::createFromAscii(":"),2); + static ::rtl::OUString sTimeSep = ::rtl::OUString::createFromAscii(":"); + + sal_Int32 nHour = getToken(rString,sTimeSep,0); + sal_Int32 nMinute = getToken(rString,sTimeSep,1); + sal_Int32 nSecond = getToken(rString,sTimeSep,2); Time aTime(0,nHour,nMinute,nSecond); Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier()); @@ -215,147 +189,6 @@ sal_Int32 getToken(const ::rtl::OUString& _rValue,const ::rtl::OUString& _rToken return rParam.xFormatter->convertNumberToString(nKey, fTime); } -DBG_NAME(OSQLParseNode); -//----------------------------------------------------------------------------- -OSQLParseNode::OSQLParseNode(const sal_Char * pNewValue, - SQLNodeType eNewNodeType, - sal_uInt32 nNewNodeID) - : m_aNodeValue(::rtl::OUString::createFromAscii(pNewValue)) - , m_eNodeType(eNewNodeType) - , m_nNodeID(nNewNodeID) - , m_pParent(NULL) -{ - - OSL_ENSURE(m_eNodeType >= SQL_NODE_RULE && m_eNodeType <= SQL_NODE_ACCESS_DATE,"OSQLParseNode: mit unzulaessigem NodeType konstruiert"); -} -//----------------------------------------------------------------------------- -OSQLParseNode::OSQLParseNode(const ::rtl::OString &_rNewValue, - SQLNodeType eNewNodeType, - sal_uInt32 nNewNodeID) - : m_aNodeValue(::rtl::OUString::createFromAscii(_rNewValue.getStr())) - , m_eNodeType(eNewNodeType) - , m_nNodeID(nNewNodeID) - , m_pParent(NULL) -{ - - OSL_ENSURE(m_eNodeType >= SQL_NODE_RULE && m_eNodeType <= SQL_NODE_ACCESS_DATE,"OSQLParseNode: mit unzulaessigem NodeType konstruiert"); -} -//----------------------------------------------------------------------------- -OSQLParseNode::OSQLParseNode(const sal_Unicode * pNewValue, - SQLNodeType eNewNodeType, - sal_uInt32 nNewNodeID) - : m_aNodeValue(pNewValue) - , m_eNodeType(eNewNodeType) - , m_nNodeID(nNewNodeID) - , m_pParent(NULL) -{ - - OSL_ENSURE(m_eNodeType >= SQL_NODE_RULE && m_eNodeType <= SQL_NODE_ACCESS_DATE,"OSQLParseNode: mit unzulaessigem NodeType konstruiert"); -} -//----------------------------------------------------------------------------- -OSQLParseNode::OSQLParseNode(const ::rtl::OUString &_rNewValue, - SQLNodeType eNewNodeType, - sal_uInt32 nNewNodeID) - : m_aNodeValue(_rNewValue) - , m_eNodeType(eNewNodeType) - , m_nNodeID(nNewNodeID) - , m_pParent(NULL) -{ - - OSL_ENSURE(m_eNodeType >= SQL_NODE_RULE && m_eNodeType <= SQL_NODE_ACCESS_DATE,"OSQLParseNode: mit unzulaessigem NodeType konstruiert"); -} -//----------------------------------------------------------------------------- -OSQLParseNode::OSQLParseNode(const OSQLParseNode& rParseNode) -{ - - // klemm den getParent auf NULL - m_pParent = NULL; - - // kopiere die member - m_aNodeValue = rParseNode.m_aNodeValue; - m_eNodeType = rParseNode.m_eNodeType; - m_nNodeID = rParseNode.m_nNodeID; - - - // denk dran, dass von Container abgeleitet wurde, laut SV-Help erzeugt - // copy-Constructor des Containers einen neuen Container mit den gleichen - // Zeigern als Inhalt -> d.h. nach dem Kopieren des Container wird fuer - // alle Zeiger ungleich NULL eine Kopie hergestellt und anstelle des alten - // Zeigers wieder eingehangen. - - // wenn kein Blatt, dann SubTrees bearbeiten - for (OSQLParseNodes::const_iterator i = rParseNode.m_aChilds.begin(); - i != rParseNode.m_aChilds.end(); i++) - append(new OSQLParseNode(**i)); -} - -//----------------------------------------------------------------------------- -OSQLParseNode& OSQLParseNode::operator=(const OSQLParseNode& rParseNode) -{ - - - if (this != &rParseNode) - { - // kopiere die member - pParent bleibt der alte - m_aNodeValue = rParseNode.m_aNodeValue; - m_eNodeType = rParseNode.m_eNodeType; - m_nNodeID = rParseNode.m_nNodeID; - - for (OSQLParseNodes::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); i++) - delete *i; - - m_aChilds.clear(); - - for (OSQLParseNodes::const_iterator j = rParseNode.m_aChilds.begin(); - j != rParseNode.m_aChilds.end(); j++) - append(new OSQLParseNode(**j)); - } - return *this; -} - -//----------------------------------------------------------------------------- -sal_Bool OSQLParseNode::operator==(OSQLParseNode& rParseNode) const -{ - // die member muessen gleich sein - sal_Bool bResult = (m_nNodeID == rParseNode.m_nNodeID) && - (m_eNodeType == rParseNode.m_eNodeType) && - (m_aNodeValue == rParseNode.m_aNodeValue) && - count() == rParseNode.count(); - - // Parameters are not equal! - bResult = bResult && !SQL_ISRULE(this, parameter); - - // compare childs - for (sal_uInt32 i=0; bResult && i < count(); i++) - bResult = *getChild(i) == *rParseNode.getChild(i); - - return bResult; -} - -//----------------------------------------------------------------------------- -OSQLParseNode::~OSQLParseNode() -{ - for (OSQLParseNodes::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); i++) - delete *i; -} - -//----------------------------------------------------------------------------- -void OSQLParseNode::append(OSQLParseNode* pNewNode) -{ - - OSL_ENSURE(pNewNode != NULL, "OSQLParseNode: ungueltiger NewSubTree"); - OSL_ENSURE(pNewNode->getParent() == NULL, "OSQLParseNode: Knoten ist kein Waise"); - OSL_ENSURE(::std::find(m_aChilds.begin(), m_aChilds.end(), pNewNode) == m_aChilds.end(), - "OSQLParseNode::append() Node already element of parent"); - - // stelle Verbindung zum getParent her: - pNewNode->setParent( this ); - // und haenge den SubTree hinten an - m_aChilds.push_back(pNewNode); -} - //----------------------------------------------------------------------------- void OSQLParseNode::parseNodeToStr(::rtl::OUString& rString, const Reference< XDatabaseMetaData > & xMeta, @@ -513,7 +346,7 @@ void OSQLParseNode::parseNodeToStr(::rtl::OUString& rString, const SQLParseNodeP try { // retrieve the fields name - rParam.xField->getPropertyValue(::rtl::OUString::createFromAscii("Name")) >>= aFieldName; + rParam.xField->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aFieldName; } catch ( Exception& ) { @@ -571,134 +404,9 @@ void OSQLParseNode::parseNodeToStr(::rtl::OUString& rString, const SQLParseNodeP } else { - // ein Blatt ist gefunden - // Inhalt dem Ausgabestring anfuegen - switch (m_eNodeType) - { - case SQL_NODE_KEYWORD: - { - if (rString.getLength()) - rString += ::rtl::OUString::createFromAscii(" "); - - rString += ::rtl::OUString::createFromAscii( - OSQLParser::TokenIDToStr(m_nNodeID, &rParam.rContext).getStr()); - } break; - case SQL_NODE_STRING: - if (rString.getLength()) - rString += ::rtl::OUString::createFromAscii(" "); - rString += SetQuotation(m_aNodeValue,::rtl::OUString::createFromAscii("\'"),::rtl::OUString::createFromAscii("\'\'")); - break; - case SQL_NODE_NAME: - if (rString.getLength()) - { - switch(rString.getStr()[rString.getLength()-1] ) - { - case ' ' : - case '.' : break; - default : - if (!rParam.aCatalogSeparator.getLength() || rString.getStr()[rString.getLength()-1] != rParam.aCatalogSeparator.toChar()) - rString += ::rtl::OUString::createFromAscii(" "); break; - } - } - if (rParam.bQuote) - { - if (rParam.bPredicate) - { - rString+= ::rtl::OUString::createFromAscii("["); - rString += m_aNodeValue; - rString+= ::rtl::OUString::createFromAscii("]"); - } - else - rString += SetQuotation(m_aNodeValue, rParam.aIdentifierQuote, rParam.aIdentifierQuote); - } - else - rString += m_aNodeValue; - break; - case SQL_NODE_ACCESS_DATE: - if (rString.getLength()) - rString += ::rtl::OUString::createFromAscii(" "); - rString += ::rtl::OUString::createFromAscii("#"); - rString += m_aNodeValue; - rString += ::rtl::OUString::createFromAscii("#"); - break; - case SQL_NODE_INTNUM: - case SQL_NODE_APPROXNUM: - { - ::rtl::OUString aTmp = m_aNodeValue; - if (rParam.bInternational && rParam.bPredicate && rParam.cDecSep != '.') - aTmp.replace('.', rParam.cDecSep); - - if (rString.getLength()) - rString += ::rtl::OUString::createFromAscii(" "); - rString += aTmp; - - } break; - // fall through - default: - if (rString.getLength() && m_aNodeValue.toChar() != '.' && m_aNodeValue.toChar() != ':' ) - { - switch( rString.getStr()[rString.getLength()-1] ) - { - case ' ' : - case '.' : break; - default : - if (!rParam.aCatalogSeparator.getLength() || rString.getStr()[rString.getLength()-1] != rParam.aCatalogSeparator.toChar()) - rString += ::rtl::OUString::createFromAscii(" "); break; - } - } - rString += m_aNodeValue; - } - } -} - -//----------------------------------------------------------------------------- -sal_Bool OSQLParseNode::addDateValue(::rtl::OUString& rString, const SQLParseNodeParameter& rParam) const -{ - // special display for date/time values - if (rParam.bPredicate && SQL_ISRULE(this,set_fct_spec) && SQL_ISPUNCTUATION(m_aChilds[0],"{")) - { - const OSQLParseNode* pODBCNode = m_aChilds[1]; - const OSQLParseNode* pODBCNodeChild = pODBCNode->m_aChilds[0]; - - if (pODBCNodeChild->getNodeType() == SQL_NODE_KEYWORD && ( - SQL_ISTOKEN(pODBCNodeChild, D) || - SQL_ISTOKEN(pODBCNodeChild, T) || - SQL_ISTOKEN(pODBCNodeChild, TS) )) - { - if (rString.getLength()) - rString += ::rtl::OUString::createFromAscii(" "); - rString += ::rtl::OUString::createFromAscii("#"); - if (SQL_ISTOKEN(pODBCNodeChild, D)) - rString += convertDateString(rParam, pODBCNode->m_aChilds[1]->getTokenValue()); - else if (SQL_ISTOKEN(pODBCNodeChild, T)) - rString += convertTimeString(rParam, pODBCNode->m_aChilds[1]->getTokenValue()); - else - rString += convertDateTimeString(rParam, pODBCNode->m_aChilds[1]->getTokenValue()); - - rString += ::rtl::OUString::createFromAscii("#"); - return sal_True; - } - } - return sal_False; -} - -//----------------------------------------------------------------------------- -void OSQLParseNode::replaceNodeValue(const ::rtl::OUString& rTableAlias,const ::rtl::OUString& rColumnName) -{ - for (sal_uInt32 i=0;i<count();++i) - { - if (SQL_ISRULE(this,column_ref) && count() == 1 && getChild(0)->getTokenValue() == rColumnName) - { - OSQLParseNode * pCol = removeAt((sal_uInt32)0); - append(new OSQLParseNode(rTableAlias,SQL_NODE_NAME)); - append(new OSQLParseNode(::rtl::OUString::createFromAscii("."),SQL_NODE_PUNCTUATION)); - append(pCol); - } - else - getChild(i)->replaceNodeValue(rTableAlias,rColumnName); + parseLeaf(rString,rParam); } } - //----------------------------------------------------------------------------- void OSQLParseNode::tableRangeNodeToStr(::rtl::OUString& rString, const SQLParseNodeParameter& rParam) const { @@ -746,7 +454,7 @@ void OSQLParseNode::likeNodeToStr(::rtl::OUString& rString, const SQLParseNodePa { // retrieve the fields name rtl::OUString aString; - rParam.xField->getPropertyValue(::rtl::OUString::createFromAscii("Name")) >>= aString; + rParam.xField->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aString; aFieldName = aString.getStr(); } catch ( Exception& ) @@ -783,620 +491,7 @@ void OSQLParseNode::likeNodeToStr(::rtl::OUString& rString, const SQLParseNodePa pEscNode->parseNodeToStr(rString, aNewParam); } -//----------------------------------------------------------------------------- -OSQLParseNode* OSQLParseNode::getByRule(OSQLParseNode::Rule eRule) const -{ - OSQLParseNode* pRetNode = 0; - if (isRule() && OSQLParser::RuleID(eRule) == getRuleID()) - pRetNode = (OSQLParseNode*)this; - else - { - for (OSQLParseNodes::const_iterator i = m_aChilds.begin(); - !pRetNode && i != m_aChilds.end(); i++) - pRetNode = (*i)->getByRule(eRule); - } - return pRetNode; -} -//----------------------------------------------------------------------------- -OSQLParseNode* MakeANDNode(OSQLParseNode *pLeftLeaf,OSQLParseNode *pRightLeaf) -{ - OSQLParseNode* pNewNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_term)); - pNewNode->append(pLeftLeaf); - pNewNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("AND"),SQL_NODE_KEYWORD,SQL_TOKEN_AND)); - pNewNode->append(pRightLeaf); - return pNewNode; -} -//----------------------------------------------------------------------------- -OSQLParseNode* MakeORNode(OSQLParseNode *pLeftLeaf,OSQLParseNode *pRightLeaf) -{ - OSQLParseNode* pNewNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::search_condition)); - pNewNode->append(pLeftLeaf); - pNewNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("OR"),SQL_NODE_KEYWORD,SQL_TOKEN_OR)); - pNewNode->append(pRightLeaf); - return pNewNode; -} -//----------------------------------------------------------------------------- -void OSQLParseNode::disjunctiveNormalForm(OSQLParseNode*& pSearchCondition) -{ - if(!pSearchCondition) // no where condition at entry point - return; - - OSQLParseNode::absorptions(pSearchCondition); - // '(' search_condition ')' - if (SQL_ISRULE(pSearchCondition,boolean_primary)) - { - OSQLParseNode* pLeft = pSearchCondition->getChild(1); - disjunctiveNormalForm(pLeft); - } - // search_condition SQL_TOKEN_OR boolean_term - else if (SQL_ISRULE(pSearchCondition,search_condition)) - { - OSQLParseNode* pLeft = pSearchCondition->getChild(0); - disjunctiveNormalForm(pLeft); - - OSQLParseNode* pRight = pSearchCondition->getChild(2); - disjunctiveNormalForm(pRight); - } - // boolean_term SQL_TOKEN_AND boolean_factor - else if (SQL_ISRULE(pSearchCondition,boolean_term)) - { - OSQLParseNode* pLeft = pSearchCondition->getChild(0); - disjunctiveNormalForm(pLeft); - - OSQLParseNode* pRight = pSearchCondition->getChild(2); - disjunctiveNormalForm(pRight); - - OSQLParseNode* pNewNode = NULL; - // '(' search_condition ')' - if(pLeft->count() == 3 && SQL_ISRULE(pLeft,boolean_primary) && SQL_ISRULE(pLeft->getChild(1),search_condition)) - { - // and-or tree on left side - OSQLParseNode* pOr = pLeft->getChild(1); - OSQLParseNode* pNewLeft = NULL; - OSQLParseNode* pNewRight = NULL; - - // cut right from parent - pSearchCondition->removeAt(2); - - pNewRight = MakeANDNode(pOr->removeAt(2) ,pRight); - pNewLeft = MakeANDNode(pOr->removeAt((sal_uInt32)0) ,new OSQLParseNode(*pRight)); - pNewNode = MakeORNode(pNewLeft,pNewRight); - // and append new Node - pSearchCondition->getParent()->replace(pSearchCondition, pNewNode); - delete pSearchCondition; - - disjunctiveNormalForm(pNewNode); - } - else if(pRight->count() == 3 && SQL_ISRULE(pRight,boolean_primary) && SQL_ISRULE(pRight->getChild(1),search_condition)) - { - // and-or tree on right side - OSQLParseNode* pOr = pRight->getChild(1); - OSQLParseNode* pNewLeft = NULL; - OSQLParseNode* pNewRight = NULL; - - // cut left from parent - pSearchCondition->removeAt((sal_uInt32)0); - - pNewRight = MakeANDNode(pLeft,pOr->removeAt(2)); - pNewLeft = MakeANDNode(new OSQLParseNode(*pLeft),pOr->removeAt((sal_uInt32)0)); - pNewNode = MakeORNode(pNewLeft,pNewRight); - - // and append new Node - pSearchCondition->getParent()->replace(pSearchCondition, pNewNode); - delete pSearchCondition; - disjunctiveNormalForm(pNewNode); - } - else if(SQL_ISRULE(pLeft,boolean_primary) && (!SQL_ISRULE(pLeft->getChild(1),search_condition) || !SQL_ISRULE(pLeft->getChild(1),boolean_term))) - pSearchCondition->replace(pLeft, pLeft->removeAt(1)); - else if(SQL_ISRULE(pRight,boolean_primary) && (!SQL_ISRULE(pRight->getChild(1),search_condition) || !SQL_ISRULE(pRight->getChild(1),boolean_term))) - pSearchCondition->replace(pRight, pRight->removeAt(1)); - } -} -//----------------------------------------------------------------------------- -void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition,sal_Bool bNegate) -{ - if(!pSearchCondition) // no where condition at entry point - return; - OSQLParseNode* pNode = NULL; - // '(' search_condition ')' - if (pSearchCondition->count() == 3 && SQL_ISRULE(pSearchCondition,boolean_primary)) - { - OSQLParseNode* pRight = pSearchCondition->getChild(1); - negateSearchCondition(pRight,bNegate); - } - // search_condition SQL_TOKEN_OR boolean_term - else if (SQL_ISRULE(pSearchCondition,search_condition)) - { - OSQLParseNode* pLeft = pSearchCondition->getChild(0); - OSQLParseNode* pRight = pSearchCondition->getChild(2); - if(bNegate) - { - OSQLParseNode* pNewNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_term)); - pNewNode->append(pSearchCondition->removeAt((sal_uInt32)0)); - pNewNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("AND"),SQL_NODE_KEYWORD,SQL_TOKEN_AND)); - pNewNode->append(pSearchCondition->removeAt((sal_uInt32)1)); - pSearchCondition->getParent()->replace(pSearchCondition, pNewNode); - delete pSearchCondition; - pLeft = pNewNode->getChild(0); - pRight = pNewNode->getChild(2); - } - - negateSearchCondition(pLeft,bNegate); - negateSearchCondition(pRight,bNegate); - } - // boolean_term SQL_TOKEN_AND boolean_factor - else if (SQL_ISRULE(pSearchCondition,boolean_term)) - { - OSQLParseNode* pLeft = pSearchCondition->getChild(0); - OSQLParseNode* pRight = pSearchCondition->getChild(2); - if(bNegate) - { - OSQLParseNode* pNewNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::search_condition)); - pNewNode->append(pSearchCondition->removeAt((sal_uInt32)0)); - pNewNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("OR"),SQL_NODE_KEYWORD,SQL_TOKEN_OR)); - pNewNode->append(pSearchCondition->removeAt((sal_uInt32)1)); - pSearchCondition->getParent()->replace(pSearchCondition, pNewNode); - delete pSearchCondition; - pLeft = pNewNode->getChild(0); - pRight = pNewNode->getChild(2); - } - - negateSearchCondition(pLeft,bNegate); - negateSearchCondition(pRight,bNegate); - } - // SQL_TOKEN_NOT boolean_test - else if (SQL_ISRULE(pSearchCondition,boolean_factor)) - { - OSQLParseNode *pNot = pSearchCondition->removeAt((sal_uInt32)0); - delete pNot; - OSQLParseNode *pBooleanTest = pSearchCondition->removeAt((sal_uInt32)0); - pBooleanTest->setParent(NULL); - pSearchCondition->getParent()->replace(pSearchCondition, pBooleanTest); - delete pSearchCondition; - if (!bNegate) - negateSearchCondition(pBooleanTest,sal_True); // negate all deeper values - } - // row_value_constructor comparison row_value_constructor - // row_value_constructor comparison any_all_some subquery - else if(bNegate && SQL_ISRULE(pSearchCondition,comparison_predicate) || SQL_ISRULE(pSearchCondition,all_or_any_predicate)) - { - OSQLParseNode* pComparison = pSearchCondition->getChild(1); - OSQLParseNode* pNewComparison = NULL; - switch(pComparison->getNodeType()) - { - case SQL_NODE_EQUAL: - pNewComparison = new OSQLParseNode(::rtl::OUString::createFromAscii("<>"),SQL_NODE_NOTEQUAL,NOTEQUAL); - break; - case SQL_NODE_LESS: - pNewComparison = new OSQLParseNode(::rtl::OUString::createFromAscii(">="),SQL_NODE_GREATEQ,GREATEQ); - break; - case SQL_NODE_GREAT: - pNewComparison = new OSQLParseNode(::rtl::OUString::createFromAscii("<="),SQL_NODE_LESSEQ,LESSEQ); - break; - case SQL_NODE_LESSEQ: - pNewComparison = new OSQLParseNode(::rtl::OUString::createFromAscii(">"),SQL_NODE_GREAT,GREAT); - break; - case SQL_NODE_GREATEQ: - pNewComparison = new OSQLParseNode(::rtl::OUString::createFromAscii("<"),SQL_NODE_LESS,LESS); - break; - case SQL_NODE_NOTEQUAL: - pNewComparison = new OSQLParseNode(::rtl::OUString::createFromAscii("="),SQL_NODE_EQUAL,EQUAL); - break; - } - pSearchCondition->replace(pComparison, pNewComparison); - delete pComparison; - } - - else if(bNegate && (SQL_ISRULE(pSearchCondition,test_for_null) || SQL_ISRULE(pSearchCondition,in_predicate) || - SQL_ISRULE(pSearchCondition,like_predicate) || SQL_ISRULE(pSearchCondition,between_predicate) || - SQL_ISRULE(pSearchCondition,boolean_test) )) - { - sal_uInt32 nNotPos = 0; - // row_value_constructor not SQL_TOKEN_IN in_predicate_value - // row_value_constructor not SQL_TOKEN_LIKE num_value_exp opt_escape - // row_value_constructor not SQL_TOKEN_BETWEEN row_value_constructor SQL_TOKEN_AND row_value_constructor - if(SQL_ISRULE(pSearchCondition,in_predicate) || SQL_ISRULE(pSearchCondition,like_predicate) || - SQL_ISRULE(pSearchCondition,between_predicate)) - nNotPos = 1; - // row_value_constructor SQL_TOKEN_IS not SQL_TOKEN_NULL - // boolean_primary SQL_TOKEN_IS not truth_value - else if(SQL_ISRULE(pSearchCondition,test_for_null) || SQL_ISRULE(pSearchCondition,boolean_test)) - nNotPos = 2; - - OSQLParseNode* pNot = pSearchCondition->getChild(nNotPos); - OSQLParseNode* pNotNot = NULL; - if(pNot->isRule()) - pNotNot = new OSQLParseNode(::rtl::OUString::createFromAscii("NOT"),SQL_NODE_KEYWORD,SQL_TOKEN_NOT); - else - pNotNot = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::not)); - pSearchCondition->replace(pNot, pNotNot); - delete pNot; - } -} -//----------------------------------------------------------------------------- -void OSQLParseNode::eraseBraces(OSQLParseNode*& pSearchCondition) -{ - if (pSearchCondition && (SQL_ISRULE(pSearchCondition,boolean_primary) || (pSearchCondition->count() == 3 && SQL_ISPUNCTUATION(pSearchCondition->getChild(0),"(") && - SQL_ISPUNCTUATION(pSearchCondition->getChild(2),")")))) - { - OSQLParseNode* pRight = pSearchCondition->getChild(1); - absorptions(pRight); - // if child is not a or or and tree then delete () around child - if(!(SQL_ISRULE(pSearchCondition->getChild(1),boolean_term) || SQL_ISRULE(pSearchCondition->getChild(1),search_condition)) || - SQL_ISRULE(pSearchCondition->getChild(1),boolean_term) || // and can always stand without () - (SQL_ISRULE(pSearchCondition->getChild(1),search_condition) && SQL_ISRULE(pSearchCondition->getParent(),search_condition))) - { - OSQLParseNode* pNode = pSearchCondition->removeAt(1); - pSearchCondition->getParent()->replace(pSearchCondition, pNode); - delete pSearchCondition; - pSearchCondition = pNode; - } - } -} -//----------------------------------------------------------------------------- -void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition) -{ - if(!pSearchCondition) // no where condition at entry point - return; - - eraseBraces(pSearchCondition); - - if(SQL_ISRULE(pSearchCondition,boolean_term) || SQL_ISRULE(pSearchCondition,search_condition)) - { - OSQLParseNode* pLeft = pSearchCondition->getChild(0); - absorptions(pLeft); - OSQLParseNode* pRight = pSearchCondition->getChild(2); - absorptions(pRight); - } - - // a and a || a or a - OSQLParseNode* pNewNode = NULL; - if(( SQL_ISRULE(pSearchCondition,boolean_term) || SQL_ISRULE(pSearchCondition,search_condition)) - && *pSearchCondition->getChild(0) == *pSearchCondition->getChild(2)) - { - pNewNode = pSearchCondition->removeAt((sal_uInt32)0); - pSearchCondition->getParent()->replace(pSearchCondition, pNewNode); - delete pSearchCondition; - pSearchCondition = pNewNode; - } - // (a or b) and a - else if(SQL_ISRULE(pSearchCondition,boolean_term) && SQL_ISRULE(pSearchCondition->getChild(0),boolean_primary) && - SQL_ISRULE(pSearchCondition->getChild(0)->getChild(1),search_condition) && - *pSearchCondition->getChild(0)->getChild(1)->getChild(0) == *pSearchCondition->getChild(2)) - { - pSearchCondition->getParent()->replace(pSearchCondition, pNewNode = pSearchCondition->removeAt(2)); - delete pSearchCondition; - pSearchCondition = pNewNode; - } - // a and ( a or b) - else if(SQL_ISRULE(pSearchCondition,boolean_term) && SQL_ISRULE(pSearchCondition->getChild(2),boolean_primary) && - SQL_ISRULE(pSearchCondition->getChild(2)->getChild(1),search_condition)) - - { - if(*pSearchCondition->getChild(2)->getChild(1)->getChild(0) == *pSearchCondition->getChild(0)) - { - pSearchCondition->getParent()->replace(pSearchCondition, pNewNode = pSearchCondition->removeAt((sal_uInt32)0)); - delete pSearchCondition; - pSearchCondition = pNewNode; - } - else if(*pSearchCondition->getChild(2)->getChild(1)->getChild(2) == *pSearchCondition->getChild(0)) - { - pSearchCondition->getParent()->replace(pSearchCondition, pNewNode = pSearchCondition->removeAt((sal_uInt32)2)); - delete pSearchCondition; - pSearchCondition = pNewNode; - } - } - // a or a and b || a or b and a - else if(SQL_ISRULE(pSearchCondition,search_condition) && SQL_ISRULE(pSearchCondition->getChild(2),boolean_term)) - { - if(*pSearchCondition->getChild(2)->getChild(0) == *pSearchCondition->getChild(0)) - { - pSearchCondition->getParent()->replace(pSearchCondition, pNewNode = pSearchCondition->removeAt((sal_uInt32)0)); - delete pSearchCondition; - pSearchCondition = pNewNode; - } - else if(*pSearchCondition->getChild(2)->getChild(2) == *pSearchCondition->getChild(0)) - { - pSearchCondition->getParent()->replace(pSearchCondition, pNewNode = pSearchCondition->removeAt((sal_uInt32)0)); - delete pSearchCondition; - pSearchCondition = pNewNode; - } - } - // a and b or a || b and a or a - else if(SQL_ISRULE(pSearchCondition,search_condition) && SQL_ISRULE(pSearchCondition->getChild(0),boolean_term)) - { - if(*pSearchCondition->getChild(0)->getChild(0) == *pSearchCondition->getChild(2)) - { - pSearchCondition->getParent()->replace(pSearchCondition, pNewNode = pSearchCondition->removeAt((sal_uInt32)2)); - delete pSearchCondition; - pSearchCondition = pNewNode; - } - else if(*pSearchCondition->getChild(0)->getChild(2) == *pSearchCondition->getChild(2)) - { - pSearchCondition->getParent()->replace(pSearchCondition, pNewNode = pSearchCondition->removeAt((sal_uInt32)2)); - delete pSearchCondition; - pSearchCondition = pNewNode; - } - } - eraseBraces(pSearchCondition); -} -//----------------------------------------------------------------------------- -void OSQLParseNode::compress(OSQLParseNode *&pSearchCondition) -{ - if(!pSearchCondition) // no where condition at entry point - return; - - OSQLParseNode::eraseBraces(pSearchCondition); - - if(SQL_ISRULE(pSearchCondition,boolean_term) || SQL_ISRULE(pSearchCondition,search_condition)) - { - OSQLParseNode* pLeft = pSearchCondition->getChild(0); - compress(pLeft); - - OSQLParseNode* pRight = pSearchCondition->getChild(2); - compress(pRight); - } - else if( SQL_ISRULE(pSearchCondition,boolean_primary) || (pSearchCondition->count() == 3 && SQL_ISPUNCTUATION(pSearchCondition->getChild(0),"(") && - SQL_ISPUNCTUATION(pSearchCondition->getChild(2),")"))) - { - OSQLParseNode* pRight = pSearchCondition->getChild(1); - compress(pRight); - // if child is not a or or and tree then delete () around child - if(!(SQL_ISRULE(pSearchCondition->getChild(1),boolean_term) || SQL_ISRULE(pSearchCondition->getChild(1),search_condition)) || - (SQL_ISRULE(pSearchCondition->getChild(1),boolean_term) && SQL_ISRULE(pSearchCondition->getParent(),boolean_term)) || - (SQL_ISRULE(pSearchCondition->getChild(1),search_condition) && SQL_ISRULE(pSearchCondition->getParent(),search_condition))) - { - OSQLParseNode* pNode = pSearchCondition->removeAt(1); - pSearchCondition->getParent()->replace(pSearchCondition, pNode); - delete pSearchCondition; - pSearchCondition = pNode; - } - } - - OSQLParseNode* pNewNode = NULL; - // or with two and trees where one element of the and trees are equal - if(SQL_ISRULE(pSearchCondition,search_condition) && SQL_ISRULE(pSearchCondition->getChild(0),boolean_term) && SQL_ISRULE(pSearchCondition->getChild(2),boolean_term)) - { - if(*pSearchCondition->getChild(0)->getChild(0) == *pSearchCondition->getChild(2)->getChild(0)) - { - OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt(2); - OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt(2); - OSQLParseNode* pNode = MakeORNode(pLeft,pRight); - - OSQLParseNode* pNewRule = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary)); - pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION)); - pNewRule->append(pNode); - pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION)); - - OSQLParseNode::eraseBraces(pLeft); - OSQLParseNode::eraseBraces(pRight); - - pNode = MakeANDNode(pSearchCondition->getChild(0)->removeAt((sal_uInt32)0),pNewRule); - pSearchCondition->getParent()->replace(pSearchCondition, pNode); - delete pSearchCondition; - pSearchCondition = pNode; - } - else if(*pSearchCondition->getChild(0)->getChild(2) == *pSearchCondition->getChild(2)->getChild(0)) - { - OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt((sal_uInt32)0); - OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt(2); - OSQLParseNode* pNode = MakeORNode(pLeft,pRight); - - OSQLParseNode* pNewRule = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary)); - pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION)); - pNewRule->append(pNode); - pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION)); - - OSQLParseNode::eraseBraces(pLeft); - OSQLParseNode::eraseBraces(pRight); - - pNode = MakeANDNode(pSearchCondition->getChild(0)->removeAt(1),pNewRule); - pSearchCondition->getParent()->replace(pSearchCondition, pNode); - delete pSearchCondition; - pSearchCondition = pNode; - } - else if(*pSearchCondition->getChild(0)->getChild(0) == *pSearchCondition->getChild(2)->getChild(2)) - { - OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt(2); - OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt((sal_uInt32)0); - OSQLParseNode* pNode = MakeORNode(pLeft,pRight); - - OSQLParseNode* pNewRule = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary)); - pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION)); - pNewRule->append(pNode); - pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION)); - - OSQLParseNode::eraseBraces(pLeft); - OSQLParseNode::eraseBraces(pRight); - - pNode = MakeANDNode(pSearchCondition->getChild(0)->removeAt((sal_uInt32)0),pNewRule); - pSearchCondition->getParent()->replace(pSearchCondition, pNode); - delete pSearchCondition; - pSearchCondition = pNode; - } - else if(*pSearchCondition->getChild(0)->getChild(2) == *pSearchCondition->getChild(2)->getChild(2)) - { - OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt((sal_uInt32)0); - OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt((sal_uInt32)0); - OSQLParseNode* pNode = MakeORNode(pLeft,pRight); - - OSQLParseNode* pNewRule = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary)); - pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION)); - pNewRule->append(pNode); - pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION)); - - OSQLParseNode::eraseBraces(pLeft); - OSQLParseNode::eraseBraces(pRight); - - pNode = MakeANDNode(pSearchCondition->getChild(0)->removeAt(1),pNewRule); - pSearchCondition->getParent()->replace(pSearchCondition, pNode); - delete pSearchCondition; - pSearchCondition = pNode; - } - } -} -//----------------------------------------------------------------------------- -void OSQLParseNode::showParseTree(::rtl::OUString& rString, sal_uInt32 nLevel) -{ - - - if (!isToken()) - { - for (sal_uInt32 j=0; j<nLevel; j++) {rString+= ::rtl::OUString::createFromAscii("\t");}; - // Regelnamen als rule: ... - rString+= ::rtl::OUString::createFromAscii("RULE_ID:\t "); - rString += ::rtl::OUString::valueOf( (sal_Int32)getRuleID()); - rString+= ::rtl::OUString::createFromAscii("("); - rString += OSQLParser::RuleIDToStr(getRuleID()); - rString+= ::rtl::OUString::createFromAscii(")"); - rString+= ::rtl::OUString::createFromAscii("\n"); - - // einmal auswerten wieviel Subtrees dieser Knoten besitzt - sal_uInt32 nStop = count(); - // hol dir den ersten Subtree - for (OSQLParseNodes::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); i++) - (*i)->showParseTree(rString, nLevel+1); - } - else { - // ein Token gefunden - // tabs fuer das Einruecken entsprechend nLevel - for (sal_uInt32 j=0; j<nLevel; j++) {rString+= ::rtl::OUString::createFromAscii("\t");}; - - switch (m_eNodeType) { - - case SQL_NODE_KEYWORD: - {rString+= ::rtl::OUString::createFromAscii("SQL_KEYWORD:\t"); - rString += ::rtl::OUString::createFromAscii(OSQLParser::TokenIDToStr(getTokenID()).getStr()); - rString+= ::rtl::OUString::createFromAscii("\n"); - break;} - - case SQL_NODE_COMPARISON: - {rString+= ::rtl::OUString::createFromAscii("SQL_COMPARISON:\t"); - rString += m_aNodeValue; // haenge Nodevalue an - rString+= ::rtl::OUString::createFromAscii("\n"); // und beginne neu Zeile - break;} - - case SQL_NODE_NAME: - {rString+= ::rtl::OUString::createFromAscii("SQL_NAME:\t"); - rString+= ::rtl::OUString::createFromAscii("\""); - rString += m_aNodeValue; - rString+= ::rtl::OUString::createFromAscii("\""); - rString+= ::rtl::OUString::createFromAscii("\n"); - break;} - - case SQL_NODE_STRING: - {rString += ::rtl::OUString::createFromAscii("SQL_STRING:\t'"); - rString += m_aNodeValue; - rString += ::rtl::OUString::createFromAscii("'\n"); - break;} - - case SQL_NODE_INTNUM: - {rString += ::rtl::OUString::createFromAscii("SQL_INTNUM:\t"); - rString += m_aNodeValue; - rString += ::rtl::OUString::createFromAscii("\n"); - break;} - - case SQL_NODE_APPROXNUM: - {rString += ::rtl::OUString::createFromAscii("SQL_APPROXNUM:\t"); - rString += m_aNodeValue; - rString += ::rtl::OUString::createFromAscii("\n"); - break;} - - case SQL_NODE_PUNCTUATION: - {rString += ::rtl::OUString::createFromAscii("SQL_PUNCTUATION:\t"); - rString += m_aNodeValue; // haenge Nodevalue an - rString += ::rtl::OUString::createFromAscii("\n"); // und beginne neu Zeile - break;} - - case SQL_NODE_AMMSC: - {rString += ::rtl::OUString::createFromAscii("SQL_AMMSC:\t"); - rString += m_aNodeValue; // haenge Nodevalue an - rString += ::rtl::OUString::createFromAscii("\n"); // und beginne neu Zeile - break;} - - default: - OSL_ASSERT("OSQLParser::ShowParseTree: unzulaessiger NodeType"); - } - }; -} - -// Insert-Methoden -//----------------------------------------------------------------------------- -void OSQLParseNode::insert(sal_uInt32 nPos, OSQLParseNode* pNewSubTree) -{ - OSL_ENSURE(pNewSubTree != NULL, "OSQLParseNode: ungueltiger NewSubTree"); - OSL_ENSURE(pNewSubTree->getParent() == NULL, "OSQLParseNode: Knoten ist kein Waise"); - // stelle Verbindung zum getParent her: - pNewSubTree->setParent( this ); - m_aChilds.insert(m_aChilds.begin() + nPos); -} - -// removeAt-Methoden -//----------------------------------------------------------------------------- -OSQLParseNode* OSQLParseNode::removeAt(sal_uInt32 nPos) -{ - OSQLParseNodes::iterator aPos(m_aChilds.begin() + nPos); - OSQLParseNode* pNode = *aPos; - - // setze den getParent des removeten auf NULL - pNode->setParent( NULL ); - - m_aChilds.erase(aPos); - return pNode; -} -//----------------------------------------------------------------------------- -OSQLParseNode* OSQLParseNode::remove(OSQLParseNode* pSubTree) -{ - OSL_ENSURE(pSubTree != NULL, "OSQLParseNode: ungueltiger SubTree"); - OSQLParseNodes::iterator aPos = ::std::find(m_aChilds.begin(), m_aChilds.end(), pSubTree); - if (aPos != m_aChilds.end()) - { - // setze den getParent des removeten auf NULL - pSubTree->setParent( NULL ); - m_aChilds.erase(aPos); - return pSubTree; - } - else - return NULL; -} - -// Replace-Methoden -//----------------------------------------------------------------------------- -OSQLParseNode* OSQLParseNode::replaceAt(sal_uInt32 nPos, OSQLParseNode* pNewSubNode) -{ - OSL_ENSURE(pNewSubNode != NULL, "OSQLParseNode: invalid nodes"); - OSL_ENSURE(pNewSubNode->getParent() == NULL, "OSQLParseNode: node already has getParent"); - OSL_ENSURE(nPos < m_aChilds.size(), "OSQLParseNode: invalid position"); - OSL_ENSURE(::std::find(m_aChilds.begin(), m_aChilds.end(), pNewSubNode) == m_aChilds.end(), - "OSQLParseNode::Replace() Node already element of parent"); - - OSQLParseNode* pOldSubNode = m_aChilds[nPos]; - - // stelle Verbindung zum getParent her: - pNewSubNode->setParent( this ); - pOldSubNode->setParent( NULL ); - - m_aChilds[nPos] = pNewSubNode; - return pOldSubNode; -} - -//----------------------------------------------------------------------------- -OSQLParseNode* OSQLParseNode::replace (OSQLParseNode* pOldSubNode, OSQLParseNode* pNewSubNode ) -{ - OSL_ENSURE(pOldSubNode != NULL && pNewSubNode != NULL, "OSQLParseNode: invalid nodes"); - OSL_ENSURE(pNewSubNode->getParent() == NULL, "OSQLParseNode: node already has getParent"); - OSL_ENSURE(::std::find(m_aChilds.begin(), m_aChilds.end(), pOldSubNode) != m_aChilds.end(), - "OSQLParseNode::Replace() Node not element of parent"); - OSL_ENSURE(::std::find(m_aChilds.begin(), m_aChilds.end(), pNewSubNode) == m_aChilds.end(), - "OSQLParseNode::Replace() Node already element of parent"); - - pOldSubNode->setParent( NULL ); - pNewSubNode->setParent( this ); - ::std::replace(m_aChilds.begin(), m_aChilds.end(), pOldSubNode, pNewSubNode); - return pOldSubNode; -} // ----------------------------------------------------------------------------- sal_Bool OSQLParseNode::getTableComponents(const OSQLParseNode* _pTableNode, ::com::sun::star::uno::Any &_rCatalog, diff --git a/connectivity/source/sdbcx/VCollection.cxx b/connectivity/source/sdbcx/VCollection.cxx index f32084b14a0c..22372d858f28 100644 --- a/connectivity/source/sdbcx/VCollection.cxx +++ b/connectivity/source/sdbcx/VCollection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VCollection.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:34:03 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:10:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,7 +97,7 @@ OCollection::OCollection(::cppu::OWeakObject& _rParent,sal_Bool _bCase, ::osl::M ,m_rMutex(_rMutex) ,m_aContainerListeners(_rMutex) ,m_aRefreshListeners(_rMutex) - ,m_aNameMap(_bCase) + ,m_aNameMap(_bCase ? true : false) { 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,::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNamed >()))); diff --git a/connectivity/source/sdbcx/VKey.cxx b/connectivity/source/sdbcx/VKey.cxx index b364b80da72c..b8d901effbda 100644 --- a/connectivity/source/sdbcx/VKey.cxx +++ b/connectivity/source/sdbcx/VKey.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VKey.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-05-17 09:13:14 $ + * last change: $Author: oj $ $Date: 2001-05-23 09:10:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -182,7 +182,7 @@ void OKey::construct() registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELETERULE), PROPERTY_ID_DELETERULE, nAttrib,&m_DeleteRule, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); } // ------------------------------------------------------------------------- -void OKey::disposing(void) +void SAL_CALL OKey::disposing() { OPropertySetHelper::disposing(); |