diff options
Diffstat (limited to 'connectivity/source')
276 files changed, 79948 insertions, 0 deletions
diff --git a/connectivity/source/commontools/CommonTools.cxx b/connectivity/source/commontools/CommonTools.cxx new file mode 100644 index 000000000000..9142ac4af8ec --- /dev/null +++ b/connectivity/source/commontools/CommonTools.cxx @@ -0,0 +1,318 @@ +/************************************************************************* + * + * $RCSfile: CommonTools.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * 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_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _RTL_CHAR_H_ +#include <rtl/char.h> +#endif +#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ +#include <com/sun/star/util/Date.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_TIME_HPP_ +#include <com/sun/star/util/Time.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ +#include <com/sun/star/util/DateTime.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#include <stdio.h> +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif + +namespace connectivity +{ + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::beans; + //------------------------------------------------------------------------------ + sal_Int32 getINT32(const Any& _rAny) + { + sal_Int32 nReturn = 0; + _rAny >>= nReturn; + return nReturn; + } + + //------------------------------------------------------------------------------ + sal_Int16 getINT16(const Any& _rAny) + { + sal_Int16 nReturn = 0; + _rAny >>= nReturn; + return nReturn; + } + + //------------------------------------------------------------------------------ + double getDouble(const Any& _rAny) + { + double nReturn = 0.0; + _rAny >>= nReturn; + return nReturn; + } + + //------------------------------------------------------------------------------ + ::rtl::OUString getString(const Any& _rAny) + { + ::rtl::OUString nReturn; + _rAny >>= nReturn; + return nReturn; + } + + //------------------------------------------------------------------------------ + sal_Bool getBOOL(const Any& _rAny) + { + return ::cppu::any2bool(_rAny); + } + //------------------------------------------------------------------ + const sal_Unicode CHAR_PLACE = '_'; + const sal_Unicode CHAR_WILD = '%'; + // ------------------------------------------------------------------------- + sal_Bool match(const sal_Unicode* pWild, const sal_Unicode* pStr, const sal_Unicode cEscape) + { + int pos=0; + int flag=0; + + while ( *pWild || flag ) + { + switch (*pWild) + { + case CHAR_PLACE: + if ( *pStr == 0 ) + return sal_False; + break; + default: + if (*pWild && (*pWild == cEscape) && ((*(pWild+1)== CHAR_PLACE) || (*(pWild+1) == CHAR_WILD)) ) + pWild++; + if ( rtl_char_toUpperCase(*pWild) != rtl_char_toUpperCase(*pStr) ) + if ( !pos ) + return sal_False; + else + pWild += pos; + else + break; // ACHTUNG laeuft unter bestimmten + // Umstaenden in den nachsten case rein!! + case CHAR_WILD: + while ( *pWild == CHAR_WILD ) + pWild++; + if ( *pWild == 0 ) + return sal_True; + flag = 1; + pos = 0; + if ( *pStr == 0 ) + return ( *pWild == 0 ); + while ( *pStr && *pStr != *pWild ) + { + if ( *pWild == CHAR_PLACE ) { + pWild++; + while ( *pWild == CHAR_WILD ) + pWild++; + } + pStr++; + if ( *pStr == 0 ) + return ( *pWild == 0 ); + } + break; + } + if ( *pWild != 0 ) + pWild++; + if ( *pStr != 0 ) + pStr++; + else + flag = 0; + if ( flag ) + pos--; + } + return ( *pStr == 0 ) && ( *pWild == 0 ); + } + //------------------------------------------------------------------ + rtl::OUString toDateString(const ::com::sun::star::util::Date& rDate) + { + sal_Char s[11]; + sprintf(s,"%04d-%02d-%02d", + (int)rDate.Year, + (int)rDate.Month, + (int)rDate.Day); + s[10] = 0; + return rtl::OUString::createFromAscii(s); + } + + //------------------------------------------------------------------ + rtl::OUString toTimeString(const ::com::sun::star::util::Time& rTime) + { + sal_Char s[9]; + sprintf(s,"%02d:%02d:%02d", + (int)rTime.Hours, + (int)rTime.Minutes, + (int)rTime.Seconds); + s[8] = 0; + return rtl::OUString::createFromAscii(s); + } + + //------------------------------------------------------------------ + rtl::OUString toDateTimeString(const ::com::sun::star::util::DateTime& rDateTime) + { + sal_Char s[21]; + sprintf(s,"%04d-%02d-%02d %02d:%02d:%02d", + (int)rDateTime.Year, + (int)rDateTime.Month, + (int)rDateTime.Day, + (int)rDateTime.Hours, + (int)rDateTime.Minutes, + (int)rDateTime.Seconds); + s[20] = 0; + return rtl::OUString::createFromAscii(s); + } + + + //-------------------------------------------------------------------------------------------------- + rtl::OUString toString(const Any& rValue) + { + rtl::OUString aRes; + TypeClass aDestinationClass = rValue.getValueType().getTypeClass(); + + switch (aDestinationClass) + { + case TypeClass_CHAR: + aRes = ::rtl::OUString::valueOf(*(sal_Unicode*)rValue.getValue()); + break; + case TypeClass_FLOAT: + aRes = ::rtl::OUString::valueOf(*(float*)rValue.getValue()); + break; + case TypeClass_DOUBLE: + aRes = ::rtl::OUString::valueOf(*(double*)rValue.getValue()); + break; + case TypeClass_BOOLEAN: + aRes = ::rtl::OUString::valueOf(*(sal_Bool*)rValue.getValue()); + break; + case TypeClass_BYTE: + case TypeClass_SHORT: + case TypeClass_LONG: + aRes = ::rtl::OUString::valueOf(*(sal_Int32*)rValue.getValue()); + break; + case TypeClass_STRING: + rValue >>= aRes; + break; + case TypeClass_STRUCT: + if (rValue.getValueType() == ::getCppuType((const ::com::sun::star::util::Date*)0)) + { + ::com::sun::star::util::Date aDate; + rValue >>= aDate; + aRes = toDateString(aDate); + } + else if (rValue.getValueType() == ::getCppuType((const ::com::sun::star::util::DateTime*)0)) + { + ::com::sun::star::util::DateTime aDT; + rValue >>= aDT; + aRes = toDateTimeString(aDT); + } + else if (rValue.getValueType() == ::getCppuType((const ::com::sun::star::util::Time*)0)) + { + ::com::sun::star::util::Time aTime; + rValue >>= aTime; + aRes = toTimeString(aTime); + } + + break; + default: + ; +// throw( CannotConvertException( ::rtl::OUString::createFromAscii("TYPE is not supported!"), Reference< XInterface > (), +// aDestinationClass, FailReason::TYPE_NOT_SUPPORTED, 0 ) ); + + } + return aRes; + } + // ------------------------------------------------------------------------- + OSQLColumns::const_iterator find( OSQLColumns::const_iterator __first, + OSQLColumns::const_iterator __last, + const ::rtl::OUString& _rVal, + const ::utl::UStringMixEqual& _rCase) + { + while (__first != __last && !_rCase(getString((*__first)->getFastPropertyValue(PROPERTY_ID_NAME)),_rVal)) + ++__first; + return __first; + } + // ------------------------------------------------------------------------- + OSQLColumns::const_iterator findRealName( OSQLColumns::const_iterator __first, + OSQLColumns::const_iterator __last, + const ::rtl::OUString& _rVal, + const ::utl::UStringMixEqual& _rCase) + { + while (__first != __last && !_rCase(getString((*__first)->getFastPropertyValue(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 ::utl::UStringMixEqual& _rCase) + { + while (__first != __last && !_rCase(getString(Reference<XPropertySet>((*__first),UNO_QUERY)->getPropertyValue(_rProp)),_rVal)) + ++__first; + return __first; + } +} diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx new file mode 100644 index 000000000000..4bfd7f5f3213 --- /dev/null +++ b/connectivity/source/commontools/DateConversion.cxx @@ -0,0 +1,370 @@ +/************************************************************************* + * + * $RCSfile: DateConversion.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * 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_DATECONVERSION_HXX_ +#include "DateConversion.hxx" +#endif + +using namespace connectivity; +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; + sal_setInt64(&nRet,nDate,nTime); + 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/makefile.mk b/connectivity/source/commontools/makefile.mk new file mode 100644 index 000000000000..321d80dd90e8 --- /dev/null +++ b/connectivity/source/commontools/makefile.mk @@ -0,0 +1,90 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=connectivity +TARGET=commontools + +ENABLE_EXCEPTIONS=TRUE +# --- Settings ----------------------------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : settings.mk +# --- Files -------------------------------------------------------- + +SLOFILES=\ + $(SLO)$/enumhelper.obj \ + $(SLO)$/propertyhelper.obj \ + $(SLO)$/simplepropertycontainer.obj \ + $(SLO)$/CommonTools.obj \ + $(SLO)$/DateConversion.obj \ + + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + diff --git a/connectivity/source/drivers/adabas/BCatalog.cxx b/connectivity/source/drivers/adabas/BCatalog.cxx new file mode 100644 index 000000000000..b9c73fdc4aa3 --- /dev/null +++ b/connectivity/source/drivers/adabas/BCatalog.cxx @@ -0,0 +1,195 @@ +/************************************************************************* + * + * $RCSfile: BCatalog.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * 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_ADABAS_CATALOG_HXX_ +#include "adabas/BCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_GROUPS_HXX_ +#include "adabas/BGroups.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_USERS_HXX_ +#include "adabas/BUsers.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLES_HXX_ +#include "adabas/BTables.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif + + +// ------------------------------------------------------------------------- +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +// ------------------------------------------------------------------------- +OAdabasCatalog::OAdabasCatalog(SQLHANDLE _aConnectionHdl, OAdabasConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon) + ,m_pConnection(_pCon) + ,m_aConnectionHdl(_aConnectionHdl) + ,m_xMetaData(m_pConnection->getMetaData( )) +{ + osl_incrementInterlockedCount( &m_refCount ); + refreshTables(); + refreshViews(); + refreshGroups(); + refreshUsers(); + osl_decrementInterlockedCount( &m_refCount ); +} +// ------------------------------------------------------------------------- +void OAdabasCatalog::refreshTables() +{ + ::std::vector< ::rtl::OUString> aVector; + Sequence< ::rtl::OUString > aTypes(1); + aTypes[0] = ::rtl::OUString::createFromAscii("%"); + Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), + ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii("."),aView = ::rtl::OUString::createFromAscii("VIEW"); + while(xResult->next()) + { + if(xRow->getString(4) != aView) + { + aName = xRow->getString(2); + aName += aDot; + aName += xRow->getString(3); + aVector.push_back(aName); + } + } + } + if(m_pTables) + delete m_pTables; + m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +void OAdabasCatalog::refreshViews() +{ + ::std::vector< ::rtl::OUString> aVector; + Sequence< ::rtl::OUString > aTypes(1); + aTypes[0] = ::rtl::OUString::createFromAscii("VIEW"); + Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), + ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii("."); + while(xResult->next()) + { + aName = xRow->getString(2); + aName += aDot; + aName += xRow->getString(3); + aVector.push_back(aName); + } + } + if(m_pViews) + delete m_pViews; + m_pViews = new OTables(m_xMetaData,*this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +void OAdabasCatalog::refreshGroups() +{ + ::std::vector< ::rtl::OUString> aVector; + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + Reference< XResultSet > xResult = xStmt->executeQuery( + ::rtl::OUString::createFromAscii("SELECT DISTINCT GROUPNAME FROM DOMAIN.USERS WHERE GROUPNAME IS NOT NULL AND GROUPNAME <> ' '")); + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(1)); + } + if(m_pGroups) + delete m_pGroups; + m_pGroups = new OGroups(*this,m_aMutex,aVector,m_pConnection,this); +} +// ------------------------------------------------------------------------- +void OAdabasCatalog::refreshUsers() +{ + ::std::vector< ::rtl::OUString> aVector; + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + Reference< XResultSet > xResult = xStmt->executeQuery( + ::rtl::OUString::createFromAscii("SELECT DISTINCT USERNAME FROM DOMAIN.USERS WHERE USERNAME IS NOT NULL AND USERNAME <> ' ' AND USERNAME <> 'CONTROL'")); + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(1)); + } + if(m_pUsers) + delete m_pUsers; + m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/adabas/BColumns.cxx b/connectivity/source/drivers/adabas/BColumns.cxx new file mode 100644 index 000000000000..cfebf615d6f2 --- /dev/null +++ b/connectivity/source/drivers/adabas/BColumns.cxx @@ -0,0 +1,241 @@ +/************************************************************************* + * + * $RCSfile: BColumns.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * 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_ADABAS_COLUMNS_HXX_ +#include "adabas/BColumns.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::adabas; +using namespace connectivity::sdbcx; +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OColumns::createObject(const ::rtl::OUString& _rName) +{ + + Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(), + m_pTable->getSchema(),m_pTable->getName(),_rName); + + Reference< XNamed > xRet = NULL; + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + { + if(xRow->getString(4) == _rName) + { + OColumn* pRet = new OColumn(_rName, + xRow->getString(6), + xRow->getString(13), + xRow->getInt(11), + xRow->getInt(7), + xRow->getInt(9), + xRow->getInt(5), + sal_False,sal_False,sal_False,sal_True); + xRet = pRet; + break; + } + } + } + + return xRet; +} + +// ------------------------------------------------------------------------- +void OColumns::impl_refresh() throw(RuntimeException) +{ + m_pTable->refreshColumns(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OColumns::createEmptyObject() +{ + OColumn* pNew = new OColumn(sal_True); + Reference< XPropertySet > xRet = pNew; + return xRet; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OColumns::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if(!m_pTable->isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + aDot + aQuote + m_pTable->getName() + aQuote; + aSql = aSql + ::rtl::OUString::createFromAscii(" ADD "); + aSql = aSql + aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote; + aSql = aSql + ::rtl::OUString::createFromAscii(" "); + + Any aTypeName = descriptor->getPropertyValue(PROPERTY_TYPENAME); + if(aTypeName.hasValue() && getString(aTypeName).getLength()) + aSql = aSql + getString(aTypeName); + else + aSql = aSql + getTypeString(descriptor) + ::rtl::OUString::createFromAscii(" "); + + // aSql = aSql + getString(descriptor->getPropertyValue(PROPERTY_TYPENAME)); + + switch(getINT32(descriptor->getPropertyValue(PROPERTY_TYPE))) + { + case DataType::CHAR: + case DataType::VARCHAR: + aSql = aSql + ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(descriptor->getPropertyValue(PROPERTY_PRECISION))) + + ::rtl::OUString::createFromAscii(")"); + break; + + case DataType::DECIMAL: + case DataType::NUMERIC: + aSql = aSql + ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(descriptor->getPropertyValue(PROPERTY_PRECISION))) + + ::rtl::OUString::createFromAscii(",") + + ::rtl::OUString::valueOf(getINT32(descriptor->getPropertyValue(PROPERTY_SCALE))) + + ::rtl::OUString::createFromAscii(")"); + break; + } + ::rtl::OUString aDefault = getString(descriptor->getPropertyValue(PROPERTY_DEFAULTVALUE)); + if(getINT32(descriptor->getPropertyValue(PROPERTY_ISNULLABLE)) == ColumnValue::NO_NULLS) + { + aSql = aSql + ::rtl::OUString::createFromAscii(" NOT NULL"); + if(aDefault.getLength()) + aSql = aSql + ::rtl::OUString::createFromAscii(" WITH DEFAULT"); + } + else if(aDefault.getLength()) + aSql = aSql + ::rtl::OUString::createFromAscii(" DEFAULT ") + aDefault; + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OColumns::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if(!m_pTable->isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + aDot + aQuote + m_pTable->getName() + aQuote; + aSql = aSql + ::rtl::OUString::createFromAscii(" DROP "); + aSql = aSql + aQuote + elementName + aQuote; + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OColumns::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + if(!m_pTable->isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + aDot + aQuote + m_pTable->getName() + aQuote; + aSql = aSql + ::rtl::OUString::createFromAscii(" DROP "); + aSql = aSql + aQuote + m_aElements[index]->first + aQuote; + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + OCollection_TYPE::dropByIndex(index); +} + + diff --git a/connectivity/source/drivers/adabas/BConnection.cxx b/connectivity/source/drivers/adabas/BConnection.cxx new file mode 100644 index 000000000000..0b7dbea58955 --- /dev/null +++ b/connectivity/source/drivers/adabas/BConnection.cxx @@ -0,0 +1,233 @@ +/************************************************************************* + * + * $RCSfile: BConnection.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * 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_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_BDRIVER_HXX_ +#include "adabas/BDriver.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_CATALOG_HXX_ +#include "adabas/BCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_ +#include "odbc/OFunctions.hxx" +#endif +#ifndef _CONNECTIVITY_OTOOLS_HXX_ +#include "odbc/OTools.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_ODATABASEMETADATA_HXX_ +#include "adabas/BDatabaseMetaData.hxx" +#endif + +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + +using namespace connectivity::adabas; +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + + +//------------------------------------------------------------------------------ +namespace starlang = ::com::sun::star::lang; +// -------------------------------------------------------------------------------- +OAdabasConnection::OAdabasConnection(const SQLHANDLE _pDriverHandle, connectivity::odbc::ODBCDriver* _pDriver) + : OConnection_BASE2(_pDriverHandle,_pDriver) +{ +} +//----------------------------------------------------------------------------- +SQLRETURN OAdabasConnection::Construct( const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + osl_incrementInterlockedCount( &m_refCount ); + + m_aConnectionHandle = SQL_NULL_HANDLE; + + // Connection allozieren + N3SQLAllocHandle(SQL_HANDLE_DBC,m_pDriverHandleCopy,&m_aConnectionHandle); + if(m_aConnectionHandle == SQL_NULL_HANDLE) + throw SQLException(); + + const PropertyValue *pBegin = info.getConstArray(); + const PropertyValue *pEnd = pBegin + info.getLength(); + ::rtl::OUString aAdminUid,aAdminPwd; + + sal_Int32 nLen = url.indexOf(':'); + nLen = url.indexOf(':',nLen+1); + ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD; + sal_Int32 nTimeout = 20; + for(;pBegin != pEnd;++pBegin) + { + if(!pBegin->Name.compareToAscii("CTRLUSER")) + pBegin->Value >>= aAdminUid; + else if(!pBegin->Name.compareToAscii("CTRLPWD")) + pBegin->Value >>= aAdminPwd; + else if(!pBegin->Name.compareToAscii("Timeout")) + pBegin->Value >>= nTimeout; + else if(!pBegin->Name.compareToAscii("user")) + pBegin->Value >>= aUID; + else if(!pBegin->Name.compareToAscii("password")) + pBegin->Value >>= aPWD; + } + + SQLRETURN nSQLRETURN = OpenConnection(aDSN,nTimeout, aUID,aPWD); + + osl_decrementInterlockedCount( &m_refCount ); + return nSQLRETURN; +} +//----------------------------------------------------------------------------- +SQLRETURN OAdabasConnection::OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, const ::rtl::OUString& _uid,const ::rtl::OUString& _pwd) +{ + if (m_aConnectionHandle == SQL_NULL_HANDLE) + return -1; + + SQLRETURN nSQLRETURN = 0; + SDB_ODBC_CHAR szDSN[4096]; + SDB_ODBC_CHAR szUID[20]; + SDB_ODBC_CHAR szPWD[20]; + + memset(szDSN,'\0',4096); + memset(szUID,'\0',20); + memset(szPWD,'\0',20); + + ::rtl::OString aConStr(::rtl::OUStringToOString(aConnectStr,osl_getThreadTextEncoding())); + ::rtl::OString aUID(::rtl::OUStringToOString(_uid,osl_getThreadTextEncoding())); + ::rtl::OString aPWD(::rtl::OUStringToOString(_pwd,osl_getThreadTextEncoding())); + memcpy(szDSN, (SDB_ODBC_CHAR*) aConStr.getStr(), ::std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength())); + memcpy(szUID, (SDB_ODBC_CHAR*) aUID.getStr(), ::std::min<sal_Int32>((sal_Int32)20,aUID.getLength())); + memcpy(szPWD, (SDB_ODBC_CHAR*) aPWD.getStr(), ::std::min<sal_Int32>((sal_Int32)20,aPWD.getLength())); + + + + N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_LOGIN_TIMEOUT,(SQLPOINTER)nTimeOut,SQL_IS_INTEGER); + // Verbindung aufbauen + + nSQLRETURN = N3SQLConnect(m_aConnectionHandle, + szDSN, + (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength()), + szUID, + (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)20,aUID.getLength()), + szPWD, + (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)20,aPWD.getLength())); + if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA) + return nSQLRETURN; + +#ifndef MAC + // autocoomit ist immer default + + N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_AUTOCOMMIT,(SQLPOINTER)SQL_AUTOCOMMIT_ON,SQL_IS_INTEGER); +#endif + buildTypeInfo(); + + return nSQLRETURN; +} + +//------------------------------------------------------------------------------ +void OAdabasConnection::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + Reference< XComponent > xComp2(m_xCatalog.get(), UNO_QUERY); + if(xComp2.is()) + xComp2->dispose(); + + m_xCatalog = Reference< XTablesSupplier >(); + + OConnection_BASE2::disposing(); +} +//------------------------------------------------------------------------------ +::com::sun::star::uno::Reference< XTablesSupplier > OAdabasConnection::createCatalog() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + Reference< XTablesSupplier > xTab = m_xCatalog; + if(!m_xCatalog.get().is()) + { + OAdabasCatalog *pCat = new OAdabasCatalog(m_aConnectionHandle,this); + xTab = pCat; + m_xCatalog = xTab; + } + return xTab; +} +// -------------------------------------------------------------------------------- +Reference< XDatabaseMetaData > SAL_CALL OAdabasConnection::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE2::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_xMetaData.is()) + m_xMetaData = new OAdabasDatabaseMetaData(m_aConnectionHandle,this); + + return m_xMetaData; +} +//------------------------------------------------------------------------------ +sal_Bool OAdabasConnection::isStarted() +{ + return sal_True; + +} + diff --git a/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx b/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx new file mode 100644 index 000000000000..00edcb7e9971 --- /dev/null +++ b/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * $RCSfile: BDatabaseMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * 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_ADABAS_BDATABASEMETADATA_HXX_ +#include "adabas/BDatabaseMetaData.hxx" +#endif + +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +::rtl::OUString SAL_CALL OAdabasDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aRet = ::rtl::OUString::createFromAscii("sdbc:adabas:") + OAdabasDatabaseMetaData_BASE::getURL(); + return aRet; +} + + diff --git a/connectivity/source/drivers/adabas/BDriver.cxx b/connectivity/source/drivers/adabas/BDriver.cxx new file mode 100644 index 000000000000..3bbf1c42bd83 --- /dev/null +++ b/connectivity/source/drivers/adabas/BDriver.cxx @@ -0,0 +1,252 @@ +/************************************************************************* + * + * $RCSfile: BDriver.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * 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_ADABAS_BDRIVER_HXX_ +#include "adabas/BDriver.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_ +#include "odbc/OFunctions.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _CONNECTIVITY_OTOOLS_HXX_ +#include "odbc/OTools.hxx" +#endif + +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +// -------------------------------------------------------------------------------- +ODriver::ODriver() +{ +} +//------------------------------------------------------------------------------ +void ODriver::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + ODriver_BASE::disposing(); +} + +// static ServiceInfo +//------------------------------------------------------------------------------ +rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException) +{ + return rtl::OUString::createFromAscii("com.sun.star.sdbc.BDriver"); +} +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > ODriver::getSupportedServiceNames_Static( ) throw (RuntimeException) +{ + Sequence< ::rtl::OUString > aSNS( 2 ); + aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver"); + aSNS[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Driver"); + return aSNS; +} +//------------------------------------------------------------------ +::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------ +sal_Bool SAL_CALL ODriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) + if (pSupported->equals(_rServiceName)) + return sal_True; + + return sal_False; +} +//------------------------------------------------------------------ +Sequence< ::rtl::OUString > SAL_CALL ODriver::getSupportedServiceNames( ) throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +//------------------------------------------------------------------ +Any SAL_CALL ODriver::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType, static_cast<XDataDefinitionSupplier*>(this)); + if(aRet.hasValue()) + return aRet; + return ODriver_BASE::queryInterface(rType); +} +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::adabas::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ) throw( ::com::sun::star::uno::Exception ) +{ + return *(new ODriver()); +} +// -------------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) +{ + if(!m_pDriverHandle) + { + ::rtl::OUString aPath; + if(!EnvironmentHandle(aPath)) + throw SQLException(aPath,*this,::rtl::OUString(),1000,Any()); + } + OAdabasConnection* pCon = new OAdabasConnection(m_pDriverHandle,this); + SQLRETURN nSQLRETURN = pCon->Construct(url,info); + + if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA) + { + connectivity::odbc::OTools::ThrowException(nSQLRETURN,pCon->getConnection(),SQL_HANDLE_DBC,*this); + } + else if(SQL_SUCCESS_WITH_INFO == nSQLRETURN) // this driver does not support odbc3 + { + } + Reference< XConnection > xCon = pCon; + m_xConnections.push_back(WeakReferenceHelper(*pCon)); + + return xCon; +} + +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url ) + throw(SQLException, RuntimeException) +{ + if(!url.compareTo(::rtl::OUString::createFromAscii("sdbc:adabas:"),12)) + { + return sal_True; + } + return sal_False; +} +// -------------------------------------------------------------------------------- +Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& , const Sequence< PropertyValue >& ) throw(SQLException, RuntimeException) +{ + return Sequence< DriverPropertyInfo >(); +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODriver::getMajorVersion( ) throw(RuntimeException) +{ + return 1; +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODriver::getMinorVersion( ) throw(RuntimeException) +{ + return 0; +} +// -------------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// ODBC Environment (gemeinsam fuer alle Connections): +SQLHANDLE ODriver::EnvironmentHandle(::rtl::OUString &_rPath) +{ + // Ist (fuer diese Instanz) bereits ein Environment erzeugt worden? + if (!m_pDriverHandle) + { + SQLHANDLE h = SQL_NULL_HANDLE; + // Environment allozieren + + // ODBC-DLL jetzt laden: + if (! connectivity::LoadLibrary_ADABAS(_rPath)) + return SQL_NULL_HANDLE; + + if (N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS) + return SQL_NULL_HANDLE; + + // In globaler Struktur merken ... + m_pDriverHandle = (void *) h; + SQLRETURN nError = N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION,(SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER); + //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER); + } + + return m_pDriverHandle; +} +// -------------------------------------------------------------------------------- +// XDataDefinitionSupplier +Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByConnection( const Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODriver_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + OAdabasConnection* pConnection = NULL; + for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) + { + if ((OAdabasConnection*) Reference< XConnection >::query(i->get().get()).get() == (OAdabasConnection*)connection.get()) + { + pConnection = (OAdabasConnection*)connection.get(); + break; + } + } + + Reference< XTablesSupplier > xTab = NULL; + if(pConnection) + xTab = pConnection->createCatalog(); + return xTab; +} + +// -------------------------------------------------------------------------------- +Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + return getDataDefinitionByConnection(connect(url,info)); +} + + diff --git a/connectivity/source/drivers/adabas/BGroup.cxx b/connectivity/source/drivers/adabas/BGroup.cxx new file mode 100644 index 000000000000..8423bf7d3384 --- /dev/null +++ b/connectivity/source/drivers/adabas/BGroup.cxx @@ -0,0 +1,131 @@ +/************************************************************************* + * + * $RCSfile: BGroup.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * 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_ADABAS_GROUP_HXX_ +#include "adabas/BGroup.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_USERS_HXX_ +#include "adabas/BUsers.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +// ------------------------------------------------------------------------- +OAdabasGroup::OAdabasGroup( OAdabasConnection* _pConnection) : connectivity::sdbcx::OGroup(sal_True) + ,m_pConnection(_pConnection) +{ + construct(); + ::std::vector< ::rtl::OUString> aVector; + m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this); +} +// ------------------------------------------------------------------------- +OAdabasGroup::OAdabasGroup( OAdabasConnection* _pConnection, + const ::rtl::OUString& _Name + ) : connectivity::sdbcx::OGroup(_Name,sal_True) + ,m_pConnection(_pConnection) +{ + construct(); + refreshUsers(); +} +// ------------------------------------------------------------------------- +void OAdabasGroup::refreshUsers() +{ + if(!m_pConnection) + return; + + ::std::vector< ::rtl::OUString> aVector; + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT USERNAME FROM DOMAIN.USERS WHERE USERNAME IS NOT NULL AND USERNAME <> ' ' AND USERNAME <> 'CONTROL' AND GROUPNAME = '"); + aSql += getName( ); + aSql += ::rtl::OUString::createFromAscii("'"); + + Reference< XResultSet > xResult = xStmt->executeQuery(aSql); + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(1)); + } + if(m_pUsers) + delete m_pUsers; + m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this); +} + + diff --git a/connectivity/source/drivers/adabas/BGroups.cxx b/connectivity/source/drivers/adabas/BGroups.cxx new file mode 100644 index 000000000000..f9a3c6b8adb7 --- /dev/null +++ b/connectivity/source/drivers/adabas/BGroups.cxx @@ -0,0 +1,161 @@ +/************************************************************************* + * + * $RCSfile: BGroups.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * 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_ADABAS_GROUPS_HXX_ +#include "adabas/BGroups.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_GROUP_HXX_ +#include "adabas/BGroup.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_ +#include "sdbcx/IRefreshable.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; +// ------------------------------------------------------------------------- +Reference< XNamed > OGroups::createObject(const ::rtl::OUString& _rName) +{ + Reference< XNamed > xRet = NULL; + OAdabasGroup* pRet = new OAdabasGroup(m_pConnection,_rName); + xRet = pRet; + return xRet; +} +// ------------------------------------------------------------------------- +void OGroups::impl_refresh() throw(RuntimeException) +{ + m_pParent->refreshGroups(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OGroups::createEmptyObject() +{ + OAdabasGroup* pNew = new OAdabasGroup(m_pConnection); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OGroups::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); + ObjectMap::iterator aIter = m_aNameMap.find(aName); + if( aIter != m_aNameMap.end()) + throw ElementExistException(aName,*this); + + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE USERGROUP "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + + aSql = aSql + aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote; + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OGroups::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP USERGROUP "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + + aSql = aSql + aQuote + elementName + aQuote; + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OGroups::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + dropByName(m_aElements[index]->first); +} + + diff --git a/connectivity/source/drivers/adabas/BIndex.cxx b/connectivity/source/drivers/adabas/BIndex.cxx new file mode 100644 index 000000000000..6d8276f9b791 --- /dev/null +++ b/connectivity/source/drivers/adabas/BIndex.cxx @@ -0,0 +1,139 @@ +/************************************************************************* + * + * $RCSfile: BIndex.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * 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_ADABAS_INDEX_HXX_ +#include "adabas/BIndex.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_ +#include "adabas/BIndexColumns.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif + +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +// ------------------------------------------------------------------------- +OAdabasIndex::OAdabasIndex( OAdabasTable* _pTable) : connectivity::sdbcx::OIndex(sal_True) + , m_pTable(_pTable) +{ + construct(); + ::std::vector< ::rtl::OUString> aVector; + m_pColumns = new OIndexColumns(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +OAdabasIndex::OAdabasIndex( OAdabasTable* _pTable, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Catalog, + sal_Bool _isUnique, + sal_Bool _isPrimaryKeyIndex, + sal_Bool _isClustered + ) : connectivity::sdbcx::OIndex(_Name, + _Catalog, + _isUnique, + _isPrimaryKeyIndex, + _isClustered,sal_True) + ,m_pTable(_pTable) +{ + construct(); + refreshColumns(); +} +// ------------------------------------------------------------------------- + +void OAdabasIndex::refreshColumns() +{ + if(!m_pTable) + return; + + ::std::vector< ::rtl::OUString> aVector; + Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getIndexInfo(Any(), + m_pTable->getSchema(),m_pTable->getName(),sal_False,sal_False); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aColName; + while(xResult->next()) + { + if(xRow->getString(9) == m_Name) + { + aColName = xRow->getString(9); + if(!xRow->wasNull()) + aVector.push_back(aColName); + } + } + } + if(m_pColumns) + delete m_pColumns; + m_pColumns = new OIndexColumns(this,m_aMutex,aVector); +} + diff --git a/connectivity/source/drivers/adabas/BIndexColumns.cxx b/connectivity/source/drivers/adabas/BIndexColumns.cxx new file mode 100644 index 000000000000..8f7582a621d2 --- /dev/null +++ b/connectivity/source/drivers/adabas/BIndexColumns.cxx @@ -0,0 +1,146 @@ +/************************************************************************* + * + * $RCSfile: BIndexColumns.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * 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_ADABAS_INDEXCOLUMNS_HXX_ +#include "adabas/BIndexColumns.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_INDEXCOLUMN_HXX_ +#include "connectivity/sdbcx/VIndexColumn.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif + +using namespace connectivity::adabas; +using namespace connectivity::sdbcx; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +// ------------------------------------------------------------------------- +Reference< XNamed > OIndexColumns::createObject(const ::rtl::OUString& _rName) +{ + + Reference< XResultSet > xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getIndexInfo(Any(), + m_pIndex->getTable()->getSchema(),m_pIndex->getTable()->getName(),sal_False,sal_False); + + sal_Bool bAsc = sal_True; + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aD(::rtl::OUString::createFromAscii("D")); + while(xResult->next()) + { + if(xRow->getString(9) == _rName) + bAsc = xRow->getString(10) != aD; + } + } + + xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns(Any(), + m_pIndex->getTable()->getSchema(),m_pIndex->getTable()->getName(),_rName); + + Reference< XNamed > xRet = NULL; + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + { + if(xRow->getString(4) == _rName) + { + OIndexColumn* pRet = new OIndexColumn(bAsc, + _rName, + xRow->getString(6), + xRow->getString(13), + xRow->getInt(11), + xRow->getInt(7), + xRow->getInt(9), + xRow->getInt(5), + sal_False,sal_False,sal_False,sal_True); + xRet = pRet; + break; + } + } + } + + return xRet; +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OIndexColumns::createEmptyObject() +{ + OIndexColumn* pNew = new OIndexColumn(sal_True); + return pNew; +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/adabas/BIndexes.cxx b/connectivity/source/drivers/adabas/BIndexes.cxx new file mode 100644 index 000000000000..82361e74977c --- /dev/null +++ b/connectivity/source/drivers/adabas/BIndexes.cxx @@ -0,0 +1,241 @@ +/************************************************************************* + * + * $RCSfile: BIndexes.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADABAS_INDEXES_HXX_ +#include "adabas/BIndexes.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_INDEX_HXX_ +#include "adabas/BIndex.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_INDEXTYPE_HPP_ +#include <com/sun/star/sdbc/IndexType.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OIndexes::createObject(const ::rtl::OUString& _rName) +{ + ::rtl::OUString aName,aQualifier; + sal_Int32 nLen = _rName.indexOf('.'); + if(nLen != -1) + { + aQualifier = _rName.copy(0,nLen); + aName = _rName.copy(nLen+1); + } + else + aName = _rName; + + + Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getIndexInfo(Any(), + m_pTable->getSchema(),m_pTable->getName(),sal_False,sal_False); + + Reference< XNamed > xRet = NULL; + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + { + if(xRow->getString(6) == aName && (!aQualifier.getLength() || xRow->getString(5) == aQualifier )) + { + OAdabasIndex* pRet = new OAdabasIndex(m_pTable,aName,aQualifier,!xRow->getBoolean(4), + aName == ::rtl::OUString::createFromAscii("SYSPRIMARYKEYINDEX"), + xRow->getShort(7) == IndexType::CLUSTERED); + xRet = pRet; + } + } + } + + return xRet; +} +// ------------------------------------------------------------------------- +void OIndexes::impl_refresh() throw(RuntimeException) +{ + m_pTable->refreshIndexes(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OIndexes::createEmptyObject() +{ + OAdabasIndex* pNew = new OAdabasIndex(m_pTable); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OIndexes::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); + ObjectMap::iterator aIter = m_aNameMap.find(aName); + if( aIter != m_aNameMap.end()) + throw ElementExistException(aName,*this); + + if(!m_pTable->isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + if(getINT32(descriptor->getPropertyValue(PROPERTY_ISUNIQUE))) + aSql = aSql + ::rtl::OUString::createFromAscii("UNIQUE "); + aSql = aSql + ::rtl::OUString::createFromAscii("INDEX "); + + + if(aName.getLength()) + { + aSql = aSql + aQuote + aName + aQuote + + ::rtl::OUString::createFromAscii(" ON ") + + aQuote + m_pTable->getSchema() + aQuote + aDot + + aQuote + m_pTable->getName() + aQuote + + ::rtl::OUString::createFromAscii(" ( "); + + Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); + Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + xColumns->getByIndex(i) >>= xColProp; + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote; + aSql = aSql + (getBOOL(xColProp->getPropertyValue(PROPERTY_ISASCENDING)) + ? + ::rtl::OUString::createFromAscii(" ASC") + : + ::rtl::OUString::createFromAscii(" DESC")) + + ::rtl::OUString::createFromAscii(","); + } + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + } + else + { + aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + aDot + aQuote + m_pTable->getName() + aQuote; + + Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); + Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + if(xColumns->getCount() != 1) + throw SQLException(); + + xColumns->getByIndex(0) >>= xColProp; + + aSql = aSql + aDot + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote; + } + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OIndexes::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + if(!m_pTable->isNew()) + { + ::rtl::OUString aName,aSchema; + sal_Int32 nLen = elementName.indexOf('.'); + aSchema = elementName.copy(0,nLen); + aName = elementName.copy(nLen+1); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP INDEX "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + aSchema + aQuote + aDot + aQuote + aName + ::rtl::OUString::createFromAscii(" ON ") + + aQuote + m_pTable->getSchema() + aQuote + m_pTable->getName() + aQuote; + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OIndexes::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + dropByName(m_aElements[index]->first); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/adabas/BKeys.cxx b/connectivity/source/drivers/adabas/BKeys.cxx new file mode 100644 index 000000000000..e3227f467b0e --- /dev/null +++ b/connectivity/source/drivers/adabas/BKeys.cxx @@ -0,0 +1,285 @@ +/************************************************************************* + * + * $RCSfile: BKeys.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADABAS_KEYS_HXX_ +#include "adabas/BKeys.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_INDEX_HXX_ +#include "adabas/BKey.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ +#include <com/sun/star/sdbcx/KeyType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Any SAL_CALL OKeys::queryInterface( const Type & rType ) throw(RuntimeException) +{ + if(rType == ::getCppuType(static_cast< Reference<XNameAccess> *>(NULL))) + return Any(); + + return OCollection_TYPE::queryInterface(rType); +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OKeys::getTypes( ) throw(RuntimeException) +{ + Sequence< Type > aTypes(OCollection_TYPE::getTypes()); + Type* pBegin = aTypes.getArray(); + Type* pEnd = pBegin + aTypes.getLength(); + + Sequence< Type > aRetType(aTypes.getLength()-1); + sal_Int32 i=0; + for(;pBegin != pEnd; ++pBegin) + { + if(*pBegin != ::getCppuType(static_cast< Reference<XNameAccess> *>(NULL))) + { + aRetType.getArray()[i++] = *pBegin; + } + } + + return aRetType; +} +// ------------------------------------------------------------------------- +Reference< XNamed > OKeys::createObject(const ::rtl::OUString& _rName) +{ + Reference< XNamed > xRet = NULL; + + if(_rName.getLength()) + { + Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getExportedKeys(Any(), + m_pTable->getSchema(),m_pTable->getName()); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii("."); + while(xResult->next()) + { + if(xRow->getString(13) == _rName) + { + aName = xRow->getString(6); + if(aName.getLength()) + aName += aDot; + aName += xRow->getString(7); + + OAdabasKey* pRet = new OAdabasKey(m_pTable,_rName,aName,KeyType::FOREIGN,xRow->getInt(10),xRow->getInt(11)); + xRet = pRet; + break; + } + } + } + } + else + { + OAdabasKey* pRet = new OAdabasKey(m_pTable,_rName,::rtl::OUString(),KeyType::PRIMARY,KeyRule::NO_ACTION,KeyRule::NO_ACTION); + xRet = pRet; + } + + return xRet; +} +// ------------------------------------------------------------------------- +void OKeys::impl_refresh() throw(RuntimeException) +{ + m_pTable->refreshKeys(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OKeys::createEmptyObject() +{ + OAdabasKey* pNew = new OAdabasKey(m_pTable); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OKeys::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); + ObjectMap::iterator aIter = m_aNameMap.find(aName); + if( aIter != m_aNameMap.end()) + throw ElementExistException(aName,*this); + if(!m_pTable->isNew()) + { + sal_Int32 nKeyType = getINT32(descriptor->getPropertyValue(PROPERTY_TYPE)); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + aDot + aQuote + m_pTable->getName() + aQuote; + if(nKeyType == KeyType::PRIMARY) + { + aSql = aSql + ::rtl::OUString::createFromAscii(" ALTER PRIMARY KEY ("); + } + else if(nKeyType == KeyType::FOREIGN) + { + aSql = aSql + ::rtl::OUString::createFromAscii(" FOREIGN KEY ("); + } + else + throw SQLException(); + + Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); + Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + xColumns->getByIndex(i) >>= xColProp; + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(","); + } + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + + if(nKeyType == KeyType::FOREIGN) + { + sal_Int32 nDeleteRule = getINT32(xColProp->getPropertyValue(PROPERTY_DELETERULE)); + + ::rtl::OUString aName,aSchema,aRefTable = getString(xColProp->getPropertyValue(PROPERTY_REFERENCEDTABLE)); + sal_Int32 nLen = aRefTable.indexOf('.'); + aSchema = aRefTable.copy(0,nLen); + aName = aRefTable.copy(nLen+1); + aSql = aSql + ::rtl::OUString::createFromAscii(" REFERENCES ") + + aQuote + aSchema + aQuote + aDot + aQuote + aName + aQuote; + + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + xColumns->getByIndex(i) >>= xColProp; + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_REFERENCEDCOLUMN)) + aQuote + + ::rtl::OUString::createFromAscii(","); + } + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + + switch(nDeleteRule) + { + case KeyRule::CASCADE: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE CASCADE "); + break; + case KeyRule::RESTRICT: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE RESTRICT "); + break; + case KeyRule::SET_NULL: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE SET NULL "); + break; + case KeyRule::SET_DEFAULT: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT "); + break; + default: + ; + } + } + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OKeys::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + if(!m_pTable->isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + m_pTable->getName() + aQuote + + ::rtl::OUString::createFromAscii(" DROP PRIMARY KEY"); + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OKeys::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + dropByName(m_aElements[index]->first); +} + diff --git a/connectivity/source/drivers/adabas/BResultSetMetaData.cxx b/connectivity/source/drivers/adabas/BResultSetMetaData.cxx new file mode 100644 index 000000000000..df70ad5de067 --- /dev/null +++ b/connectivity/source/drivers/adabas/BResultSetMetaData.cxx @@ -0,0 +1,249 @@ +/************************************************************************* + * + * $RCSfile: BResultSetMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADABAS_BRESULTSETMETADATA_HXX_ +#include "adabas/BResultSetMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_OTOOLS_HXX_ +#include "adabas/BTools.hxx" +#endif + +using namespace connectivity::adabas; +// ------------------------------------------------------------------------- +OResultSetMetaData::~OResultSetMetaData() +{ +} +// ------------------------------------------------------------------------- +::rtl::OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + sal_Int32 column = _column; + if(_column < m_vMapping.size()) // use mapping + column = m_vMapping[_column]; + + sal_Int32 BUFFER_LEN = 128; + char *pName = new char[BUFFER_LEN]; + SQLSMALLINT nRealLen=0; + OTools::ThrowException(N3SQLColAttribute(m_aStatementHandle, + column, + ident, + (SQLPOINTER)pName, + BUFFER_LEN, + &nRealLen, + NULL + ),m_aStatementHandle,SQL_HANDLE_STMT,*this); + if(nRealLen > BUFFER_LEN) + { + delete pName; + pName = new char[nRealLen]; + OTools::ThrowException(N3SQLColAttribute(m_aStatementHandle, + column, + ident, + (SQLPOINTER)pName, + nRealLen, + &nRealLen, + NULL + ),m_aStatementHandle,SQL_HANDLE_STMT,*this); + } + + return ::rtl::OUString::createFromAscii(pName); +} +// ------------------------------------------------------------------------- +sal_Int32 OResultSetMetaData::getNumColAttrib(sal_Int32 _column,sal_Int32 ident) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + sal_Int32 column = _column; + if(_column < m_vMapping.size()) // use mapping + column = m_vMapping[_column]; + + sal_Int32 nValue; + OTools::ThrowException(N3SQLColAttribute(m_aStatementHandle, + column, + ident, + NULL, + 0, + NULL, + &nValue),m_aStatementHandle,SQL_HANDLE_STMT,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_DISPLAY_SIZE); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return OTools::MapOdbcType2Jdbc(getNumColAttrib(column,SQL_DESC_TYPE)); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + if(m_nColCount != -1) + return m_nColCount; + sal_Int16 nNumResultCols=0; + OTools::ThrowException(N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this); + return m_nColCount = nNumResultCols; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_CASE_SENSITIVE) == SQL_TRUE; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_SCHEMA_NAME); +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_NAME); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_TABLE_NAME); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_CATALOG_NAME); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_TYPE_NAME +); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_LABEL); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_FIXED_PREC_SCALE) == SQL_TRUE; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_AUTO_UNIQUE_VALUE) == SQL_TRUE; +} +// ------------------------------------------------------------------------- + + +sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_UNSIGNED) == SQL_FALSE; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_PRECISION); +} +sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_SCALE); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_NULLABLE) == SQL_NULLABLE; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_SEARCHABLE) != SQL_PRED_NONE; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_READONLY; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_WRITE; +; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_WRITE; +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/adabas/BTable.cxx b/connectivity/source/drivers/adabas/BTable.cxx new file mode 100644 index 000000000000..3452ed9b80df --- /dev/null +++ b/connectivity/source/drivers/adabas/BTable.cxx @@ -0,0 +1,590 @@ +/************************************************************************* + * + * $RCSfile: BTable.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_INDEXES_HXX_ +#include "adabas/BIndexes.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_COLUMNS_HXX_ +#include "adabas/BColumns.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_KEYS_HXX_ +#include "adabas/BKeys.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ +#include <com/sun/star/sdbcx/KeyType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +OAdabasTable::OAdabasTable(OAdabasConnection* _pConnection) : OTable_TYPEDEF(sal_True) + ,m_pConnection(_pConnection) +{ + construct(); + ::std::vector< ::rtl::OUString> aVector; + m_pColumns = new OColumns(this,m_aMutex,aVector); + m_pKeys = new OKeys(this,m_aMutex,aVector); + m_pIndexes = new OIndexes(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +OAdabasTable::OAdabasTable( OAdabasConnection* _pConnection, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description , + const ::rtl::OUString& _SchemaName, + const ::rtl::OUString& _CatalogName + ) : OTable_TYPEDEF(sal_True,_Name, + _Type, + _Description, + _SchemaName, + _CatalogName) + ,m_pConnection(_pConnection) +{ + construct(); + refreshColumns(); + refreshKeys(); + refreshIndexes(); +} +// ------------------------------------------------------------------------- +void OAdabasTable::refreshColumns() +{ + ::std::vector< ::rtl::OUString> aVector; + Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(Any(), + m_SchemaName,m_Name,::rtl::OUString::createFromAscii("%")); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(4)); + } + + if(m_pColumns) + delete m_pColumns; + m_pColumns = new OColumns(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +void OAdabasTable::refreshPrimaryKeys(std::vector< ::rtl::OUString>& _rKeys) +{ + Reference< XResultSet > xResult = m_pConnection->getMetaData()->getPrimaryKeys(Any(),m_SchemaName,m_Name); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + if(xResult->next()) // there can be only one primary key + { + ::rtl::OUString aPkName = xRow->getString(6); + _rKeys.push_back(aPkName); + } + } +} +// ------------------------------------------------------------------------- +void OAdabasTable::refreshForgeinKeys(std::vector< ::rtl::OUString>& _rKeys) +{ + Reference< XResultSet > xResult = m_pConnection->getMetaData()->getExportedKeys(Any(),m_SchemaName,m_Name); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + _rKeys.push_back(xRow->getString(12)); + } +} +// ------------------------------------------------------------------------- +void OAdabasTable::refreshKeys() +{ + ::std::vector< ::rtl::OUString> aVector; + + refreshPrimaryKeys(aVector); + refreshForgeinKeys(aVector); + if(m_pKeys) + delete m_pKeys; + m_pKeys = new OKeys(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +void OAdabasTable::refreshIndexes() +{ + ::std::vector< ::rtl::OUString> aVector; + // fill indexes + Reference< XResultSet > xResult = m_pConnection->getMetaData()->getIndexInfo(Any(), + m_SchemaName,m_Name,sal_False,sal_False); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii("."); + while(xResult->next()) + { + aName = xRow->getString(5); + if(aName.getLength()) + aName += aDot; + aName += xRow->getString(6); + if(aName.getLength()) + aVector.push_back(aName); + } + } + + if(m_pIndexes) + delete m_pIndexes; + m_pIndexes = new OIndexes(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OAdabasTable::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); + if(aRet.hasValue()) + return aRet; + return OTable_TYPEDEF::queryInterface(rType); +} + +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdabasTable::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdabasTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; +} +// ------------------------------------------------------------------------- +sal_Bool OAdabasTable::create() throw(SQLException, RuntimeException) +{ + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + ::rtl::OUString aComma = ::rtl::OUString::createFromAscii(", "); + + aSql += aQuote + m_SchemaName + aQuote + aDot + aQuote + m_Name + aQuote; + aSql += ::rtl::OUString::createFromAscii(" ( "); + + sal_Int32 nCount = m_pColumns->getCount(); + Reference< XPropertySet > xProp; + for(sal_Int32 i=0;i<nCount;++i) + { + m_pColumns->getByIndex(i) >>= xProp; + aSql += aQuote + getString(xProp->getPropertyValue(PROPERTY_NAME)) + aQuote + + getString(xProp->getPropertyValue(PROPERTY_TYPENAME)); + + // add type definition + switch(getINT32(xProp->getPropertyValue(PROPERTY_TYPE))) + { + case DataType::CHAR: + case DataType::VARCHAR: + aSql += ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(xProp->getPropertyValue(PROPERTY_TYPE))) + + ::rtl::OUString::createFromAscii(")"); + break; + + case DataType::DECIMAL: + case DataType::NUMERIC: + aSql += ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(xProp->getPropertyValue(PROPERTY_TYPE))) + + ::rtl::OUString::createFromAscii(",") + + ::rtl::OUString::valueOf(getINT32(xProp->getPropertyValue(PROPERTY_SCALE))) + + ::rtl::OUString::createFromAscii(")"); + break; + } + + ::rtl::OUString aDefault = getString(xProp->getPropertyValue(PROPERTY_DEFAULTVALUE)); + if(getINT32(xProp->getPropertyValue(PROPERTY_ISNULLABLE)) == ColumnValue::NO_NULLS) + { + aSql += ::rtl::OUString::createFromAscii(" NOT NULL"); + if(aDefault.getLength()) + aSql += ::rtl::OUString::createFromAscii(" WITH DEFAULT"); + } + else if(aDefault.getLength()) + aSql += ::rtl::OUString::createFromAscii(" DEFAULT ") + aDefault; + + aSql += aComma; + } + + // create the key columns ( only the string ) + nCount = m_pKeys->getCount(); + + for(i=0;i<nCount;++i) + { + m_pKeys->getByIndex(i) >>= xProp; + Reference< XColumnsSupplier > xKey(xProp,UNO_QUERY); + Reference< ::com::sun::star::container::XIndexAccess > xCols(xKey->getColumns(),UNO_QUERY); + switch(getINT32(xProp->getPropertyValue(PROPERTY_TYPE))) + { + case KeyType::PRIMARY: + { + sal_Int32 nCols = xCols->getCount(); + if(nCols) + aSql += ::rtl::OUString::createFromAscii(" PRIMARY KEY( "); + for(sal_Int32 i=0;i<nCols;++i) + { + xCols->getByIndex(i) >>= xProp; + aSql += aQuote + getString(xProp->getPropertyValue(PROPERTY_NAME)) + aQuote; + aSql += aComma; + } + if(nCols) + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + } + case KeyType::UNIQUE: + { + sal_Int32 nCols = xCols->getCount(); + if(nCols) + aSql += ::rtl::OUString::createFromAscii(" UNIQUE( "); + for(sal_Int32 i=0;i<nCols;++i) + { + xCols->getByIndex(i) >>= xProp; + aSql += aQuote + getString(xProp->getPropertyValue(PROPERTY_NAME)) + aQuote; + aSql += aComma; + } + if(nCols) + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + } + case KeyType::FOREIGN: + { + sal_Int32 nCols = xCols->getCount(); + if(nCols) + { + aSql += ::rtl::OUString::createFromAscii(" FOREIGN KEY( "); + ::rtl::OUString aKeyName = getString(xProp->getPropertyValue(PROPERTY_NAME)); + ::rtl::OUString aRefTableName = getString(xProp->getPropertyValue(PROPERTY_REFERENCEDTABLE)); + sal_Int32 nDeleteRule = getINT32(xProp->getPropertyValue(PROPERTY_DELETERULE)); + if(aKeyName.getLength()) + { + aSql += aQuote + aKeyName + aQuote; + aSql += ::rtl::OUString::createFromAscii(" "); + } + + for(sal_Int32 i=0;i<nCols;++i) + { + xCols->getByIndex(i) >>= xProp; + aSql += aQuote + getString(xProp->getPropertyValue(PROPERTY_NAME)) + aQuote; + aSql += aComma; + } + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + aSql += ::rtl::OUString::createFromAscii(" REFERENCES ") + + aQuote + aRefTableName + aQuote; + switch(nDeleteRule) + { + case KeyRule::CASCADE: + aSql += ::rtl::OUString::createFromAscii(" ON DELETE CASCADE "); + break; + case KeyRule::RESTRICT: + aSql += ::rtl::OUString::createFromAscii(" ON DELETE RESTRICT "); + break; + case KeyRule::SET_NULL: + aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET NULL "); + break; + case KeyRule::NO_ACTION: + break; + case KeyRule::SET_DEFAULT: + aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT "); + break; + } + } + + } + } + } + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + return sal_True; +} +// ------------------------------------------------------------------------- +// XRename +void SAL_CALL OAdabasTable::rename( const ::rtl::OUString& newName ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( +#ifdef GCC + sdbcx::OTable_BASE::rBHelper.bDisposed +#else + rBHelper.bDisposed +#endif + ) + throw DisposedException(); + + if(!isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("RENAME TABLE "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + ::rtl::OUString aName,aSchema; + sal_Int32 nLen = newName.indexOf('.'); + aSchema = newName.copy(0,nLen); + aName = newName.copy(nLen+1); + + aSql += aQuote + m_SchemaName + aQuote + aDot + aQuote + m_Name + aQuote + + ::rtl::OUString::createFromAscii(" TO ") + + aQuote + aSchema + aQuote + aDot + aQuote + aName + aQuote; + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + } + else + m_Name = newName; +} +// ------------------------------------------------------------------------- +// XAlterTable +void SAL_CALL OAdabasTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( +#ifdef GCC + sdbcx::OTable_BASE::rBHelper.bDisposed +#else + rBHelper.bDisposed +#endif + ) + throw DisposedException(); + + if(!isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql += aQuote + m_SchemaName + aQuote + aDot + aQuote + m_Name + aQuote + + ::rtl::OUString::createFromAscii(" COLUMN ") + + aQuote + colName + aQuote + + ::rtl::OUString::createFromAscii(" ALTER "); + + aSql += aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote + + getString(descriptor->getPropertyValue(PROPERTY_TYPENAME)); + + switch(getINT32(descriptor->getPropertyValue(PROPERTY_TYPE))) + { + case DataType::CHAR: + case DataType::VARCHAR: + aSql += ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(descriptor->getPropertyValue(PROPERTY_TYPE))) + + ::rtl::OUString::createFromAscii(")"); + break; + + case DataType::DECIMAL: + case DataType::NUMERIC: + aSql += ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(descriptor->getPropertyValue(PROPERTY_TYPE))) + + ::rtl::OUString::createFromAscii(",") + + ::rtl::OUString::valueOf(getINT32(descriptor->getPropertyValue(PROPERTY_SCALE))) + + ::rtl::OUString::createFromAscii(")"); + break; + } + ::rtl::OUString aDefault = getString(descriptor->getPropertyValue(PROPERTY_DEFAULTVALUE)); + if(getINT32(descriptor->getPropertyValue(PROPERTY_ISNULLABLE)) == ColumnValue::NO_NULLS) + { + aSql += ::rtl::OUString::createFromAscii(" NOT NULL"); + if(aDefault.getLength()) + aSql += ::rtl::OUString::createFromAscii(" WITH DEFAULT"); + } + else if(aDefault.getLength()) + aSql += ::rtl::OUString::createFromAscii(" DEFAULT ") + aDefault; + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + + refreshColumns(); + } + else + { + if(m_pColumns) + { + m_pColumns->dropByName(colName); + m_pColumns->appendByDescriptor(descriptor); + } + } + +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdabasTable::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( +#ifdef GCC + sdbcx::OTable_BASE::rBHelper.bDisposed +#else + rBHelper.bDisposed +#endif + ) + throw DisposedException(); + + Reference< XPropertySet > xOld; + if(m_pColumns->getByIndex(index) >>= xOld) + alterColumnByName(getString(xOld->getPropertyValue(PROPERTY_NAME)),descriptor); +} + +// ------------------------------------------------------------------------- +::rtl::OUString connectivity::adabas::getTypeString(const Reference< ::com::sun::star::beans::XPropertySet >& xColProp) +{ + ::rtl::OUString aValue; + switch(getINT32(xColProp->getPropertyValue(PROPERTY_TYPE))) + { + case DataType::BIT: + aValue = ::rtl::OUString::createFromAscii("BOOLEAN"); + break; + case DataType::TINYINT: + aValue = ::rtl::OUString::createFromAscii("SMALLINT"); + break; + case DataType::SMALLINT: + aValue = ::rtl::OUString::createFromAscii("SMALLINT"); + break; + case DataType::INTEGER: + aValue = ::rtl::OUString::createFromAscii("INT"); + break; + case DataType::FLOAT: + aValue = ::rtl::OUString::createFromAscii("FLOAT"); + break; + case DataType::REAL: + aValue = ::rtl::OUString::createFromAscii("REAL"); + break; + case DataType::DOUBLE: + aValue = ::rtl::OUString::createFromAscii("DOUBLE"); + break; + case DataType::NUMERIC: + aValue = ::rtl::OUString::createFromAscii("DECIMAL"); + break; + case DataType::DECIMAL: + aValue = ::rtl::OUString::createFromAscii("DECIMAL"); + break; + case DataType::CHAR: + aValue = ::rtl::OUString::createFromAscii("CHAR"); + break; + case DataType::VARCHAR: + aValue = ::rtl::OUString::createFromAscii("VARCHAR"); + break; + case DataType::LONGVARCHAR: + aValue = ::rtl::OUString::createFromAscii("LONG VARCHAR"); + break; + case DataType::DATE: + aValue = ::rtl::OUString::createFromAscii("DATE"); + break; + case DataType::TIME: + aValue = ::rtl::OUString::createFromAscii("TIME"); + break; + case DataType::TIMESTAMP: + aValue = ::rtl::OUString::createFromAscii("TIMESTAMP"); + break; + case DataType::BINARY: + aValue = ::rtl::OUString::createFromAscii("BOOLEAN"); + break; + case DataType::VARBINARY: + aValue = ::rtl::OUString::createFromAscii("VARCHAR BYTE"); + break; + case DataType::LONGVARBINARY: + aValue = ::rtl::OUString::createFromAscii("LONG BYTE"); + break; + } + return aValue; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OAdabasTable::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OTable_TYPEDEF::getTypes()); +} + + + diff --git a/connectivity/source/drivers/adabas/BTables.cxx b/connectivity/source/drivers/adabas/BTables.cxx new file mode 100644 index 000000000000..93c4e3961715 --- /dev/null +++ b/connectivity/source/drivers/adabas/BTables.cxx @@ -0,0 +1,419 @@ +/************************************************************************* + * + * $RCSfile: BTables.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADABAS_TABLES_HXX_ +#include "adabas/BTables.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.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 +#ifndef _CONNECTIVITY_ADABAS_CATALOG_HXX_ +#include "adabas/BCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OTables::createObject(const ::rtl::OUString& _rName) +{ + ::rtl::OUString aName,aSchema; + sal_Int32 nLen = _rName.indexOf('.'); + aSchema = _rName.copy(0,nLen); + aName = _rName.copy(nLen+1); + + Sequence< ::rtl::OUString > aTypes(1); + aTypes[0] = ::rtl::OUString::createFromAscii("%"); + // aTypes[0] = ::rtl::OUString::createFromAscii("TABLE"); + // aTypes[1] = ::rtl::OUString::createFromAscii("SYSTEMTABLE"); + + Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), + aSchema,aName,aTypes); + + Reference< XNamed > xRet = NULL; + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + if(xResult->next()) // there can be only one table with this name + { + OAdabasTable* pRet = new OAdabasTable( static_cast<OAdabasCatalog&>(m_rParent).getConnection(), + aName,xRow->getString(4),xRow->getString(5),aSchema); + xRet = pRet; + } + } + + return xRet; +} +// ------------------------------------------------------------------------- +void OTables::impl_refresh( ) throw(RuntimeException) +{ + static_cast<OAdabasCatalog&>(m_rParent).refreshTables(); +} +// ------------------------------------------------------------------------- +void OTables::disposing(void) +{ + m_xMetaData = NULL; + OCollection::disposing(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OTables::createEmptyObject() +{ + OAdabasTable* pNew = new OAdabasTable(static_cast<OAdabasCatalog&>(m_rParent).getConnection()); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OTables::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); + ObjectMap::iterator aIter = m_aNameMap.find(aName); + if( aIter != m_aNameMap.end()) + throw ElementExistException(aName,*this); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE "); + ::rtl::OUString aQuote = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + getString(descriptor->getPropertyValue(PROPERTY_SCHEMANAME)) + aQuote + aDot + + aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(" ("); + + // columns + Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); + Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + + Any aTypeName; + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + if(xColumns->getByIndex(i) >>= xColProp) + { + + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote; + + aSql = aSql + ::rtl::OUString::createFromAscii(" "); + + aTypeName = xColProp->getPropertyValue(PROPERTY_TYPENAME); + + if(aTypeName.hasValue() && getString(aTypeName).getLength()) + aSql = aSql + getString(aTypeName); + else + aSql = aSql + getTypeString(xColProp) + ::rtl::OUString::createFromAscii(" "); + + switch(getINT32(xColProp->getPropertyValue(PROPERTY_TYPE))) + { + case DataType::CHAR: + case DataType::VARCHAR: + aSql = aSql + ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(xColProp->getPropertyValue(PROPERTY_PRECISION))) + + ::rtl::OUString::createFromAscii(")"); + break; + + case DataType::DECIMAL: + case DataType::NUMERIC: + aSql = aSql + ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(xColProp->getPropertyValue(PROPERTY_PRECISION))) + + ::rtl::OUString::createFromAscii(",") + + ::rtl::OUString::valueOf(getINT32(xColProp->getPropertyValue(PROPERTY_SCALE))) + + ::rtl::OUString::createFromAscii(")"); + break; + } + ::rtl::OUString aDefault = getString(xColProp->getPropertyValue(PROPERTY_DEFAULTVALUE)); + if(getINT32(xColProp->getPropertyValue(PROPERTY_ISNULLABLE)) == ColumnValue::NO_NULLS) + { + aSql = aSql + ::rtl::OUString::createFromAscii(" NOT NULL"); + if(aDefault.getLength()) + aSql = aSql + ::rtl::OUString::createFromAscii(" WITH DEFAULT"); + } + else if(aDefault.getLength()) + aSql = aSql + ::rtl::OUString::createFromAscii(" DEFAULT ") + aDefault; + + aSql = aSql + ::rtl::OUString::createFromAscii(","); + } + } + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + + // keys + + Reference<XKeysSupplier> xKeySup(descriptor,UNO_QUERY); + + Reference<XIndexAccess> xKeys = xKeySup->getKeys(); + if(xKeys.is()) + { + sal_Bool bPKey = sal_False; + for(sal_Int32 i=0;i<xKeys->getCount();++i) + { + if(xColumns->getByIndex(i) >>= xColProp) + { + + sal_Int32 nKeyType = getINT32(xColProp->getPropertyValue(PROPERTY_TYPE)); + + if(nKeyType == KeyType::PRIMARY) + { + if(!bPKey) + throw SQLException(); + + bPKey = sal_True; + xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY); + xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY); + if(!xColumns->getCount()) + throw SQLException(); + + aSql = aSql + ::rtl::OUString::createFromAscii(" PRIMARY KEY ("); + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + if(xColumns->getByIndex(i) >>= xColProp) + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(","); + } + + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + } + else if(nKeyType == KeyType::UNIQUE) + { + xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY); + xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY); + if(!xColumns->getCount()) + throw SQLException(); + + aSql = aSql + ::rtl::OUString::createFromAscii(" UNIQUE ("); + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + if(xColumns->getByIndex(i) >>= xColProp) + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(","); + } + + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + } + else if(nKeyType == KeyType::FOREIGN) + { + sal_Int32 nDeleteRule = getINT32(xColProp->getPropertyValue(PROPERTY_DELETERULE)); + + xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY); + xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY); + if(!xColumns->getCount()) + throw SQLException(); + + aSql = aSql + ::rtl::OUString::createFromAscii(" FOREIGN KEY "); + ::rtl::OUString aName,aSchema,aRefTable = getString(xColProp->getPropertyValue(PROPERTY_REFERENCEDTABLE)); + sal_Int32 nLen = aRefTable.indexOf('.'); + aSchema = aRefTable.copy(0,nLen); + aName = aRefTable.copy(nLen+1); + + aSql = aSql + aQuote + aSchema + aQuote + aDot + + aQuote + aName + aQuote + + ::rtl::OUString::createFromAscii(" ("); + + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + if(xColumns->getByIndex(i) >>= xColProp) + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(","); + } + + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + + switch(nDeleteRule) + { + case KeyRule::CASCADE: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE CASCADE "); + break; + case KeyRule::RESTRICT: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE RESTRICT "); + break; + case KeyRule::SET_NULL: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE SET NULL "); + break; + case KeyRule::SET_DEFAULT: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT "); + break; + default: + ; + } + } + } + } + } + + OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection(); + Reference< XStatement > xStmt = pConnection->createStatement( ); + xStmt->execute(aSql); + + if(getString(descriptor->getPropertyValue(PROPERTY_DESCRIPTION)).getLength()) + setComments(descriptor); + + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +void OTables::setComments(const Reference< XPropertySet >& descriptor ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE "); + ::rtl::OUString aQuote = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection(); + Reference< XStatement > xStmt = pConnection->createStatement( ); + aSql = ::rtl::OUString::createFromAscii("COMMENT ON TABLE ") + + aQuote + getString(descriptor->getPropertyValue(PROPERTY_SCHEMANAME)) + aQuote + aDot + + aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(" '") + + getString(descriptor->getPropertyValue(PROPERTY_DESCRIPTION)) + + ::rtl::OUString::createFromAscii("'"); + xStmt->execute(aSql); + + // columns + Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); + Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + + aSql = ::rtl::OUString::createFromAscii("COMMENT ON COLUMN ") + + aQuote + getString(descriptor->getPropertyValue(PROPERTY_SCHEMANAME)) + aQuote + aDot + + aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote + aDot + + aQuote; + + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + xColumns->getByIndex(i) >>= xColProp; + ::rtl::OUString aDescription = getString(xColProp->getPropertyValue(PROPERTY_DESCRIPTION)); + if(aDescription.getLength()) + { + ::rtl::OUString aCom = aSql + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(" '") + + aDescription + + ::rtl::OUString::createFromAscii("'"); + xStmt->execute(aSql); + } + } +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OTables::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(aIter->second.get(),UNO_QUERY); + if(xTunnel.is()) + { + OAdabasTable* pTable = (OAdabasTable*)xTunnel->getSomething(OAdabasTable:: getUnoTunnelImplementationId()); + + if(!pTable->isNew()) + { + OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection(); + Reference< XStatement > xStmt = pConnection->createStatement( ); + + ::rtl::OUString aName,aSchema; + sal_Int32 nLen = elementName.indexOf('.'); + aSchema = elementName.copy(0,nLen); + aName = elementName.copy(nLen+1); + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP TABLE "); + aSql = aSql + m_xMetaData->getIdentifierQuoteString( ) + aSchema + m_xMetaData->getIdentifierQuoteString( ); + aSql = aSql + ::rtl::OUString::createFromAscii("."); + aSql = aSql + m_xMetaData->getIdentifierQuoteString( ) + aName + m_xMetaData->getIdentifierQuoteString( ); + xStmt->execute(aSql); + } + } + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OTables::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + dropByName((*m_aElements[index]).first); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/adabas/BUser.cxx b/connectivity/source/drivers/adabas/BUser.cxx new file mode 100644 index 000000000000..b017fc2d1f18 --- /dev/null +++ b/connectivity/source/drivers/adabas/BUser.cxx @@ -0,0 +1,151 @@ +/************************************************************************* + * + * $RCSfile: BUser.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADABAS_USER_HXX_ +#include "adabas/BUser.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_GROUPS_HXX_ +#include "adabas/BGroups.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +// ------------------------------------------------------------------------- +OAdabasUser::OAdabasUser( OAdabasConnection* _pConnection) : connectivity::sdbcx::OUser(sal_True) + ,m_pConnection(_pConnection) +{ + construct(); +} +// ------------------------------------------------------------------------- +OAdabasUser::OAdabasUser( OAdabasConnection* _pConnection, + const ::rtl::OUString& _Name + ) : connectivity::sdbcx::OUser(_Name,sal_True) + ,m_pConnection(_pConnection) +{ + construct(); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OAdabasUser::queryInterface( const Type & rType ) throw(RuntimeException) +{ +// if(rType == ::getCppuType((const ::com::sun::star::uno::Reference< XGroupsSupplier>*)0)) +// return Any(); + + return OUser_TYPEDEF::queryInterface(rType); +} +// ------------------------------------------------------------------------- +void OAdabasUser::refreshGroups() +{ + if(!m_pConnection) + return; + + ::std::vector< ::rtl::OUString> aVector; + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT GROUPNAME FROM DOMAIN.USERS WHERE GROUPNAME IS NOT NULL AND GROUPNAME <> ' ' AND USERNAME = '"); + aSql += getName( ); + aSql += ::rtl::OUString::createFromAscii("'"); + + Reference< XResultSet > xResult = xStmt->executeQuery(aSql); + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(1)); + } + + if(m_pGroups) + delete m_pGroups; + m_pGroups = new OGroups(*this,m_aMutex,aVector,m_pConnection,this); +} +// ------------------------------------------------------------------------- +OUserExtend::OUserExtend( OAdabasConnection* _pConnection) : OAdabasUser(_pConnection) +{ + construct(); +} +// ------------------------------------------------------------------------- +OUserExtend::OUserExtend( OAdabasConnection* _pConnection,const ::rtl::OUString& _Name) : OAdabasUser(_pConnection,_Name) +{ + construct(); +} +// ------------------------------------------------------------------------- +typedef connectivity::sdbcx::OUser OUser_TYPEDEF; +void OUserExtend::construct() +{ + OUser_TYPEDEF::construct(); + registerProperty(PROPERTY_PASSWORD, PROPERTY_ID_PASSWORD,0,&m_Password,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); +} + diff --git a/connectivity/source/drivers/adabas/BUsers.cxx b/connectivity/source/drivers/adabas/BUsers.cxx new file mode 100644 index 000000000000..50d896c0b05a --- /dev/null +++ b/connectivity/source/drivers/adabas/BUsers.cxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * $RCSfile: BUsers.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADABAS_USERS_HXX_ +#include "adabas/BUsers.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_USER_HXX_ +#include "adabas/BUser.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_ +#include "connectivity/sdbcx/IRefreshable.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OUsers::createObject(const ::rtl::OUString& _rName) +{ + OAdabasUser* pRet = new OAdabasUser(m_pConnection,_rName); + Reference< XNamed > xRet = pRet; + return xRet; +} +// ------------------------------------------------------------------------- +void OUsers::impl_refresh() throw(RuntimeException) +{ + m_pParent->refreshUsers(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OUsers::createEmptyObject() +{ + OUserExtend* pNew = new OUserExtend(m_pConnection); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OUsers::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); + ObjectMap::iterator aIter = m_aNameMap.find(aName); + if( aIter != m_aNameMap.end()) + throw ElementExistException(aName,*this); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE USER "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + + aSql = aSql + aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(" PASSWORD ") + + getString(descriptor->getPropertyValue(PROPERTY_PASSWORD)); + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OUsers::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP USER "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + + aSql = aSql + aQuote + elementName + aQuote; + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + + OCollection_TYPE::dropByName(elementName); +} + +// ------------------------------------------------------------------------- +void SAL_CALL OUsers::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + dropByName(m_aElements[index]->first); +} + diff --git a/connectivity/source/drivers/adabas/Bservices.cxx b/connectivity/source/drivers/adabas/Bservices.cxx new file mode 100644 index 000000000000..7485587dc4b8 --- /dev/null +++ b/connectivity/source/drivers/adabas/Bservices.cxx @@ -0,0 +1,212 @@ +/************************************************************************* + * + * $RCSfile: Bservices.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADABAS_BDRIVER_HXX_ +#include "adabas/BDriver.hxx" +#endif +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +using namespace connectivity::adabas; +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::registry::XRegistryKey; +using ::com::sun::star::lang::XSingleServiceFactory; +using ::com::sun::star::lang::XMultiServiceFactory; + +typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) + ( + const Reference< XMultiServiceFactory > & rServiceManager, + const OUString & rComponentName, + ::cppu::ComponentInstantiation pCreateFunction, + const Sequence< OUString > & rServiceNames + ); + +//*************************************************************************************** +// +// Die vorgeschriebene C-Api muss erfuellt werden! +// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen. +// + +//--------------------------------------------------------------------------------------- +void REGISTER_PROVIDER( + const OUString& aServiceImplName, + const Sequence< OUString>& Services, + const Reference< ::com::sun::star::registry::XRegistryKey > & xKey) +{ + OUString aMainKeyName; + aMainKeyName = OUString::createFromAscii("/"); + aMainKeyName += aServiceImplName; + aMainKeyName += OUString::createFromAscii("/UNO/SERVICES"); + + Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) ); + OSL_ENSHURE(xNewKey.is(), "ADABAS::component_writeInfo : could not create a registry key !"); + + for (sal_uInt32 i=0; i<Services.getLength(); ++i) + xNewKey->createKey(Services[i]); +} + + +//--------------------------------------------------------------------------------------- +struct ProviderRequest +{ + Reference< XSingleServiceFactory > xRet; + Reference< XMultiServiceFactory > const xServiceManager; + OUString const sImplementationName; + + ProviderRequest( + void* pServiceManager, + sal_Char const* pImplementationName + ) + : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) + , sImplementationName(OUString::createFromAscii(pImplementationName)) + { + } + + inline + sal_Bool CREATE_PROVIDER( + const OUString& Implname, + const Sequence< OUString > & Services, + ::cppu::ComponentInstantiation Factory, + createFactoryFunc creator + ) + { + if (!xRet.is() && (Implname == sImplementationName)) + try + { + xRet = creator( xServiceManager, sImplementationName,Factory, Services); + } + catch(...) + { + } + return xRet.is(); + } + + void* getProvider() const { return xRet.get(); } +}; + +//--------------------------------------------------------------------------------------- + +extern "C" void SAL_CALL component_getImplementationEnvironment( + const sal_Char **ppEnvTypeName, + uno_Environment **ppEnv + ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//--------------------------------------------------------------------------------------- +extern "C" sal_Bool SAL_CALL component_writeInfo( + void* pServiceManager, + void* pRegistryKey + ) +{ + if (pRegistryKey) + try + { + Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey)); + + REGISTER_PROVIDER( + ODriver::getImplementationName_Static(), + ODriver::getSupportedServiceNames_Static(), xKey); + + return sal_True; + } + catch (::com::sun::star::registry::InvalidRegistryException& ) + { + OSL_ENSHURE(sal_False, "ODBC::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !"); + } + + return sal_False; +} + +//--------------------------------------------------------------------------------------- +extern "C" void* SAL_CALL component_getFactory( + const sal_Char* pImplementationName, + void* pServiceManager, + void* pRegistryKey) +{ + void* pRet = 0; + if (pServiceManager) + { + ProviderRequest aReq(pServiceManager,pImplementationName); + + aReq.CREATE_PROVIDER( + ODriver::getImplementationName_Static(), + ODriver::getSupportedServiceNames_Static(), + ODriver_CreateInstance, ::cppu::createSingleFactory) + ; + + if(aReq.xRet.is()) + aReq.xRet->acquire(); + + pRet = aReq.getProvider(); + } + + return pRet; +}; + + diff --git a/connectivity/source/drivers/adabas/adabas.map b/connectivity/source/drivers/adabas/adabas.map new file mode 100644 index 000000000000..7ce4c703e6b3 --- /dev/null +++ b/connectivity/source/drivers/adabas/adabas.map @@ -0,0 +1,8 @@ +ADABAS_2_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + local: + *; +}; diff --git a/connectivity/source/drivers/adabas/adabas.xml b/connectivity/source/drivers/adabas/adabas.xml new file mode 100644 index 000000000000..40070e191e75 --- /dev/null +++ b/connectivity/source/drivers/adabas/adabas.xml @@ -0,0 +1,70 @@ +<?xml version='1.0' encoding="UTF-8"?> +<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//W3C//DTD HTML 3.2//EN" "componentdependencies.dtd"> +<COMPONENTDESCRIPTION> + +<Name> com.sun.star.sdbc.BDriver </Name> + +<Description> + This is the implementation of the sdbc-odbc bridge. +</Description> + +<ModuleName> odbc </ModuleName> + +<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName> + +<SupportedService> com.sun.star.sdbc.Driver </SupportedService> + +<ServiceDependency> ... </ServiceDependency> + +<ProjectBuildDependency> cppuhelper </ProjectBuildDependency> +<ProjectBuildDependency> cppu </ProjectBuildDependency> +<ProjectBuildDependency> sal </ProjectBuildDependency> +<ProjectBuildDependency> vos </ProjectBuildDependency> + +<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency> +<RuntimeModuleDependency> cppu1 </RuntimeModuleDependency> +<RuntimeModuleDependency> sal1 </RuntimeModuleDependency> +<RuntimeModuleDependency> vos </RuntimeModuleDependency> + +<Language> c++ </Language> + +<Status StatusValue="final"/> + +<Type> com.sun.star.util.XCancellable </Type> +<Type> com.sun.star.util.XNumberFormatter </Type> +<Type> com.sun.star.uno.TypeClass </Type> +<Type> com.sun.star.uno.XWeak </Type> +<Type> com.sun.star.uno.XAggregation </Type> +<Type> com.sun.star.beans.XPropertyState </Type> +<Type> com.sun.star.beans.XPropertySet </Type> +<Type> com.sun.star.beans.PropertyValue </Type> +<Type> com.sun.star.beans.XMultiPropertySet </Type> +<Type> com.sun.star.beans.XFastPropertySet </Type> +<Type> com.sun.star.lang.XTypeProvider </Type> +<Type> com.sun.star.lang.EventObject </Type> +<Type> com.sun.star.lang.XComponent </Type> +<Type> com.sun.star.lang.IllegalArgumentException </Type> +<Type> com.sun.star.lang.XMultiServiceFactory </Type> +<Type> com.sun.star.java.XJavaThreadRegister_11 </Type> +<Type> com.sun.star.java.XJavaVM </Type> +<Type> com.sun.star.sdbc.XConnection </Type> +<Type> com.sun.star.sdbc.XStatement </Type> +<Type> com.sun.star.sdbc.XResultSet </Type> +<Type> com.sun.star.sdbc.XResultSetMetaDataSupplier</Type> +<Type> com.sun.star.sdbc.XColumnLocate </Type> +<Type> com.sun.star.sdbc.XResultSetUpdate </Type> +<Type> com.sun.star.sdbc.XWarningsSupplier </Type> +<Type> com.sun.star.sdbc.XRowUpdate </Type> +<Type> com.sun.star.sdbc.XMultipleResults </Type> +<Type> com.sun.star.sdbc.XBatchExecution </Type> +<Type> com.sun.star.sdbc.XPreparedBatchExecution </Type> +<Type> com.sun.star.sdbc.XParameters </Type> +<Type> com.sun.star.sdbc.XOutParameters </Type> +<Type> com.sun.star.sdbc.DriverPropertyInfo </Type> +<Type> com.sun.star.sdbc.XRow </Type> +<Type> com.sun.star.sdb.XColumnUpdate </Type> +<Type> com.sun.star.sdb.XColumn </Type> + +</COMPONENTDESCRIPTION> + + diff --git a/connectivity/source/drivers/adabas/exports.dxp b/connectivity/source/drivers/adabas/exports.dxp new file mode 100644 index 000000000000..9630d7e06768 --- /dev/null +++ b/connectivity/source/drivers/adabas/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/connectivity/source/drivers/adabas/makefile.mk b/connectivity/source/drivers/adabas/makefile.mk new file mode 100644 index 000000000000..2df67f8df3d1 --- /dev/null +++ b/connectivity/source/drivers/adabas/makefile.mk @@ -0,0 +1,199 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=..$/.. +PRJNAME=connectivity +TARGET=adabas + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/version.mk + +# --- Types ------------------------------------- + + +UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb + +UNOUCROUT=$(OUT)$/inc +INCPRE+=$(UNOUCROUT) + +# --- Types ------------------------------------- + +UNOTYPES+= \ + com.sun.star.util.XCancellable \ + com.sun.star.util.XNumberFormatter \ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XWeak \ + com.sun.star.uno.XAggregation \ + com.sun.star.beans.XPropertyState \ + com.sun.star.beans.XPropertySet \ + com.sun.star.beans.PropertyValue \ + com.sun.star.beans.XMultiPropertySet \ + com.sun.star.beans.XFastPropertySet \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.EventObject \ + com.sun.star.lang.XComponent \ + com.sun.star.lang.IllegalArgumentException \ + com.sun.star.lang.DisposedException \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.lang.XUnoTunnel \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.java.XJavaThreadRegister_11 \ + com.sun.star.java.XJavaVM \ + com.sun.star.sdbc.XConnection \ + com.sun.star.sdbc.XStatement \ + com.sun.star.sdbc.XResultSet \ + com.sun.star.sdbc.XResultSetMetaDataSupplier \ + com.sun.star.sdbc.XColumnLocate \ + com.sun.star.sdbc.XResultSetUpdate \ + com.sun.star.sdbc.XWarningsSupplier \ + com.sun.star.sdbc.XRowUpdate \ + com.sun.star.sdbc.XMultipleResults \ + com.sun.star.sdbc.XBatchExecution \ + com.sun.star.sdbc.XPreparedBatchExecution \ + com.sun.star.sdbc.XParameters \ + com.sun.star.sdbc.XOutParameters \ + com.sun.star.sdbc.DriverPropertyInfo \ + com.sun.star.sdbc.XDriver \ + com.sun.star.sdbc.XRow \ + com.sun.star.sdbc.SQLWarning \ + com.sun.star.sdbc.ColumnSearch \ + com.sun.star.sdbc.DataType \ + com.sun.star.sdbc.ResultSetConcurrency \ + com.sun.star.sdbc.ResultSetType \ + com.sun.star.sdbc.ColumnValue \ + com.sun.star.sdbcx.KeyType \ + com.sun.star.sdb.XColumnUpdate \ + com.sun.star.sdb.XColumn \ + + + +# --- Files ------------------------------------- + +SLOFILES=\ + $(SLO)$/BConnection.obj \ + $(SLO)$/BDriver.obj \ + $(SLO)$/BCatalog.obj \ + $(SLO)$/BGroups.obj \ + $(SLO)$/BGroup.obj \ + $(SLO)$/BUser.obj \ + $(SLO)$/BUsers.obj \ + $(SLO)$/BKeyColumns.obj \ + $(SLO)$/BKey.obj \ + $(SLO)$/BKeys.obj \ + $(SLO)$/BColumns.obj \ + $(SLO)$/BIndex.obj \ + $(SLO)$/BIndexColumns.obj \ + $(SLO)$/BIndexes.obj \ + $(SLO)$/BTable.obj \ + $(SLO)$/BTables.obj \ + $(SLO)$/Bservices.obj \ + $(SLO)$/BDatabaseMetaData.obj \ + $(SLO)$/OPreparedStatement.obj \ + $(SLO)$/OStatement.obj \ + $(SLO)$/OResultSetMetaData.obj \ + $(SLO)$/OResultSet.obj \ + $(SLO)$/OTools.obj \ + $(SLO)$/ODatabaseMetaData.obj \ + $(SLO)$/ODriver.obj \ + $(SLO)$/OFunctions.obj \ + $(SLO)$/OConnection.obj + + +# --- Library ----------------------------------- + +SHL1TARGET= $(ADABAS_TARGET)$(ADABAS_MAJOR) +SHL1VERSIONMAP= $(TARGET).map +SHL1OBJS=$(SLOFILES) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(OSLLIB) \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(SHL1TARGET) +SHL1LIBS= $(SLB)$/commontools.lib \ + $(SLB)$/resource.lib \ + $(SLB)$/sdbcx.lib + +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + + diff --git a/connectivity/source/drivers/ado/ACallableStatement.cxx b/connectivity/source/drivers/ado/ACallableStatement.cxx new file mode 100644 index 000000000000..487cf29f4fca --- /dev/null +++ b/connectivity/source/drivers/ado/ACallableStatement.cxx @@ -0,0 +1,258 @@ +/************************************************************************* + * + * $RCSfile: ACallableStatement.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ACALLABLESTATEMENT_HXX_ +#include "ado/ACallableStatement.hxx" +#endif + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::container; +using namespace com::sun::star::lang; + +IMPLEMENT_SERVICE_INFO(OCallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement"); + +#define GET_PARAM() \ + ADOParameter* pParam = NULL; \ + m_pParameters->get_Item(OLEVariant(columnIndex-1),&pParam); \ + if(pParam) \ + pParam->get_Value(&m_aValue); +//************************************************************** +//************ Class: java.sql.CallableStatement +//************************************************************** +OCallableStatement::OCallableStatement( OConnection* _pConnection,const ::std::vector<connectivity::OTypeInfo>& _TypeInfo,const ::rtl::OUString& sql ) + : OPreparedStatement( _pConnection, _TypeInfo, sql ) +{ + m_Command.put_CommandType(adCmdStoredProc); +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OCallableStatement::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OPreparedStatement::queryInterface(rType); + if(!aRet.hasValue()) + aRet = ::cppu::queryInterface(rType,static_cast< XRow*>(this)); + return aRet; +} +// ------------------------------------------------------------------------- + + +sal_Bool SAL_CALL OCallableStatement::wasNull( ) throw(SQLException, RuntimeException) +{ + return m_aValue.isNull(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- +sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- +Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- +::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- +double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + +float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return (sal_Int64)m_aValue.getCurrency(); +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OCallableStatement::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) +{ + return Any(); +} +// ------------------------------------------------------------------------- + +sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + + ::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + + ::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(SQLException, RuntimeException) +{ + ADOParameter* pParam = NULL; + m_pParameters->get_Item(OLEVariant(parameterIndex-1),&pParam); + if(pParam) + { + pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType)); + pParam->put_Direction(adParamOutput); + } +} +// ------------------------------------------------------------------------- +void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException) +{ + ADOParameter* pParam = NULL; + m_pParameters->get_Item(OLEVariant(parameterIndex-1),&pParam); + if(pParam) + { + pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType)); + pParam->put_Direction(adParamOutput); + pParam->put_NumericScale(scale); + } +} +// ------------------------------------------------------------------------- + + +Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + m_aValue.setNull(); + return NULL; +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + m_aValue.setNull(); + return NULL; +} +// ------------------------------------------------------------------------- + +Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + m_aValue.setNull(); + return NULL; +} +// ------------------------------------------------------------------------- + +Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + m_aValue.setNull(); + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + m_aValue.setNull(); + return NULL; +} +// ------------------------------------------------------------------------- + +Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + m_aValue.setNull(); + return NULL; +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/ACatalog.cxx b/connectivity/source/drivers/ado/ACatalog.cxx new file mode 100644 index 000000000000..1f78d41c2e32 --- /dev/null +++ b/connectivity/source/drivers/ado/ACatalog.cxx @@ -0,0 +1,216 @@ +/************************************************************************* + * + * $RCSfile: ACatalog.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_CATALOG_HXX_ +#include "ado/ACatalog.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_GROUPS_HXX_ +#include "ado/AGroups.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_USERS_HXX_ +#include "ado/AUsers.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_TABLES_HXX_ +#include "ado/ATables.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_VIEWS_HXX_ +#include "ado/AViews.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif + + +// ------------------------------------------------------------------------- +using namespace connectivity::ado; +// ------------------------------------------------------------------------- +OCatalog::OCatalog(_ADOCatalog* _pCatalog,OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon) + ,m_pConnection(_pCon) + ,m_aCatalog(_pCatalog) +{ + osl_incrementInterlockedCount( &m_refCount ); + refreshTables(); + refreshViews(); + refreshGroups(); + refreshUsers(); + osl_decrementInterlockedCount( &m_refCount ); +} +// ------------------------------------------------------------------------- +void OCatalog::refreshTables() +{ + ::std::vector< ::rtl::OUString> aVector; + + ADOTables* pTables = m_aCatalog.get_Tables(); + if(pTables) + { + pTables->Refresh(); + + sal_Int32 nCount = 0; + pTables->get_Count(&nCount); + for(sal_Int32 i=0;i< nCount;++i) + { + ADOTable* pTable = NULL; + pTables->get_Item(OLEVariant(i),&pTable); + if(pTable) + { + WpADOTable aTable(pTable); + aVector.push_back(aTable.get_Name()); + } + } + } + + if(m_pTables) + delete m_pTables; + m_pTables = new OTables(*this,m_aMutex,aVector,pTables,m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); +} +// ------------------------------------------------------------------------- +void OCatalog::refreshViews() +{ + ::std::vector< ::rtl::OUString> aVector; + + ADOViews* pViews = m_aCatalog.get_Views(); + if(pViews) + { + pViews->Refresh(); + + sal_Int32 nCount = 0; + pViews->get_Count(&nCount); + for(sal_Int32 i=0;i< nCount;++i) + { + ADOView* pView = NULL; + pViews->get_Item(OLEVariant(i),&pView); + if(pView) + { + WpADOView aView(pView); + aVector.push_back(aView.get_Name()); + } + } + } + + if(m_pViews) + delete m_pViews; + m_pViews = new OViews(*this,m_aMutex,aVector,pViews,m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); +} +// ------------------------------------------------------------------------- +void OCatalog::refreshGroups() +{ + ::std::vector< ::rtl::OUString> aVector; + + ADOGroups* pGroups = m_aCatalog.get_Groups(); + if(pGroups) + { + pGroups->Refresh(); + + sal_Int32 nCount = 0; + pGroups->get_Count(&nCount); + for(sal_Int32 i=0;i< nCount;++i) + { + ADOGroup* pGroup = NULL; + pGroups->get_Item(OLEVariant(i),&pGroup); + if(pGroup) + { + WpADOGroup aGroup(pGroup); + aVector.push_back(aGroup.get_Name()); + } + } + } + + if(m_pGroups) + delete m_pGroups; + m_pGroups = new OGroups(*this,m_aMutex,aVector,pGroups,m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); +} +// ------------------------------------------------------------------------- +void OCatalog::refreshUsers() +{ + ::std::vector< ::rtl::OUString> aVector; + + ADOUsers* pUsers = m_aCatalog.get_Users(); + if(pUsers) + { + pUsers->Refresh(); + + sal_Int32 nCount = 0; + pUsers->get_Count(&nCount); + for(sal_Int32 i=0;i< nCount;++i) + { + ADOUser* pUser = NULL; + pUsers->get_Item(OLEVariant(i),&pUser); + if(pUser) + { + WpADOUser aUser(pUser); + aVector.push_back(aUser.get_Name()); + } + } + } + + if(m_pUsers) + delete m_pUsers; + m_pUsers = new OUsers(*this,m_aMutex,aVector,pUsers,m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/AColumn.cxx b/connectivity/source/drivers/ado/AColumn.cxx new file mode 100644 index 000000000000..7bb7d0c45d30 --- /dev/null +++ b/connectivity/source/drivers/ado/AColumn.cxx @@ -0,0 +1,426 @@ +/************************************************************************* + * + * $RCSfile: AColumn.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_COLUMN_HXX_ +#include "ado/AColumn.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_ +#include "ado/Awrapado.hxx" +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +void WpADOColumn::Create() +{ + IClassFactory2* pIUnknown = NULL; + IUnknown *pOuter = NULL; + HRESULT hr = -1; + _ADOColumn* pCommand; + hr = CoCreateInstance(ADOS::CLSID_ADOCOLUMN_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOCOLUMN_25, + (void**)&pCommand ); + + + if( !FAILED( hr ) ) + { + pInterface = pCommand; + pInterface->AddRef(); + } +} +// ------------------------------------------------------------------------- +OAdoColumn::OAdoColumn(sal_Bool _bCase,_ADOColumn* _pColumn) : connectivity::sdbcx::OColumn(_bCase) +{ + if(_pColumn) + m_aColumn = WpADOColumn(_pColumn); + else + m_aColumn.Create(); +} +// ------------------------------------------------------------------------- +OAdoColumn::OAdoColumn( const ::rtl::OUString& _Name, + const ::rtl::OUString& _TypeName, + const ::rtl::OUString& _DefaultValue, + sal_Int32 _IsNullable, + sal_Int32 _Precision, + sal_Int32 _Scale, + sal_Int32 _Type, + sal_Bool _IsAutoIncrement, + sal_Bool _IsCurrency, + sal_Bool _bCase + ) : connectivity::sdbcx::OColumn(_Name, + _TypeName, + _DefaultValue, + _IsNullable, + _Precision, + _Scale, + _Type, + _IsAutoIncrement, + sal_False,_IsCurrency,_bCase) +{ + m_aColumn.Create(); + m_aColumn.put_Name(_Name); + m_aColumn.put_Type(ADOS::MapJdbc2ADOType(_Type)); + m_aColumn.put_Precision(_Precision); + if(_IsNullable) + m_aColumn.put_Attributes(adColNullable); + { + ADOProperties* pProps = m_aColumn.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("AutoIncrement")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + aProp.PutValue(_IsAutoIncrement); + pProps->Release(); + } + { + ADOProperties* pProps = m_aColumn.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Default")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + aProp.PutValue(_DefaultValue); + pProps->Release(); + } +} +// ------------------------------------------------------------------------- +Any SAL_CALL OAdoColumn::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); + if(aRet.hasValue()) + return aRet; + return OColumn_ADO::queryInterface(rType); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OAdoColumn::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OColumn_ADO::getTypes()); +} + +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoColumn::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoColumn::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; +} + + +typedef connectivity::sdbcx::ODescriptor ODescriptor_TYPEDEF; +// ------------------------------------------------------------------------- +//void OAdoColumn::construct() +//{ +// ODescriptor_TYPEDEF::construct(); +// sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; +// +// registerProperty(PROPERTY_TYPENAME, PROPERTY_ID_TYPENAME, nAttrib,&m_TypeName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); +// registerProperty(PROPERTY_DEFAULTVALUE, PROPERTY_ID_DEFAULTVALUE, nAttrib,&m_DefaultValue, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); +// registerProperty(PROPERTY_PRECISION, PROPERTY_ID_PRECISION, nAttrib,&m_Precision, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); +// registerProperty(PROPERTY_TYPE, PROPERTY_ID_TYPE, nAttrib,&m_Type, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); +// registerProperty(PROPERTY_SCALE, PROPERTY_ID_SCALE, nAttrib,&m_Scale, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); +// registerProperty(PROPERTY_ISNULLABLE, PROPERTY_ID_ISNULLABLE, nAttrib,&m_IsNullable, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); +// registerProperty(PROPERTY_ISAUTOINCREMENT, PROPERTY_ID_ISAUTOINCREMENT, nAttrib,&m_IsAutoIncrement, ::getBooleanCppuType()); +//} +// +void OAdoColumn::setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const Any& rValue + ) + throw (Exception) +{ + if(m_aColumn.IsValid()) + { + + switch(nHandle) + { + case PROPERTY_ID_NAME: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aColumn.put_Name(aVal); + } + break; + case PROPERTY_ID_TYPE: + { + sal_Int32 nVal=0; + rValue >>= nVal; + m_aColumn.put_Type(ADOS::MapJdbc2ADOType(nVal)); + } + break; + case PROPERTY_ID_TYPENAME: + // rValue <<= getResultSetType(); + break; + case PROPERTY_ID_PRECISION: + { + sal_Int32 nVal=0; + rValue >>= nVal; + m_aColumn.put_Precision(nVal); + } + break; + case PROPERTY_ID_SCALE: + { + sal_Int32 nVal=0; + rValue >>= nVal; + m_aColumn.put_NumericScale(nVal); + } + break; + case PROPERTY_ID_ISNULLABLE: + { + sal_Bool _b; + rValue >>= _b; + if(_b) + m_aColumn.put_Attributes(adColNullable); + } + break; + case PROPERTY_ID_ISASCENDING: + { + sal_Bool _b; + rValue >>= _b; + m_aColumn.put_SortOrder( _b ? adSortAscending : adSortDescending); + } + break; + case PROPERTY_ID_ISROWVERSION: + break; + case PROPERTY_ID_ISAUTOINCREMENT: + { + ADOProperties* pProps = m_aColumn.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("AutoIncrement")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + aProp.PutValue(getString(rValue)); + pProps->Release(); + } + break; + case PROPERTY_ID_DESCRIPTION: + { + ADOProperties* pProps = m_aColumn.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Default")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + aProp.PutValue(getString(rValue)); + pProps->Release(); + } + break; + case PROPERTY_ID_DEFAULTVALUE: + { + ADOProperties* pProps = m_aColumn.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Description")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + aProp.PutValue(getString(rValue)); + pProps->Release(); + } + break; + case PROPERTY_ID_ISCURRENCY: + { + ADOProperties* pProps = m_aColumn.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Fixed Length")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + aProp.PutValue(getBOOL(rValue)); + pProps->Release(); + } + break; + } + } +} +// ------------------------------------------------------------------------- +void OAdoColumn::getFastPropertyValue( + Any& rValue, + sal_Int32 nHandle + ) const +{ + if(m_aColumn.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + rValue <<= m_aColumn.get_Name(); + break; + case PROPERTY_ID_TYPE: + rValue <<= ADOS::MapADOType2Jdbc(m_aColumn.get_Type()); + break; + case PROPERTY_ID_TYPENAME: + // rValue <<= getResultSetType(); + break; + case PROPERTY_ID_PRECISION: + rValue <<= m_aColumn.get_Precision(); + break; + case PROPERTY_ID_SCALE: + rValue <<= m_aColumn.get_NumericScale(); + break; + case PROPERTY_ID_ISNULLABLE: + { + sal_Bool _b = m_aColumn.get_Attributes() == adColNullable; + rValue <<= Any(&_b, ::getBooleanCppuType()); + } + break; + case PROPERTY_ID_ISASCENDING: + { + sal_Bool _b = m_aColumn.get_SortOrder() == adSortAscending; + rValue <<= Any(&_b, ::getBooleanCppuType()); + } + case PROPERTY_ID_ISAUTOINCREMENT: + { + ADOProperties* pProps = m_aColumn.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("AutoIncrement")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + { + sal_Bool b = aProp.GetValue(); + rValue <<= Any(&b, ::getBooleanCppuType()); + } + pProps->Release(); + } + break; + case PROPERTY_ID_ISROWVERSION: + // rValue <<= getResultSetType(); + break; + case PROPERTY_ID_DESCRIPTION: + { + ADOProperties* pProps = m_aColumn.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Description")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + rValue <<= (::rtl::OUString)aProp.GetValue(); + pProps->Release(); + } + break; + case PROPERTY_ID_DEFAULTVALUE: + { + ADOProperties* pProps = m_aColumn.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Default")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + rValue <<= (::rtl::OUString)aProp.GetValue(); + pProps->Release(); + } + break; + case PROPERTY_ID_ISCURRENCY: + { + ADOProperties* pProps = m_aColumn.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Fixed Length")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + { + sal_Bool bVal = aProp.GetValue(); + rValue <<= Any(&bVal,getBooleanCppuType()); + } + pProps->Release(); + } + break; + } + } +} + + + diff --git a/connectivity/source/drivers/ado/AColumns.cxx b/connectivity/source/drivers/ado/AColumns.cxx new file mode 100644 index 000000000000..bbed8e773114 --- /dev/null +++ b/connectivity/source/drivers/ado/AColumns.cxx @@ -0,0 +1,149 @@ +/************************************************************************* + * + * $RCSfile: AColumns.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_COLUMNS_HXX_ +#include "ado/AColumns.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_COLUMN_HXX_ +#include "ado/AColumn.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif + +using namespace connectivity::ado; +using namespace connectivity; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::container; + +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OColumns::createObject(const ::rtl::OUString& _rName) +{ + + ADOColumn* pColumn = NULL; + m_pCollection->get_Item(OLEVariant(_rName),&pColumn); + + Reference< XNamed > xRet = new OAdoColumn(isCaseSensitive(),pColumn); + + return xRet; +} + +// ------------------------------------------------------------------------- +void OColumns::impl_refresh() throw(RuntimeException) +{ + m_pCollection->Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OColumns::createEmptyObject() +{ + OAdoColumn* pNew = new OAdoColumn(isCaseSensitive()); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OColumns::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(descriptor,UNO_QUERY); + if(xTunnel.is()) + { + OAdoColumn* pColumn = (OAdoColumn*)xTunnel->getSomething(OAdoColumn::getUnoTunnelImplementationId()); + m_pCollection->Append(OLEVariant(pColumn->getColumnImpl())); + } + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OColumns::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + m_pCollection->Delete(OLEVariant(elementName)); + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OColumns::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + m_pCollection->Delete(OLEVariant(index)); + OCollection_TYPE::dropByIndex(index); +} + + diff --git a/connectivity/source/drivers/ado/AConnection.cxx b/connectivity/source/drivers/ado/AConnection.cxx new file mode 100644 index 000000000000..7baf3eed0c05 --- /dev/null +++ b/connectivity/source/drivers/ado/AConnection.cxx @@ -0,0 +1,554 @@ +/************************************************************************* + * + * $RCSfile: AConnection.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ACONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ADATABASEMETADATA_HXX_ +#include "ado/ADatabaseMetaData.hxx" +#endif + +#ifndef _CONNECTIVITY_RESOURCE_HRC_ +#include "Resource.hrc" +#endif +#ifndef _CONNECTIVITY_MODULECONTEXT_HXX_ +#include "ModuleContext.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ADRIVER_HXX_ +#include "ado/ADriver.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ASTATEMENT_HXX_ +#include "ado/AStatement.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ACALLABLESTATEMENT_HXX_ +#include "ado/ACallableStatement.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_APREPAREDSTATEMENT_HXX_ +#include "ado/APreparedStatement.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_TRANSACTIONISOLATION_HPP_ +#include <com/sun/star/sdbc/TransactionIsolation.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +//------------------------------------------------------------------------------ +IMPLEMENT_SERVICE_INFO(OConnection,"com.sun.star.sdbcx.AConnection","com.sun.star.sdbc.Connection"); +// -------------------------------------------------------------------------------- +OConnection::OConnection(const ::rtl::OUString& url, const Sequence< PropertyValue >& info, + ODriver* _pDriver) throw(SQLException, RuntimeException) + : OConnection_BASE(m_aMutex), + OSubComponent<OConnection>((::cppu::OWeakObject*)_pDriver), + m_bClosed(sal_False), + m_xMetaData(NULL), + m_xCatalog(NULL), + m_pDriver(_pDriver), + m_pAdoConnection(NULL), + m_bAutocommit(sal_True) +{ + ModuleContext::AddRef(); + + osl_incrementInterlockedCount( &m_refCount ); + + IClassFactory2* pIUnknown = NULL; + IUnknown *pOuter = NULL; + HRESULT hr; + hr = CoGetClassObject( ADOS::CLSID_ADOCONNECTION_21, + CLSCTX_INPROC_SERVER, + NULL, + IID_IClassFactory2, + (void**)&pIUnknown ); + + if( !FAILED( hr ) ) + { + pIUnknown->AddRef(); + + ADOConnection *pCon = NULL; + hr = pIUnknown->CreateInstanceLic( pOuter, + NULL, + ADOS::IID_ADOCONNECTION_21, + ADOS::GetKeyStr(), + (void**) &pCon); + + if( !FAILED( hr ) ) + { + m_pAdoConnection = new WpADOConnection(pCon); + // Class Factory is no longer needed + + + } + pIUnknown->Release(); + } + + osl_decrementInterlockedCount( &m_refCount ); +} +//----------------------------------------------------------------------------- +OConnection::~OConnection() +{ + delete m_pAdoConnection; + ModuleContext::ReleaseRef(); +} +//----------------------------------------------------------------------------- +void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) +{ + osl_incrementInterlockedCount( &m_refCount ); + + sal_Int32 nLen = url.indexOf(':'); + nLen = url.indexOf(':',nLen+1); + ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD; + + sal_Int32 nTimeout = 20; + sal_Bool bSilent = sal_True; + const PropertyValue *pBegin = info.getConstArray(); + const PropertyValue *pEnd = pBegin + info.getLength(); + for(;pBegin != pEnd;++pBegin) + { + if(!pBegin->Name.compareToAscii("Timeout")) + pBegin->Value >>= nTimeout; + else if(!pBegin->Name.compareToAscii("Silent")) + pBegin->Value >>= bSilent; + else if(!pBegin->Name.compareToAscii("user")) + pBegin->Value >>= aUID; + else if(!pBegin->Name.compareToAscii("password")) + pBegin->Value >>= aPWD; + } + + if(m_pAdoConnection) + { + if(m_pAdoConnection->Open(aDSN,aUID,aPWD,adConnectUnspecified)) + m_pAdoConnection->PutCommandTimeout(nTimeout); + else + ADOS::ThrowException(*m_pAdoConnection,*this); + if(m_pAdoConnection->get_State() != adStateOpen) + throw SQLException(); + + ADOProperties* pProps=m_pAdoConnection->get_Properties(); + if(pProps) + { + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Jet OLEDB:ODBC Parsing")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + { + aProp.PutValue(OLEVariant(VARIANT_TRUE)); + OLEVariant aVar = aProp.GetValue(); + } + pProps->Release(); + } + //bErg = TRUE; + } + else + throw SQLException(); + + osl_decrementInterlockedCount( &m_refCount ); +} +//----------------------------------------------------------------------------- +void SAL_CALL OConnection::release() throw(RuntimeException) +{ + relase_ChildImpl(); + OConnection_BASE::release(); +} +// -------------------------------------------------------------------------------- +Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + OStatement* pStmt = new OStatement(this); + Reference< XStatement > xStmt = pStmt; + m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + return pStmt; +} +// -------------------------------------------------------------------------------- +Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OPreparedStatement* pStmt = new OPreparedStatement(this,m_aTypeInfo,sql); + Reference< XPreparedStatement > xPStmt = pStmt; + m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + return xPStmt; +} +// -------------------------------------------------------------------------------- +Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OCallableStatement* pStmt = new OCallableStatement(this,m_aTypeInfo,sql); + Reference< XPreparedStatement > xPStmt = pStmt; + m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + return xPStmt; +} +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& _sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ::rtl::OUString sql = _sql; + ADOProperties* pProps=m_pAdoConnection->get_Properties(); + if(pProps) + { + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Jet OLEDB:ODBC Parsing")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + { + pProp->put_Value(OLEVariant(VARIANT_TRUE)); + WpADOCommand aCommand; + aCommand.Create(); + aCommand.put_ActiveConnection((IDispatch*)*m_pAdoConnection); + aCommand.put_CommandText(sql); + sql = aCommand.get_CommandText(); + } + pProps->Release(); + } + + return sql; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_bAutocommit = autoCommit; + if(!autoCommit) + m_pAdoConnection->BeginTrans(); + else + m_pAdoConnection->RollbackTrans(); +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_bAutocommit; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_pAdoConnection->CommitTrans(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_pAdoConnection->RollbackTrans(); +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return OConnection_BASE::rBHelper.bDisposed && !m_pAdoConnection->get_State(); +} +// -------------------------------------------------------------------------------- +Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_xMetaData.is()) + m_xMetaData = new ODatabaseMetaData(this); + + return m_xMetaData; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_pAdoConnection->put_Mode(adModeRead); + ADOS::ThrowException(*m_pAdoConnection,*this); +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_pAdoConnection->get_Mode() == adModeRead; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_pAdoConnection->PutDefaultDatabase(catalog); + ADOS::ThrowException(*m_pAdoConnection,*this); +} +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_pAdoConnection->GetDefaultDatabase(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + IsolationLevelEnum eIso; + switch(level) + { + case TransactionIsolation::NONE: + eIso = adXactUnspecified; + break; + case TransactionIsolation::READ_UNCOMMITTED: + eIso = adXactReadUncommitted; + break; + case TransactionIsolation::READ_COMMITTED: + eIso = adXactReadCommitted; + break; + case TransactionIsolation::REPEATABLE_READ: + eIso = adXactRepeatableRead; + break; + case TransactionIsolation::SERIALIZABLE: + eIso = adXactSerializable; + break; + default: + OSL_ENSHURE(0,"OConnection::setTransactionIsolation invalid level"); + return; + } + m_pAdoConnection->put_IsolationLevel(eIso); + ADOS::ThrowException(*m_pAdoConnection,*this); +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 nRet = 0; + switch(m_pAdoConnection->get_IsolationLevel()) + { + case adXactUnspecified: + nRet = TransactionIsolation::NONE; + break; + case adXactReadUncommitted: + nRet = TransactionIsolation::READ_UNCOMMITTED; + break; + case adXactReadCommitted: + nRet = TransactionIsolation::READ_COMMITTED; + break; + case adXactRepeatableRead: + nRet = TransactionIsolation::REPEATABLE_READ; + break; + case adXactSerializable: + nRet = TransactionIsolation::SERIALIZABLE; + break; + default: + OSL_ENSHURE(0,"OConnection::setTransactionIsolation invalid level"); + } + ADOS::ThrowException(*m_pAdoConnection,*this); + return nRet; +} +// -------------------------------------------------------------------------------- +Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return NULL; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) +{ +} +// -------------------------------------------------------------------------------- +// XCloseable +void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + } + dispose(); +} +// -------------------------------------------------------------------------------- +// XWarningsSupplier +Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException) +{ + return Any(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException) +{ +} +//-------------------------------------------------------------------- +void OConnection::buildTypeInfo() throw( SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + Reference< XResultSet> xRs = getMetaData ()->getTypeInfo (); + Reference< XRow> xRow(xRs,UNO_QUERY); + // Information for a single SQL type + + // Loop on the result set until we reach end of file + + sal_Bool more = xRs->next (); + while (more) + { + OTypeInfo aInfo; + aInfo.aTypeName = xRow->getString (1); + aInfo.aLiteralPrefix = xRow->getString (4); + aInfo.aLiteralSuffix = xRow->getString (5); + aInfo.aCreateParams = xRow->getString (6); + aInfo.aLocalTypeName = xRow->getString (13); + + aInfo.nPrecision = xRow->getInt (3); + aInfo.nMaximumScale = xRow->getShort (15); + aInfo.nMinimumScale = xRow->getShort (14); + aInfo.nType = xRow->getShort (2); + aInfo.nSearchType = xRow->getShort (9); + aInfo.nNumPrecRadix = xRow->getInt (18); + + aInfo.bCurrency = xRow->getBoolean (11); + aInfo.bAutoIncrement = xRow->getBoolean (12); + aInfo.bNullable = xRow->getBoolean (7) == ColumnValue::NULLABLE; + aInfo.bCaseSensitive = xRow->getBoolean (8); + aInfo.bUnsigned = xRow->getBoolean (10); + + // Now that we have the type info, save it + // in the Hashtable if we don't already have an + // entry for this SQL type. + + m_aTypeInfo.push_back(aInfo); + more = xRs->next (); + } + + // Close the result set/statement. + + Reference< XCloseable>(xRs,UNO_QUERY)->close(); +} +//------------------------------------------------------------------------------ +void OConnection::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + // m_aTables.disposing(); + for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i) + { + Reference< XComponent > xComp(i->get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + } + m_aStatements.clear(); + + Reference< XComponent > xComp2(m_xCatalog.get(), UNO_QUERY); + if(xComp2.is()) + xComp2->dispose(); + + m_bClosed = sal_True; + m_xMetaData = NULL; + + m_pAdoConnection->Close(); + + dispose_ChildImpl(); + OConnection_BASE::disposing(); +} + + diff --git a/connectivity/source/drivers/ado/ADatabaseMetaData.cxx b/connectivity/source/drivers/ado/ADatabaseMetaData.cxx new file mode 100644 index 000000000000..1484b81cc008 --- /dev/null +++ b/connectivity/source/drivers/ado/ADatabaseMetaData.cxx @@ -0,0 +1,1602 @@ +/************************************************************************* + * + * $RCSfile: ADatabaseMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADATABASEMETADATARESULTSET_HXX_ +#include "ado/ADatabaseMetaDataResultSet.hxx" +#endif + +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_TRANSACTIONISOLATION_HPP_ +#include <com/sun/star/sdbc/TransactionIsolation.hpp> +#endif + +#ifndef _CONNECTIVITY_ADO_ADOIMP_HXX_ +#include "ado/adoimp.hxx" +#endif + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +// using namespace connectivity; + +ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon) + : m_pADOConnection(_pCon->getConnection()) + ,m_pConnection(_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_ENSHURE(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(); + ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId); + if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported) + return ((*aIter).second.cchMaxLen == (-1)) ? 0 : (*aIter).second.cchMaxLen; + return 0; +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::isCapable(sal_uInt32 _nId) throw(SQLException, RuntimeException) +{ + if(!m_aLiteralInfo.size()) + fillLiterals(); + ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId); + if(aIter != m_aLiteralInfo.end()) + (*aIter).second.fSupported; + return sal_False; +} + +// ------------------------------------------------------------------------- +::rtl::OUString ODatabaseMetaData::getLiteral(sal_uInt32 _nId) throw(SQLException, RuntimeException) +{ + if(!m_aLiteralInfo.size()) + fillLiterals(); + ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId); + if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported) + return (*aIter).second.pwszLiteralValue; + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +sal_Int32 ODatabaseMetaData::getInt32Property(const ::rtl::OUString& _aProperty) throw(SQLException, RuntimeException) +{ + WpOLEAppendCollection<ADOProperties, ADOProperty, WpADOProperty> aProps(m_pADOConnection->get_Properties()); + ADOS::ThrowException(*m_pADOConnection,*this); + OSL_ENSHURE(aProps.IsValid(),"There are no properties at the connection"); + ADO_PROP(_aProperty); + sal_Int32 nValue(0); + if(!aVar.isNull() && !aVar.isEmpty()) + nValue = aVar; + return nValue; +} + +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::getBoolProperty(const ::rtl::OUString& _aProperty) throw(SQLException, RuntimeException) +{ + WpOLEAppendCollection<ADOProperties, ADOProperty, WpADOProperty> aProps(m_pADOConnection->get_Properties()); + ADOS::ThrowException(*m_pADOConnection,*this); + OSL_ENSHURE(aProps.IsValid(),"There are no properties at the connection"); + ADO_PROP(_aProperty); + return (!aVar.isNull() && !aVar.isEmpty() ? aVar.getBool() : sal_False); +} +// ------------------------------------------------------------------------- +::rtl::OUString ODatabaseMetaData::getStringProperty(const ::rtl::OUString& _aProperty) throw(SQLException, RuntimeException) +{ + WpOLEAppendCollection<ADOProperties, ADOProperty, WpADOProperty> aProps(m_pADOConnection->get_Properties()); + ADOS::ThrowException(*m_pADOConnection,*this); + OSL_ENSHURE(aProps.IsValid(),"There are no properties at the connection"); + + ADO_PROP(_aProperty); + ::rtl::OUString aValue; + if(!aVar.isNull() && !aVar.isEmpty() && aVar.getType() == VT_BSTR) + aValue = aVar; + + 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); + ADOS::ThrowException(*m_pADOConnection,*this); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRec); + pResult->setTypeInfoMap(); + Reference< XResultSet > xRef = pResult; + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException) +{ + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + ADORecordset *pRecordset = NULL; + m_pADOConnection->OpenSchema(adSchemaCatalogs,vtEmpty,vtEmpty,&pRecordset); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setCatalogsMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogSeparator( ) throw(SQLException, RuntimeException) +{ + return getLiteral(DBLITERAL_CATALOG_SEPARATOR); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException) +{ + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + ADORecordset *pRecordset = NULL; + m_pADOConnection->OpenSchema(adSchemaSchemata,vtEmpty,vtEmpty,&pRecordset); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setSchemasMap(); + xRef = pResult; + return xRef; +} +// ------------------------------------------------------------------------- +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); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setColumnPrivilegesMap(); + xRef = pResult; + return xRef; +} +// ------------------------------------------------------------------------- +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); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setColumnsMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +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); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setTablesMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +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); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setProcedureColumnsMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures( + const Any& catalog, const ::rtl::OUString& schemaPattern, + 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); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setProceduresMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(NULL); + xRef = pResult; + return xRef; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_BINARY_LITERAL); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Maximum Row Size")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_CATALOG_NAME); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_CHAR_LITERAL); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_COLUMN_NAME); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in Index")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_CURSOR_NAME); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Active Sessions")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in Table")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_TEXT_COMMAND); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_TABLE_NAME); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTablesInSelect( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Maximum Tables in SELECT")); +} +// ------------------------------------------------------------------------- +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); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setCrossReferenceMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +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); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setCrossReferenceMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +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); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setPrimaryKeysMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +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); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setIndexInfoMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, + sal_Bool nullable ) throw(SQLException, RuntimeException) +{ + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(NULL); + xRef = pResult; + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) 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(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); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setTablePrivilegesMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference( + const Any& primaryCatalog, const ::rtl::OUString& primarySchema, + 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); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setCrossReferenceMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException) +{ + return getBoolProperty(::rtl::OUString::createFromAscii("Maximum Row Size Includes BLOB")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Quoted Identifier Case Sensitivity")) & DBPROPVAL_IC_LOWER) == DBPROPVAL_IC_LOWER ; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_LOWER) == DBPROPVAL_IC_LOWER ; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Quoted Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED) == DBPROPVAL_IC_MIXED ; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED) == DBPROPVAL_IC_MIXED ; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Quoted Identifier Case Sensitivity")) & DBPROPVAL_IC_UPPER) == DBPROPVAL_IC_UPPER ; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_UPPER) == DBPROPVAL_IC_UPPER ; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Maximum Index Size")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("NULL Concatenation Behavior")) == DBPROPVAL_CB_NON_NULL; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("Catalog Term")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getIdentifierQuoteString( ) throw(SQLException, RuntimeException) +{ + return getLiteral(DBLITERAL_QUOTE_PREFIX); + +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("Special Characters")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException) +{ + return isCapable(DBLITERAL_CORRELATION_NAME); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::isCatalogAtStart( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Catalog Location")) == DBPROPVAL_CL_START; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_DDL_IGNORE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_DDL_COMMIT; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_DML; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_ALL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Prepare Abort Behavior")) == DBPROPVAL_CB_PRESERVE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Prepare Commit Behavior")) == DBPROPVAL_CB_PRESERVE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Isolation Retention")) & DBPROPVAL_TR_COMMIT) == DBPROPVAL_TR_COMMIT; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Isolation Retention")) & DBPROPVAL_TR_ABORT) == DBPROPVAL_TR_ABORT; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException) +{ + sal_Bool bValue(sal_False); + + sal_Int32 nTxn = getInt32Property(::rtl::OUString::createFromAscii("Isolation Levels")); + if(level == TransactionIsolation::NONE) + bValue = sal_True; + else if(level == TransactionIsolation::READ_UNCOMMITTED) + bValue = (nTxn & DBPROPVAL_TI_READUNCOMMITTED) == DBPROPVAL_TI_READUNCOMMITTED; + else if(level == TransactionIsolation::READ_COMMITTED) + bValue = (nTxn & DBPROPVAL_TI_READCOMMITTED) == DBPROPVAL_TI_READCOMMITTED; + else if(level == TransactionIsolation::REPEATABLE_READ) + bValue = (nTxn & DBPROPVAL_TI_REPEATABLEREAD) == DBPROPVAL_TI_REPEATABLEREAD; + else if(level == TransactionIsolation::SERIALIZABLE) + bValue = (nTxn & DBPROPVAL_TI_SERIALIZABLE) == DBPROPVAL_TI_SERIALIZABLE; + + return bValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInDataManipulation( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Schema Usage")) & DBPROPVAL_SU_DML_STATEMENTS) == DBPROPVAL_SU_DML_STATEMENTS; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("SQL Support")) & DBPROPVAL_SQL_ANSI92_FULL) == DBPROPVAL_SQL_ANSI92_FULL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("SQL Support")) & DBPROPVAL_SQL_ANSI92_ENTRY) == DBPROPVAL_SQL_ANSI92_ENTRY; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("SQL Support")) & DBPROPVAL_SQL_ANSI89_IEF) == DBPROPVAL_SQL_ANSI89_IEF; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Schema Usage")) & DBPROPVAL_SU_INDEX_DEFINITION) == DBPROPVAL_SU_INDEX_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInTableDefinitions( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Schema Usage")) & DBPROPVAL_SU_TABLE_DEFINITION) == DBPROPVAL_SU_TABLE_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Catalog Usage")) & DBPROPVAL_CU_TABLE_DEFINITION) == DBPROPVAL_CU_TABLE_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Catalog Usage")) & DBPROPVAL_CU_INDEX_DEFINITION) == DBPROPVAL_CU_INDEX_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Catalog Usage")) & DBPROPVAL_CU_DML_STATEMENTS) == DBPROPVAL_CU_DML_STATEMENTS; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException) +{ + return getBoolProperty(::rtl::OUString::createFromAscii("Outer Join Capabilities")); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException) +{ + // Create elements used in the array + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(NULL); + xRef = pResult; + return xRef; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatements( ) throw(SQLException, RuntimeException) +{ + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_PROCEDURE_NAME); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_SCHEMA_NAME); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_NONE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException) +{ + return getBoolProperty(::rtl::OUString::createFromAscii("Read-Only Data Source")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("NULL Concatenation Behavior")) == DBPROPVAL_CB_NULL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException) +{ + return isCapable(DBLITERAL_COLUMN_ALIAS); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException) +{ + return isCapable(DBLITERAL_CORRELATION_NAME); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(SQLException, RuntimeException) +{ + return getBoolProperty(::rtl::OUString::createFromAscii("Rowset Conversions on Command")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException) +{ + return getBoolProperty(::rtl::OUString::createFromAscii("ORDER BY Columns in Select List")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("GROUP BY Support")) != DBPROPVAL_GB_NOT_SUPPORTED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("GROUP BY Support")) != DBPROPVAL_GB_CONTAINS_SELECT; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("GROUP BY Support")) == DBPROPVAL_GB_NO_RELATION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException) +{ + return isCapable(DBLITERAL_ESCAPE_PERCENT); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException) +{ + return getBoolProperty(::rtl::OUString::createFromAscii("ORDER BY Columns in Select List")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED) == DBPROPVAL_IC_MIXED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED) == DBPROPVAL_IC_MIXED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("NULL Collation Order")) & DBPROPVAL_NC_END) == DBPROPVAL_NC_END; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("NULL Collation Order")) & DBPROPVAL_NC_START) == DBPROPVAL_NC_START; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("NULL Collation Order")) & DBPROPVAL_NC_HIGH) == DBPROPVAL_NC_HIGH; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("NULL Collation Order")) & DBPROPVAL_NC_LOW) == DBPROPVAL_NC_LOW; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Schema Usage")) & DBPROPVAL_SU_PRIVILEGE_DEFINITION) == DBPROPVAL_SU_PRIVILEGE_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Catalog Usage")) & DBPROPVAL_CU_PRIVILEGE_DEFINITION) == DBPROPVAL_CU_PRIVILEGE_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_CORRELATEDSUBQUERIES) == DBPROPVAL_SQ_CORRELATEDSUBQUERIES; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_COMPARISON) == DBPROPVAL_SQ_COMPARISON; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_EXISTS) == DBPROPVAL_SQ_EXISTS; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_IN) == DBPROPVAL_SQ_IN; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_QUANTIFIED) == DBPROPVAL_SQ_QUANTIFIED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("SQL Support")) & DBPROPVAL_SQL_ANSI92_INTERMEDIATE) == DBPROPVAL_SQL_ANSI92_INTERMEDIATE; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString::createFromAscii("sdbc:ado:")+ m_pADOConnection->GetConnectionString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("User Name")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("Provider Friendly Name")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("Provider Version")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("DBMS Version")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("DBMS Name")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("Procedure Term")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("Schema Term")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException) +{ + return 1; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nRet = TransactionIsolation::NONE; + switch(m_pADOConnection->get_IsolationLevel()) + { + case adXactReadCommitted: + nRet = TransactionIsolation::READ_COMMITTED; + break; + case adXactRepeatableRead: + nRet = TransactionIsolation::REPEATABLE_READ; + break; + case adXactSerializable: + nRet = TransactionIsolation::SERIALIZABLE; + break; + case adXactReadUncommitted: + nRet = TransactionIsolation::READ_UNCOMMITTED; + break; + default: + ; + } + return nRet; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException) +{ + return 0; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException) +{ + ADORecordset *pRecordset = NULL; + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + m_pADOConnection->OpenSchema(adSchemaDBInfoKeywords,vtEmpty,vtEmpty,&pRecordset); + ADOS::ThrowException(*m_pADOConnection,*this); + WpADORecordset aRecordset(pRecordset); + + aRecordset.MoveFirst(); + OLEVariant aValue; + ::rtl::OUString aRet,aComma = ::rtl::OUString::createFromAscii(",");; + while(!aRecordset.IsAtEOF()) + { + WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(aRecordset.GetFields()); + WpADOField aField(aFields.GetItem(0)); + aField.get_Value(aValue); + aRet = aRet + aValue + aComma; + aRecordset.MoveNext(); + } + aRecordset.Close(); + return aRet.copy(0,aRet.lastIndexOf(',')); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException) +{ + return getLiteral(DBLITERAL_ESCAPE_PERCENT); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue.copy(0,aValue.lastIndexOf(',')); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue.copy(0,aValue.lastIndexOf(',')); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("SQL Support")) & DBPROPVAL_SQL_ODBC_EXTENDED) == DBPROPVAL_SQL_ODBC_EXTENDED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("SQL Support")) & DBPROPVAL_SQL_ODBC_CORE) == DBPROPVAL_SQL_ODBC_CORE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("SQL Support")) & DBPROPVAL_SQL_ODBC_MINIMUM) == DBPROPVAL_SQL_ODBC_MINIMUM; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Outer Join Capabilities")) & 0x00000004L) == 0x00000004L; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException) +{ + return supportsFullOuterJoins( ); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in Group By")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in Order by")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in Select")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_USER_NAME); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(SQLException, RuntimeException) +{ +// ADOProperties* pProps = m_pADOConnection->get_Properties(); +// OSL_ENSHURE(pProps,"There are no properties at the connection"); +// if(!pProps) +// return sal_False; +// pProps->AddRef(); +// ADO_PROP("Maximum Row Size"INCLUDESBLOB); +// sal_Bool bValue(sal_False); +// bValue = (!aVar.isNull() && !aVar.isEmpty() ? aVar.getBool() : sal_False); +// pProps->Release(); +// return bValue; + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const Sequence< sal_Int32 >& types ) throw(SQLException, RuntimeException) +{ + Reference< XResultSet > xRef = NULL; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(NULL); + xRef = pResult; + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection( ) throw(SQLException, RuntimeException) +{ + return (Reference< XConnection >)m_pConnection;//new OConnection(m_aConnectionHandle); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx new file mode 100644 index 000000000000..295029ab8a1f --- /dev/null +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx @@ -0,0 +1,1282 @@ +/************************************************************************* + * + * $RCSfile: ADatabaseMetaDataResultSet.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADATABASEMETADATARESULTSET_HXX_ +#include "ado/ADatabaseMetaDataResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSETMETADATA_HXX_ +#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_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_PROCEDURERESULT_HPP_ +#include <com/sun/star/sdbc/ProcedureResult.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_INDEXTYPE_HPP_ +#include <com/sun/star/sdbc/IndexType.hpp> +#endif +#ifndef _UTL_PROPERTY_HXX_ +#include <unotools/property.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_FETCHDIRECTION_HPP_ +#include <com/sun/star/sdbc/FetchDirection.hpp> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif + +#include <oledb.h> + + +using namespace connectivity::ado; +using namespace cppu; +//------------------------------------------------------------------------------ +using namespace ::com::sun::star::lang; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +// ------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(ADORecordset* _pRecordSet) : ODatabaseMetaDataResultSet_BASE(m_aMutex) + ,OPropertySetHelper(ODatabaseMetaDataResultSet_BASE::rBHelper) + ,m_aStatement(NULL) + ,m_xMetaData(NULL) + ,m_pRecordSet(_pRecordSet) + ,m_bEOF(sal_False) +{ + osl_incrementInterlockedCount( &m_refCount ); + m_aColMapping.push_back(-1); + if(_pRecordSet) + { + m_pRecordSet->AddRef(); + VARIANT_BOOL bIsAtBOF; + m_pRecordSet->get_BOF(&bIsAtBOF); + m_bOnFirstAfterOpen = !(sal_Bool)bIsAtBOF; + } + else + m_bOnFirstAfterOpen = sal_False; + osl_decrementInterlockedCount( &m_refCount ); + // allocBuffer(); +} + +// ------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet() +{ + if(m_pRecordSet) + m_pRecordSet->Release(); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::disposing(void) +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + if(m_pRecordSet) + m_pRecordSet->Close(); + m_aStatement = NULL; + m_xMetaData = NULL; +} +// ------------------------------------------------------------------------- +Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OPropertySetHelper::queryInterface(rType); + if(!aRet.hasValue()) + aRet = ODatabaseMetaDataResultSet_BASE::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes()); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ) + throw DisposedException(); + + Reference< XResultSetMetaData > xMeta = getMetaData(); + sal_Int32 nLen = xMeta->getColumnCount(); + sal_Int32 i = 1; + for(;i<=nLen;++i) + if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) : columnName.equalsIgnoreCase(xMeta->getColumnName(i))) + break; + return i; +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + return NULL; +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + return NULL; +} + +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end()) + return (*m_aValueRangeIter).second[(sal_Int32)m_aValue]; + else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end()) + return (*m_aStrValueRangeIter).second[m_aValue]; + return m_aValue; +} +// ------------------------------------------------------------------------- + +Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end()) + return (*m_aValueRangeIter).second[(sal_Int32)m_aValue]; + else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end()) + return (*m_aStrValueRangeIter).second[m_aValue]; + return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + return 0; +} +// ------------------------------------------------------------------------- + +sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + ADO_GETFIELD(columnIndex); + return sal_Int64(0); +} +// ------------------------------------------------------------------------- + +Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + if(!m_xMetaData.is()) + m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + + return m_xMetaData; +} +// ------------------------------------------------------------------------- +Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + return NULL; +} + +// ------------------------------------------------------------------------- + +Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + return NULL; +} +// ------------------------------------------------------------------------- + +Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + return NULL; +} +// ------------------------------------------------------------------------- + +Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + return Any(); +} +// ------------------------------------------------------------------------- + +sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end()) + return (*m_aValueRangeIter).second[(sal_Int32)m_aValue]; + else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end()) + return (*m_aStrValueRangeIter).second[m_aValue]; + return m_aValue; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + + if(m_aIntValueRange.size() && (m_aIntValueRangeIter = m_aIntValueRange.find(columnIndex)) != m_aIntValueRange.end()) + return (*m_aIntValueRangeIter).second[m_aValue]; + return m_aValue; +} + +// ------------------------------------------------------------------------- + + +::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); return m_aValue; +} +// ------------------------------------------------------------------------- + + +::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + columnIndex = mapColumn(columnIndex); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + sal_Int16 bIsAtEOF; + m_pRecordSet->get_EOF(&bIsAtEOF); + return bIsAtEOF; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + return m_nRowPos == 1; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + return sal_True; +} +// ------------------------------------------------------------------------- +void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + if(first()) + previous(); +} +// ------------------------------------------------------------------------- +void SAL_CALL ODatabaseMetaDataResultSet::afterLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + if(last()) + next(); + m_bEOF = sal_True; +} +// ------------------------------------------------------------------------- + +void SAL_CALL ODatabaseMetaDataResultSet::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + } + dispose(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_pRecordSet) + return sal_False; + + sal_Bool bRet; + if(bRet = SUCCEEDED(m_pRecordSet->MoveFirst())) + m_nRowPos = 1; + return bRet; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ) + throw DisposedException(); + + return m_pRecordSet ? SUCCEEDED(m_pRecordSet->MoveLast()) : sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(first()) + { + OLEVariant aEmpty; + aEmpty.setNoArg(); + sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty)); + if(bRet) + m_nRowPos = row; + return bRet; + } + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_pRecordSet) + return sal_False; + + OLEVariant aEmpty; + aEmpty.setNoArg(); + sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty)); + if(bRet) + m_nRowPos += row; + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_pRecordSet) + return sal_False; + + sal_Bool bRet = SUCCEEDED(m_pRecordSet->MovePrevious()); + if(bRet) + --m_nRowPos; + return bRet; +} +// ------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) throw(SQLException, RuntimeException) +{ + return m_aStatement.get(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + RecordStatusEnum eRec; + m_pRecordSet->get_Status((sal_Int32*)&eRec); + return (eRec & adRecDeleted) == adRecDeleted; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException, RuntimeException) +{ ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + RecordStatusEnum eRec; + m_pRecordSet->get_Status((sal_Int32*)&eRec); + return (eRec & adRecNew) == adRecNew; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + RecordStatusEnum eRec; + m_pRecordSet->get_Status((sal_Int32*)&eRec); + return (eRec & adRecModified) == adRecModified; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_pRecordSet) + return sal_True; + + sal_Int16 bIsAtBOF; + m_pRecordSet->get_BOF(&bIsAtBOF); + return bIsAtBOF; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_pRecordSet) + return sal_False; + + if(m_bOnFirstAfterOpen) + { + m_bOnFirstAfterOpen = sal_False; + return sal_True; + } + else + return SUCCEEDED(m_pRecordSet->MoveNext()); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + return m_aValue.isNull(); +} +// ------------------------------------------------------------------------- +void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + m_pRecordSet->Resync(adAffectCurrent,adResyncAllValues); +} +// ------------------------------------------------------------------------- + +void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(!m_pRecordSet) + throw SQLException(); + + m_pRecordSet->Cancel(); +} +// ------------------------------------------------------------------------- +void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- +Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( ) throw(SQLException, RuntimeException) +{ + return Any(); +} +//------------------------------------------------------------------------------ +sal_Int32 ODatabaseMetaDataResultSet::getResultSetConcurrency() const +{ + return ResultSetConcurrency::READ_ONLY; +} +//------------------------------------------------------------------------------ +sal_Int32 ODatabaseMetaDataResultSet::getResultSetType() const +{ + return ResultSetType::FORWARD_ONLY; +} +//------------------------------------------------------------------------------ +sal_Int32 ODatabaseMetaDataResultSet::getFetchDirection() const +{ + return FetchDirection::FORWARD; +} +//------------------------------------------------------------------------------ +sal_Int32 ODatabaseMetaDataResultSet::getFetchSize() const +{ + sal_Int32 nValue=-1; + if(m_pRecordSet) + m_pRecordSet->get_CacheSize(&nValue); + return nValue; +} +//------------------------------------------------------------------------------ +::rtl::OUString ODatabaseMetaDataResultSet::getCursorName() const +{ + return ::rtl::OUString(); +} + +//------------------------------------------------------------------------------ +void ODatabaseMetaDataResultSet::setFetchDirection(sal_Int32 _par0) +{ +} +//------------------------------------------------------------------------------ +void ODatabaseMetaDataResultSet::setFetchSize(sal_Int32 _par0) +{ + if(m_pRecordSet) + m_pRecordSet->put_CacheSize(_par0); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const +{ + + Sequence< com::sun::star::beans::Property > aProps(5); + com::sun::star::beans::Property* pProperties = aProps.getArray(); + sal_Int32 nPos = 0; + DECL_PROP0(CURSORNAME, ::rtl::OUString); + DECL_PROP0(FETCHDIRECTION, sal_Int32); + DECL_PROP0(FETCHSIZE, sal_Int32); + DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32); + DECL_PROP0(RESULTSETTYPE, sal_Int32); + + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper() +{ + return *const_cast<ODatabaseMetaDataResultSet*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaDataResultSet::convertFastPropertyValue( + Any & rConvertedValue, + Any & rOldValue, + sal_Int32 nHandle, + const Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException) +{ + switch(nHandle) + { + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + throw ::com::sun::star::lang::IllegalArgumentException(); + break; + case PROPERTY_ID_FETCHDIRECTION: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); + case PROPERTY_ID_FETCHSIZE: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); + default: + ; + } + return sal_False; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const Any& rValue + ) + throw (Exception) +{ + switch(nHandle) + { + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + case PROPERTY_ID_FETCHDIRECTION: + case PROPERTY_ID_FETCHSIZE: + throw Exception(); + break; + default: + OSL_ENSHURE(0,"setFastPropertyValue_NoBroadcast: Illegal handle value!"); + } +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::getFastPropertyValue( + Any& rValue, + sal_Int32 nHandle + ) const +{ + switch(nHandle) + { + case PROPERTY_ID_CURSORNAME: + rValue <<= getCursorName(); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + rValue <<= getResultSetConcurrency(); + break; + case PROPERTY_ID_RESULTSETTYPE: + rValue <<= getResultSetType(); + break; + case PROPERTY_ID_FETCHDIRECTION: + rValue <<= getFetchDirection(); + break; + case PROPERTY_ID_FETCHSIZE: + rValue <<= getFetchSize(); + break; + } +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setProceduresMap() +{ + + for(sal_Int32 i=1;i<4;i++) + m_aColMapping.push_back(i); + m_aColMapping.push_back(5); + m_aColMapping.push_back(7); + m_aColMapping.push_back(8); + m_aColMapping.push_back(6); + m_aColMapping.push_back(4); + + ::std::map<sal_Int32,sal_Int32> aMap; + aMap[DB_PT_UNKNOWN] = ProcedureResult::UNKNOWN; + aMap[DB_PT_PROCEDURE] = ProcedureResult::NONE; + aMap[DB_PT_FUNCTION] = ProcedureResult::RETURN; + m_aValueRange[4] = aMap; + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setProceduresMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setCatalogsMap() +{ + m_aColMapping.push_back(1); + + m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setSchemasMap() +{ + m_aColMapping.push_back(2); + + m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setColumnPrivilegesMap() +{ + + m_aColMapping.push_back(3); + m_aColMapping.push_back(4); + m_aColMapping.push_back(5); + m_aColMapping.push_back(6); + m_aColMapping.push_back(2); + m_aColMapping.push_back(9); + m_aColMapping.push_back(10); + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setColumnPrivilegesMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setColumnsMap() +{ + + for(sal_Int32 i=1;i<5;++i) + m_aColMapping.push_back(i); + + m_aColMapping.push_back(12); + m_aColMapping.push_back(12); // is used as TYPE_NAME + + m_aColMapping.push_back(14); + m_aColMapping.push_back(6); + m_aColMapping.push_back(17); + m_aColMapping.push_back(18); + + m_aColMapping.push_back(11); + m_aColMapping.push_back(29); + m_aColMapping.push_back(9); + m_aColMapping.push_back(18); + m_aColMapping.push_back(18); + + m_aColMapping.push_back(15); + m_aColMapping.push_back(7); + m_aColMapping.push_back(11); + + ::std::map<sal_Int32,sal_Int32> aMap; + aMap[DBTYPE_EMPTY] = DataType::SQLNULL; + aMap[DBTYPE_NULL] = DataType::SQLNULL; + aMap[DBTYPE_I2] = DataType::SMALLINT; + aMap[DBTYPE_I4] = DataType::INTEGER; + aMap[DBTYPE_R4] = DataType::FLOAT; + aMap[DBTYPE_R8] = DataType::DOUBLE; + aMap[DBTYPE_CY] = DataType::BIGINT; + aMap[DBTYPE_DATE] = DataType::DATE; + aMap[DBTYPE_BSTR] = DataType::VARCHAR; + aMap[DBTYPE_IDISPATCH] = DataType::OBJECT; + aMap[DBTYPE_ERROR] = DataType::OTHER; + aMap[DBTYPE_BOOL] = DataType::BIT; + aMap[DBTYPE_VARIANT] = DataType::STRUCT; + aMap[DBTYPE_IUNKNOWN] = DataType::OTHER; + aMap[DBTYPE_DECIMAL] = DataType::DECIMAL; + aMap[DBTYPE_UI1] = DataType::TINYINT; + aMap[DBTYPE_ARRAY] = DataType::ARRAY; + aMap[DBTYPE_BYREF] = DataType::REF; + aMap[DBTYPE_I1] = DataType::CHAR; + aMap[DBTYPE_UI2] = DataType::SMALLINT; + aMap[DBTYPE_UI4] = DataType::INTEGER; + + // aMap[The] = ; + // aMap[in] = ; + aMap[DBTYPE_I8] = DataType::BIGINT; + aMap[DBTYPE_UI8] = DataType::BIGINT; + aMap[DBTYPE_GUID] = DataType::OTHER; + aMap[DBTYPE_VECTOR] = DataType::OTHER; + aMap[DBTYPE_FILETIME] = DataType::OTHER; + aMap[DBTYPE_RESERVED] = DataType::OTHER; + + // aMap[The] = ; + aMap[DBTYPE_BYTES] = DataType::VARBINARY; + aMap[DBTYPE_STR] = DataType::LONGVARCHAR; + aMap[DBTYPE_WSTR] = DataType::LONGVARCHAR; + aMap[DBTYPE_NUMERIC] = DataType::NUMERIC; + aMap[DBTYPE_UDT] = DataType::OTHER; + aMap[DBTYPE_DBDATE] = DataType::DATE; + aMap[DBTYPE_DBTIME] = DataType::TIME; + aMap[DBTYPE_DBTIMESTAMP] = DataType::TIMESTAMP; + aMap[DBTYPE_HCHAPTER] = DataType::OTHER; + aMap[DBTYPE_PROPVARIANT] = DataType::OTHER; + aMap[DBTYPE_VARNUMERIC] = DataType::NUMERIC; + + m_aValueRange[12] = aMap; + + ::std::map< sal_Int32,::rtl::OUString> aMap2; + aMap2[0] = ::rtl::OUString::createFromAscii("YES"); + aMap2[1] = ::rtl::OUString::createFromAscii("NO"); + m_aIntValueRange[18] = aMap2; + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setColumnsMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setTablesMap() +{ + + for(sal_Int32 i=1;i<5;i++) + m_aColMapping.push_back(i); + m_aColMapping.push_back(6); + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setTablesMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setProcedureColumnsMap() +{ + + for(sal_Int32 i=1;i<5;i++) + m_aColMapping.push_back(i); + m_aColMapping.push_back(6); + m_aColMapping.push_back(10); + m_aColMapping.push_back(16); + m_aColMapping.push_back(13); + m_aColMapping.push_back(11); + m_aColMapping.push_back(12); + + m_aColMapping.push_back(9); + m_aColMapping.push_back(14); + + ::std::map<sal_Int32,sal_Int32> aMap; + aMap[DBTYPE_EMPTY] = DataType::SQLNULL; + aMap[DBTYPE_NULL] = DataType::SQLNULL; + aMap[DBTYPE_I2] = DataType::SMALLINT; + aMap[DBTYPE_I4] = DataType::INTEGER; + aMap[DBTYPE_R4] = DataType::FLOAT; + aMap[DBTYPE_R8] = DataType::DOUBLE; + aMap[DBTYPE_CY] = DataType::BIGINT; + aMap[DBTYPE_DATE] = DataType::DATE; + aMap[DBTYPE_BSTR] = DataType::VARCHAR; + aMap[DBTYPE_IDISPATCH] = DataType::OBJECT; + aMap[DBTYPE_ERROR] = DataType::OTHER; + aMap[DBTYPE_BOOL] = DataType::BIT; + aMap[DBTYPE_VARIANT] = DataType::STRUCT; + aMap[DBTYPE_IUNKNOWN] = DataType::OTHER; + aMap[DBTYPE_DECIMAL] = DataType::DECIMAL; + aMap[DBTYPE_UI1] = DataType::TINYINT; + aMap[DBTYPE_ARRAY] = DataType::ARRAY; + aMap[DBTYPE_BYREF] = DataType::REF; + aMap[DBTYPE_I1] = DataType::CHAR; + aMap[DBTYPE_UI2] = DataType::SMALLINT; + aMap[DBTYPE_UI4] = DataType::INTEGER; + + // aMap[The] = ; + // aMap[in] = ; + aMap[DBTYPE_I8] = DataType::BIGINT; + aMap[DBTYPE_UI8] = DataType::BIGINT; + aMap[DBTYPE_GUID] = DataType::OTHER; + aMap[DBTYPE_VECTOR] = DataType::OTHER; + aMap[DBTYPE_FILETIME] = DataType::OTHER; + aMap[DBTYPE_RESERVED] = DataType::OTHER; + + // aMap[The] = ; + aMap[DBTYPE_BYTES] = DataType::VARBINARY; + aMap[DBTYPE_STR] = DataType::LONGVARCHAR; + aMap[DBTYPE_WSTR] = DataType::LONGVARCHAR; + aMap[DBTYPE_NUMERIC] = DataType::NUMERIC; + aMap[DBTYPE_UDT] = DataType::OTHER; + aMap[DBTYPE_DBDATE] = DataType::DATE; + aMap[DBTYPE_DBTIME] = DataType::TIME; + aMap[DBTYPE_DBTIMESTAMP] = DataType::TIMESTAMP; + aMap[DBTYPE_HCHAPTER] = DataType::OTHER; + aMap[DBTYPE_PROPVARIANT] = DataType::OTHER; + aMap[DBTYPE_VARNUMERIC] = DataType::NUMERIC; + + m_aValueRange[10] = aMap; + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setProcedureColumnsMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setPrimaryKeysMap() +{ + + sal_Int32 i=1; + for(;i<5;i++) + m_aColMapping.push_back(i); + m_aColMapping.push_back(7); + m_aColMapping.push_back(8); + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setProcedureColumnsMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setIndexInfoMap() +{ + + sal_Int32 i=1; + for(;i<4;i++) + m_aColMapping.push_back(i); + m_aColMapping.push_back(8); + m_aColMapping.push_back(4); + m_aColMapping.push_back(6); + m_aColMapping.push_back(10); + m_aColMapping.push_back(17); + m_aColMapping.push_back(18); + m_aColMapping.push_back(21); + m_aColMapping.push_back(22); + m_aColMapping.push_back(23); + m_aColMapping.push_back(24); + + ::std::map<sal_Int32,sal_Int32> aMap; + aMap[DBPROPVAL_IT_HASH] = IndexType::HASHED; + aMap[DBPROPVAL_IT_CONTENT] = IndexType::OTHER; + aMap[DBPROPVAL_IT_OTHER] = IndexType::OTHER; + aMap[DBPROPVAL_IT_BTREE] = IndexType::OTHER; + + m_aValueRange[10] = aMap; + + ::std::map<sal_Int32,sal_Int32> aMap2; + aMap[0] = 1; + aMap[1] = 0; + m_aValueRange[8] = aMap2; + + ::std::map< sal_Int32,::rtl::OUString> aMap3; + aMap3[0] = ::rtl::OUString(); + aMap3[DB_COLLATION_ASC] = ::rtl::OUString::createFromAscii("A"); + aMap3[DB_COLLATION_DESC] = ::rtl::OUString::createFromAscii("D"); + + m_aIntValueRange[21] = aMap3; + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setIndexInfoMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setTablePrivilegesMap() +{ + + sal_Int32 i=3; + for(;i<6;i++) + m_aColMapping.push_back(i); + m_aColMapping.push_back(1); + m_aColMapping.push_back(2); + m_aColMapping.push_back(6); + m_aColMapping.push_back(7); + + ::std::map< sal_Int32,::rtl::OUString> aMap; + aMap[0] = ::rtl::OUString::createFromAscii("YES"); + aMap[1] = ::rtl::OUString::createFromAscii("NO"); + m_aIntValueRange[7] = aMap; + + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setTablePrivilegesMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setCrossReferenceMap() +{ + + sal_Int32 i=1; + for(;i<5;i++) + m_aColMapping.push_back(i); + for(i=7;i<11;i++) + m_aColMapping.push_back(i); + + m_aColMapping.push_back(13); + m_aColMapping.push_back(14); + m_aColMapping.push_back(15); + m_aColMapping.push_back(17); + m_aColMapping.push_back(16); + m_aColMapping.push_back(18); + + ::std::map< ::rtl::OUString,sal_Int32> aMap; + aMap[ ::rtl::OUString::createFromAscii("CASCADE")] = KeyRule::CASCADE; + aMap[ ::rtl::OUString::createFromAscii("RESTRICT")] = KeyRule::RESTRICT; + aMap[ ::rtl::OUString::createFromAscii("SET NULL")] = KeyRule::SET_NULL; + aMap[ ::rtl::OUString::createFromAscii("SET DEFAULT")] = KeyRule::SET_DEFAULT; + aMap[ ::rtl::OUString::createFromAscii("NO ACTION")] = KeyRule::NO_ACTION; + + m_aStrValueRange[14] = aMap; + m_aStrValueRange[15] = aMap; + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setCrossReferenceMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setTypeInfoMap() +{ + sal_Int32 i=1; + for(;i<19;i++) + m_aColMapping.push_back(i); + + ::std::map< ::rtl::OUString,sal_Int32> aMap1; + aMap1[ ::rtl::OUString()] = 10; + + m_aStrValueRange[18] = aMap1; + + ::std::map<sal_Int32,sal_Int32> aMap; + aMap[DBTYPE_EMPTY] = DataType::SQLNULL; + aMap[DBTYPE_NULL] = DataType::SQLNULL; + aMap[DBTYPE_I2] = DataType::SMALLINT; + aMap[DBTYPE_I4] = DataType::INTEGER; + aMap[DBTYPE_R4] = DataType::FLOAT; + aMap[DBTYPE_R8] = DataType::DOUBLE; + aMap[DBTYPE_CY] = DataType::BIGINT; + aMap[DBTYPE_DATE] = DataType::DATE; + aMap[DBTYPE_BSTR] = DataType::VARCHAR; + aMap[DBTYPE_IDISPATCH] = DataType::OBJECT; + aMap[DBTYPE_ERROR] = DataType::OTHER; + aMap[DBTYPE_BOOL] = DataType::BIT; + aMap[DBTYPE_VARIANT] = DataType::STRUCT; + aMap[DBTYPE_IUNKNOWN] = DataType::OTHER; + aMap[DBTYPE_DECIMAL] = DataType::DECIMAL; + aMap[DBTYPE_UI1] = DataType::TINYINT; + aMap[DBTYPE_ARRAY] = DataType::ARRAY; + aMap[DBTYPE_BYREF] = DataType::REF; + aMap[DBTYPE_I1] = DataType::CHAR; + aMap[DBTYPE_UI2] = DataType::SMALLINT; + aMap[DBTYPE_UI4] = DataType::INTEGER; + + // aMap[The] = ; + // aMap[in] = ; + aMap[DBTYPE_I8] = DataType::BIGINT; + aMap[DBTYPE_UI8] = DataType::BIGINT; + aMap[DBTYPE_GUID] = DataType::OTHER; + aMap[DBTYPE_VECTOR] = DataType::OTHER; + aMap[DBTYPE_FILETIME] = DataType::OTHER; + aMap[DBTYPE_RESERVED] = DataType::OTHER; + + // aMap[The] = ; + aMap[DBTYPE_BYTES] = DataType::VARBINARY; + aMap[DBTYPE_STR] = DataType::LONGVARCHAR; + aMap[DBTYPE_WSTR] = DataType::LONGVARCHAR; + aMap[DBTYPE_NUMERIC] = DataType::NUMERIC; + aMap[DBTYPE_UDT] = DataType::OTHER; + aMap[DBTYPE_DBDATE] = DataType::DATE; + aMap[DBTYPE_DBTIME] = DataType::TIME; + aMap[DBTYPE_DBTIMESTAMP] = DataType::TIMESTAMP; + aMap[DBTYPE_HCHAPTER] = DataType::OTHER; + aMap[DBTYPE_PROPVARIANT] = DataType::OTHER; + aMap[DBTYPE_VARNUMERIC] = DataType::NUMERIC; + + m_aValueRange[2] = aMap; + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setTypeInfoMap(); + m_xMetaData = pMetaData; +} + diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx new file mode 100644 index 000000000000..ede0a0d5be02 --- /dev/null +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx @@ -0,0 +1,515 @@ +/************************************************************************* + * + * $RCSfile: ADatabaseMetaDataResultSetMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADATABASEMETADATARESULTSETMETADATA_HXX_ +#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 +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity; +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +// ------------------------------------------------------------------------- +ODatabaseMetaDataResultSetMetaData::~ODatabaseMetaDataResultSetMetaData() +{ + if(m_pRecordSet) + m_pRecordSet->Release(); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getColumnDisplaySize(); + + if(!m_pRecordSet) + return 0; + ADO_GETFIELD(m_vMapping[column]); + if(aField.IsValid()) + return aField.GetActualSize(); + return 0; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getColumnType(); + if(!m_pRecordSet) + return 0; + ADO_GETFIELD(m_vMapping[column]); + return MapADOType2Jdbc(aField.GetADOType()); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException) +{ + if(!m_pRecordSet) + return 0; + if(m_nColCount != -1) + return m_nColCount; + + if(m_vMapping.size()) + return m_mColumns.size(); + + ADOFields* pFields = NULL; + m_pRecordSet->get_Fields(&pFields); + WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(pFields); + m_nColCount = aFields.GetItemCount(); + return m_nColCount; +} +// ------------------------------------------------------------------------- + +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()) + return (*m_mColumnsIter).second.getColumnName(); + if(!m_pRecordSet) + return ::rtl::OUString(); + ADO_GETFIELD(m_vMapping[column]); + if(aField.IsValid()) + return aField.GetName(); + + 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()) + return (*m_mColumnsIter).second.getColumnLabel(); + 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) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isCurrency(); + if(!m_pRecordSet) + return 0; + ADO_GETFIELD(m_vMapping[column]); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldFixed) == adFldFixed; + } + return sal_False; +} +// ------------------------------------------------------------------------- + +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) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isSigned(); + if(!m_pRecordSet) + return 0; + ADO_GETFIELD(m_vMapping[column]); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldNegativeScale) == adFldNegativeScale; + } + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getPrecision(); + if(!m_pRecordSet) + return 0; + ADO_GETFIELD(m_vMapping[column]); + if(aField.IsValid()) + return aField.GetPrecision(); + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getScale(); + + if(!m_pRecordSet) + return 0; + + ADO_GETFIELD(m_vMapping[column]); + if(aField.IsValid()) + return aField.GetNumericScale(); + return 0; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isNullable(); + + if(!m_pRecordSet) + return 0; + + ADO_GETFIELD(m_vMapping[column]); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldIsNullable) == adFldIsNullable; + } + return sal_False; +} +// ------------------------------------------------------------------------- + +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()) + return (*m_mColumnsIter).second.isReadOnly(); + + if(!m_pRecordSet) + return 0; + + ADO_GETFIELD(m_vMapping[column]); + if(aField.IsValid()) + { + // return (aField.GetStatus() & adFieldReadOnly) == adFieldReadOnly; + } + return sal_False; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isDefinitelyWritable(); + + if(!m_pRecordSet) + return 0; + + ADO_GETFIELD(m_vMapping[column]); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldUpdatable) == adFldUpdatable; + } + return sal_False; +; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isWritable(); + return isDefinitelyWritable(column); +} +// ------------------------------------------------------------------------- +sal_Int32 ODatabaseMetaDataResultSetMetaData::MapADOType2Jdbc(DataTypeEnum eType) +{ + switch (eType) + { + case adUnsignedSmallInt: + case adSmallInt: return DataType::SMALLINT; break; + case adUnsignedInt: + case adInteger: return DataType::INTEGER; break; + case adUnsignedBigInt: + case adBigInt: return DataType::BIGINT; break; + case adSingle: return DataType::FLOAT; break; + case adDouble: return DataType::DOUBLE; break; + case adCurrency: return DataType::DOUBLE; break; + case adVarNumeric: + case adNumeric: return DataType::NUMERIC; break; + case adDecimal: return DataType::DECIMAL; break; + case adDate: + case adDBDate: return DataType::DATE; break; + case adDBTime: return DataType::TIME; break; + case adDBTimeStamp: return DataType::TIMESTAMP; break; + case adBoolean: return DataType::BIT; break; + case adBinary: + case adGUID: return DataType::BINARY; break; + case adBSTR: + case adVarWChar: + case adVarChar: return DataType::VARCHAR; break; + case adLongVarWChar: + case adLongVarChar: return DataType::LONGVARCHAR; break; + case adVarBinary: return DataType::VARBINARY; break; + case adLongVarBinary: return DataType::LONGVARBINARY; break; + case adWChar: + case adChar: return DataType::CHAR; break; + case adUnsignedTinyInt: + case adTinyInt: return DataType::TINYINT; break; + default: + ; + } +} +// ------------------------------------------------------------------------- +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 new file mode 100644 index 000000000000..f0b8ce81a1bf --- /dev/null +++ b/connectivity/source/drivers/ado/ADriver.cxx @@ -0,0 +1,265 @@ +/************************************************************************* + * + * $RCSfile: ADriver.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADRIVER_HXX_ +#include "ado/ADriver.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ACONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_ +#include "ado/Awrapado.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ADOIMP_HXX_ +#include "ado/adoimp.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_CATALOG_HXX_ +#include "ado/ACatalog.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::lang; + +// -------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------- +ODriver::ODriver() : ODriver_BASE(m_aMutex) +{ + CoInitialize(NULL); +} +// ------------------------------------------------------------------------- +ODriver::~ODriver() +{ + CoUninitialize(); +} +//------------------------------------------------------------------------------ +void ODriver::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + + for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) + { + Reference< XComponent > xComp(i->get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + } + m_xConnections.clear(); + + ODriver_BASE::disposing(); +} +// static ServiceInfo +//------------------------------------------------------------------------------ +rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException) +{ + return rtl::OUString::createFromAscii("com.sun.star.sdbc.ADriver"); +} +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > ODriver::getSupportedServiceNames_Static( ) throw (RuntimeException) +{ + Sequence< ::rtl::OUString > aSNS( 2 ); + aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver"); + aSNS[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Driver"); + return aSNS; +} +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::ado::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ) +{ + return *(new ODriver()); +} + +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL ODriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) + if (pSupported->equals(_rServiceName)) + return sal_True; + + return sal_False; +} + +// -------------------------------------------------------------------------------- +Sequence< ::rtl::OUString > SAL_CALL ODriver::getSupportedServiceNames( ) throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +// -------------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) +{ + OConnection* pCon = new OConnection(url,info,this); + pCon->construct(url,info); + Reference< XConnection > xCon = pCon; + m_xConnections.push_back(WeakReferenceHelper(*pCon)); + + return xCon; +} +// -------------------------------------------------------------------------------- +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; +} +// -------------------------------------------------------------------------------- +Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) +{ + return Sequence< DriverPropertyInfo >(); +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODriver::getMajorVersion( ) throw(RuntimeException) +{ + return 1; +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODriver::getMinorVersion( ) throw(RuntimeException) +{ + return 0; +} +// -------------------------------------------------------------------------------- +// XDataDefinitionSupplier +Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByConnection( const Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODriver_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OConnection* pConnection = NULL; + for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) + { + if ((OConnection*) Reference< XConnection >::query(i->get().get()).get() == (OConnection*)connection.get()) + { + pConnection = (OConnection*)connection.get(); + break; + } + } + Reference< XTablesSupplier > xTab = NULL; + if(pConnection) + { + WpADOCatalog aCatalog; + aCatalog.Create(); + if(aCatalog.IsValid()) + { + aCatalog.putref_ActiveConnection(*pConnection->getConnection()); + xTab = new OCatalog(aCatalog,pConnection); + pConnection->setCatalog(xTab); + } + } + return xTab; +} +// -------------------------------------------------------------------------------- +Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + 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 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 ) ) + { + pInterface = pCommand; + pInterface->AddRef(); + } +} + + diff --git a/connectivity/source/drivers/ado/AGroup.cxx b/connectivity/source/drivers/ado/AGroup.cxx new file mode 100644 index 000000000000..971922addf62 --- /dev/null +++ b/connectivity/source/drivers/ado/AGroup.cxx @@ -0,0 +1,342 @@ +/************************************************************************* + * + * $RCSfile: AGroup.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_GROUP_HXX_ +#include "ado/AGroup.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_USERS_HXX_ +#include "ado/AUsers.hxx" +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/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> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; + +// ------------------------------------------------------------------------- +void WpADOGroup::Create() +{ + IClassFactory2* pIUnknown = NULL; + IUnknown *pOuter = NULL; + HRESULT hr = -1; + ADOGroup* pCommand; + hr = CoCreateInstance(ADOS::CLSID_ADOGROUP_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOGROUP_25, + (void**)&pCommand ); + + + if( !FAILED( hr ) ) + { + pInterface = pCommand; + pInterface->AddRef(); + } +} +// ------------------------------------------------------------------------- +OAdoGroup::OAdoGroup(sal_Bool _bCase, ADOGroup* _pGroup) : OGroup_ADO(_bCase) +{ + construct(); + if(_pGroup) + m_aGroup = WpADOGroup(_pGroup); + else + m_aGroup.Create(); + + refreshUsers(); +} +// ------------------------------------------------------------------------- +OAdoGroup::OAdoGroup(sal_Bool _bCase, const ::rtl::OUString& _Name) : OGroup_ADO(_Name,_bCase) +{ + construct(); + m_aGroup.Create(); + m_aGroup.put_Name(_Name); + refreshUsers(); +} +// ------------------------------------------------------------------------- +void OAdoGroup::refreshUsers() +{ + ::std::vector< ::rtl::OUString> aVector; + + ADOUsers* pUsers = m_aGroup.get_Users(); + if(pUsers) + { + pUsers->Refresh(); + + sal_Int32 nCount = 0; + pUsers->get_Count(&nCount); + for(sal_Int32 i=0;i< nCount;++i) + { + ADOUser* pUser = NULL; + pUsers->get_Item(OLEVariant(i),&pUser); + if(pUser) + { + WpADOUser aUser(pUser); + aVector.push_back(aUser.get_Name()); + } + } + } + + if(m_pUsers) + delete m_pUsers; + m_pUsers = new OUsers(*this,m_aMutex,aVector,pUsers,isCaseSensitive()); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OAdoGroup::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); + if(aRet.hasValue()) + return aRet; + return OGroup_ADO::queryInterface(rType); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OAdoGroup::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OGroup_ADO::getTypes()); +} +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoGroup::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoGroup::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; +} + +// ------------------------------------------------------------------------- +void OAdoGroup::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + if(m_aGroup.IsValid()) + { + + switch(nHandle) + { + case PROPERTY_ID_NAME: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aGroup.put_Name(aVal); + } + break; + } + } +} +// ------------------------------------------------------------------------- +void OAdoGroup::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + if(m_aGroup.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + rValue <<= m_aGroup.get_Name(); + break; + } + } +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OAdoGroup::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + return MapRight(m_aGroup.GetPermissions(objName,MapObjectType(objType))); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OAdoGroup::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + RightsEnum eNum = m_aGroup.GetPermissions(objName,MapObjectType(objType)); + if(eNum & adRightWithGrant) + return MapRight(eNum); + return 0; +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoGroup::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + m_aGroup.SetPermissions(objName,MapObjectType(objType),adAccessGrant,Map2Right(objPrivileges)); +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoGroup::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + 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; +} + + diff --git a/connectivity/source/drivers/ado/AGroups.cxx b/connectivity/source/drivers/ado/AGroups.cxx new file mode 100644 index 000000000000..d3e75885d029 --- /dev/null +++ b/connectivity/source/drivers/ado/AGroups.cxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * $RCSfile: AGroups.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_GROUPS_HXX_ +#include "ado/AGroups.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_GROUP_HXX_ +#include "ado/AGroup.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_TABLE_HXX_ +#include "ado/ATable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_ +#include "connectivity/sdbcx/IRefreshable.hxx" +#endif + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::container; + +typedef connectivity::sdbcx::OCollection OCollection_TYPE; +// ------------------------------------------------------------------------- +Reference< XNamed > OGroups::createObject(const ::rtl::OUString& _rName) +{ + Reference< XNamed > xRet = NULL; + OAdoGroup* pRet = new OAdoGroup(isCaseSensitive(),_rName); + xRet = pRet; + return xRet; +} +// ------------------------------------------------------------------------- +void OGroups::impl_refresh() throw(RuntimeException) +{ + m_pCollection->Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OGroups::createEmptyObject() +{ + OAdoGroup* pNew = new OAdoGroup(isCaseSensitive()); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OGroups::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(descriptor,UNO_QUERY); + if(xTunnel.is()) + { + OAdoGroup* pGroup = (OAdoGroup*)xTunnel->getSomething(OAdoGroup::getUnoTunnelImplementationId()); + m_pCollection->Append(OLEVariant(pGroup->getImpl())); + } + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OGroups::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + m_pCollection->Delete(OLEVariant(elementName)); + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OGroups::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + m_pCollection->Delete(OLEVariant(index)); + + OCollection_TYPE::dropByIndex(index); +} + + diff --git a/connectivity/source/drivers/ado/AIndex.cxx b/connectivity/source/drivers/ado/AIndex.cxx new file mode 100644 index 000000000000..f5c60ea843b9 --- /dev/null +++ b/connectivity/source/drivers/ado/AIndex.cxx @@ -0,0 +1,283 @@ +/************************************************************************* + * + * $RCSfile: AIndex.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_INDEX_HXX_ +#include "ado/AIndex.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CONNECTIVITY_ADO_COLUMNS_HXX_ +#include "ado/AColumns.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +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 ) ) + { + pInterface = pCommand; + pInterface->AddRef(); + } +} +// ------------------------------------------------------------------------- +OAdoIndex::OAdoIndex(sal_Bool _bCase, ADOIndex* _pIndex) : OIndex_ADO(_bCase) +{ + construct(); + if(_pIndex) + m_aIndex = WpADOIndex(_pIndex); + else + m_aIndex.Create(); + + refreshColumns(); +} +// ------------------------------------------------------------------------- +OAdoIndex::OAdoIndex( const ::rtl::OUString& _Name, + const ::rtl::OUString& _Catalog, + sal_Bool _isUnique, + sal_Bool _isPrimaryKeyIndex, + sal_Bool _isClustered, + sal_Bool _bCase + ) : OIndex_ADO(_Name, + _Catalog, + _isUnique, + _isPrimaryKeyIndex, + _isClustered,_bCase) +{ + construct(); + m_aIndex.Create(); + m_aIndex.put_Name(_Name); + m_aIndex.put_Unique(_isUnique); + m_aIndex.put_PrimaryKey(_isPrimaryKeyIndex); + m_aIndex.put_Clustered(_isClustered); + + refreshColumns(); +} +// ------------------------------------------------------------------------- + +void OAdoIndex::refreshColumns() +{ + ::std::vector< ::rtl::OUString> aVector; + + ADOColumns* pColumns = m_aIndex.get_Columns(); + if(pColumns) + { + pColumns->Refresh(); + + sal_Int32 nCount = 0; + pColumns->get_Count(&nCount); + for(sal_Int32 i=0;i< nCount;++i) + { + ADOColumn* pColumn = NULL; + pColumns->get_Item(OLEVariant(i),&pColumn); + if(pColumn) + { + WpADOColumn aColumn(pColumn); + aVector.push_back(aColumn.get_Name()); + } + } + } + if(m_pColumns) + delete m_pColumns; + m_pColumns = new OColumns(*this,m_aMutex,aVector,pColumns,isCaseSensitive()); +} + +// ------------------------------------------------------------------------- +Any SAL_CALL OAdoIndex::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); + if(aRet.hasValue()) + return aRet; + return OIndex_ADO::queryInterface(rType); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OAdoIndex::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OIndex_ADO::getTypes()); +} +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoIndex::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoIndex::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoIndex::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + if(m_aIndex.IsValid()) + { + + switch(nHandle) + { + case PROPERTY_ID_NAME: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aIndex.put_Name(aVal); + } + break; + case PROPERTY_ID_CATALOG: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aIndex.put_Name(aVal); + } + break; + case PROPERTY_ID_ISUNIQUE: + m_aIndex.put_Unique(getBOOL(rValue)); + break; + case PROPERTY_ID_ISPRIMARYKEYINDEX: + m_aIndex.put_PrimaryKey(getBOOL(rValue)); + break; + case PROPERTY_ID_ISCLUSTERED: + m_aIndex.put_Clustered(getBOOL(rValue)); + break; + } + } +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoIndex::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + if(m_aIndex.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + rValue <<= m_aIndex.get_Name(); + break; + case PROPERTY_ID_CATALOG: + // rValue <<= getResultSetType(); + break; + case PROPERTY_ID_ISUNIQUE: + { + sal_Bool _b = m_aIndex.get_Unique(); + rValue <<= Any(&_b, ::getBooleanCppuType()); + } + break; + case PROPERTY_ID_ISPRIMARYKEYINDEX: + { + sal_Bool _b = m_aIndex.get_PrimaryKey(); + rValue <<= Any(&_b, ::getBooleanCppuType()); + } + break; + case PROPERTY_ID_ISCLUSTERED: + { + sal_Bool _b = m_aIndex.get_Clustered(); + rValue <<= Any(&_b, ::getBooleanCppuType()); + } + break; + } + } +} + + + + diff --git a/connectivity/source/drivers/ado/AIndexes.cxx b/connectivity/source/drivers/ado/AIndexes.cxx new file mode 100644 index 000000000000..798f54916660 --- /dev/null +++ b/connectivity/source/drivers/ado/AIndexes.cxx @@ -0,0 +1,148 @@ +/************************************************************************* + * + * $RCSfile: AIndexes.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_INDEXES_HXX_ +#include "ado/AIndexes.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_INDEX_HXX_ +#include "ado/AIndex.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_INDEXTYPE_HPP_ +#include <com/sun/star/sdbc/IndexType.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::container; + +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OIndexes::createObject(const ::rtl::OUString& _rName) +{ + ADOIndex* pIndex = NULL; + m_pCollection->get_Item(OLEVariant(_rName),&pIndex); + + Reference< XNamed > xRet = new OAdoIndex(isCaseSensitive(),pIndex); + + return xRet; +} +// ------------------------------------------------------------------------- +void OIndexes::impl_refresh() throw(RuntimeException) +{ + m_pCollection->Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OIndexes::createEmptyObject() +{ + OAdoIndex* pNew = new OAdoIndex(isCaseSensitive()); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OIndexes::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(descriptor,UNO_QUERY); + if(xTunnel.is()) + { + OAdoIndex* pIndex = (OAdoIndex*)xTunnel->getSomething(OAdoIndex:: getUnoTunnelImplementationId()); + m_pCollection->Append(OLEVariant(getString(descriptor->getPropertyValue(PROPERTY_NAME))), + OLEVariant(pIndex->getImpl())); + } + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OIndexes::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + m_pCollection->Delete(OLEVariant(elementName)); + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OIndexes::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + m_pCollection->Delete(OLEVariant(index)); + + OCollection_TYPE::dropByIndex(index); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/AKey.cxx b/connectivity/source/drivers/ado/AKey.cxx new file mode 100644 index 000000000000..6a7f7a437cf7 --- /dev/null +++ b/connectivity/source/drivers/ado/AKey.cxx @@ -0,0 +1,326 @@ +/************************************************************************* + * + * $RCSfile: AKey.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_KEY_HXX_ +#include "ado/AKey.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif +#ifndef _CONNECTIVITY_ADO_COLUMNS_HXX_ +#include "ado/AColumns.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +// ------------------------------------------------------------------------- +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 ) ) + { + pInterface = pCommand; + pInterface->AddRef(); + } +} +// ------------------------------------------------------------------------- +OAdoKey::OAdoKey(sal_Bool _bCase, ADOKey* _pKey) : OKey_ADO(_bCase) +{ + construct(); + if(_pKey) + m_aKey = WpADOKey(_pKey); + else + m_aKey.Create(); + + refreshColumns(); +} +// ------------------------------------------------------------------------- +OAdoKey::OAdoKey( const ::rtl::OUString& _Name, + const ::rtl::OUString& _ReferencedTable, + sal_Int32 _Type, + sal_Int32 _UpdateRule, + sal_Int32 _DeleteRule, + sal_Bool _bCase + ) : OKey_ADO(_Name, + _ReferencedTable, + _Type, + _UpdateRule, + _DeleteRule,_bCase) +{ + construct(); + m_aKey.Create(); + m_aKey.put_Name(_Name); + m_aKey.put_UpdateRule(Map2Rule(_UpdateRule)); + m_aKey.put_DeleteRule(Map2Rule(_DeleteRule)); + m_aKey.put_RelatedTable(_ReferencedTable); + m_aKey.put_Type((KeyTypeEnum)_Type); + + refreshColumns(); +} +// ------------------------------------------------------------------------- +void OAdoKey::refreshColumns() +{ + ::std::vector< ::rtl::OUString> aVector; + + ADOColumns* pColumns = m_aKey.get_Columns(); + if(pColumns) + { + pColumns->Refresh(); + + sal_Int32 nCount = 0; + pColumns->get_Count(&nCount); + for(sal_Int32 i=0;i< nCount;++i) + { + ADOColumn* pColumn = NULL; + pColumns->get_Item(OLEVariant(i),&pColumn); + if(pColumn) + { + WpADOColumn aColumn(pColumn); + aVector.push_back(aColumn.get_Name()); + } + } + } + + m_pColumns = new OColumns(*this,m_aMutex,aVector,pColumns,isCaseSensitive()); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OAdoKey::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); + if(aRet.hasValue()) + return aRet; + return OKey_ADO::queryInterface(rType); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OAdoKey::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OKey_ADO::getTypes()); +} +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoKey::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoKey::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; +} +// ------------------------------------------------------------------------- +void OAdoKey::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + if(m_aKey.IsValid()) + { + + switch(nHandle) + { + case PROPERTY_ID_NAME: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aKey.put_Name(aVal); + } + break; + case PROPERTY_ID_TYPE: + { + sal_Int32 nVal=0; + rValue >>= nVal; + m_aKey.put_Type((KeyTypeEnum)nVal); + } + break; + case PROPERTY_ID_REFERENCEDTABLE: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aKey.put_RelatedTable(aVal); + } + break; + case PROPERTY_ID_UPDATERULE: + { + sal_Int32 nVal=0; + rValue >>= nVal; + m_aKey.put_UpdateRule(Map2Rule(nVal)); + } + break; + case PROPERTY_ID_DELETERULE: + { + sal_Int32 nVal=0; + rValue >>= nVal; + m_aKey.put_DeleteRule(Map2Rule(nVal)); + } + break; + } + } +} +// ------------------------------------------------------------------------- +void OAdoKey::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + if(m_aKey.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + rValue <<= m_aKey.get_Name(); + break; + case PROPERTY_ID_TYPE: + rValue <<= (sal_Int32)m_aKey.get_Type(); + break; + case PROPERTY_ID_REFERENCEDTABLE: + rValue <<= m_aKey.get_RelatedTable(); + break; + case PROPERTY_ID_UPDATERULE: + rValue <<= MapRule(m_aKey.get_UpdateRule()); + break; + case PROPERTY_ID_DELETERULE: + rValue <<= MapRule(m_aKey.get_DeleteRule()); + break; + } + } +} +// ------------------------------------------------------------------------- +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; +} + + diff --git a/connectivity/source/drivers/ado/AKeyColumn.cxx b/connectivity/source/drivers/ado/AKeyColumn.cxx new file mode 100644 index 000000000000..2ed8f753acec --- /dev/null +++ b/connectivity/source/drivers/ado/AKeyColumn.cxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * $RCSfile: AKeyColumn.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADABAS_KEYCOLUMN_HXX_ +#include "adabas/BKeyColumn.hxx" +#endif + +using namespace connectivity::adabas; +namespace starbeans = ::com::sun::star::beans; +// ------------------------------------------------------------------------- +OKeyColumn::OKeyColumn() : OColumn() +{ + construct(); +} +// ------------------------------------------------------------------------- +OKeyColumn::OKeyColumn( const ::rtl::OUString& _ReferencedColumn, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _TypeName, + const ::rtl::OUString& _DefaultValue, + sal_Int32 _IsNullable, + sal_Int32 _Precision, + sal_Int32 _Scale, + sal_Int32 _Type, + sal_Bool _IsAutoIncrement + ) : OColumn(_Name, + _TypeName, + _DefaultValue, + _IsNullable, + _Precision, + _Scale, + _Type, + _IsAutoIncrement) + , m_ReferencedColumn(_ReferencedColumn) +{ + construct(); +} +// ------------------------------------------------------------------------- +void OKeyColumn::construct() +{ + sal_Int32 nAttrib = isNew() ? 0 : starbeans::PropertyAttribute::READONLY; + registerProperty(PROPERTY_REFERENCEDCOLUMN, PROPERTY_ID_REFERENCEDCOLUMN, nAttrib,&m_ReferencedColumn, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); +} + diff --git a/connectivity/source/drivers/ado/AKeyColumns.cxx b/connectivity/source/drivers/ado/AKeyColumns.cxx new file mode 100644 index 000000000000..251dfbe4ca6a --- /dev/null +++ b/connectivity/source/drivers/ado/AKeyColumns.cxx @@ -0,0 +1,142 @@ +/************************************************************************* + * + * $RCSfile: AKeyColumns.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_ADABAS_KEYCOLUMNS_HXX_ +#include "adabas/BKeyColumns.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_KEYCOLUMN_HXX_ +#include "adabas/BKeyColumn.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif + +using namespace connectivity::adabas; +// ------------------------------------------------------------------------- +staruno::Reference< starcontainer::XNamed > OKeyColumns::createObject(const ::rtl::OUString& _rName) +{ + + staruno::Reference< starsdbc::XResultSet > + xResult = m_pTable->getConnection()->getMetaData()->getImportedKeys(staruno::Any(), + m_pTable->getSchema(),m_pTable->getName()); + + ::rtl::OUString aRefColumnName; + if(xResult.is()) + { + staruno::Reference< starsdbc::XRow > xRow(xResult,staruno::UNO_QUERY); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + while(xResult->next()) + { + if(xRow->getString(8) == _rName) + { + aRefColumnName = xRow->getString(4); + break; + } + } + } + + xResult = m_pTable->getConnection()->getMetaData()->getColumns(staruno::Any(), + m_pTable->getSchema(),m_pTable->getName(),_rName); + + staruno::Reference< starcontainer::XNamed > xRet = NULL; + if(xResult.is()) + { + staruno::Reference< starsdbc::XRow > xRow(xResult,staruno::UNO_QUERY); + if(xResult->next()) + { + if(xRow->getString(4) == _rName) + { + OKeyColumn* pRet = new OKeyColumn(aRefColumnName, + _rName, + xRow->getString(6), + xRow->getString(13), + xRow->getInt(11), + xRow->getInt(7), + xRow->getInt(9), + xRow->getInt(5), + sal_False); + xRet = pRet; + } + } + } + + return xRet; +} +// ------------------------------------------------------------------------- +staruno::Reference< starbeans::XPropertySet > OKeyColumns::createEmptyObject() +{ + OKeyColumn* pNew = new OKeyColumn(); + return pNew; +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/ado/AKeys.cxx b/connectivity/source/drivers/ado/AKeys.cxx new file mode 100644 index 000000000000..e24988173ad3 --- /dev/null +++ b/connectivity/source/drivers/ado/AKeys.cxx @@ -0,0 +1,153 @@ +/************************************************************************* + * + * $RCSfile: AKeys.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_KEYS_HXX_ +#include "ado/AKeys.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_INDEX_HXX_ +#include "ado/AKey.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ +#include <com/sun/star/sdbcx/KeyType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::container; + +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OKeys::createObject(const ::rtl::OUString& _rName) +{ + ADOKey* pKey = NULL; + m_pCollection->get_Item(OLEVariant(_rName),&pKey); + + Reference< XNamed > xRet = new OAdoKey(isCaseSensitive(),pKey); + + return xRet; +} +// ------------------------------------------------------------------------- +void OKeys::impl_refresh() throw(RuntimeException) +{ + m_pCollection->Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OKeys::createEmptyObject() +{ + OAdoKey* pNew = new OAdoKey(isCaseSensitive()); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OKeys::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(descriptor,UNO_QUERY); + if(xTunnel.is()) + { + OAdoKey* pKey = (OAdoKey*)xTunnel->getSomething(OAdoKey:: getUnoTunnelImplementationId()); + // To pass as column parameter to Key's Apppend method + OLEVariant vOptional; + vOptional.vt = VT_ERROR; + vOptional.scode = DISP_E_PARAMNOTFOUND; + + m_pCollection->Append(OLEVariant(pKey->getImpl()),(KeyTypeEnum)getINT32(descriptor->getPropertyValue(PROPERTY_TYPE)),vOptional); + } + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OKeys::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + m_pCollection->Delete(OLEVariant(elementName)); + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OKeys::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + m_pCollection->Delete(OLEVariant(index)); + + OCollection_TYPE::dropByIndex(index); +} + diff --git a/connectivity/source/drivers/ado/APreparedStatement.cxx b/connectivity/source/drivers/ado/APreparedStatement.cxx new file mode 100644 index 000000000000..423bff42b47c --- /dev/null +++ b/connectivity/source/drivers/ado/APreparedStatement.cxx @@ -0,0 +1,446 @@ +/************************************************************************* + * + * $RCSfile: APreparedStatement.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * 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_APREPAREDSTATEMENT_HXX_ +#include "ado/APreparedStatement.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _CONNECTIVITY_ADO_ARESULTSETMETADATA_HXX_ +#include "ado/AResultSetMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ARESULTSET_HXX_ +#include "ado/AResultSet.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif + +#define CHECK_RETURN(x) \ + if(!x) \ + ADOS::ThrowException(*m_pConnection->getConnection(),*this); + +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +using namespace connectivity::ado; +using namespace connectivity; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::util; + + +IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.APreparedStatement","com.sun.star.sdbc.PreparedStatement"); + +OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const ::std::vector<OTypeInfo>& _TypeInfo,const ::rtl::OUString& sql) + : OStatement_Base( _pConnection ),m_aTypeInfo(_TypeInfo) +{ + osl_incrementInterlockedCount( &m_refCount ); + + CHECK_RETURN(m_Command.put_CommandText(sql)) + CHECK_RETURN(m_Command.put_Prepared(VARIANT_TRUE)) + m_pParameters = m_Command.get_Parameters(); + m_pParameters->AddRef(); + m_pParameters->Refresh(); + + osl_decrementInterlockedCount( &m_refCount ); +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OStatement_Base::queryInterface(rType); + if(!aRet.hasValue()) + aRet = ::cppu::queryInterface( rType, + static_cast< XPreparedStatement*>(this), + static_cast< XParameters*>(this), + static_cast< XPreparedBatchExecution*>(this), + static_cast< XResultSetMetaDataSupplier*>(this)); + return aRet; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XResultSetMetaDataSupplier > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedBatchExecution > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OStatement_Base::getTypes()); +} +// ------------------------------------------------------------------------- + +Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException) +{ + Reference< XResultSetMetaData > xRef = new OResultSetMetaData(m_RecordSet); + return xRef; +} +// ------------------------------------------------------------------------- +void OPreparedStatement::disposing() +{ + if(m_RecordSet.IsValid()) + m_RecordSet.Close(); + if(m_pParameters) + m_pParameters->Release(); + OStatement_Base::disposing(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::close( ) throw(SQLException, RuntimeException) +{ + + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + } + dispose(); + +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + SQLWarning warning; + + // Reset warnings + + clearWarnings (); + + // Reset the statement handle, warning and saved Resultset + + reset(); + + // Call SQLExecute + + try { + ADORecordset* pSet=NULL; + CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdUnknown,&pSet)) + m_RecordSet = WpADORecordset(pSet); + } + catch (SQLWarning& ex) + { + + // Save pointer to warning and save with ResultSet + // object once it is created. + + warning = ex; + } + return m_RecordSet.IsValid(); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ADORecordset* pSet=NULL; + CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdUnknown,&pSet)) + m_RecordSet = WpADORecordset(pSet); + return m_RecordsAffected; +} + +// ------------------------------------------------------------------------- +void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const DataTypeEnum& _eType, + const sal_Int32& _nSize,const OLEVariant& _Val) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 nCount = 0; + m_pParameters->get_Count(&nCount); + if(!nCount) + { + + ADOParameter* pParam = m_Command.CreateParameter(::rtl::OUString(),_eType,adParamInput,_nSize,_Val); + if(pParam) + { + pParam->AddRef(); + m_pParameters->Append(pParam); + } + } + else + { + ADOParameter* pParam = NULL; + m_pParameters->get_Item(OLEVariant(parameterIndex-1),&pParam); + if(pParam) + pParam->put_Value(_Val); + } + ADOS::ThrowException(*m_pConnection->getConnection(),*this); +} +// ------------------------------------------------------------------------- +void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adLongVarWChar,x.getLength(),x); +} +// ------------------------------------------------------------------------- + +Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return (Reference< XConnection >)m_pConnection; +} +// ------------------------------------------------------------------------- + +Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + WpADORecordset aSet; + aSet.Create(); + OLEVariant aCmd; + aCmd.setIDispatch(m_Command); + OLEVariant aCon; + aCon.setNoArg(); + CHECK_RETURN(aSet.put_CacheSize(m_nFetchSize)) + CHECK_RETURN(aSet.put_MaxRecords(m_nMaxRows)) + CHECK_RETURN(aSet.Open(aCmd,aCon,m_eCursorType,m_eLockType,adOpenUnspecified)) + + CHECK_RETURN(aSet.get_CacheSize(m_nFetchSize)) + CHECK_RETURN(aSet.get_MaxRecords(m_nMaxRows)) + CHECK_RETURN(aSet.get_CursorType(m_eCursorType)) + CHECK_RETURN(aSet.get_LockType(m_eLockType)) + + OResultSet* pSet = new OResultSet(aSet,this); + Reference< XResultSet > pRs = pSet; + m_xResultSet = WeakReference<XResultSet>(pRs); + + return m_xResultSet; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adBoolean,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adTinyInt,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adDBDate,sizeof(x),x); +} +// ------------------------------------------------------------------------- + + +void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adDBTime,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adDBTimeStamp,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adDouble,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adSingle,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adInteger,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adBigInt,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(SQLException, RuntimeException) +{ + OLEVariant aVal; + aVal.setNull(); + setParameter(parameterIndex,adEmpty,0,aVal); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setArray( sal_Int32 parameterIndex, const Reference< XArray >& x ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setRef( sal_Int32 parameterIndex, const Reference< XRef >& x ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(SQLException, RuntimeException) +{ + setNull(parameterIndex,sqlType); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException) +{ + // setObject (parameterIndex, x, sqlType, 0); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adSmallInt,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adVarBinary,sizeof(sal_Int8)*x.getLength(),x); +} + +// ------------------------------------------------------------------------- + + +void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(m_pParameters) + { + sal_Int32 nCount = 0; + m_pParameters->get_Count(&nCount); + for(sal_Int32 i=nCount-1;i>=0;--i) + m_pParameters->Delete(OLEVariant(i)); + + } +} +// ------------------------------------------------------------------------- +void SAL_CALL OPreparedStatement::clearBatch( ) throw(SQLException, RuntimeException) +{ + // clearParameters( ); + // m_aBatchList.erase(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::addBatch( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +Sequence< sal_Int32 > SAL_CALL OPreparedStatement::executeBatch( ) throw(SQLException, RuntimeException) +{ + return Sequence< sal_Int32 > (); +} + + diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx new file mode 100644 index 000000000000..f85bed5f0207 --- /dev/null +++ b/connectivity/source/drivers/ado/AResultSet.cxx @@ -0,0 +1,1269 @@ +/************************************************************************* + * + * $RCSfile: AResultSet.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_ARESULTSET_HXX_ +#include "ado/AResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ARESULTSETMETADATA_HXX_ +#include "ado/AResultSetMetaData.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_INDEXTYPE_HPP_ +#include <com/sun/star/sdbc/IndexType.hpp> +#endif +#ifndef _UTL_PROPERTY_HXX_ +#include <unotools/property.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_FETCHDIRECTION_HPP_ +#include <com/sun/star/sdbc/FetchDirection.hpp> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif + +#include <oledb.h> + +#define CHECK_RETURN(x) \ + if(!SUCCEEDED(x)) \ + ADOS::ThrowException(*m_pStmt->m_pConnection->getConnection(),*this); + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +//------------------------------------------------------------------------------ +// IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.AResultSet","com.sun.star.sdbc.ResultSet"); +::rtl::OUString SAL_CALL OResultSet::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) \ +{ + return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ado.ResultSet"); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(2); + aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet"); + aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet"); + return aSupported; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) + if (pSupported->equals(_rServiceName)) + return sal_True; + + return sal_False; +} +// ------------------------------------------------------------------------- +OResultSet::OResultSet(ADORecordset* _pRecordSet,OStatement_Base* pStmt) : OResultSet_BASE(m_aMutex) + ,OPropertySetHelper(OResultSet_BASE::rBHelper) + ,m_aStatement((::cppu::OWeakObject*)pStmt) + ,m_pStmt(pStmt) + ,m_nRowPos(0) + ,m_xMetaData(NULL) + ,m_pRecordSet(_pRecordSet) + ,m_bEOF(sal_False) +{ + osl_incrementInterlockedCount( &m_refCount ); + OSL_ENSHURE(_pRecordSet,"No RecordSet !"); + if(!_pRecordSet) + throw SQLException(); + m_pRecordSet->AddRef(); + VARIANT_BOOL bIsAtBOF; + CHECK_RETURN(m_pRecordSet->get_BOF(&bIsAtBOF)) + m_bOnFirstAfterOpen = !(sal_Bool)bIsAtBOF; + osl_decrementInterlockedCount( &m_refCount ); +} +// ------------------------------------------------------------------------- +OResultSet::OResultSet(ADORecordset* _pRecordSet) : OResultSet_BASE(m_aMutex) + ,OPropertySetHelper(OResultSet_BASE::rBHelper) + ,m_aStatement(NULL) + ,m_xMetaData(NULL) + ,m_pRecordSet(_pRecordSet) + ,m_bEOF(sal_False) +{ + osl_incrementInterlockedCount( &m_refCount ); + OSL_ENSHURE(_pRecordSet,"No RecordSet !"); + if(!_pRecordSet) + throw SQLException(); + m_pRecordSet->AddRef(); + VARIANT_BOOL bIsAtBOF; + CHECK_RETURN(m_pRecordSet->get_BOF(&bIsAtBOF)) + m_bOnFirstAfterOpen = !(sal_Bool)bIsAtBOF; + osl_decrementInterlockedCount( &m_refCount ); + // allocBuffer(); +} + +// ------------------------------------------------------------------------- +OResultSet::~OResultSet() +{ + if(m_pRecordSet) + m_pRecordSet->Release(); +} +// ------------------------------------------------------------------------- +void OResultSet::disposing(void) +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + if(m_pRecordSet) + m_pRecordSet->Close(); + m_aStatement = NULL; + m_xMetaData = NULL; +} +// ------------------------------------------------------------------------- +Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OPropertySetHelper::queryInterface(rType); + if(!aRet.hasValue()) + aRet = OResultSet_BASE::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes()); +} + +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + Reference< XResultSetMetaData > xMeta = getMetaData(); + sal_Int32 nLen = xMeta->getColumnCount(); + sal_Int32 i = 1; + for(;i<=nLen;++i) + if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) : columnName.equalsIgnoreCase(xMeta->getColumnName(i))) + break; + return i; +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + return NULL; +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + return NULL; +} + +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +::com::sun::star::util::Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + PositionEnum aPos; + m_pRecordSet->get_AbsolutePosition(&aPos); + return (aPos > 0) ? aPos : m_nRowPos; + // return the rowcount from driver if the driver doesn't support this return our count +} +// ------------------------------------------------------------------------- + +sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ADO_GETFIELD(columnIndex); + return sal_Int64(0); +} +// ------------------------------------------------------------------------- + +Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_xMetaData.is()) + m_xMetaData = new OResultSetMetaData(m_pRecordSet); + return m_xMetaData; +} +// ------------------------------------------------------------------------- +Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + + return NULL; +} + +// ------------------------------------------------------------------------- + +Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + + return NULL; +} +// ------------------------------------------------------------------------- + +Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + + return NULL; +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) +{ + + return Any(); +} +// ------------------------------------------------------------------------- + +sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ADO_GETFIELD(columnIndex); + m_aValue = aField.get_Value(); + return m_aValue; +} + +// ------------------------------------------------------------------------- + + +::com::sun::star::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + + +::com::sun::star::util::DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ADO_GETFIELD(columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int16 bIsAtEOF; + CHECK_RETURN(m_pRecordSet->get_EOF(&bIsAtEOF)) + return bIsAtEOF; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_nRowPos == 1; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return sal_True; +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(first()) + previous(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(last()) + next(); + m_bEOF = sal_True; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + } + dispose(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(SUCCEEDED(m_pRecordSet->MoveFirst())) + { + m_nRowPos = 1; + return sal_True; + } + return sal_False; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Bool bRet = SUCCEEDED(m_pRecordSet->MoveLast()); + if(bRet) + m_pRecordSet->get_RecordCount(&m_nRowPos); + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!row) // absolute with zero not allowed + throw SQLException(); + + sal_Bool bCheck = sal_True; + if(row < 0) + { + if(bCheck = SUCCEEDED(m_pRecordSet->MoveLast())) + { + while(++row < 0 && bCheck) + bCheck = m_pRecordSet->MovePrevious(); + } + } + else + { + first(); + OLEVariant aEmpty; + aEmpty.setNoArg(); + bCheck = SUCCEEDED(m_pRecordSet->Move(row-1,aEmpty)); // move to row -1 because we stand already on the first + if(bCheck) + m_nRowPos = row; + } + return bCheck; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OLEVariant aEmpty; + aEmpty.setNoArg(); + sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty)); + if(bRet) + m_nRowPos += row; + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Bool bRet = SUCCEEDED(m_pRecordSet->MovePrevious()); + if(bRet) + --m_nRowPos; + return bRet; +} +// ------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException) +{ + return m_aStatement.get(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + RecordStatusEnum eRec; + m_pRecordSet->get_Status((sal_Int32*)&eRec); + sal_Bool bRet = (eRec & adRecDeleted) == adRecDeleted; + if(bRet) + --m_nRowPos; + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException) +{ ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + RecordStatusEnum eRec; + m_pRecordSet->get_Status((sal_Int32*)&eRec); + sal_Bool bRet = (eRec & adRecNew) == adRecNew; + if(bRet) + ++m_nRowPos; + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + RecordStatusEnum eRec; + m_pRecordSet->get_Status((sal_Int32*)&eRec); + return (eRec & adRecModified) == adRecModified; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OSL_ENSHURE(!m_nRowPos,"OResultSet::isBeforeFirst: Error in setting m_nRowPos!"); + sal_Int16 bIsAtBOF; + m_pRecordSet->get_BOF(&bIsAtBOF); + return bIsAtBOF; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Bool bRet = sal_True; + if(m_bOnFirstAfterOpen) + { + m_bOnFirstAfterOpen = sal_False; + ++m_nRowPos; + } + else + { + bRet = SUCCEEDED(m_pRecordSet->MoveNext()); + + if(bRet) + { + VARIANT_BOOL bIsAtEOF; + CHECK_RETURN(m_pRecordSet->get_EOF(&bIsAtEOF)) + bRet = !(sal_Bool)bIsAtEOF; + ++m_nRowPos; + } + else + ADOS::ThrowException(*m_pStmt->m_pConnection->getConnection(),*this); + } + + return bRet; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_aValue.isNull(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::cancel( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_pRecordSet->Cancel(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- +Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException) +{ + return Any(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OLEVariant aEmpty; + aEmpty.setNoArg(); + m_pRecordSet->AddNew(aEmpty,aEmpty); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OLEVariant aEmpty; + aEmpty.setNoArg(); + m_pRecordSet->Update(aEmpty,aEmpty); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::deleteRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_pRecordSet->Delete(adAffectCurrent); + m_pRecordSet->UpdateBatch(adAffectCurrent); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_pRecordSet->CancelUpdate(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + OLEVariant x; + x.setNull(); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + aField.PutValue(x); +} +// ----------------------------------------------------------------------- +void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + ADO_GETFIELD(columnIndex); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_pRecordSet->Resync(adAffectCurrent,adResyncAllValues); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException) +{ + +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 scale ) throw(SQLException, RuntimeException) +{ + + OSL_ENSHURE(0,"OResultSet::updateNumericObject: NYI"); +} +//------------------------------------------------------------------------------ +// XRowLocate +Any SAL_CALL OResultSet::getBookmark( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(m_nRowPos < m_aBookmarks.size()) // this bookmark was already fetched + return makeAny(sal_Int32(m_nRowPos-1)); + + OLEVariant aVar; + m_pRecordSet->get_Bookmark(&aVar); + m_aBookmarks.push_back(aVar); + return makeAny((sal_Int32)(m_aBookmarks.size()-1)); + +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OResultSet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 nPos; + bookmark >>= nPos; + OSL_ENSHURE(nPos >= 0 && nPos < m_aBookmarks.size(),"Invalid Index for vector"); + if(nPos < 0 || nPos >= m_aBookmarks.size()) + throw SQLException(); + + return SUCCEEDED(m_pRecordSet->Move(0,m_aBookmarks[nPos])); +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 nPos; + bookmark >>= nPos; + nPos += rows; + OSL_ENSHURE(nPos >= 0 && nPos < m_aBookmarks.size(),"Invalid Index for vector"); + if(nPos < 0 || nPos >= m_aBookmarks.size()) + throw SQLException(); + return SUCCEEDED(m_pRecordSet->Move(rows,m_aBookmarks[nPos])); +} +//------------------------------------------------------------------------------ +sal_Int32 SAL_CALL OResultSet::compareBookmarks( const Any& first, const Any& second ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 nPos1; + first >>= nPos1; + sal_Int32 nPos2; + second >>= nPos2; + if(nPos1 == nPos2) // they should be equal + return sal_True; + + OSL_ENSHURE((nPos1 >= 0 && nPos1 < m_aBookmarks.size()) || (nPos1 >= 0 && nPos2 < m_aBookmarks.size()),"Invalid Index for vector"); + + CompareEnum eNum; + m_pRecordSet->CompareBookmarks(m_aBookmarks[nPos1],m_aBookmarks[nPos2],&eNum); + return ((sal_Int32)eNum) +1; +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ADOProperties* pProps = NULL; + m_pRecordSet->get_Properties(&pProps); + WpOLEAppendCollection<ADOProperties, ADOProperty, WpADOProperty> aProps(pProps); + ADOS::ThrowException(*((OConnection*)m_pStmt->getConnection().get())->getConnection(),*this); + OSL_ENSHURE(aProps.IsValid(),"There are no properties at the connection"); + + WpADOProperty aProp(aProps.GetItem(::rtl::OUString::createFromAscii("Bookmarks Ordered"))); + OLEVariant aVar; + if(aProp.IsValid()) + aVar = aProp.GetValue(); + else + ADOS::ThrowException(*((OConnection*)m_pStmt->getConnection().get())->getConnection(),*this); + + sal_Bool bValue(sal_False); + if(!aVar.isNull() && !aVar.isEmpty()) + bValue = aVar; + return bValue; +} +//------------------------------------------------------------------------------ +sal_Int32 SAL_CALL OResultSet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 nPos; + bookmark >>= nPos; + return nPos; +} +//------------------------------------------------------------------------------ +// XDeleteRows +Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& rows ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OLEVariant aVar; + sal_Int32 nPos; + + // Create SafeArray Bounds and initialize the array + SAFEARRAYBOUND rgsabound[1]; + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = rows.getLength(); + SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + const Any* pBegin = rows.getConstArray(); + const Any* pEnd = pBegin + rows.getLength(); + for(sal_Int32 i=0;pBegin != pEnd ;++pBegin,++i) + { + *pBegin >>= nPos; + SafeArrayPutElement(psa,&i,&m_aBookmarks[nPos]); + } + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + m_pRecordSet->put_Filter(vsa); + m_pRecordSet->Delete(adAffectGroup); + m_pRecordSet->UpdateBatch(adAffectGroup); + + Sequence< sal_Int32 > aSeq(rows.getLength()); + if(first()) + { + sal_Int32* pSeq = aSeq.getArray(); + sal_Int32 i=0; + do + { + OSL_ENSHURE(i<aSeq.getLength(),"Index greater than length of sequence"); + m_pRecordSet->get_Status(&pSeq[i]); + if(pSeq[i++] == adRecDeleted) + --m_nRowPos; + } + while(next()); + } + return aSeq; +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getResultSetConcurrency() const +{ + sal_Int32 nValue=0; + LockTypeEnum eRet; + if(!SUCCEEDED(m_pRecordSet->get_LockType(&eRet))) + { + switch(eRet) + { + case adLockReadOnly: + nValue = ResultSetConcurrency::READ_ONLY; + break; + default: + nValue = ResultSetConcurrency::UPDATABLE; + break; + } + } + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getResultSetType() const +{ + sal_Int32 nValue=0; + CursorTypeEnum eRet; + if(!SUCCEEDED(m_pRecordSet->get_CursorType(&eRet))) + { + switch(eRet) + { + case adOpenUnspecified: + case adOpenForwardOnly: + nValue = ResultSetType::FORWARD_ONLY; + break; + case adOpenStatic: + case adOpenKeyset: + nValue = ResultSetType::SCROLL_INSENSITIVE; + break; + case adOpenDynamic: + nValue = ResultSetType::SCROLL_SENSITIVE; + break; + } + } + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getFetchDirection() const +{ + return FetchDirection::FORWARD; +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getFetchSize() const +{ + sal_Int32 nValue=-1; + m_pRecordSet->get_CacheSize(&nValue); + return nValue; +} +//------------------------------------------------------------------------------ +::rtl::OUString OResultSet::getCursorName() const +{ + return ::rtl::OUString(); +} + +//------------------------------------------------------------------------------ +void OResultSet::setFetchDirection(sal_Int32 _par0) +{ +} +//------------------------------------------------------------------------------ +void OResultSet::setFetchSize(sal_Int32 _par0) +{ + m_pRecordSet->put_CacheSize(_par0); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const +{ + Sequence< com::sun::star::beans::Property > aProps(5); + com::sun::star::beans::Property* pProperties = aProps.getArray(); + sal_Int32 nPos = 0; + + // DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY); + DECL_PROP0(FETCHDIRECTION, sal_Int32); + DECL_PROP0(FETCHSIZE, sal_Int32); + DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY); + DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY); + DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY); + + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & OResultSet::getInfoHelper() +{ + return *const_cast<OResultSet*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +sal_Bool OResultSet::convertFastPropertyValue( + Any & rConvertedValue, + Any & rOldValue, + sal_Int32 nHandle, + const Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException) +{ + switch(nHandle) + { + case PROPERTY_ID_ISBOOKMARKABLE: + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + throw ::com::sun::star::lang::IllegalArgumentException(); + break; + case PROPERTY_ID_FETCHDIRECTION: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); + case PROPERTY_ID_FETCHSIZE: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); + default: + ; + } + return sal_False; +} +// ------------------------------------------------------------------------- +void OResultSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + switch(nHandle) + { + case PROPERTY_ID_ISBOOKMARKABLE: + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + throw Exception(); + break; + case PROPERTY_ID_FETCHDIRECTION: + setFetchDirection(getINT32(rValue)); + break; + case PROPERTY_ID_FETCHSIZE: + setFetchSize(getINT32(rValue)); + break; + default: + ; + } +} +// ------------------------------------------------------------------------- +void OResultSet::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + switch(nHandle) + { + case PROPERTY_ID_ISBOOKMARKABLE: + { + VARIANT_BOOL bBool; + m_pRecordSet->Supports(adBookmark,&bBool); + sal_Bool bRet = bBool == VARIANT_TRUE; + rValue.setValue(&bRet, ::getCppuBooleanType() ); + } + break; + case PROPERTY_ID_CURSORNAME: + rValue <<= getCursorName(); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + rValue <<= getResultSetConcurrency(); + break; + case PROPERTY_ID_RESULTSETTYPE: + rValue <<= getResultSetType(); + break; + case PROPERTY_ID_FETCHDIRECTION: + rValue <<= getFetchDirection(); + break; + case PROPERTY_ID_FETCHSIZE: + rValue <<= getFetchSize(); + break; + } +} + + diff --git a/connectivity/source/drivers/ado/AResultSetMetaData.cxx b/connectivity/source/drivers/ado/AResultSetMetaData.cxx new file mode 100644 index 000000000000..fa1161fd358a --- /dev/null +++ b/connectivity/source/drivers/ado/AResultSetMetaData.cxx @@ -0,0 +1,257 @@ +/************************************************************************* + * + * $RCSfile: AResultSetMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_ARESULTSETMETADATA_HXX_ +#include "ado/AResultSetMetaData.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.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 +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity; +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +// ------------------------------------------------------------------------- +OResultSetMetaData::~OResultSetMetaData() +{ + m_pRecordSet->Release(); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + ADO_GETFIELD(column); + if(aField.IsValid() && aField.GetActualSize() != -1) + return aField.GetActualSize(); + return 0; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + ADO_GETFIELD(column); + return ADOS::MapADOType2Jdbc(aField.GetADOType()); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException) +{ + if(m_nColCount != -1) + return m_nColCount; + + ADOFields* pFields = NULL; + m_pRecordSet->get_Fields(&pFields); + WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(pFields); + m_nColCount = aFields.GetItemCount(); + return m_nColCount; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + ADO_GETFIELD(column); + if(aField.IsValid()) + return aField.GetName(); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getColumnName(column); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + ADO_GETFIELD(column); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldFixed) == adFldFixed; + } + return sal_False; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- + + +sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + ADO_GETFIELD(column); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldNegativeScale) == adFldNegativeScale; + } + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + ADO_GETFIELD(column); + if(aField.IsValid()) + return aField.GetPrecision(); + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ADO_GETFIELD(column); + if(aField.IsValid()) + return aField.GetNumericScale(); + return 0; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + ADO_GETFIELD(column); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldIsNullable) == adFldIsNullable; + } + return sal_False; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + ADO_GETFIELD(column); + if(aField.IsValid()) + { + // return (aField.GetStatus() & adFieldReadOnly) == adFieldReadOnly; + } + return sal_False; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + ADO_GETFIELD(column); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldUpdatable) == adFldUpdatable; + } + return sal_False; +; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return isDefinitelyWritable(column); +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/ado/AStatement.cxx b/connectivity/source/drivers/ado/AStatement.cxx new file mode 100644 index 000000000000..652b17b42c4a --- /dev/null +++ b/connectivity/source/drivers/ado/AStatement.cxx @@ -0,0 +1,840 @@ +/************************************************************************* + * + * $RCSfile: AStatement.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_ASTATEMENT_HXX_ +#include "ado/AStatement.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ACONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ARESULTSET_HXX_ +#include "ado/AResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _UTL_PROPERTY_HXX_ +#include <unotools/property.hxx> +#endif +#ifndef _UTL_UNO3_HXX_ +#include <unotools/uno3.hxx> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_FETCHDIRECTION_HPP_ +#include <com/sun/star/sdbc/FetchDirection.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + +#define CHECK_RETURN(x) \ + if(!x) \ + ADOS::ThrowException(*m_pConnection->getConnection(),*this); + +using namespace connectivity::ado; + +//------------------------------------------------------------------------------ +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +//------------------------------------------------------------------------------ +OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE(m_aMutex) + ,OPropertySetHelper(OStatement_BASE::rBHelper) + ,OSubComponent< OStatement_Base>((::cppu::OWeakObject*)_pConnection) + ,m_pConnection(_pConnection) + ,m_nFetchSize(1) + ,m_nMaxRows(0) + ,m_eLockType(adLockReadOnly) + ,m_eCursorType(adOpenForwardOnly) +{ + osl_incrementInterlockedCount( &m_refCount ); + + m_Command.Create(); + if(m_Command.IsValid()) + m_Command.putref_ActiveConnection(m_pConnection->getConnection()); + else + ADOS::ThrowException(*m_pConnection->getConnection(),*this); + + m_RecordsAffected.setNoArg(); + m_Parameters.setNoArg(); + + m_pConnection->acquire(); + + osl_decrementInterlockedCount( &m_refCount ); +} +//------------------------------------------------------------------------------ +void OStatement_Base::disposeResultSet() +{ + // free the cursor if alive + Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + m_xResultSet = Reference< XResultSet>(); +} + +//------------------------------------------------------------------------------ +void OStatement_Base::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + + disposeResultSet(); + + m_Command.clear(); + m_RecordSet.clear(); + + if (m_pConnection) + m_pConnection->release(); + + dispose_ChildImpl(); + OStatement_BASE::disposing(); +} +//----------------------------------------------------------------------------- +void SAL_CALL OStatement_Base::release() throw(RuntimeException) +{ + relase_ChildImpl(); + OStatement_BASE::release(); +} +//----------------------------------------------------------------------------- +Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OStatement_BASE::queryInterface(rType); + if(!aRet.hasValue()) + aRet = OPropertySetHelper::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OStatement_Base::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes()); +} + +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + CHECK_RETURN(m_Command.Cancel()) +} +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + } + dispose(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement::clearBatch( ) throw(SQLException, RuntimeException) +{ + +} +// ------------------------------------------------------------------------- + +void OStatement_Base::reset() throw (SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + clearWarnings (); + + if (m_xResultSet.get().is()) + clearMyResultSet(); + else + { + if(0) + { + m_Command.clear(); + m_Command.Create(); + if(m_Command.IsValid()) + m_Command.putref_ActiveConnection(m_pConnection->getConnection()); + else + ADOS::ThrowException(*m_pConnection->getConnection(),*this); + + m_RecordsAffected.setNoArg(); + m_Parameters.setNoArg(); + } + } +} +//-------------------------------------------------------------------- +// clearMyResultSet +// If a ResultSet was created for this Statement, close it +//-------------------------------------------------------------------- + +void OStatement_Base::clearMyResultSet () throw (SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + Reference<XCloseable> xCloseable; + if(::utl::query_interface(m_xResultSet.get(),xCloseable)) + xCloseable->close(); + m_xResultSet = Reference< XResultSet>(); +} +//-------------------------------------------------------------------- +sal_Int32 OStatement_Base::getRowCount () throw( SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_RecordsAffected; +} +//-------------------------------------------------------------------- +// getPrecision +// Given a SQL type, return the maximum precision for the column. +// Returns -1 if not known +//-------------------------------------------------------------------- + +sal_Int32 OStatement_Base::getPrecision ( sal_Int32 sqlType) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 prec = -1; + OTypeInfo aInfo; + aInfo.nType = sqlType; + if (m_aTypeInfo.size()) + { + ::std::vector<OTypeInfo>::const_iterator aIter = ::std::find(m_aTypeInfo.begin(),m_aTypeInfo.end(),aInfo); + for(;aIter != m_aTypeInfo.end();++aIter) + { + prec = max(prec,(*aIter).nPrecision); + } + } + + return prec; +} +//-------------------------------------------------------------------- +// setWarning +// Sets the warning +//-------------------------------------------------------------------- + +void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_aLastWarning = ex; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + // Reset the statement handle and warning + + reset(); + + try { + ADORecordset* pSet = NULL; + CHECK_RETURN(m_Command.put_CommandText(sql)) + CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText,&pSet)) + m_RecordSet = WpADORecordset(pSet); + } + catch (SQLWarning& ex) { + + // Save pointer to warning and save with ResultSet + // object once it is created. + + m_aLastWarning = ex; + } + + return m_RecordSet.IsValid(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + reset(); + + m_xResultSet = WeakReference<XResultSet>(NULL); + + WpADORecordset aSet; + aSet.Create(); + CHECK_RETURN(m_Command.put_CommandText(sql)) + OLEVariant aCmd; + aCmd.setIDispatch(m_Command); + OLEVariant aCon; + aCon.setNoArg(); + CHECK_RETURN(aSet.put_CacheSize(m_nFetchSize)) + CHECK_RETURN(aSet.put_MaxRecords(m_nMaxRows)) + CHECK_RETURN(aSet.Open(aCmd,aCon,m_eCursorType,m_eLockType,adOpenUnspecified)) + + + CHECK_RETURN(aSet.get_CacheSize(m_nFetchSize)) + CHECK_RETURN(aSet.get_MaxRecords(m_nMaxRows)) + CHECK_RETURN(aSet.get_CursorType(m_eCursorType)) + CHECK_RETURN(aSet.get_LockType(m_eLockType)) + + OResultSet* pSet = new OResultSet(aSet,this); + Reference< XResultSet > pRs = pSet; + + m_xResultSet = WeakReference<XResultSet>(pRs); + + return m_xResultSet; +} +// ------------------------------------------------------------------------- + +Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return (Reference< XConnection >)m_pConnection; +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this)); + if(!aRet.hasValue()) + aRet = OStatement_Base::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement::addBatch( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_aBatchList.push_back(sql); +} +// ------------------------------------------------------------------------- +Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + reset(); + + ::rtl::OUString aBatchSql; + sal_Int32 nLen = 0; + for(::std::list< ::rtl::OUString>::const_iterator i=m_aBatchList.begin();i != m_aBatchList.end();++i,++nLen) + aBatchSql = aBatchSql + *i + ::rtl::OUString::createFromAscii(";"); + + ADORecordset* pSet=NULL; + m_RecordSet.clear(); + m_RecordSet.Create(); + + CHECK_RETURN(m_Command.put_CommandText(aBatchSql)) + m_RecordSet.PutRefDataSource((IDispatch*)&m_Command); + + CHECK_RETURN(m_RecordSet.UpdateBatch(adAffectAll)) + + Sequence< sal_Int32 > aRet(nLen); + sal_Int32* pArray = aRet.getArray(); + for(sal_Int32 j=0;j<nLen;++j) + { + pSet = NULL; + OLEVariant aRecordsAffected; + if(m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet) + { + m_RecordSet = WpADORecordset(pSet); + sal_Int32 nValue; + if(m_RecordSet.get_RecordCount(nValue)) + pArray[j] = nValue; + } + } + return aRet; +} +// ------------------------------------------------------------------------- + + +sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + reset(); + + try { + ADORecordset* pSet = NULL; + CHECK_RETURN(m_Command.put_CommandText(sql)) + CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText|adExecuteNoRecords,&pSet)) + } + catch (SQLWarning& ex) { + + // Save pointer to warning and save with ResultSet + // object once it is created. + + m_aLastWarning = ex; + } + if(!m_RecordsAffected.isEmpty() && !m_RecordsAffected.isNull() && m_RecordsAffected.getType() != VT_ERROR) + return m_RecordsAffected; + + return 0; +} +// ------------------------------------------------------------------------- + +Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_xResultSet; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OStatement_Base::getUpdateCount( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 nRet; + if(m_RecordSet.IsValid() && m_RecordSet.get_RecordCount(nRet)) + return nRet; + return -1; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OStatement_Base::getMoreResults( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + SQLWarning warning; + + // clear previous warnings + + clearWarnings (); + + // Call SQLMoreResults + + try { + ADORecordset* pSet=NULL; + OLEVariant aRecordsAffected; + if(m_RecordSet.IsValid() && m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet) + m_RecordSet = WpADORecordset(pSet); + } + catch (SQLWarning &ex) { + + // Save pointer to warning and save with ResultSet + // object once it is created. + + warning = ex; + } + return m_RecordSet.IsValid(); +} +// ------------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return makeAny(m_aLastWarning); +} +// ------------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_aLastWarning = SQLWarning(); +} +// ------------------------------------------------------------------------- +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getQueryTimeOut() const throw(SQLException, RuntimeException) +{ + return m_Command.get_CommandTimeout(); +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getMaxRows() const throw(SQLException, RuntimeException) +{ + sal_Int32 nRet=-1; + if(!m_RecordSet.IsValid() && m_RecordSet.get_MaxRecords(nRet)) + throw SQLException(); + return nRet; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getResultSetConcurrency() const throw(SQLException, RuntimeException) +{ + return m_eLockType; + sal_Int32 nValue=0; + switch(m_eLockType) + { + case adLockReadOnly: + nValue = ResultSetConcurrency::READ_ONLY; + break; + default: + nValue = ResultSetConcurrency::UPDATABLE; + break; + } + + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getResultSetType() const throw(SQLException, RuntimeException) +{ + sal_Int32 nValue=0; + switch(m_eCursorType) + { + case adOpenUnspecified: + case adOpenForwardOnly: + nValue = ResultSetType::FORWARD_ONLY; + break; + case adOpenStatic: + case adOpenKeyset: + nValue = ResultSetType::SCROLL_INSENSITIVE; + break; + case adOpenDynamic: + nValue = ResultSetType::SCROLL_SENSITIVE; + break; + } + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getFetchDirection() const throw(SQLException, RuntimeException) +{ + return FetchDirection::FORWARD; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getFetchSize() const throw(SQLException, RuntimeException) +{ + return m_nFetchSize; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getMaxFieldSize() const throw(SQLException, RuntimeException) +{ + return 0; +} +//------------------------------------------------------------------------------ +::rtl::OUString OStatement_Base::getCursorName() const throw(SQLException, RuntimeException) +{ + return m_Command.GetName(); +} +//------------------------------------------------------------------------------ +void OStatement_Base::setQueryTimeOut(sal_Int32 seconds) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_Command.put_CommandTimeout(seconds); +} +//------------------------------------------------------------------------------ +void OStatement_Base::setMaxRows(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_nMaxRows = _par0; +} +//------------------------------------------------------------------------------ +void OStatement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + switch(_par0) + { + case ResultSetConcurrency::READ_ONLY: + m_eLockType = adLockReadOnly; + break; + default: + m_eLockType = adLockOptimistic; + break; + } +} +//------------------------------------------------------------------------------ +void OStatement_Base::setResultSetType(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + switch(_par0) + { + case ResultSetType::FORWARD_ONLY: + m_eCursorType = adOpenForwardOnly; + break; + case ResultSetType::SCROLL_INSENSITIVE: + m_eCursorType = adOpenKeyset; + break; + case ResultSetType::SCROLL_SENSITIVE: + m_eCursorType = adOpenDynamic; + break; + } +} +//------------------------------------------------------------------------------ +void OStatement_Base::setFetchDirection(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); +} +//------------------------------------------------------------------------------ +void OStatement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_nFetchSize = _par0; + // m_RecordSet.put_CacheSize(_par0); +} +//------------------------------------------------------------------------------ +void OStatement_Base::setMaxFieldSize(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + +} +//------------------------------------------------------------------------------ +void OStatement_Base::setCursorName(const ::rtl::OUString &_par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + m_Command.put_Name(_par0); +} + +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const +{ + Sequence< com::sun::star::beans::Property > aProps(10); + com::sun::star::beans::Property* pProperties = aProps.getArray(); + sal_Int32 nPos = 0; + DECL_PROP0(CURSORNAME, ::rtl::OUString); + DECL_BOOL_PROP0(ESCAPEPROCESSING); + DECL_PROP0(FETCHDIRECTION,sal_Int32); + DECL_PROP0(FETCHSIZE, sal_Int32); + DECL_PROP0(MAXFIELDSIZE,sal_Int32); + DECL_PROP0(MAXROWS, sal_Int32); + DECL_PROP0(QUERYTIMEOUT,sal_Int32); + DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32); + DECL_PROP0(RESULTSETTYPE,sal_Int32); + DECL_BOOL_PROP0(USEBOOKMARKS); + + + return new ::cppu::OPropertyArrayHelper(aProps); +} + +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper() +{ + return *const_cast<OStatement_Base*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +sal_Bool OStatement_Base::convertFastPropertyValue( + Any & rConvertedValue, + Any & rOldValue, + sal_Int32 nHandle, + const Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException) +{ + switch(nHandle) + { + case PROPERTY_ID_QUERYTIMEOUT: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut()); + case PROPERTY_ID_MAXFIELDSIZE: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize()); + case PROPERTY_ID_MAXROWS: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxRows()); + case PROPERTY_ID_CURSORNAME: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName()); + case PROPERTY_ID_RESULTSETCONCURRENCY: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency()); + case PROPERTY_ID_RESULTSETTYPE: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType()); + case PROPERTY_ID_FETCHDIRECTION: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); + case PROPERTY_ID_FETCHSIZE: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); + case PROPERTY_ID_ESCAPEPROCESSING: + // return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink); + case PROPERTY_ID_USEBOOKMARKS: + // return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink); + default: + ; + } + return sal_False; +} +// ------------------------------------------------------------------------- +void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception) +{ + switch(nHandle) + { + case PROPERTY_ID_QUERYTIMEOUT: + setQueryTimeOut(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_MAXFIELDSIZE: + setMaxFieldSize(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_MAXROWS: + setMaxRows(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_CURSORNAME: + setCursorName(connectivity::getString(rValue)); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + setResultSetConcurrency(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_RESULTSETTYPE: + setResultSetType(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_FETCHDIRECTION: + setFetchDirection(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_FETCHSIZE: + setFetchSize(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_ESCAPEPROCESSING: + // return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink); + case PROPERTY_ID_USEBOOKMARKS: + // return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink); + default: + ; + } +} +// ------------------------------------------------------------------------- +void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + switch(nHandle) + { + case PROPERTY_ID_QUERYTIMEOUT: + rValue <<= getQueryTimeOut(); + break; + case PROPERTY_ID_MAXFIELDSIZE: + rValue <<= getMaxFieldSize(); + break; + case PROPERTY_ID_MAXROWS: + rValue <<= getMaxRows(); + break; + case PROPERTY_ID_CURSORNAME: + rValue <<= getCursorName(); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + rValue <<= getResultSetConcurrency(); + break; + case PROPERTY_ID_RESULTSETTYPE: + rValue <<= getResultSetType(); + break; + case PROPERTY_ID_FETCHDIRECTION: + rValue <<= getFetchDirection(); + break; + case PROPERTY_ID_FETCHSIZE: + rValue <<= getFetchSize(); + break; + case PROPERTY_ID_ESCAPEPROCESSING: + case PROPERTY_ID_USEBOOKMARKS: + default: + ; + } +} +// ------------------------------------------------------------------------- +OStatement::~OStatement() +{ +} +IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.AStatement","com.sun.star.sdbc.Statement"); + diff --git a/connectivity/source/drivers/ado/ATable.cxx b/connectivity/source/drivers/ado/ATable.cxx new file mode 100644 index 000000000000..7d106cfa5323 --- /dev/null +++ b/connectivity/source/drivers/ado/ATable.cxx @@ -0,0 +1,444 @@ +/************************************************************************* + * + * $RCSfile: ATable.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_TABLE_HXX_ +#include "ado/ATable.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_INDEXES_HXX_ +#include "ado/AIndexes.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_COLUMNS_HXX_ +#include "ado/AColumns.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_COLUMN_HXX_ +#include "ado/AColumn.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_KEYS_HXX_ +#include "ado/AKeys.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ +#include <com/sun/star/sdbcx/KeyType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.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 +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +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 ) ) + { + pInterface = pCommand; + pInterface->AddRef(); + } +} +// ------------------------------------------------------------------------- +OAdoTable::OAdoTable(sal_Bool _bCase,_ADOTable* _pTable) : OTable_TYPEDEF(_bCase) +{ + construct(); + if(_pTable) + m_aTable = WpADOTable(_pTable); + else + m_aTable.Create(); + + refreshColumns(); + refreshKeys(); + refreshIndexes(); +} +// ------------------------------------------------------------------------- +OAdoTable::OAdoTable(sal_Bool _bCase, const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description , + const ::rtl::OUString& _SchemaName, + const ::rtl::OUString& _CatalogName + ) : OTable_TYPEDEF(_bCase,_Name, + _Type, + _Description, + _SchemaName, + _CatalogName) +{ + construct(); + m_aTable.Create(); + m_aTable.put_Name(_Name); + { + ADOProperties* pProps = m_aTable.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Type")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + aProp.PutValue(_Type); + pProps->Release(); + } + { + ADOProperties* pProps = m_aTable.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Description")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + aProp.PutValue(_Description); + pProps->Release(); + } + + + refreshColumns(); + refreshKeys(); + refreshIndexes(); +} +// ------------------------------------------------------------------------- +void OAdoTable::refreshColumns() +{ + ::std::vector< ::rtl::OUString> aVector; + + ADOColumns* pColumns = m_aTable.get_Columns(); + if(pColumns) + { + pColumns->Refresh(); + + sal_Int32 nCount = 0; + pColumns->get_Count(&nCount); + for(sal_Int32 i=0;i< nCount;++i) + { + ADOColumn* pColumn = NULL; + pColumns->get_Item(OLEVariant(i),&pColumn); + if(pColumn) + { + WpADOColumn aColumn(pColumn); + aVector.push_back(aColumn.get_Name()); + } + } + } + + m_pColumns = new OColumns(*this,m_aMutex,aVector,pColumns,isCaseSensitive()); +} +// ------------------------------------------------------------------------- +void OAdoTable::refreshKeys() +{ + ::std::vector< ::rtl::OUString> aVector; + + ADOKeys* pKeys = m_aTable.get_Keys(); + if(pKeys) + { + pKeys->Refresh(); + + sal_Int32 nCount = 0; + pKeys->get_Count(&nCount); + for(sal_Int32 i=0;i< nCount;++i) + { + ADOKey* pKey = NULL; + pKeys->get_Item(OLEVariant(i),&pKey); + if(pKey) + { + WpADOKey aKey(pKey); + aVector.push_back(aKey.get_Name()); + } + } + } + + m_pKeys = new OKeys(*this,m_aMutex,aVector,pKeys,isCaseSensitive()); +} +// ------------------------------------------------------------------------- +void OAdoTable::refreshIndexes() +{ + ::std::vector< ::rtl::OUString> aVector; + + ADOIndexes* pIndexes = m_aTable.get_Indexes(); + if(pIndexes) + { + pIndexes->Refresh(); + + sal_Int32 nCount = 0; + pIndexes->get_Count(&nCount); + for(sal_Int32 i=0;i< nCount;++i) + { + ADOIndex* pIndex = NULL; + pIndexes->get_Item(OLEVariant(i),&pIndex); + if(pIndex) + { + WpADOIndex aIndex(pIndex); + aVector.push_back(aIndex.get_Name()); + } + } + } + + m_pIndexes = new OIndexes(*this,m_aMutex,aVector,pIndexes,isCaseSensitive()); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OAdoTable::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); + if(aRet.hasValue()) + return aRet; + return OTable_TYPEDEF::queryInterface(rType); +} + +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OAdoTable::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OTable_TYPEDEF::getTypes()); +} +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoTable::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; +} +// ------------------------------------------------------------------------- +// XRename +void SAL_CALL OAdoTable::rename( const ::rtl::OUString& newName ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (rBHelper.bDisposed) + throw DisposedException(); + + m_aTable.put_Name(newName); +} +// ------------------------------------------------------------------------- +// XAlterTable +void SAL_CALL OAdoTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (rBHelper.bDisposed) + throw DisposedException(); + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(descriptor,UNO_QUERY); + if(xTunnel.is()) + { + OAdoColumn* pColumn = (OAdoColumn*)xTunnel->getSomething(OAdoColumn:: getUnoTunnelImplementationId()); + m_aTable.get_Columns()->Delete(OLEVariant(colName)); + m_aTable.get_Columns()->Append(OLEVariant(pColumn->getColumnImpl())); + } + + refreshColumns(); + +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoTable::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (rBHelper.bDisposed) + throw DisposedException(); + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(descriptor,UNO_QUERY); + if(xTunnel.is()) + { + OAdoColumn* pColumn = (OAdoColumn*)xTunnel->getSomething(OAdoColumn:: getUnoTunnelImplementationId()); + m_aTable.get_Columns()->Delete(OLEVariant(index)); + m_aTable.get_Columns()->Append(OLEVariant(pColumn->getColumnImpl())); + } +} +// ------------------------------------------------------------------------- +void OAdoTable::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + if(m_aTable.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + m_aTable.put_Name(getString(rValue)); + break; + case PROPERTY_ID_TYPE: + { + ADOProperties* pProps = m_aTable.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Type")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + aProp.PutValue(getString(rValue)); + pProps->Release(); + } + break; + case PROPERTY_ID_DESCRIPTION: + { + ADOProperties* pProps = m_aTable.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Description")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + aProp.PutValue(getString(rValue)); + pProps->Release(); + } + break; + case PROPERTY_ID_SCHEMANAME: + break; + default: + throw Exception(); + } + } +} +// ------------------------------------------------------------------------- +void OAdoTable::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + if(m_aTable.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + rValue <<= m_aTable.get_Name(); + break; + case PROPERTY_ID_TYPE: + rValue <<= m_aTable.get_Type(); + break; + case PROPERTY_ID_CATALOGNAME: + { + WpADOCatalog aCat(m_aTable.get_ParentCatalog()); + if(aCat.IsValid()) + rValue <<= aCat.GetObjectOwner(m_aTable.get_Name(),adPermObjTable); + } + break; + case PROPERTY_ID_SCHEMANAME: + // rValue <<= m_aTable.get_Type(); + break; + case PROPERTY_ID_DESCRIPTION: + { + ADOProperties* pProps = m_aTable.get_Properties(); + pProps->AddRef(); + ADOProperty* pProp = NULL; + pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Description")),&pProp); + WpADOProperty aProp(pProp); + if(pProp) + rValue <<= (::rtl::OUString)aProp.GetValue(); + pProps->Release(); + } + break; + } + } +} +// ------------------------------------------------------------------------- +::rtl::OUString WpADOCatalog::GetObjectOwner(const ::rtl::OUString& _rName, ObjectTypeEnum _eNum) +{ + OLEVariant _rVar; + _rVar.setNoArg(); + BSTR aBSTR; + pInterface->GetObjectOwner(SysAllocString(_rName.getStr()),_eNum,_rVar,&aBSTR); + rtl::OUString sRetStr((sal_Unicode*)aBSTR); + SysFreeString(aBSTR); + return sRetStr; +} + + + diff --git a/connectivity/source/drivers/ado/ATables.cxx b/connectivity/source/drivers/ado/ATables.cxx new file mode 100644 index 000000000000..3dd247d3f731 --- /dev/null +++ b/connectivity/source/drivers/ado/ATables.cxx @@ -0,0 +1,158 @@ +/************************************************************************* + * + * $RCSfile: ATables.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_TABLES_HXX_ +#include "ado/ATables.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_TABLE_HXX_ +#include "ado/ATable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.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 +#ifndef _CONNECTIVITY_ADO_CATALOG_HXX_ +#include "ado/ACatalog.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::container; +using namespace com::sun::star::lang; + +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OTables::createObject(const ::rtl::OUString& _rName) +{ + ADOTable* pTable = NULL; + m_pCollection->get_Item(OLEVariant(_rName),&pTable); + + Reference< XNamed > xRet = new OAdoTable(isCaseSensitive(),pTable); + + return xRet; +} +// ------------------------------------------------------------------------- +void OTables::impl_refresh( ) throw(RuntimeException) +{ + m_pCollection->Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OTables::createEmptyObject() +{ + OAdoTable* pNew = new OAdoTable(isCaseSensitive()); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OTables::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(descriptor,UNO_QUERY); + if(xTunnel.is()) + { + OAdoTable* pTable = (OAdoTable*)xTunnel->getSomething(OAdoTable:: getUnoTunnelImplementationId()); + m_pCollection->Append(OLEVariant(pTable->getImpl())); + } + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OTables::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + m_pCollection->Delete(OLEVariant(elementName)); + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OTables::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + m_pCollection->Delete(OLEVariant(index)); + + OCollection_TYPE::dropByIndex(index); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/AUser.cxx b/connectivity/source/drivers/ado/AUser.cxx new file mode 100644 index 000000000000..c15770cca86c --- /dev/null +++ b/connectivity/source/drivers/ado/AUser.cxx @@ -0,0 +1,248 @@ +/************************************************************************* + * + * $RCSfile: AUser.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_USER_HXX_ +#include "ado/AUser.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_GROUPS_HXX_ +#include "ado/AGroups.hxx" +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +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 ) ) + { + pInterface = pCommand; + pInterface->AddRef(); + } +} +// ------------------------------------------------------------------------- +OAdoUser::OAdoUser(sal_Bool _bCase, ADOUser* _pUser) : OUser_TYPEDEF(_bCase) +{ + construct(); + + if(_pUser) + m_aUser = WpADOUser(_pUser); + else + m_aUser.Create(); + refreshGroups(); +} +// ------------------------------------------------------------------------- +OAdoUser::OAdoUser(sal_Bool _bCase, const ::rtl::OUString& _Name) : OUser_TYPEDEF(_Name,_bCase) +{ + construct(); + m_aUser.Create(); + m_aUser.put_Name(_Name); + refreshGroups(); +} +// ------------------------------------------------------------------------- +void OAdoUser::refreshGroups() +{ + + ::std::vector< ::rtl::OUString> aVector; + + ADOGroups* pGroups = m_aUser.get_Groups(); + if(pGroups) + { + pGroups->Refresh(); + + sal_Int32 nCount = 0; + pGroups->get_Count(&nCount); + for(sal_Int32 i=0;i< nCount;++i) + { + ADOGroup* pGroup = NULL; + pGroups->get_Item(OLEVariant(i),&pGroup); + if(pGroup) + { + WpADOGroup aGroup(pGroup); + aVector.push_back(aGroup.get_Name()); + } + } + } + + if(m_pGroups) + delete m_pGroups; + m_pGroups = new OGroups(*this,m_aMutex,aVector,pGroups,isCaseSensitive()); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OAdoUser::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); + if(aRet.hasValue()) + return aRet; + return OUser_TYPEDEF::queryInterface(rType); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OAdoUser::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OUser_TYPEDEF::getTypes()); +} +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoUser::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoUser::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; +} + +// ------------------------------------------------------------------------- +void OAdoUser::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + if(m_aUser.IsValid()) + { + + switch(nHandle) + { + case PROPERTY_ID_NAME: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aUser.put_Name(aVal); + } + break; + } + } +} +// ------------------------------------------------------------------------- +void OAdoUser::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + if(m_aUser.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + rValue <<= m_aUser.get_Name(); + break; + } + } +} +// ------------------------------------------------------------------------- +OUserExtend::OUserExtend(sal_Bool _bCase, ADOUser* _pUser) : OAdoUser(_bCase,_pUser) +{ +} +// ------------------------------------------------------------------------- +OUserExtend::OUserExtend(sal_Bool _bCase, const ::rtl::OUString& _Name) : OAdoUser(_bCase,_Name) +{ +} +// ------------------------------------------------------------------------- +void OUserExtend::construct() +{ + OUser_TYPEDEF::construct(); + registerProperty(PROPERTY_PASSWORD, PROPERTY_ID_PASSWORD,0,&m_Password,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); +} + + diff --git a/connectivity/source/drivers/ado/AUsers.cxx b/connectivity/source/drivers/ado/AUsers.cxx new file mode 100644 index 000000000000..29a2c9bf3f56 --- /dev/null +++ b/connectivity/source/drivers/ado/AUsers.cxx @@ -0,0 +1,144 @@ +/************************************************************************* + * + * $RCSfile: AUsers.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_USERS_HXX_ +#include "ado/AUsers.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_USER_HXX_ +#include "ado/AUser.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_TABLE_HXX_ +#include "ado/ATable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_ +#include "connectivity/sdbcx/IRefreshable.hxx" +#endif + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::container; + +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OUsers::createObject(const ::rtl::OUString& _rName) +{ + OAdoUser* pRet = new OAdoUser(isCaseSensitive(),_rName); + Reference< XNamed > xRet = pRet; + return xRet; +} +// ------------------------------------------------------------------------- +void OUsers::impl_refresh() throw(RuntimeException) +{ + m_pCollection->Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OUsers::createEmptyObject() +{ + OUserExtend* pNew = new OUserExtend(isCaseSensitive()); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OUsers::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(descriptor,UNO_QUERY); + if(xTunnel.is()) + { + OUserExtend* pUser = (OUserExtend*)xTunnel->getSomething(OUserExtend::getUnoTunnelImplementationId()); + if(pUser) + m_pCollection->Append(OLEVariant(pUser->getImpl()),(BSTR)pUser->getPassword().getStr()); + } + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OUsers::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + m_pCollection->Delete(OLEVariant(elementName)); + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OUsers::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + m_pCollection->Delete(OLEVariant(index)); + + OCollection_TYPE::dropByIndex(index); +} + diff --git a/connectivity/source/drivers/ado/AView.cxx b/connectivity/source/drivers/ado/AView.cxx new file mode 100644 index 000000000000..690eb3735e84 --- /dev/null +++ b/connectivity/source/drivers/ado/AView.cxx @@ -0,0 +1,222 @@ +/************************************************************************* + * + * $RCSfile: AView.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_VIEW_HXX_ +#include "ado/AView.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ADOIMP_HXX_ +#include "ado/adoimp.hxx" +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_ +#include "ado/Awrapado.hxx" +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +// ------------------------------------------------------------------------- +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +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 ) ) + { + pInterface = pCommand; + pInterface->AddRef(); + } +} + +// ------------------------------------------------------------------------- +OAdoView::OAdoView(sal_Bool _bCase,ADOView* _pView) : OView_ADO(_bCase) +{ + construct(); + + if(_pView) + m_aView = WpADOView(_pView); + else + m_aView.Create(); +} +// ------------------------------------------------------------------------- +OAdoView::OAdoView(sal_Bool _bCase, const ::rtl::OUString& _Name, + sal_Int32 _CheckOption, + const ::rtl::OUString& _Command, + const ::rtl::OUString& _SchemaName, + const ::rtl::OUString& _CatalogName) + : OView_ADO( _bCase, + _Name, + _CheckOption, + _Command, + _SchemaName, + _CatalogName) +{ + construct(); + m_aView.Create(); + WpADOCommand aCommand; + aCommand.Create(); + aCommand.put_Name(_Name); + aCommand.put_CommandText(_Command); + + m_aView.put_Command(OLEVariant((IDispatch*)aCommand)); + +} +// ------------------------------------------------------------------------- +Any SAL_CALL OAdoView::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); + if(aRet.hasValue()) + return aRet; + return OView_ADO::queryInterface(rType); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OAdoView::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OAdoView::getTypes()); +} +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoView::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoView::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; +} + +// ------------------------------------------------------------------------- +void OAdoView::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception) +{ + throw Exception(); +} +// ------------------------------------------------------------------------- +void OAdoView::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + if(m_aView.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + rValue <<= m_aView.get_Name(); + break; + case PROPERTY_ID_CATALOGNAME: + break; + case PROPERTY_ID_SCHEMANAME: + // rValue <<= m_aView.get_Type(); + break; + case PROPERTY_ID_COMMAND: + { + OLEVariant aVar; + m_aView.get_Command(aVar); + if(!aVar.isNull() && !aVar.isEmpty()) + { + ADOCommand* pCom = (ADOCommand*)aVar.getIDispatch(); + BSTR aBSTR; pCom->get_CommandText(&aBSTR); + ::rtl::OUString sRetStr(aBSTR); + SysFreeString(aBSTR); + rValue <<= sRetStr; + } + } + break; + } + } +} + diff --git a/connectivity/source/drivers/ado/AViews.cxx b/connectivity/source/drivers/ado/AViews.cxx new file mode 100644 index 000000000000..afabefabbfb5 --- /dev/null +++ b/connectivity/source/drivers/ado/AViews.cxx @@ -0,0 +1,158 @@ +/************************************************************************* + * + * $RCSfile: AViews.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_VIEWS_HXX_ +#include "ado/AViews.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_VIEW_HXX_ +#include "ado/AView.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.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 +#ifndef _CONNECTIVITY_ADO_CATALOG_HXX_ +#include "ado/ACatalog.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::container; + +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OViews::createObject(const ::rtl::OUString& _rName) +{ + ADOView* pView = NULL; + m_pCollection->get_Item(OLEVariant(_rName),&pView); + + Reference< XNamed > xRet = new OAdoView(isCaseSensitive(),pView); + + return xRet; +} +// ------------------------------------------------------------------------- +void OViews::impl_refresh( ) throw(RuntimeException) +{ + m_pCollection->Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OViews::createEmptyObject() +{ + OAdoView* pNew = new OAdoView(isCaseSensitive()); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OViews::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(descriptor,UNO_QUERY); + if(xTunnel.is()) + { + OAdoView* pView = (OAdoView*)xTunnel->getSomething(OAdoView:: getUnoTunnelImplementationId()); + m_pCollection->Append((BSTR)getString(descriptor->getPropertyValue(PROPERTY_NAME)).getStr(),(IDispatch *)pView->getImpl()); + } + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OViews::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + m_pCollection->Delete(OLEVariant(elementName)); + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OViews::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + m_pCollection->Delete(OLEVariant(index)); + + OCollection_TYPE::dropByIndex(index); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/Aservices.cxx b/connectivity/source/drivers/ado/Aservices.cxx new file mode 100644 index 000000000000..b62d68b4c3d0 --- /dev/null +++ b/connectivity/source/drivers/ado/Aservices.cxx @@ -0,0 +1,212 @@ +/************************************************************************* + * + * $RCSfile: Aservices.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_ADRIVER_HXX_ +#include "ado/ADriver.hxx" +#endif +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +using namespace connectivity::ado; +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::registry::XRegistryKey; +using ::com::sun::star::lang::XSingleServiceFactory; +using ::com::sun::star::lang::XMultiServiceFactory; + +typedef Reference< XSingleServiceFactory > (SAL_CALL &createFactoryFunc) + ( + const Reference< XMultiServiceFactory > & rServiceManager, + const OUString & rComponentName, + ::cppu::ComponentInstantiation pCreateFunction, + const Sequence< OUString > & rServiceNames + ); + +//*************************************************************************************** +// +// Die vorgeschriebene C-Api muss erfuellt werden! +// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen. +// + +//--------------------------------------------------------------------------------------- +void REGISTER_PROVIDER( + const OUString& aServiceImplName, + const Sequence< OUString>& Services, + const Reference< ::com::sun::star::registry::XRegistryKey > & xKey) +{ + OUString aMainKeyName; + aMainKeyName = OUString::createFromAscii("/"); + aMainKeyName += aServiceImplName; + aMainKeyName += OUString::createFromAscii("/UNO/SERVICES"); + + Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) ); + OSL_ENSHURE(xNewKey.is(), "ADO::component_writeInfo : could not create a registry key !"); + + for (sal_uInt32 i=0; i<Services.getLength(); ++i) + xNewKey->createKey(Services[i]); +} + + +//--------------------------------------------------------------------------------------- +struct ProviderRequest +{ + Reference< XSingleServiceFactory > xRet; + Reference< XMultiServiceFactory > const xServiceManager; + OUString const sImplementationName; + + ProviderRequest( + void* pServiceManager, + sal_Char const* pImplementationName + ) + : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) + , sImplementationName(OUString::createFromAscii(pImplementationName)) + { + } + + inline + sal_Bool CREATE_PROVIDER( + const OUString& Implname, + const Sequence< OUString > & Services, + ::cppu::ComponentInstantiation Factory, + createFactoryFunc creator + ) + { + if (!xRet.is() && (Implname == sImplementationName)) + try + { + xRet = creator( xServiceManager, sImplementationName,Factory, Services); + } + catch(...) + { + } + return xRet.is(); + } + + void* getProvider() const { return xRet.get(); } +}; + +//--------------------------------------------------------------------------------------- + +extern "C" void SAL_CALL component_getImplementationEnvironment( + const sal_Char **ppEnvTypeName, + uno_Environment **ppEnv + ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//--------------------------------------------------------------------------------------- +extern "C" sal_Bool SAL_CALL component_writeInfo( + void* pServiceManager, + void* pRegistryKey + ) +{ + if (pRegistryKey) + try + { + Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey)); + + REGISTER_PROVIDER( + ODriver::getImplementationName_Static(), + ODriver::getSupportedServiceNames_Static(), xKey); + + return sal_True; + } + catch (::com::sun::star::registry::InvalidRegistryException& ) + { + OSL_ENSHURE(sal_False, "ODBC::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !"); + } + + return sal_False; +} + +//--------------------------------------------------------------------------------------- +extern "C" void* SAL_CALL component_getFactory( + const sal_Char* pImplementationName, + void* pServiceManager, + void* pRegistryKey) +{ + void* pRet = 0; + if (pServiceManager) + { + ProviderRequest aReq(pServiceManager,pImplementationName); + + aReq.CREATE_PROVIDER( + ODriver::getImplementationName_Static(), + ODriver::getSupportedServiceNames_Static(), + ODriver_CreateInstance, ::cppu::createSingleFactory) + ; + + if(aReq.xRet.is()) + aReq.xRet->acquire(); + + pRet = aReq.getProvider(); + } + + return pRet; +}; + + diff --git a/connectivity/source/drivers/ado/ado.xml b/connectivity/source/drivers/ado/ado.xml new file mode 100644 index 000000000000..1e923b53493f --- /dev/null +++ b/connectivity/source/drivers/ado/ado.xml @@ -0,0 +1,70 @@ +<?xml version='1.0' encoding="UTF-8"?> +<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//W3C//DTD HTML 3.2//EN" "componentdependencies.dtd"> +<COMPONENTDESCRIPTION> + +<Name> com.sun.star.sdbc.ADODriver </Name> + +<Description> + This is the implementation of the sdbc-ado bridge. +</Description> + +<ModuleName> ado </ModuleName> + +<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName> + +<SupportedService> com.sun.star.sdbc.Driver </SupportedService> + +<ServiceDependency> ... </ServiceDependency> + +<ProjectBuildDependency> cppuhelper </ProjectBuildDependency> +<ProjectBuildDependency> cppu </ProjectBuildDependency> +<ProjectBuildDependency> sal </ProjectBuildDependency> +<ProjectBuildDependency> vos </ProjectBuildDependency> + +<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency> +<RuntimeModuleDependency> cppu1 </RuntimeModuleDependency> +<RuntimeModuleDependency> sal1 </RuntimeModuleDependency> +<RuntimeModuleDependency> vos </RuntimeModuleDependency> + +<Language> c++ </Language> + +<Status StatusValue="final"/> + +<Type> com.sun.star.util.XCancellable </Type> +<Type> com.sun.star.util.XNumberFormatter </Type> +<Type> com.sun.star.uno.TypeClass </Type> +<Type> com.sun.star.uno.XWeak </Type> +<Type> com.sun.star.uno.XAggregation </Type> +<Type> com.sun.star.beans.XPropertyState </Type> +<Type> com.sun.star.beans.XPropertySet </Type> +<Type> com.sun.star.beans.PropertyValue </Type> +<Type> com.sun.star.beans.XMultiPropertySet </Type> +<Type> com.sun.star.beans.XFastPropertySet </Type> +<Type> com.sun.star.lang.XTypeProvider </Type> +<Type> com.sun.star.lang.EventObject </Type> +<Type> com.sun.star.lang.XComponent </Type> +<Type> com.sun.star.lang.IllegalArgumentException </Type> +<Type> com.sun.star.lang.XMultiServiceFactory </Type> +<Type> com.sun.star.java.XJavaThreadRegister_11 </Type> +<Type> com.sun.star.java.XJavaVM </Type> +<Type> com.sun.star.sdbc.XConnection </Type> +<Type> com.sun.star.sdbc.XStatement </Type> +<Type> com.sun.star.sdbc.XResultSet </Type> +<Type> com.sun.star.sdbc.XResultSetMetaDataSupplier</Type> +<Type> com.sun.star.sdbc.XColumnLocate </Type> +<Type> com.sun.star.sdbc.XResultSetUpdate </Type> +<Type> com.sun.star.sdbc.XWarningsSupplier </Type> +<Type> com.sun.star.sdbc.XRowUpdate </Type> +<Type> com.sun.star.sdbc.XMultipleResults </Type> +<Type> com.sun.star.sdbc.XBatchExecution </Type> +<Type> com.sun.star.sdbc.XPreparedBatchExecution </Type> +<Type> com.sun.star.sdbc.XParameters </Type> +<Type> com.sun.star.sdbc.XOutParameters </Type> +<Type> com.sun.star.sdbc.DriverPropertyInfo </Type> +<Type> com.sun.star.sdbc.XRow </Type> +<Type> com.sun.star.sdb.XColumnUpdate </Type> +<Type> com.sun.star.sdb.XColumn </Type> + +</COMPONENTDESCRIPTION> + + diff --git a/connectivity/source/drivers/ado/adoimp.cxx b/connectivity/source/drivers/ado/adoimp.cxx new file mode 100644 index 000000000000..f86752150032 --- /dev/null +++ b/connectivity/source/drivers/ado/adoimp.cxx @@ -0,0 +1,229 @@ +/************************************************************************* + * + * $RCSfile: adoimp.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_AWRAPADO_HXX_ +#include "ado/Awrapado.hxx" +#endif + +#ifndef _CONNECTIVITY_ADO_ADOIMP_HXX_ +#include "ado/adoimp.hxx" +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::sdbc; + + +#define MYADOID(l) {l, 0,0x10,0x80,0,0,0xAA,0,0x6D,0x2E,0xA4}; + +const CLSID ADOS::CLSID_ADOCONNECTION_21 = MYADOID(0x00000514); +const IID ADOS::IID_ADOCONNECTION_21 = MYADOID(0x00000550); + +const CLSID ADOS::CLSID_ADOCOMMAND_21 = MYADOID(0x00000507); +const IID ADOS::IID_ADOCOMMAND_21 = MYADOID(0x0000054E); + +const CLSID ADOS::CLSID_ADORECORDSET_21 = MYADOID(0x00000535); +const IID ADOS::IID_ADORECORDSET_21 = MYADOID(0x0000054F); + +const CLSID ADOS::CLSID_ADOCATALOG_25 = MYADOID(0x00000602); +const IID ADOS::IID_ADOCATALOG_25 = MYADOID(0x00000603); + +const CLSID ADOS::CLSID_ADOINDEX_25 = MYADOID(0x0000061E); +const IID ADOS::IID_ADOINDEX_25 = MYADOID(0x0000061F); + +const CLSID ADOS::CLSID_ADOTABLE_25 = MYADOID(0x00000609); +const IID ADOS::IID_ADOTABLE_25 = MYADOID(0x00000610); + +const CLSID ADOS::CLSID_ADOKEY_25 = MYADOID(0x00000621); +const IID ADOS::IID_ADOKEY_25 = MYADOID(0x00000622); + +const CLSID ADOS::CLSID_ADOCOLUMN_25 = MYADOID(0x0000061B); +const IID ADOS::IID_ADOCOLUMN_25 = MYADOID(0x0000061C); + +const CLSID ADOS::CLSID_ADOGROUP_25 = MYADOID(0x00000615); +const IID ADOS::IID_ADOGROUP_25 = MYADOID(0x00000616); + +const CLSID ADOS::CLSID_ADOUSER_25 = MYADOID(0x00000618); +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_ENSHURE(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->Release(); + throw aException; + } + pErrors->Release(); +} + +// ------------------------------------------------------------------------- +sal_Int32 ADOS::MapADOType2Jdbc(DataTypeEnum eType) +{ + switch (eType) + { + case adUnsignedSmallInt: + case adSmallInt: return DataType::SMALLINT; break; + case adUnsignedInt: + case adInteger: return DataType::INTEGER; break; + case adUnsignedBigInt: + case adBigInt: return DataType::BIGINT; break; + case adSingle: return DataType::FLOAT; break; + case adDouble: return DataType::DOUBLE; break; + case adCurrency: return DataType::DOUBLE; break; + case adVarNumeric: + case adNumeric: return DataType::NUMERIC; break; + case adDecimal: return DataType::DECIMAL; break; + case adDate: + case adDBDate: return DataType::DATE; break; + case adDBTime: return DataType::TIME; break; + case adDBTimeStamp: return DataType::TIMESTAMP; break; + case adBoolean: return DataType::BIT; break; + case adBinary: + case adGUID: return DataType::BINARY; break; + case adBSTR: + case adVarWChar: + case adVarChar: return DataType::VARCHAR; break; + case adLongVarWChar: + case adLongVarChar: return DataType::LONGVARCHAR; break; + case adVarBinary: return DataType::VARBINARY; break; + case adLongVarBinary: return DataType::LONGVARBINARY; break; + case adWChar: + case adChar: return DataType::CHAR; break; + case adUnsignedTinyInt: + case adTinyInt: return DataType::TINYINT; break; + default: + ; + } + return DataType::TINYINT; +} +// ------------------------------------------------------------------------- +DataTypeEnum ADOS::MapJdbc2ADOType(sal_Int32 _nType) +{ + switch (_nType) + { + case DataType::SMALLINT: return adSmallInt; break; + case DataType::INTEGER: return adInteger; break; + case DataType::BIGINT: return adBigInt; break; + case DataType::FLOAT: return adSingle; break; + case DataType::DOUBLE: return adDouble; break; + case DataType::NUMERIC: return adNumeric; break; + case DataType::DECIMAL: return adDecimal; break; + case DataType::DATE: return adDBDate; break; + case DataType::TIME: return adDBTime; break; + case DataType::TIMESTAMP: return adDBTimeStamp; break; + case DataType::BIT: return adBoolean; break; + case DataType::BINARY: return adBinary; break; + case DataType::VARCHAR: return adVarWChar; break; + case DataType::LONGVARCHAR: return adLongVarWChar; break; + case DataType::VARBINARY: return adVarBinary; break; + case DataType::LONGVARBINARY: return adLongVarBinary; break; + case DataType::CHAR: return adWChar; break; + case DataType::TINYINT: return adTinyInt; break; + default: + ; + } + return adEmpty; +} + + + diff --git a/connectivity/source/drivers/ado/exports.dxp b/connectivity/source/drivers/ado/exports.dxp new file mode 100644 index 000000000000..9630d7e06768 --- /dev/null +++ b/connectivity/source/drivers/ado/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/connectivity/source/drivers/ado/makefile.mk b/connectivity/source/drivers/ado/makefile.mk new file mode 100644 index 000000000000..649e0c507b40 --- /dev/null +++ b/connectivity/source/drivers/ado/makefile.mk @@ -0,0 +1,226 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* +.IF "$(GUI)"=="WNT" + +PRJ=..$/..$/.. +PRJINC=..$/.. +PRJNAME=connectivity +TARGET=ado + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/version.mk + +# --- Types ------------------------------------- + + +UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb + +UNOUCROUT=$(OUT)$/inc +INCPRE+=$(UNOUCROUT) + +# --- Types ------------------------------------- + +UNOTYPES+= \ + com.sun.star.util.XCancellable \ + com.sun.star.util.XNumberFormatter \ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XWeak \ + com.sun.star.uno.XAggregation \ + com.sun.star.beans.XPropertyState \ + com.sun.star.beans.XPropertySet \ + com.sun.star.beans.PropertyValue \ + com.sun.star.beans.XMultiPropertySet \ + com.sun.star.beans.XFastPropertySet \ + com.sun.star.container.XIndexAccess \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.EventObject \ + com.sun.star.lang.XComponent \ + com.sun.star.lang.IllegalArgumentException \ + com.sun.star.lang.DisposedException \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.java.XJavaThreadRegister_11 \ + com.sun.star.java.XJavaVM \ + com.sun.star.sdbc.XConnection \ + com.sun.star.sdbc.XStatement \ + com.sun.star.sdbc.XResultSet \ + com.sun.star.sdbc.XResultSetMetaDataSupplier \ + com.sun.star.sdbc.XColumnLocate \ + com.sun.star.sdbc.XResultSetUpdate \ + com.sun.star.sdbc.XWarningsSupplier \ + com.sun.star.sdbc.XRowUpdate \ + com.sun.star.sdbc.XMultipleResults \ + com.sun.star.sdbc.XBatchExecution \ + com.sun.star.sdbc.XPreparedBatchExecution \ + com.sun.star.sdbc.XParameters \ + com.sun.star.sdbc.XOutParameters \ + com.sun.star.sdbc.DriverPropertyInfo \ + com.sun.star.sdbc.XDriver \ + com.sun.star.sdbc.XRow \ + com.sun.star.sdbc.SQLWarning \ + com.sun.star.sdbc.ColumnSearch \ + com.sun.star.sdbc.DataType \ + com.sun.star.sdbc.ResultSetConcurrency \ + com.sun.star.sdbc.ResultSetType \ + com.sun.star.sdbc.ColumnValue \ + com.sun.star.sdbc.TransactionIsolation \ + com.sun.star.sdbc.FetchDirection \ + com.sun.star.sdbc.KeyRule \ + com.sun.star.sdbc.IndexType \ + com.sun.star.sdbc.ProcedureResult \ + com.sun.star.sdb.XColumnUpdate \ + com.sun.star.sdb.XColumn \ + com.sun.star.sdbcx.XDataDescriptorFactory \ + com.sun.star.sdbcx.XColumnsSupplier \ + com.sun.star.sdbcx.XIndexesSupplier \ + com.sun.star.sdbcx.XKeysSupplier \ + com.sun.star.sdbcx.XRename \ + com.sun.star.sdbcx.XAlterTable \ + com.sun.star.sdbcx.XDataDefinitionSupplier \ + com.sun.star.sdbcx.XViewsSupplier \ + com.sun.star.sdbcx.XUsersSupplier \ + com.sun.star.sdbcx.XGroupsSupplier \ + com.sun.star.sdbcx.XAuthorizable \ + com.sun.star.sdbcx.Privilege \ + com.sun.star.sdbcx.PrivilegeObject \ + com.sun.star.sdbcx.XUser \ + com.sun.star.sdbcx.XRowLocate \ + com.sun.star.sdbcx.XDeleteRows \ + com.sun.star.lang.XServiceInfo + + + +# --- Files ------------------------------------- + +SLOFILES=\ + $(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)$/ADatabaseMetaData.obj \ + $(SLO)$/AStatement.obj \ + $(SLO)$/APreparedStatement.obj \ + $(SLO)$/AResultSetMetaData.obj \ + $(SLO)$/ADriver.obj \ + $(SLO)$/Aservices.obj \ + $(SLO)$/adoimp.obj + + +# --- Library ----------------------------------- + +SHL1TARGET= $(ADO_TARGET)$(ADO_MAJOR) +SHL1OBJS=$(SLOFILES) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(OSLLIB) \ + $(SALLIB) \ + ole32.lib \ + oleaut32.lib \ + uuid.lib + +SHL1DEPN= +SHL1IMPLIB= i$(SHL1TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib \ + $(SLB)$/commontools.lib \ + $(SLB)$/resource.lib \ + $(SLB)$/sdbcx.lib + + +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + +.ENDIF + diff --git a/connectivity/source/drivers/dbase/DCatalog.cxx b/connectivity/source/drivers/dbase/DCatalog.cxx new file mode 100644 index 000000000000..ece2f98db7d2 --- /dev/null +++ b/connectivity/source/drivers/dbase/DCatalog.cxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * $RCSfile: DCatalog.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_CATALOG_HXX_ +#include "dbase/DCatalog.hxx" +#endif + +#ifndef _CONNECTIVITY_DBASE_DCONNECTION_HXX_ +#include "dbase/DConnection.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_TABLES_HXX_ +#include "dbase/DTables.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; + +// ------------------------------------------------------------------------- +using namespace connectivity::dbase; +// ------------------------------------------------------------------------- +ODbaseCatalog::ODbaseCatalog(ODbaseConnection* _pCon) : file::OFileCatalog(_pCon) +{ + osl_incrementInterlockedCount( &m_refCount ); + refreshTables(); + osl_decrementInterlockedCount( &m_refCount ); +} +// ------------------------------------------------------------------------- +void ODbaseCatalog::refreshTables() +{ + ::std::vector< ::rtl::OUString> aVector; + Sequence< ::rtl::OUString > aTypes(1); + aTypes[0] = ::rtl::OUString::createFromAscii("%"); + Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), + ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(3)); + } + if(m_pTables) + delete m_pTables; + m_pTables = new ODbaseTables(m_xMetaData,*this,m_aMutex,aVector); +} + + diff --git a/connectivity/source/drivers/dbase/DColumns.cxx b/connectivity/source/drivers/dbase/DColumns.cxx new file mode 100644 index 000000000000..d375e517f602 --- /dev/null +++ b/connectivity/source/drivers/dbase/DColumns.cxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * $RCSfile: DColumns.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_COLUMNS_HXX_ +#include "dbase/DColumns.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_TABLE_HXX_ +#include "dbase/DTable.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif + +using namespace connectivity::dbase; +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; + + +Reference< XNamed > ODbaseColumns::createObject(const ::rtl::OUString& _rName) +{ + + ODbaseTable* pTable = (ODbaseTable*)m_pTable; + + // Reference< XFastPropertySet> xCol(pTable->getColumns()[_rName],UNO_QUERY); + ::vos::ORef<OSQLColumns> aCols = pTable->getTableColumns(); + + Reference< XNamed > xRet(*find(aCols->begin(),aCols->end(),_rName,::utl::UStringMixEqual(isCaseSensitive())),UNO_QUERY); + return xRet; +} + +// ------------------------------------------------------------------------- +void ODbaseColumns::impl_refresh() throw(RuntimeException) +{ + m_pTable->refreshColumns(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > ODbaseColumns::createEmptyObject() +{ + sdbcx::OColumn* pRet = new sdbcx::OColumn(isCaseSensitive()); + Reference< XPropertySet > xRet = pRet; + return xRet; +} + diff --git a/connectivity/source/drivers/dbase/DConnection.cxx b/connectivity/source/drivers/dbase/DConnection.cxx new file mode 100644 index 000000000000..7756d01f637e --- /dev/null +++ b/connectivity/source/drivers/dbase/DConnection.cxx @@ -0,0 +1,141 @@ +/************************************************************************* + * + * $RCSfile: DConnection.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_OCONNECTION_HXX_ +#include "dbase/DConnection.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_ODATABASEMETADATA_HXX_ +#include "dbase/DDatabaseMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_CATALOG_HXX_ +#include "dbase/DCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_RESOURCE_HRC_ +#include "Resource.hrc" +#endif +#ifndef _CONNECTIVITY_MODULECONTEXT_HXX_ +#include "ModuleContext.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_ODRIVER_HXX_ +#include "dbase/DDriver.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _URLOBJ_HXX //autogen wg. INetURLObject +#include <tools/urlobj.hxx> +#endif +//#ifndef _FSYS_HXX //autogen +//#include <tools/fsys.hxx> +//#endif + +using namespace connectivity::dbase; +using namespace connectivity::file; + +typedef connectivity::file::OConnection OConnection_B; + +//------------------------------------------------------------------------------ +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::lang; + +// -------------------------------------------------------------------------------- +ODbaseConnection::ODbaseConnection(ODriver* _pDriver) : OConnection(_pDriver) +{ + m_aFilenameExtension = String::CreateFromAscii("dbf"); +} +//----------------------------------------------------------------------------- +ODbaseConnection::~ODbaseConnection() +{ +} + +// XServiceInfo +// -------------------------------------------------------------------------------- +IMPLEMENT_SERVICE_INFO(ODbaseConnection, "com.sun.star.sdbc.drivers.dbase.Connection", "com.sun.star.sdbc.Connection") + +// -------------------------------------------------------------------------------- +Reference< XDatabaseMetaData > SAL_CALL ODbaseConnection::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_B::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_xMetaData.is()) + m_xMetaData = new ODbaseDatabaseMetaData(this); + + return m_xMetaData; +} +//------------------------------------------------------------------------------ +::com::sun::star::uno::Reference< XTablesSupplier > ODbaseConnection::createCatalog() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + Reference< XTablesSupplier > xTab = m_xCatalog; + if(!m_xCatalog.get().is()) + { + ODbaseCatalog *pCat = new ODbaseCatalog(this); + xTab = pCat; + m_xCatalog = xTab; + } + return xTab; +} + diff --git a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx new file mode 100644 index 000000000000..40a12d9e234d --- /dev/null +++ b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx @@ -0,0 +1,457 @@ +/************************************************************************* + * + * $RCSfile: DDatabaseMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_ODATABASEMETADATA_HXX_ +#include "dbase/DDatabaseMetaData.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XFASTPROPERTYSET_HPP_ +#include <com/sun/star/beans/XFastPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XIndexesSupplier.hpp> +#endif +#ifndef _URLOBJ_HXX //autogen wg. INetURLObject +#include <tools/urlobj.hxx> +#endif +//#ifndef _FSYS_HXX //autogen +//#include <tools/fsys.hxx> +//#endif +#ifndef _CONNECTIVITY_FILE_ADATABASEMETADATARESULTSET_HXX_ +#include "file/FDatabaseMetaDataResultSet.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif +#ifndef _CONNECTIVITY_DBASE_INDEX_HXX_ +#include "dbase/DIndex.hxx" +#endif + +using namespace connectivity::dbase; +using namespace connectivity::file; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; + + + +ODbaseDatabaseMetaData::ODbaseDatabaseMetaData(OConnection* _pCon) :ODatabaseMetaData(_pCon) +{ +} +// ------------------------------------------------------------------------- +ODbaseDatabaseMetaData::~ODbaseDatabaseMetaData() +{ +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setTypeInfoMap(); + ORows aRows; + ORow aRow; + + aRow.push_back(Any()); + aRow.push_back(makeAny(::rtl::OUString::createFromAscii("CHAR"))); + aRow.push_back(makeAny(DataType::CHAR)); + aRow.push_back(makeAny((sal_Int32)254)); + aRow.push_back(makeAny(::rtl::OUString::createFromAscii("'"))); + aRow.push_back(makeAny(::rtl::OUString::createFromAscii("'"))); + aRow.push_back(Any()); + aRow.push_back(makeAny((sal_Int32)ColumnValue::NULLABLE)); + aRow.push_back(makeAny((sal_Int32)1)); + aRow.push_back(makeAny((sal_Int32)ColumnSearch::CHAR)); + aRow.push_back(makeAny((sal_Int32)1)); + aRow.push_back(makeAny((sal_Int32)0)); + aRow.push_back(makeAny((sal_Int32)0)); + aRow.push_back(Any()); + aRow.push_back(makeAny((sal_Int32)0)); + aRow.push_back(makeAny((sal_Int32)0)); + aRow.push_back(Any()); + aRow.push_back(Any()); + aRow.push_back(makeAny((sal_Int32)10)); + aRows.push_back(aRow); + + aRow[1] = makeAny(::rtl::OUString::createFromAscii("VARCHAR")); + aRow[2] = makeAny(DataType::VARCHAR); + aRow[4] = makeAny(::rtl::OUString::createFromAscii("'")); + aRow[5] = makeAny(::rtl::OUString::createFromAscii("'")); + aRows.push_back(aRow); + + + aRow[1] = makeAny(::rtl::OUString::createFromAscii("LONGVARCHAR")); + aRow[2] = makeAny(DataType::LONGVARCHAR); + aRow[3] = makeAny((sal_Int32)65535); + aRow[4] = makeAny(::rtl::OUString::createFromAscii("'")); + aRow[5] = makeAny(::rtl::OUString::createFromAscii("'")); + aRows.push_back(aRow); + + aRow[1] = makeAny(::rtl::OUString::createFromAscii("BOOL")); + aRow[2] = makeAny(DataType::BIT); + aRow[3] = makeAny((sal_Int32)1); + aRow[9] = makeAny((sal_Int32)ColumnSearch::BASIC); + aRows.push_back(aRow); + + aRow[1] = makeAny(::rtl::OUString::createFromAscii("DATE")); + aRow[2] = makeAny(DataType::DATE); + aRow[3] = makeAny((sal_Int32)10); + aRow[4] = makeAny(::rtl::OUString::createFromAscii("'")); + aRow[5] = makeAny(::rtl::OUString::createFromAscii("'")); + aRows.push_back(aRow); + + aRow[1] = makeAny(::rtl::OUString::createFromAscii("DECIMAL")); + aRow[2] = makeAny(DataType::DECIMAL); + aRow[3] = makeAny((sal_Int32)20); + aRow[15] = makeAny((sal_Int32)15); + aRows.push_back(aRow); + + aRow[1] = makeAny(::rtl::OUString::createFromAscii("NUMERIC")); + aRow[2] = makeAny(DataType::NUMERIC); + aRow[3] = makeAny((sal_Int32)20); + aRow[15] = makeAny((sal_Int32)20); + aRows.push_back(aRow); + + pResult->setRows(aRows); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getColumnPrivileges( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, + const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setColumnPrivilegesMap(); + return xRef; +} + +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getColumns( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, + const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + + Reference< XTablesSupplier > xTables = m_pConnection->createCatalog(); + if(!xTables.is()) + throw SQLException(); + + Reference< XNameAccess> xNames = xTables->getTables(); + if(!xNames.is()) + throw SQLException(); + + ORows aRows; + ORow aRow(19); + aRow[10] <<= (sal_Int32)10; + Sequence< ::rtl::OUString> aTabNames(xNames->getElementNames()); + const ::rtl::OUString* pTabBegin = aTabNames.getConstArray(); + const ::rtl::OUString* pTabEnd = pTabBegin + aTabNames.getLength(); + for(;pTabBegin != pTabEnd;++pTabBegin) + { + if(match(tableNamePattern,*pTabBegin,'\0')) + { + Reference< XColumnsSupplier> xTable; + xNames->getByName(*pTabBegin) >>= xTable; + aRow[3] <<= *pTabBegin; + + Reference< XNameAccess> xColumns = xTable->getColumns(); + if(!xColumns.is()) + throw SQLException(); + + Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames()); + + const ::rtl::OUString* pBegin = aColNames.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aColNames.getLength(); + Reference< XFastPropertySet> xColumn; + for(sal_Int32 i=1;pBegin != pEnd;++pBegin,++i) + { + if(match(columnNamePattern,*pBegin,'\0')) + { + aRow[4] <<= *pBegin; + + xColumns->getByName(*pBegin) >>= xColumn; + OSL_ENSHURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!"); + aRow[5] = xColumn->getFastPropertyValue(PROPERTY_ID_TYPE); + aRow[6] = xColumn->getFastPropertyValue(PROPERTY_ID_TYPENAME); + aRow[7] = xColumn->getFastPropertyValue(PROPERTY_ID_PRECISION); + // aRow[8] = xColumn->getFastPropertyValue(PROPERTY_ID_TYPENAME); + aRow[9] = xColumn->getFastPropertyValue(PROPERTY_ID_SCALE); + aRow[11] = xColumn->getFastPropertyValue(PROPERTY_ID_ISNULLABLE); + // aRow[12] = xColumn->getFastPropertyValue(PROPERTY_ID_TYPENAME); + aRow[13] = xColumn->getFastPropertyValue(PROPERTY_ID_DEFAULTVALUE); + // aRow[14] = xColumn->getFastPropertyValue(PROPERTY_ID_TYPENAME); + // aRow[15] = xColumn->getFastPropertyValue(PROPERTY_ID_TYPENAME); + switch(getINT32(aRow[5])) + { + case DataType::CHAR: + case DataType::VARCHAR: + aRow[16] <<= (sal_Int32)254; + break; + case DataType::LONGVARCHAR: + aRow[16] <<= (sal_Int32)65535; + break; + default: + aRow[16] <<= (sal_Int32)0; + } + aRow[17] <<= i; + switch(getINT32(aRow[11])) + { + case ColumnValue::NO_NULLS: + aRow[18] <<= ::rtl::OUString::createFromAscii("NO"); + break; + case ColumnValue::NULLABLE: + aRow[18] <<= ::rtl::OUString::createFromAscii("YES"); + break; + default: + aRow[18] <<= ::rtl::OUString(); + } + aRows.push_back(aRow); + } + } + } + } + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setColumnsMap(); + pResult->setRows(aRows); + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getVersionColumns( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setVersionColumnsMap(); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getExportedKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setExportedKeysMap(); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getImportedKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setImportedKeysMap(); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getPrimaryKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setPrimaryKeysMap(); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getIndexInfo( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, + sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + Reference< XTablesSupplier > xTables = m_pConnection->createCatalog(); + if(!xTables.is()) + throw SQLException(); + + Reference< XNameAccess> xNames = xTables->getTables(); + if(!xNames.is()) + throw SQLException(); + + ORows aRows; + ORow aRow(14); + aRow[5] <<= ::rtl::OUString(); + aRow[10] <<= ::rtl::OUString::createFromAscii("A"); + + Reference< XIndexesSupplier> xTable; + xNames->getByName(table) >>= xTable; + aRow[3] <<= table; + aRow[7] <<= (sal_Int32)3; + + Reference< XNameAccess> xIndexes = xTable->getIndexes(); + if(!xIndexes.is()) + throw SQLException(); + + Sequence< ::rtl::OUString> aIdxNames(xIndexes->getElementNames()); + + const ::rtl::OUString* pBegin = aIdxNames.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aIdxNames.getLength(); + Reference< XFastPropertySet> xIndex; + for(;pBegin != pEnd;++pBegin) + { + xIndexes->getByName(*pBegin) >>= xIndex; + OSL_ENSHURE(xIndex.is(),"Indexes contains a column who isn't a fastpropertyset!"); + + if(unique && !getBOOL(xIndex->getFastPropertyValue(PROPERTY_ID_ISUNIQUE))) + continue; + aRow[4] = xIndex->getFastPropertyValue(PROPERTY_ID_ISUNIQUE); + aRow[6] <<= *pBegin; + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(xIndex,UNO_QUERY); + if(xTunnel.is()) + { + ODbaseIndex* pIndex = (ODbaseIndex*)xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()); + if(pIndex) + { + aRow[11] <<= pIndex->getHeader().db_maxkeys; + aRow[12] <<= pIndex->getHeader().db_pagecount; + } + } + + Reference<XColumnsSupplier> xColumnsSup(xIndex,UNO_QUERY); + Reference< XNameAccess> xColumns = xColumnsSup->getColumns(); + Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames()); + + const ::rtl::OUString* pColBegin = aColNames.getConstArray(); + const ::rtl::OUString* pColEnd = pColBegin + aColNames.getLength(); + Reference< XFastPropertySet> xColumn; + for(sal_Int32 j=1;pColBegin != pColEnd;++pColBegin,++j) + { + xColumns->getByName(*pColBegin) >>= xColumn; + aRow[8] <<= j; + aRow[9] <<= *pColBegin; + aRows.push_back(aRow); + } + } + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setIndexInfoMap(); + pResult->setRows(aRows); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getBestRowIdentifier( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, + sal_Bool nullable ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setBestRowIdentifierMap(); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getTablePrivileges( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setTablePrivilegesMap(); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getCrossReference( + const Any& primaryCatalog, const ::rtl::OUString& primarySchema, + const ::rtl::OUString& primaryTable, const Any& foreignCatalog, + const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setCrossReferenceMap(); + return xRef; +} + diff --git a/connectivity/source/drivers/dbase/DDriver.cxx b/connectivity/source/drivers/dbase/DDriver.cxx new file mode 100644 index 000000000000..66639239c8e3 --- /dev/null +++ b/connectivity/source/drivers/dbase/DDriver.cxx @@ -0,0 +1,151 @@ +/************************************************************************* + * + * $RCSfile: DDriver.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_DDRIVER_HXX_ +#include "dbase/DDriver.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_DCONNECTION_HXX_ +#include "dbase/DConnection.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + +using namespace connectivity::dbase; +using namespace connectivity::file; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::lang; + + +// static ServiceInfo +//------------------------------------------------------------------------------ +rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException) +{ + return rtl::OUString::createFromAscii("com.sun.star.sdbc.driver.dbase.Driver"); +} +//------------------------------------------------------------------------------ +//Sequence< ::rtl::OUString > ODriver::getSupportedServiceNames_Static( ) throw (RuntimeException) +//{ +// Sequence< ::rtl::OUString > aSNS( 2 ); +// aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver"); +// aSNS[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Driver"); +// return aSNS; +//} + +//------------------------------------------------------------------ +::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------ +//sal_Bool SAL_CALL ODriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) +//{ +// Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); +// const ::rtl::OUString* pSupported = aSupported.getConstArray(); +// for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) +// if (pSupported->equals(_rServiceName)) +// return sal_True; +// +// return sal_False; +//} + +//------------------------------------------------------------------ +//Sequence< ::rtl::OUString > SAL_CALL ODriver::getSupportedServiceNames( ) throw(RuntimeException) +//{ +// return getSupportedServiceNames_Static(); +//} + + +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::dbase::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ) +{ + return *(new ODriver(_rxFactory)); +} +// -------------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODriver_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ODbaseConnection* pCon = new ODbaseConnection(this); + pCon->construct(url,info); + Reference< XConnection > xCon = pCon; + m_xConnections.push_back(WeakReferenceHelper(*pCon)); + + return xCon; +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url ) + throw(SQLException, RuntimeException) +{ + if(!url.compareTo(::rtl::OUString::createFromAscii("sdbc:dbase:"),11)) + { + return sal_True; + } + return sal_False; +} + + diff --git a/connectivity/source/drivers/dbase/DIndex.cxx b/connectivity/source/drivers/dbase/DIndex.cxx new file mode 100644 index 000000000000..62315ef98f88 --- /dev/null +++ b/connectivity/source/drivers/dbase/DIndex.cxx @@ -0,0 +1,701 @@ +/************************************************************************* + * + * $RCSfile: DIndex.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_INDEX_HXX_ +#include "dbase/DIndex.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_INDEXCOLUMNS_HXX_ +#include "dbase/DIndexColumns.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CONNECTIVITY_DBASE_TABLE_HXX_ +#include "dbase/DTable.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_INDEXITER_HXX_ +#include "dbase/DIndexIter.hxx" +#endif +//#ifndef _FSYS_HXX //autogen +//#include <tools/fsys.hxx> +//#endif +#ifndef _CONFIG_HXX //autogen +#include <vcl/config.hxx> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _UCBHELPER_CONTENT_HXX +#include <ucbhelper/content.hxx> +#endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif +// ------------------------------------------------------------------------- +using namespace connectivity; +using namespace ucb; +using namespace cppu; +using namespace connectivity::file; +using namespace connectivity::sdbcx; +using namespace connectivity::dbase; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::uno; +using namespace com::sun::star::beans; +using namespace com::sun::star::ucb; + + +IMPLEMENT_SERVICE_INFO(ODbaseIndex,"com.sun.star.sdbcx.driver.dbase.Index","com.sun.star.sdbcx.Index"); +// ------------------------------------------------------------------------- +ODbaseIndex::ODbaseIndex(ODbaseTable* _pTable) : OIndex(_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()) + , m_pTable(_pTable) +{ + construct(); +} +// ------------------------------------------------------------------------- +ODbaseIndex::ODbaseIndex( ODbaseTable* _pTable, + const NDXHeader& _rHeader, + const ::rtl::OUString& _rName) + : OIndex(_rName,::rtl::OUString(),_rHeader.db_unique,sal_False,sal_False,_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()) + , m_aHeader(_rHeader) + , m_pTable(_pTable) +{ + construct(); +} +// ------------------------------------------------------------------------- +void ODbaseIndex::refreshColumns() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ::std::vector< ::rtl::OUString> aVector; + aVector.push_back(::rtl::OUString::createFromAscii(m_aHeader.db_name)); + + if(m_pColumns) + delete m_pColumns; + m_pColumns = new ODbaseIndexColumns(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +Any SAL_CALL ODbaseIndex::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); + if(aRet.hasValue()) + return aRet; + + return ODbaseIndex_BASE::queryInterface(rType); +} + +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > ODbaseIndex::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 ODbaseIndex::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL ODbaseIndex::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),ODbaseIndex_BASE::getTypes()); +} + +//------------------------------------------------------------------ +ONDXPagePtr ODbaseIndex::getRoot() +{ + openIndexFile(); + if (!m_aRoot.Is()) + { + m_nRootPage = m_aHeader.db_rootpage; + m_nPageCount = m_aHeader.db_pagecount; + m_aRoot = CreatePage(m_nRootPage,NULL,TRUE); + } + return m_aRoot; +} +//------------------------------------------------------------------ +sal_Bool ODbaseIndex::openIndexFile() +{ + if(!m_aFileStream.IsOpen()) + { + INetURLObject aURL; + aURL.SetSmartProtocol(INET_PROT_FILE); + aURL.SetSmartURL(m_pTable->getEntry(), INetURLObject::ENCODE_ALL); + + aURL.setName(m_Name); + aURL.setExtension(String::CreateFromAscii("ndx")); + + // Dir* pDir = m_pTable->getConnection()->getDir(); + // String aPath = pDir->GetName(); + // aPath += m_Name.getStr(); + // DirEntry aEntry(aPath); + // aEntry.setExtension(String::CreateFromAscii("ndx")); + m_aFileStream.Open(aURL.GetMainURL(), STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE); + + m_aFileStream.SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN); + m_aFileStream.SetBufferSize(512); + } + + return m_aFileStream.IsOpen(); +} +//------------------------------------------------------------------ +OIndexIterator* ODbaseIndex::createIterator(OBoolOperator* pOp, + const OOperand* pOperand) +{ + openIndexFile(); + return new OIndexIterator(this, pOp, pOperand); +} +//------------------------------------------------------------------ +BOOL ODbaseIndex::ConvertToKey(ONDXKey* rKey, sal_uInt32 nRec, const OFileValue& rValue) +{ + OSL_ENSHURE(m_aFileStream.IsOpen(),"FileStream is not opened!"); + // Sucht ein bestimmten Wert im Index + // Wenn der Index Unique ist, interssiert der Key nicht, sonst ja + try + { + if (m_aHeader.db_keytype == 0) + { + *rKey = ONDXKey(rValue.getString(), nRec ); + } + else + { + if (rValue.isNull()) + *rKey = ONDXKey(rValue.getDouble(), DataType::DOUBLE, nRec ); + else + *rKey = ONDXKey(rValue.getDouble(), nRec ); + } + } + catch (...) + { + return FALSE; + } + return TRUE; +} + +//------------------------------------------------------------------ +BOOL ODbaseIndex::Find(sal_uInt32 nRec, const OFileValue& rValue) +{ + openIndexFile(); + OSL_ENSHURE(m_aFileStream.IsOpen(),"FileStream is not opened!"); + // Sucht ein bestimmten Wert im Index + // Wenn der Index Unique ist, interssiert der Key nicht, sonst ja + ONDXKey aKey; + return ConvertToKey(&aKey, nRec, rValue) && getRoot()->Find(aKey); +} + +//------------------------------------------------------------------ +BOOL ODbaseIndex::Insert(sal_uInt32 nRec, const OFileValue& rValue) +{ + openIndexFile(); + OSL_ENSHURE(m_aFileStream.IsOpen(),"FileStream is not opened!"); + ONDXKey aKey; + + // Existiert der Wert bereits + // Find immer verwenden um das aktuelle Blatt zu bestimmen + if (!ConvertToKey(&aKey, nRec, rValue) || (getRoot()->Find(aKey) && isUnique())) + return FALSE; + + ONDXNode aNewNode(aKey); + + // einfuegen in das aktuelle Blatt + if (!m_aCurLeaf.Is()) + return FALSE; + + BOOL bResult = m_aCurLeaf->Insert(aNewNode); + Release(bResult); + + return bResult; +} + +//------------------------------------------------------------------ +BOOL ODbaseIndex::Update(sal_uInt32 nRec, const OFileValue& rOldValue, + const OFileValue& rNewValue) +{ + openIndexFile(); + OSL_ENSHURE(m_aFileStream.IsOpen(),"FileStream is not opened!"); + ONDXKey aKey; + if (!ConvertToKey(&aKey, nRec, rNewValue) || (isUnique() && getRoot()->Find(aKey))) + return FALSE; + else + return Delete(nRec, rOldValue) && Insert(nRec,rNewValue); +} + +//------------------------------------------------------------------ +BOOL ODbaseIndex::Delete(sal_uInt32 nRec, const OFileValue& rValue) +{ + openIndexFile(); + OSL_ENSHURE(m_aFileStream.IsOpen(),"FileStream is not opened!"); + // Existiert der Wert bereits + // Find immer verwenden um das aktuelle Blatt zu bestimmen + ONDXKey aKey; + if (!ConvertToKey(&aKey, nRec, rValue) || !getRoot()->Find(aKey)) + return FALSE; + + ONDXNode aNewNode(aKey); + + // einfuegen in das aktuelle Blatt + if (!m_aCurLeaf.Is()) + return FALSE; +#if DEBUG + m_aRoot->PrintPage(); +#endif + + return m_aCurLeaf->Delete(m_nCurNode); +} +//------------------------------------------------------------------ +void ODbaseIndex::Collect(ONDXPage* pPage) +{ + OSL_ENSHURE(m_aFileStream.IsOpen(),"FileStream is not opened!"); + if (pPage) + m_aCollector.push_back(pPage); +} +//------------------------------------------------------------------ +void ODbaseIndex::Release(BOOL bSave) +{ + // Freigeben der Indexressourcen + m_bUseCollector = FALSE; + + if (m_aCurLeaf.Is()) + { + m_aCurLeaf->Release(bSave); + m_aCurLeaf.Clear(); + } + + // Wurzel freigeben + if (m_aRoot.Is()) + { + m_aRoot->Release(bSave); + m_aRoot.Clear(); + } + // alle Referenzen freigeben, bevor der FileStream geschlossen wird + for (ULONG i = 0; i < m_aCollector.size(); i++) + m_aCollector[i]->QueryDelete(); + + m_aCollector.clear(); + + // Header modifiziert ? + if (bSave && (m_aHeader.db_rootpage != m_nRootPage || + m_aHeader.db_pagecount != m_nPageCount)) + { + m_aHeader.db_rootpage = m_nRootPage; + m_aHeader.db_pagecount = m_nPageCount; + m_aFileStream << *this; + } + m_nRootPage = m_nPageCount = 0; + m_nCurNode = NODE_NOTFOUND; +} +//------------------------------------------------------------------ +ONDXPage* ODbaseIndex::CreatePage(sal_uInt32 nPagePos, ONDXPage* pParent, BOOL bLoad) +{ + OSL_ENSHURE(m_aFileStream.IsOpen(),"FileStream is not opened!"); + + ONDXPage* pPage; + if (m_aCollector.size()) + { + pPage = *(m_aCollector.end() - 1); + m_aCollector.pop_back(); + pPage->SetPagePos(nPagePos); + pPage->SetParent(pParent); + } + else + pPage = new ONDXPage(*this, nPagePos, pParent); + + if (bLoad) + m_aFileStream >> *pPage; + + return pPage; +} + +//------------------------------------------------------------------ +SvStream& connectivity::dbase::operator >> (SvStream &rStream, ODbaseIndex& rIndex) +{ + rStream.Seek(0); + rStream.Read(&rIndex.m_aHeader,512); + + // Text convertierung + ByteString aText(rIndex.m_aHeader.db_name); + // aText.Convert(rIndex.GetDBFConnection()->GetCharacterSet(), gsl_getSystemTextEncoding()); + // aText.Convert(rIndex.GetDBFConnection()->GetCharacterSet(), gsl_getSystemTextEncoding()); + strcpy(rIndex.m_aHeader.db_name,aText.GetBuffer()); + + rIndex.m_nRootPage = rIndex.m_aHeader.db_rootpage; + rIndex.m_nPageCount = rIndex.m_aHeader.db_pagecount; + return rStream; +} +//------------------------------------------------------------------ +SvStream& connectivity::dbase::operator << (SvStream &rStream, ODbaseIndex& rIndex) +{ + rStream.Seek(0); + ByteString aText(rIndex.m_aHeader.db_name); + // aText.Convert(gsl_getSystemTextEncoding(), rIndex.GetDBFConnection()->GetCharacterSet()); + strcpy(rIndex.m_aHeader.db_name,aText.GetBuffer()); + sal_Int32 nWrites = rStream.Write(&rIndex.m_aHeader,512); + OSL_ENSHURE(nWrites == 512,"Write not successful: Wrong header size for dbase index!"); + return rStream; +} +// ------------------------------------------------------------------------- +INetURLObject ODbaseIndex::getEntry() +{ + INetURLObject aDir = m_pTable->getEntry(); + aDir.setName(m_Name); + return aDir; +} +//------------------------------------------------------------------ +void ODbaseIndex::createINFEntry() +{ + // inf Datei abgleichen + String aNDX; + // Dir* pDir = m_pTable->getConnection()->getDir(); + // String aPath = pDir->GetName(); + // aPath += m_Name.getStr(); + INetURLObject aEntry(getEntry()); + aEntry.setExtension(String::CreateFromAscii("ndx")); + + INetURLObject aInfEntry(m_pTable->getEntry()); + aInfEntry.setExtension(String::CreateFromAscii("inf")); + + Config aInfFile(aInfEntry.GetMainURL()); + aInfFile.SetGroup(dBASE_III_GROUP); + + USHORT nSuffix = aInfFile.GetKeyCount(); + ByteString aNewEntry,aKeyName; + BOOL bCase = isCaseSensitive(); + while (!aNewEntry.Len()) + { + aNewEntry = "NDX"; + aNewEntry += ByteString::CreateFromInt32(++nSuffix); + for (USHORT i = 0; i < aInfFile.GetKeyCount(); i++) + { + aKeyName = aInfFile.GetKeyName(i); + if (bCase ? aKeyName == aNewEntry : aKeyName.EqualsIgnoreCaseAscii(aNewEntry)) + { + aNewEntry.Erase(); + break; + } + } + } + aInfFile.WriteKey(aNewEntry,ByteString(aEntry.GetName(),gsl_getSystemTextEncoding())); +} +// ------------------------------------------------------------------------- +BOOL ODbaseIndex::DropImpl() +{ + if (m_aFileStream.IsOpen()) + m_aFileStream.Close(); + + INetURLObject aIndexEntry(getEntry()); + aIndexEntry.setExtension(String::CreateFromAscii("ndx")); + + Content aContent(aIndexEntry.GetMainURL(),Reference<XCommandEnvironment>()); + aContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) ); + +// ULONG nErrorCode = aIndexEntry.Kill(); +// if (nErrorCode != SVSTREAM_OK && nErrorCode != SVSTREAM_FILE_NOT_FOUND) +// { +// // aStatus.SetError(nErrorCode,INDEX,aName); +// return FALSE; +// } + + // InfDatei abgleichen + String aNDX; + INetURLObject aEntry( m_pTable->getEntry()); + aEntry.setExtension(String::CreateFromAscii("inf")); + + Config aInfFile(aEntry.GetMainURL()); + aInfFile.SetGroup(dBASE_III_GROUP); + USHORT nKeyCnt = aInfFile.GetKeyCount(); + ByteString aKeyName; + + INetURLObject aEntryToComp(getEntry()); + aEntryToComp.setExtension(String::CreateFromAscii("ndx")); + + for (USHORT nKey = 0; nKey < nKeyCnt; nKey++) + { + // Verweist der Key auf ein Indexfile?... + aKeyName = aInfFile.GetKeyName( nKey ); + //...wenn ja, Indexliste der Tabelle hinzufuegen + if (aEntry.IsCaseSensitive() ? aKeyName.Copy(0,3) == "NDX" : aKeyName.Copy(0,3).EqualsIgnoreCaseAscii("NDX")) + { + aEntryToComp.setName(String(aInfFile.ReadKey(aKeyName),gsl_getSystemTextEncoding())); + aEntryToComp.setExtension(String::CreateFromAscii("ndx")); + if (aEntryToComp == aIndexEntry) + { + aInfFile.DeleteKey(aKeyName); + break; + } + } + } + return TRUE; +} +// ------------------------------------------------------------------------- +//------------------------------------------------------------------ +BOOL ODbaseIndex::CreateImpl() +{ + // Anlegen des Index + INetURLObject aEntry(getEntry()); + aEntry.setExtension(String::CreateFromAscii("ndx")); + + Content aContent(aEntry.GetMainURL(),Reference<XCommandEnvironment>()); + if (aContent.isDocument()) + { + // aStatus.SetError(ERRCODE_IO_ALREADYEXISTS,INDEX,aEntry.GetFull()); + return FALSE; + } + + // Index ist nur einstufig + if (m_pColumns->getCount() != 2) + { + // aStatus.SetDriverNotCapableError(); + return FALSE; + } + + Reference<XFastPropertySet> xCol; + m_pColumns->getByIndex(1) >>= xCol; + + // ist die Spalte schon indiziert ? + if (!xCol.is()) + { +// String aText = String(OResId(STR_STAT_INDEX_COLUMN_NOT_FOUND)); +// aText.SearchAndReplace(String::CreateFromAscii("#"),pColumn->GetName()); +// aText.SearchAndReplace(String::CreateFromAscii("%"),GetTable()->Name()); +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(aText), +// 0, String() ); + return FALSE; + } +// else if (pColumn && pColumn->IsIndexed()) +// { +// String aText = String(OResId(STR_STAT_INDEX_COLUMN_ALREADY_INDEXED)); +// aText.SearchAndReplace(String::CreateFromAscii("#"),pColumn->GetName()); +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(aText), +// 0, String() ); +// return FALSE; +// } + + // Anlegen des Indexfiles + m_aFileStream.Open(aEntry.GetMainURL(), STREAM_READWRITE | STREAM_SHARE_DENYWRITE | STREAM_TRUNC); + if (!m_aFileStream.IsOpen()) + return FALSE; + + m_aFileStream.SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN); + m_aFileStream.SetBufferSize(512); + + // Zunchst mu das Ergebnis sortiert sein + Reference<XStatement> xStmt = m_pTable->getConnection()->createStatement(); + + String aName(getString(xCol->getFastPropertyValue(PROPERTY_ID_NAME))); + + String aQuote(m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString()); + String aStatement; + aStatement.AssignAscii("SELECT "); + aStatement += aQuote; + aStatement += aName; + aStatement += aQuote; + aStatement.AppendAscii(" FROM "); + aStatement += aQuote; + aStatement += m_pTable->getName().getStr(); + aStatement += aQuote; + aStatement.AppendAscii(" ORDER BY "); + aStatement += aQuote; + aStatement += aName; + aStatement += aQuote; + + if (!m_IsUnique) // zusaetzlich sortierung mit der bookmarkspalte + { + aStatement.AppendAscii(" ,"); + aStatement += aQuote; + aStatement.AppendAscii("[BOOKMARK]"); // this is a special column + aStatement += aQuote; + } + + Reference<XResultSet> xSet = xStmt->executeQuery(aStatement); + + if (!xSet.is()) + { + m_aFileStream.Close(); + // aEntry.Kill(); + aContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) ); + return FALSE; + } + + // Setzen der Headerinfo + memset(&m_aHeader,0,sizeof(m_aHeader)); + m_aFileStream.SetStreamSize(512); + + sal_Int32 nType = 0; + xCol->getFastPropertyValue(PROPERTY_ID_TYPE) >>= nType; + + m_aHeader.db_keytype = (nType == DataType::VARCHAR || nType == DataType::CHAR) ? 0 : 1; + m_aHeader.db_keylen = (m_aHeader.db_keytype) ? 8 : (USHORT)getINT32(xCol->getFastPropertyValue(PROPERTY_ID_PRECISION)); + m_aHeader.db_maxkeys = (512 - 8) / (8 + m_aHeader.db_keylen); + ByteString aCol(aName,gsl_getSystemTextEncoding()); + strcpy(m_aHeader.db_name,aCol.GetBuffer()); + m_aHeader.db_unique = m_IsUnique ? 1: 0; + m_aHeader.db_keyrec = m_aHeader.db_keylen + 8; + + // modifizierung am Header werden ueber Unterschiede zw. HeaderInfo und nRootPage + // bzw. nPageCout erkannt + + m_nRootPage = 1; + m_nPageCount = 2; + + // ODatabaseType eType = m_aHeader.db_keytype == 0 ? DataType::VARCHAR : DataType::DOUBLE; + m_aCurLeaf = m_aRoot = CreatePage(m_nRootPage); + m_aRoot->SetModified(TRUE); + + m_bUseCollector = TRUE; + + // ULONG nRowsLeft = pCursor->RowCount(); + Reference<XRow> xRow(xSet,UNO_QUERY); + + xSet->last(); + sal_Int32 nRowsLeft = xSet->getRow(); + xSet->beforeFirst(); + + // Erzeugen der Indexstruktur + while (xSet->next()) + { + // ODbRow& rRow = *pCursor->GetRow(); + // ueberpruefen auf doppelten eintrag + if (m_IsUnique && m_nCurNode != NODE_NOTFOUND) + { + ONDXKey aKey(m_aHeader.db_keytype ? OFileValue(xRow->getDouble(1)) : OFileValue(xRow->getString(1)), nType, 0); + if (aKey == (*m_aCurLeaf)[m_nCurNode].GetKey()) + { +// String aText = String(OResId(STR_STAT_INDEX_NOT_UNIQUE)); +// aText.SearchAndReplace(String::CreateFromAscii("#"),aName); +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(aText), +// 0, String() ); + break; + } + } + ONDXKey aKey(m_aHeader.db_keytype ? OFileValue(xRow->getDouble(1)) : OFileValue(xRow->getString(1)), nType, xSet->getRow()); + ONDXNode aNewNode(aKey); + if (!m_aCurLeaf->Insert(aNewNode, --nRowsLeft)) + break; + +#ifdef DEBUG + //DBG_TRACE1("SDB: %s", (const char*)pCursor->Variable(1)->GetString()); + // PrintTree(); +#endif + } + +// BOOL bResult = !pCursor->IsInRange(); +// if (!bResult) +// { +// m_aFileStream.Close(); +// aEntry.Kill(); +// Release(FALSE); +// } +// else +// { + + Release(); +// m_aFileStream.Close(); + // den FielStream NICHT schliessen, da per definitionem ein OObject nach dem Kreieren offen ist + + // inf Datei abgleichen + createINFEntry(); +// } +// + // pCursor->ReleaseRef(); + return sal_True; +} + + + diff --git a/connectivity/source/drivers/dbase/DIndexColumns.cxx b/connectivity/source/drivers/dbase/DIndexColumns.cxx new file mode 100644 index 000000000000..56d473a2ddff --- /dev/null +++ b/connectivity/source/drivers/dbase/DIndexColumns.cxx @@ -0,0 +1,119 @@ +/************************************************************************* + * + * $RCSfile: DIndexColumns.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_INDEXCOLUMNS_HXX_ +#include "dbase/DIndexColumns.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_TABLE_HXX_ +#include "dbase/DTable.hxx" +#endif + +#ifndef _CONNECTIVITY_SDBCX_INDEXCOLUMN_HXX_ +#include "connectivity/sdbcx/VIndexColumn.hxx" +#endif + +using namespace connectivity::dbase; +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; + + +Reference< XNamed > ODbaseIndexColumns::createObject(const ::rtl::OUString& _rName) +{ + const ODbaseTable* pTable = m_pIndex->getTable(); + + ::vos::ORef<OSQLColumns> aCols = pTable->getTableColumns(); + + Reference< XFastPropertySet > xCol(*find(aCols->begin(),aCols->end(),_rName,::utl::UStringMixEqual(isCaseSensitive()))); + if(!xCol.is()) + return Reference< XNamed >(); + + Reference< XNamed > xRet = new sdbcx::OIndexColumn(sal_True,_rName + ,getString(xCol->getFastPropertyValue(PROPERTY_ID_TYPENAME)) + ,::rtl::OUString() + ,getINT32(xCol->getFastPropertyValue(PROPERTY_ID_ISNULLABLE)) + ,getINT32(xCol->getFastPropertyValue(PROPERTY_ID_PRECISION)) + ,getINT32(xCol->getFastPropertyValue(PROPERTY_ID_SCALE)) + ,getINT32(xCol->getFastPropertyValue(PROPERTY_ID_TYPE)) + ,sal_False + ,sal_False + ,sal_False + ,pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()); + + return xRet; +} + +// ------------------------------------------------------------------------- +void ODbaseIndexColumns::impl_refresh() throw(RuntimeException) +{ + m_pIndex->refreshColumns(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > ODbaseIndexColumns::createEmptyObject() +{ + sdbcx::OColumn* pRet = new sdbcx::OIndexColumn(m_pIndex->getTable()->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()); + Reference< XPropertySet > xRet = pRet; + return xRet; +} + diff --git a/connectivity/source/drivers/dbase/DIndexIter.cxx b/connectivity/source/drivers/dbase/DIndexIter.cxx new file mode 100644 index 000000000000..e5669df7d29f --- /dev/null +++ b/connectivity/source/drivers/dbase/DIndexIter.cxx @@ -0,0 +1,344 @@ +/************************************************************************* + * + * $RCSfile: DIndexIter.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_INDEXITER_HXX_ +#include "dbase/DIndexIter.hxx" +#endif + +using namespace connectivity; +using namespace connectivity::dbase; +using namespace connectivity::file; +//================================================================== +// OIndexIterator +//================================================================== +//------------------------------------------------------------------ +OIndexIterator::~OIndexIterator() +{ + // m_pIndex->UnLock(); + m_pIndex->release(); +} + +//------------------------------------------------------------------ +ULONG OIndexIterator::First() +{ + return Find(TRUE); +} + +//------------------------------------------------------------------ +ULONG OIndexIterator::Next() +{ + return Find(FALSE); +} +//------------------------------------------------------------------ +ULONG OIndexIterator::Find(BOOL bFirst) +{ + // ONDXIndex* m_pIndex = GetNDXIndex(); + + ULONG nRes = STRING_NOTFOUND; +// if (!m_pIndex->IsOpen()) +// return nRes; + + if (bFirst) + { + m_aRoot = m_pIndex->getRoot(); + m_aCurLeaf = NULL; + } + + if (!m_pOperator) + { + // Vorbereitung , auf kleinstes Element positionieren + if (bFirst) + { + ONDXPage* pPage = m_aRoot.getBodyPtr(); + while (pPage && !pPage->IsLeaf()) + pPage = pPage->GetChild(m_pIndex).getBodyPtr(); + + m_aCurLeaf = pPage; + m_nCurNode = NODE_NOTFOUND; + } + ONDXKey* pKey = GetNextKey(); + nRes = pKey ? pKey->GetRecord() : STRING_NOTFOUND; + } + else if (m_pOperator->IsA(TYPE(OOp_ISNOTNULL))) + nRes = GetNotNull(bFirst); + else if (m_pOperator->IsA(TYPE(OOp_ISNULL))) + nRes = GetNull(bFirst); + else if (m_pOperator->IsA(TYPE(OOp_LIKE))) + nRes = GetLike(bFirst); + else if (m_pOperator->IsA(TYPE(OOp_COMPARE))) + nRes = GetCompare(bFirst); + + return nRes; +} + +//------------------------------------------------------------------ +ONDXKey* OIndexIterator::GetFirstKey(ONDXPage* pPage, const OOperand& rKey) +{ + // sucht den vorgegeben key + // Besonderheit: gelangt der Algorithmus ans Ende + // wird immer die aktuelle Seite und die Knotenposition vermerkt + // auf die die Bedingung <= zutrifft + // dieses findet beim Insert besondere Beachtung + // ONDXIndex* m_pIndex = GetNDXIndex(); + OOp_COMPARE aTempOp(SQL_PRED_GREATER); + USHORT i = 0; + + if (pPage->IsLeaf()) + { + // im blatt wird die eigentliche Operation ausgefuehrt, sonst die temp. (>) + while (i < pPage->Count() && !m_pOperator->operate(&((*pPage)[i]).GetKey(),&rKey)) + i++; + } + else + while (i < pPage->Count() && !aTempOp.operate(&((*pPage)[i]).GetKey(),&rKey)) + i++; + + + ONDXKey* pFoundKey = NULL; + if (!pPage->IsLeaf()) + { + // weiter absteigen + ONDXPagePtr aPage = (i==0) ? pPage->GetChild(m_pIndex) + : ((*pPage)[i-1]).GetChild(m_pIndex, pPage); + pFoundKey = aPage.Is() ? GetFirstKey(aPage.getBodyPtr(), rKey) : NULL; + } + else if (i == pPage->Count()) + { + pFoundKey = NULL; + } + else + { + pFoundKey = &(*pPage)[i].GetKey(); + if (!m_pOperator->operate(pFoundKey,&rKey)) + pFoundKey = NULL; + + m_aCurLeaf = pPage; + m_nCurNode = pFoundKey ? i : i - 1; + } + return pFoundKey; +} + +//------------------------------------------------------------------ +ULONG OIndexIterator::GetCompare(BOOL bFirst) +{ + ONDXKey* pKey = NULL; + // ONDXIndex* m_pIndex = GetNDXIndex(); + OSQLPredicateType ePredicateType = PTR_CAST(file::OOp_COMPARE,m_pOperator)->getPredicateType(); + + if (bFirst) + { + // Vorbereitung , auf kleinstes Element positionieren + ONDXPage* pPage = m_aRoot.getBodyPtr(); + switch (ePredicateType) + { + case SQL_PRED_NOTEQUAL: + case SQL_PRED_LESS: + case SQL_PRED_LESSOREQUAL: + while (pPage && !pPage->IsLeaf()) + pPage = pPage->GetChild(m_pIndex).getBodyPtr(); + + m_aCurLeaf = pPage; + m_nCurNode = NODE_NOTFOUND; + } + + + switch (ePredicateType) + { + case SQL_PRED_NOTEQUAL: + while ((pKey = GetNextKey()) && !m_pOperator->operate(pKey,m_pOperand)); + break; + case SQL_PRED_LESS: + while ((pKey = GetNextKey()) && !pKey->getValue().hasValue()); + break; + case SQL_PRED_LESSOREQUAL: + while (pKey = GetNextKey()); + break; + case SQL_PRED_GREATEROREQUAL: + case SQL_PRED_EQUAL: + pKey = GetFirstKey(m_aRoot.getBodyPtr(),*m_pOperand); + break; + case SQL_PRED_GREATER: + if (!(pKey = GetFirstKey(m_aRoot.getBodyPtr(),*m_pOperand))) + while ((pKey = GetNextKey()) && !m_pOperator->operate(pKey,m_pOperand)); + } + } + else + { + switch (ePredicateType) + { + case SQL_PRED_NOTEQUAL: + while ((pKey = GetNextKey()) && !m_pOperator->operate(pKey,m_pOperand)) + ; + break; + case SQL_PRED_LESS: + case SQL_PRED_LESSOREQUAL: + case SQL_PRED_EQUAL: + if (!(pKey = GetNextKey()) || !m_pOperator->operate(pKey,m_pOperand)) + { + pKey = NULL; + m_aCurLeaf = NULL; + } + break; + case SQL_PRED_GREATEROREQUAL: + case SQL_PRED_GREATER: + pKey = GetNextKey(); + } + } + + return pKey ? pKey->GetRecord() : STRING_NOTFOUND; +} + +//------------------------------------------------------------------ +ULONG OIndexIterator::GetLike(BOOL bFirst) +{ + // ONDXIndex* m_pIndex = GetNDXIndex(); + if (bFirst) + { + ONDXPage* pPage = m_aRoot.getBodyPtr(); + + while (pPage && !pPage->IsLeaf()) + pPage = pPage->GetChild(m_pIndex).getBodyPtr(); + + m_aCurLeaf = pPage; + m_nCurNode = NODE_NOTFOUND; + } + + ONDXKey* pKey; + while ((pKey = GetNextKey()) && !m_pOperator->operate(pKey,m_pOperand)) + ; + return pKey ? pKey->GetRecord() : STRING_NOTFOUND; +} + +//------------------------------------------------------------------ +ULONG OIndexIterator::GetNull(BOOL bFirst) +{ + // ONDXIndex* m_pIndex = GetNDXIndex(); + if (bFirst) + { + ONDXPage* pPage = m_aRoot.getBodyPtr(); + while (pPage && !pPage->IsLeaf()) + pPage = pPage->GetChild(m_pIndex).getBodyPtr(); + + m_aCurLeaf = pPage; + m_nCurNode = NODE_NOTFOUND; + } + + ONDXKey* pKey; + if (!(pKey = GetNextKey()) || pKey->getValue().hasValue()) + { + pKey = NULL; + m_aCurLeaf = NULL; + } + return pKey ? pKey->GetRecord() : STRING_NOTFOUND; +} + +//------------------------------------------------------------------ +ULONG OIndexIterator::GetNotNull(BOOL bFirst) +{ + ONDXKey* pKey; + // ONDXIndex* m_pIndex = GetNDXIndex(); + if (bFirst) + { + // erst alle NULL werte abklappern + for (ULONG nRec = GetNull(bFirst); + nRec != STRING_NOTFOUND; + nRec = GetNull(FALSE)) + ; + pKey = m_aCurLeaf.Is() ? &(*m_aCurLeaf)[m_nCurNode].GetKey() : NULL; + } + else + pKey = GetNextKey(); + + return pKey ? pKey->GetRecord() : STRING_NOTFOUND; +} + +//------------------------------------------------------------------ +ONDXKey* OIndexIterator::GetNextKey() +{ + // ONDXIndex* m_pIndex = GetNDXIndex(); + if (m_aCurLeaf.Is() && ((++m_nCurNode) >= m_aCurLeaf->Count())) + { + ONDXPage* pPage = m_aCurLeaf.getBodyPtr(); + // naechste Seite suchen + while (pPage) + { + ONDXPage* pParentPage = pPage->GetParent().getBodyPtr(); + if (pParentPage) + { + USHORT nPos = pParentPage->Search(pPage); + if (nPos != pParentPage->Count() - 1) + { // Seite gefunden + pPage = (*pParentPage)[nPos+1].GetChild(m_pIndex,pParentPage).getBodyPtr(); + break; + } + } + pPage = pParentPage; + } + + // jetzt wieder zum Blatt + while (pPage && !pPage->IsLeaf()) + pPage = pPage->GetChild(m_pIndex).getBodyPtr(); + + m_aCurLeaf = pPage; + m_nCurNode = 0; + } + return m_aCurLeaf.Is() ? &(*m_aCurLeaf)[m_nCurNode].GetKey() : NULL; +} + diff --git a/connectivity/source/drivers/dbase/DIndexes.cxx b/connectivity/source/drivers/dbase/DIndexes.cxx new file mode 100644 index 000000000000..0ad5cd4127d6 --- /dev/null +++ b/connectivity/source/drivers/dbase/DIndexes.cxx @@ -0,0 +1,172 @@ +/************************************************************************* + * + * $RCSfile: DIndexes.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_INDEXES_HXX_ +#include "dbase/DIndexes.hxx" +#endif +//#ifndef _FSYS_HXX //autogen +//#include <tools/fsys.hxx> +//#endif +#ifndef _CONNECTIVITY_DBASE_INDEX_HXX_ +#include "dbase/DIndex.hxx" +#endif + + +using namespace connectivity::dbase; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +namespace starutil = ::com::sun::star::util; + +Reference< XNamed > ODbaseIndexes::createObject(const ::rtl::OUString& _rName) +{ + // Dir* pDir = m_pTable->getConnection()->getDir(); + // String aPath = pDir->GetName(); + // aPath += _rName.getStr(); + INetURLObject aEntry(m_pTable->getEntry()); + aEntry.setName(_rName); + aEntry.setExtension(String::CreateFromAscii("ndx")); + SvFileStream aFileStream; + aFileStream.Open(aEntry.GetMainURL(), STREAM_READ | STREAM_NOCREATE| STREAM_SHARE_DENYWRITE); + + + // Anlegen des Indexfiles + // aFileStream.Open(aEntry.GetFull(), STREAM_READWRITE | STREAM_NOCREATE| STREAM_SHARE_DENYWRITE); + + aFileStream.SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN); + aFileStream.SetBufferSize(512); + ODbaseIndex::NDXHeader aHeader; + + aFileStream.Seek(0); + aFileStream.Read(&aHeader,512); + + ODbaseIndex* pIndex = new ODbaseIndex(m_pTable,aHeader,_rName); + + Reference< XNamed > xRet = pIndex; + return xRet; +} +// ------------------------------------------------------------------------- +void ODbaseIndexes::impl_refresh( ) throw(RuntimeException) +{ + if(m_pTable) + m_pTable->refreshIndexes(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > ODbaseIndexes::createEmptyObject() +{ + ODbaseIndex* pRet = new ODbaseIndex(m_pTable); + Reference< XPropertySet > xRet = pRet; + return xRet; +} +typedef connectivity::sdbcx::OCollection ODbaseTables_BASE_BASE; +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL ODbaseIndexes::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); + ObjectMap::iterator aIter = m_aNameMap.find(aName); + if( aIter != m_aNameMap.end()) + throw ElementExistException(aName,*this); + + Reference<XUnoTunnel> xTunnel(descriptor,UNO_QUERY); + if(xTunnel.is()) + { + ODbaseIndex* pIndex = (ODbaseIndex*)xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()); + if(pIndex && pIndex->CreateImpl()) + ODbaseIndexes_BASE::appendByDescriptor(descriptor); + } +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL ODbaseIndexes::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + Reference< XUnoTunnel> xTunnel(aIter->second.get(),UNO_QUERY); + if(xTunnel.is()) + { + ODbaseIndex* pIndex = (ODbaseIndex*)xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()); + if(pIndex && pIndex->DropImpl()) + ODbaseIndexes_BASE::dropByName(elementName); + } + +} +// ------------------------------------------------------------------------- +void SAL_CALL ODbaseIndexes::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + dropByName((*m_aElements[index]).first); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx new file mode 100644 index 000000000000..268792404cd6 --- /dev/null +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -0,0 +1,1861 @@ +/************************************************************************* + * + * $RCSfile: DTable.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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 _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_XCONTENTACCESS_HPP_ +#include <com/sun/star/ucb/XContentAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _SV_CONVERTER_HXX_ +#include <svtools/converter.hxx> +#endif +#ifndef _CONNECTIVITY_DBASE_DCONNECTION_HXX_ +#include "dbase/DConnection.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_COLUMNS_HXX_ +#include "dbase/DColumns.hxx" +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _CONFIG_HXX //autogen +#include <vcl/config.hxx> +#endif +#ifndef _CONNECTIVITY_DBASE_INDEX_HXX_ +#include "dbase/DIndex.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_INDEXES_HXX_ +#include "dbase/DIndexes.hxx" +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ +#include "DateConversion.hxx" +#endif +#ifndef _INTN_HXX //autogen +#include <tools/intn.hxx> +#endif +#ifndef _ZFORLIST_HXX //autogen +#include <svtools/zforlist.hxx> +#endif +#ifndef _SOLMATH_HXX //autogen wg. SolarMath +#include <tools/solmath.hxx> +#endif +#include <stdio.h> //sprintf +#ifndef _UCBHELPER_CONTENT_HXX +#include <ucbhelper/content.hxx> +#endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif + +using namespace connectivity; +using namespace connectivity::dbase; +using namespace connectivity::file; +using namespace ucb; +using namespace cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::ucb; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +// ------------------------------------------------------------------------- +void ODbaseTable::readHeader() +{ + m_aFileStream.RefreshBuffer(); // sicherstellen, dass die Kopfinformationen tatsaechlich neu gelesen werden + m_aFileStream.Seek(STREAM_SEEK_TO_BEGIN); + + BYTE aTyp; + m_aFileStream >> aTyp; + m_aFileStream.Read((char*)m_aHeader.db_aedat, 3*sizeof(BYTE)); + m_aFileStream >> m_aHeader.db_anz; + m_aFileStream >> m_aHeader.db_kopf; + m_aFileStream >> m_aHeader.db_slng; + m_aFileStream.Read((char*)m_aHeader.db_frei, 20*sizeof(BYTE)); + + if (m_aHeader.db_anz < 0 || + m_aHeader.db_kopf <= 0 || + m_aHeader.db_slng <= 0 || + ((m_aHeader.db_kopf - 1) / 32 - 1) <= 0) // anzahl felder + { + // Dies ist keine DBase Datei + } + else + { + // Konsistenzpruefung des Header: + m_aHeader.db_typ = (DBFType)aTyp; + switch (m_aHeader.db_typ) + { + case dBaseIII: + case dBaseIV: + case dBaseV: + case dBaseFS: + case dBaseFSMemo: + case dBaseIVMemoSQL: + case dBaseIIIMemo: + case dBaseIVMemo: + case FoxProMemo: + m_aFileStream.SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN); + break; + default: + { // Dies ist keine DBase Datei + } + } + } +} +// ------------------------------------------------------------------------- +void ODbaseTable::fillColumns() +{ + m_aFileStream.Seek(STREAM_SEEK_TO_BEGIN); + m_aFileStream.Seek(32L); + + // Anzahl Felder: + sal_uInt32 nFieldCount = (m_aHeader.db_kopf - 1) / 32 - 1; + + String aStrFieldName;aStrFieldName.AssignAscii("Column"); + sal_Int32 nFieldCnt = 0; + ::rtl::OUString aTypeName; + + for (sal_uInt32 i = 0; i < nFieldCount; i++) + { + DBFColumn aDBFColumn; + m_aFileStream.Read((char*)&aDBFColumn, sizeof(aDBFColumn)); + + // Info auslesen und in SdbColumn packen: + String aColumnName((const char *)aDBFColumn.db_fnm,osl_getThreadTextEncoding()); + +// while (aOriginalColumns->ColumnNumber(aColumnName) != SDB_COLUMN_NOTFOUND) +// (aColumnName = aStrFieldName) += String::CreateFromsal_Int32(++nFieldCnt); + + sal_Int32 nPrecision = aDBFColumn.db_flng; + sal_Int32 eType; + + switch (aDBFColumn.db_typ) + { + case 'C': + eType = DataType::VARCHAR; + aTypeName = ::rtl::OUString::createFromAscii("VARCHAR"); + break; + case 'F': + case 'N': + eType = DataType::DECIMAL; + aTypeName = ::rtl::OUString::createFromAscii("DECIMAL"); + + // Bei numerischen Feldern werden zwei Zeichen mehr geschrieben, als die Precision der Spaltenbeschreibung eigentlich + // angibt, um Platz fuer das eventuelle Vorzeichen und das Komma zu haben. Das muss ich jetzt aber wieder rausrechnen. + nPrecision = SvDbaseConverter::ConvertPrecisionToOdbc(nPrecision,aDBFColumn.db_dez); + // leider gilt das eben Gesagte nicht fuer aeltere Versionen .... + ; + break; + case 'L': + eType = DataType::BIT; + aTypeName = ::rtl::OUString::createFromAscii("BIT"); + break; + case 'D': + eType = DataType::DATE; + aTypeName = ::rtl::OUString::createFromAscii("DATE"); + break; + case 'M': + eType = DataType::LONGVARCHAR; + aTypeName = ::rtl::OUString::createFromAscii("LONGVARCHAR"); + nPrecision = 0; + break; + default: + aTypeName = ::rtl::OUString::createFromAscii("OTHER"); + eType = DataType::OTHER; + + } + + sal_Int32 nFlags = 0; + switch (aDBFColumn.db_typ) + { + case 'C': + case 'D': + case 'L': nFlags = ColumnSearch::FULL; break; + case 'F': + case 'N': nFlags = ColumnSearch::BASIC; break; + case 'M': nFlags = ColumnSearch::CHAR; break; + default: + nFlags = ColumnSearch::NONE; + + } + sdbcx::OColumn* pColumn = new sdbcx::OColumn(aColumnName,aTypeName,::rtl::OUString(), + ColumnValue::NULLABLE,nPrecision,aDBFColumn.db_dez,eType,sal_False,sal_False,sal_False, + getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()); + Reference< XFastPropertySet> xCol = pColumn; + m_aColumns->push_back(xCol); + } +} +// ------------------------------------------------------------------------- +//void ODbaseTable::fillIndexes() +//{ +// Dir* pDir = m_pConnection->getDir(); +// String aPath = pDir->GetName(); +// aPath += _Name.getStr(); +// DirEntry aEntry(aPath); +// aEntry.SetExtension(String::CreateFromAscii("inf")); +// +// Config aInfFile(aEntry.GetFull()); +// aInfFile.SetGroup(dBASE_III_GROUP); +// sal_Int32 nKeyCnt = aInfFile.GetKeyCount(); +// ByteString aKeyName; +// ByteString aIndexName; +// +// for (sal_Int32 nKey = 0,nPos=0; nKey < nKeyCnt; nKey++) +// { +// // Verweist der Key auf ein Indexfile?... +// aKeyName = aInfFile.GetKeyName( nKey ); +// //...wenn ja, Indexliste der Tabelle hinzufuegen +// if (aKeyName.Copy(0,3) == ByteString("NDX") ) +// { +// aIndexName = aInfFile.ReadKey(aKeyName); +// aEntry.SetName(String(aIndexName,osl_getThreadTextEncoding())); +// if (aEntry.Exists()) +// { +// readIndex(aEntry.GetBase()); +// } +// // _rList.Insert(new String(aEntry.GetBase()), nPos++); +// } +// } +//} +// ------------------------------------------------------------------------- +//void ODbaseTable::readIndex(const String& _rName) +//{ +//} +// ------------------------------------------------------------------------- +ODbaseTable::ODbaseTable(ODbaseConnection* _pConnection) : ODbaseTable_BASE(_pConnection) + // , m_aColumns(_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()) +{ + +} +// ------------------------------------------------------------------------- +ODbaseTable::ODbaseTable(ODbaseConnection* _pConnection, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description , + const ::rtl::OUString& _SchemaName, + const ::rtl::OUString& _CatalogName + ) : ODbaseTable_BASE(_pConnection,_Name, + _Type, + _Description, + _SchemaName, + _CatalogName) + // , m_aColumns(_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()) +{ + INetURLObject aURL; + aURL.SetSmartProtocol(INET_PROT_FILE); + aURL.SetSmartURL(getEntry(), INetURLObject::ENCODE_ALL); + + if(aURL.getExtension() != m_pConnection->getExtension()) + aURL.setExtension(m_pConnection->getExtension()); + + // Content aContent(aURL.GetMainURL()); + + m_aFileStream.Open(aURL.GetMainURL(), STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE); + if(!m_aFileStream.IsOpen()) + m_aFileStream.Open(aURL.GetMainURL(), STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE ); + + if(m_aFileStream.IsOpen()) + { + readHeader(); + + if (HasMemoFields()) + { + // Memo-Dateinamen bilden (.DBT): + // nyi: Unschoen fuer Unix und Mac! + + if (m_aHeader.db_typ == FoxProMemo) // foxpro verwendet andere extension + aURL.SetExtension(String::CreateFromAscii("fpt")); // nyi: Gross-/Kleinschreibung bei Unix? Klein ist sicherlich schoener. + else + aURL.SetExtension(String::CreateFromAscii("dbt")); // nyi: Gross-/Kleinschreibung bei Unix? Klein ist sicherlich schoener. + + // Wenn die Memodatei nicht gefunden wird, werden die Daten trotzdem angezeigt + // allerdings koennen keine Updates durchgefuehrt werden + // jedoch die Operation wird ausgefuehrt + m_aMemoStream.Open(aURL.GetMainURL(), STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE); + if (m_aMemoStream.IsOpen()) + ReadMemoHeader(); + + // if (aStatus.IsError()) + // { + // String aText = String(SdbResId(STR_STAT_FILE_NOT_FOUND)); + // aText.SearchAndReplace(String::CreateFromAscii("%%d"),aFileEntry.GetName()); + // aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO)); + // aStatus.Set(SDB_STAT_SUCCESS_WITH_INFO, + // String::CreateFromAscii("01000"), + // aStatus.CreateErrorMessage(aText), + // 0, String() ); + // m_aMemoStream.Close(); + // } + } + // if (aStatus.IsError()) + // FileClose(); + // + fillColumns(); + + m_aFileStream.Seek(STREAM_SEEK_TO_END); + UINT32 nFileSize = m_aFileStream.Tell(); + m_aFileStream.Seek(STREAM_SEEK_TO_BEGIN); + + // Buffersize abhaengig von der Filegroesse + m_aFileStream.SetBufferSize(nFileSize > 1000000 ? 32768 : + nFileSize > 100000 ? 16384 : + nFileSize > 10000 ? 4096 : 1024); + + if (m_aMemoStream.IsOpen()) + { + // Puffer genau auf Laenge eines Satzes stellen + m_aMemoStream.Seek(STREAM_SEEK_TO_END); + nFileSize = m_aMemoStream.Tell(); + m_aMemoStream.Seek(STREAM_SEEK_TO_BEGIN); + + // Buffersize abhaengig von der Filegroesse + m_aMemoStream.SetBufferSize(nFileSize > 1000000 ? 32768 : + nFileSize > 100000 ? 16384 : + nFileSize > 10000 ? 4096 : + m_aMemoHeader.db_size); + } + + AllocBuffer(); + + refreshColumns(); + refreshIndexes(); + } +} +//------------------------------------------------------------------ +BOOL ODbaseTable::ReadMemoHeader() +{ + m_aMemoStream.SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN); + m_aMemoStream.RefreshBuffer(); // sicherstellen das die Kopfinformationen tatsaechlich neu gelesen werden + m_aMemoStream.Seek(0L); + + m_aMemoStream >> m_aMemoHeader.db_next; + switch (m_aHeader.db_typ) + { + case dBaseIIIMemo: // dBase III: feste Blockgre + case dBaseIVMemo: + // manchmal wird aber auch dBase3 dBase4 Memo zugeordnet + m_aMemoStream.Seek(20L); + m_aMemoStream >> m_aMemoHeader.db_size; + if (m_aMemoHeader.db_size > 1 && m_aMemoHeader.db_size != 512) // 1 steht auch fuer dBase 3 + m_aMemoHeader.db_typ = MemodBaseIV; + else if (m_aMemoHeader.db_size > 1 && m_aMemoHeader.db_size == 512) + { + // nun gibt es noch manche Dateien, die verwenden eine Genangabe, + // sind aber dennoch dBase Dateien + char sHeader[4]; + m_aMemoStream.Seek(m_aMemoHeader.db_size); + m_aMemoStream.Read(sHeader,4); + + if ((m_aMemoStream.GetErrorCode() != ERRCODE_NONE) || ((BYTE)sHeader[0]) != 0xFF || ((BYTE)sHeader[1]) != 0xFF || ((BYTE)sHeader[2]) != 0x08) + m_aMemoHeader.db_typ = MemodBaseIII; + else + m_aMemoHeader.db_typ = MemodBaseIV; + } + else + { + m_aMemoHeader.db_typ = MemodBaseIII; + m_aMemoHeader.db_size = 512; + } + break; + case FoxProMemo: + m_aMemoHeader.db_typ = MemoFoxPro; + m_aMemoStream.Seek(6L); + m_aMemoStream.SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN); + m_aMemoStream >> m_aMemoHeader.db_size; + } + return TRUE; +} +// ------------------------------------------------------------------------- +::rtl::OUString ODbaseTable::getEntry() +{ + ::rtl::OUString aURL; + Reference< XResultSet > xDir = m_pConnection->getDir(); + Reference< XRow> xRow(xDir,UNO_QUERY); + while(xDir->next()) + { + if(xRow->getString(1) == m_Name) + { + Reference< XContentAccess > xContentAccess( xDir, UNO_QUERY ); + aURL = xContentAccess->queryContentIdentfierString(); + break; + } + } + xDir->beforeFirst(); // move back to before first record + return aURL; +} +// ------------------------------------------------------------------------- +void ODbaseTable::refreshColumns() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ::std::vector< ::rtl::OUString> aVector; + + for(OSQLColumns::const_iterator aIter = m_aColumns->begin();aIter != m_aColumns->end();++aIter) + aVector.push_back(Reference< XNamed>(*aIter,UNO_QUERY)->getName()); + + if(m_pColumns) + delete m_pColumns; + m_pColumns = new ODbaseColumns(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +void ODbaseTable::refreshIndexes() +{ +// Dir* pDir = m_pConnection->getDir(); +// String aPath = pDir->GetName(); +// aPath += m_Name.getStr(); + INetURLObject aURL; + aURL.SetSmartProtocol(INET_PROT_FILE); + aURL.SetSmartURL(getEntry(), INetURLObject::ENCODE_ALL); + + aURL.setExtension(String::CreateFromAscii("inf")); + + Config aInfFile(aURL.GetMainURL()); + aInfFile.SetGroup(dBASE_III_GROUP); + sal_Int32 nKeyCnt = aInfFile.GetKeyCount(); + ByteString aKeyName; + ByteString aIndexName; + + ::std::vector< ::rtl::OUString> aVector; + + for (sal_Int32 nKey = 0,nPos=0; nKey < nKeyCnt; nKey++) + { + // Verweist der Key auf ein Indexfile?... + aKeyName = aInfFile.GetKeyName( nKey ); + //...wenn ja, Indexliste der Tabelle hinzufuegen + if (aKeyName.Copy(0,3) == ByteString("NDX") ) + { + aIndexName = aInfFile.ReadKey(aKeyName); + aURL.setName(String(aIndexName,osl_getThreadTextEncoding())); + Content aCnt(aURL.GetMainURL(),Reference<XCommandEnvironment>()); + if (aCnt.isDocument()) + { + aVector.push_back(aURL.getBase()); + } + } + } + if(m_pIndexes) + delete m_pIndexes; + m_pIndexes = new ODbaseIndexes(this,m_aMutex,aVector); +} + +// ------------------------------------------------------------------------- +void SAL_CALL ODbaseTable::disposing(void) +{ + OFileTable::disposing(); + ::osl::MutexGuard aGuard(m_aMutex); + m_aColumns->clear(); +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL ODbaseTable::getTypes( ) throw(RuntimeException) +{ + Sequence< Type > aTypes = OTable_TYPEDEF::getTypes(); + Sequence< Type > aRet(aTypes.getLength()-3); + const Type* pBegin = aTypes.getConstArray(); + const Type* pEnd = pBegin + aTypes.getLength(); + sal_Int32 i=0; + for(;pBegin != pEnd;++pBegin,++i) + { + if(!(*pBegin == ::getCppuType((const Reference<XKeysSupplier>*)0) || + *pBegin == ::getCppuType((const Reference<XRename>*)0) || + *pBegin == ::getCppuType((const Reference<XAlterTable>*)0) || + *pBegin == ::getCppuType((const Reference<XDataDescriptorFactory>*)0))) + { + aRet.getArray()[i] = *pBegin; + } + } + aRet.getArray()[i] = ::getCppuType( (const Reference< ::com::sun::star::lang::XUnoTunnel > *)0 ); + + return aRet; +} + +// ------------------------------------------------------------------------- +Any SAL_CALL ODbaseTable::queryInterface( const Type & rType ) throw(RuntimeException) +{ + if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) || + rType == ::getCppuType((const Reference<XRename>*)0) || + rType == ::getCppuType((const Reference<XAlterTable>*)0) || + rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0)) + return Any(); + + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); + if(aRet.hasValue()) + return aRet; + + return OTable_TYPEDEF::queryInterface(rType); +} + +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > ODbaseTable::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 ODbaseTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return ODbaseTable_BASE::getSomething(rId); +} +//------------------------------------------------------------------ +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_ENSHURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position"); + sal_Int32 nPos = m_aHeader.db_kopf + (sal_Int32)(m_nFilePos-1) * nEntryLen; + + m_aFileStream.Seek(nPos); +// if (aStatus.SetError(m_aFileStream) +// goto Error; + + m_aFileStream.Read((char*)m_pBuffer, nEntryLen); +// if (aStatus.SetError(m_aFileStream) +// 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(file::OValueRow _rRow,const OSQLColumns & _rCols, sal_Bool bRetrieveData) +{ + // Einlesen der Daten + BOOL bIsCurRecordDeleted = ((char)m_pBuffer[0] == '*') ? TRUE : FALSE; + + // only read the bookmark + + // Satz als geloescht markieren + // rRow.setState(bIsCurRecordDeleted ? ROW_DELETED : ROW_CLEAN ); + _rRow->setDeleted(bIsCurRecordDeleted); + (*_rRow)[0] = m_nFilePos; + + if (!bRetrieveData) + return TRUE; + + sal_Int32 nByteOffset = 1; + // Felder: + OSQLColumns::const_iterator aIter = _rCols.begin(); + for (sal_Int32 i = 1; aIter != _rCols.end();++aIter, i++) + { + // pVal = (*_rRow)[i].getBodyPtr(); + Reference< XFastPropertySet> xColumn = *aIter; + + // Laengen je nach Datentyp: + // nyi: eine zentrale Funktion, die die Laenge liefert! + sal_Int32 nLen; + xColumn->getFastPropertyValue(PROPERTY_ID_PRECISION) >>= nLen; + sal_Int32 nType = getINT32(xColumn->getFastPropertyValue(PROPERTY_ID_TYPE)); + switch(nType) + { + case DataType::DATE: nLen = 8; break; + case DataType::DECIMAL: + nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,getINT32(xColumn->getFastPropertyValue(PROPERTY_ID_SCALE))); + break; // das Vorzeichen und das Komma + case DataType::BIT: nLen = 1; break; + case DataType::LONGVARCHAR: nLen = 10; break; + case DataType::OTHER: + nByteOffset += nLen; + continue; + default: break; + } + + // Ist die Variable ueberhaupt gebunden? + if (!(*_rRow)[i].isBound()) + { + // Nein - naechstes Feld. + nByteOffset += nLen; + continue; + } + + char *pData = (char *) (m_pBuffer + nByteOffset); + + (*_rRow)[i].setType(nType); + + if (nType == DataType::CHAR || nType == DataType::VARCHAR) + { + char cLast = pData[nLen]; + pData[nLen] = 0; + String aStr(pData,osl_getThreadTextEncoding()); + aStr.EraseTrailingChars(); + + if (!aStr.Len()) // keine StringLaenge, dann NULL + (*_rRow)[i].setNull(); + else + { + ::rtl::OUString aStr2(aStr); + (*_rRow)[i] = aStr2; + } + pData[nLen] = cLast; + } + else + { + // Falls Nul-Zeichen im String enthalten sind, in Blanks umwandeln! + for (sal_Int32 k = 0; k < nLen; k++) + { + if (pData[k] == '\0') + pData[k] = ' '; + } + + String aStr(pData, nLen); // Spaces am Anfang und am Ende entfernen: + aStr.EraseLeadingChars(); + aStr.EraseTrailingChars(); + + if (!aStr.Len()) + { + nByteOffset += nLen; + (*_rRow)[i].setNull(); // keine Werte -> fertig + continue; + } + + switch (nType) + { + case DataType::DATE: + { + if (aStr.Len() != nLen) + { + (*_rRow)[i].setNull(); + break; + } + sal_Int32 nYear = aStr.Copy( 0, 4 ).ToInt32(); + sal_Int32 nMonth = aStr.Copy( 4, 2 ).ToInt32(); + sal_Int32 nDay = aStr.Copy( 6, 2 ).ToInt32(); + + ::com::sun::star::util::Date aDate(nDay,nMonth,nYear); + (*_rRow)[i] = DateConversion::toDouble(aDate); + } + break; + case DataType::DECIMAL: + (*_rRow)[i] = aStr.ToDouble(); + // pVal->setDouble(SdbTools::ToDouble(aStr)); + break; + case DataType::BIT: + { + BOOL b; + switch (* ((const char *)pData)) + { + case 'T': + case 'Y': + case 'J': b = TRUE; break; + default: b = FALSE; break; + } + (*_rRow)[i] = b; + // pVal->setDouble(b); + } + break; + case DataType::LONGVARCHAR: + { + long nBlockNo = aStr.ToInt32(); // Blocknummer lesen + if (nBlockNo > 0 && m_aMemoStream.IsOpen()) // Daten aus Memo-Datei lesen, nur wenn + { + if (!ReadMemo(nBlockNo, (*_rRow)[i])) + break; + } + else + (*_rRow)[i].setNull(); + } break; + default: + OSL_ASSERT("Falscher Type"); + } + } + +// if (aStatus.IsError()) +// break; + // Und weiter ... + nByteOffset += nLen; + } + return sal_True; +} +//------------------------------------------------------------------ +BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, OFileValue& aVariable) +{ + BOOL bIsText = TRUE; + // SdbConnection* pConnection = GetConnection(); + + m_aMemoStream.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 aStr; + static char aBuf[514]; + aBuf[512] = 0; // sonst kann der Zufall uebel mitspielen + BOOL bReady = FALSE; + + do + { + m_aMemoStream.Read(&aBuf,512); + + USHORT i = 0; + while (aBuf[i] != cEOF && ++i < 512) + ; + bReady = aBuf[i] == cEOF; + + aBuf[i] = 0; + aStr += aBuf; + + } while (!bReady && !m_aMemoStream.IsEof() && aStr.Len() < STRING_MAXLEN); + + aVariable = ::rtl::OUString(aStr.GetBuffer(), aStr.Len(),osl_getThreadTextEncoding()); + } break; + case MemoFoxPro: + case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe + { + char sHeader[4]; + m_aMemoStream.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_aMemoStream.GetFileName()); +// aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO)); +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(aText), +// 0, String() ); + return 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_aMemoStream.GetFileName()); +// aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO)); +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(aText), +// 0, String() ); + return FALSE; + } + + ULONG nLength; + m_aMemoStream >> nLength; + + if (m_aMemoHeader.db_typ == MemodBaseIV) + nLength -= 8; + + // char cChar; + if (nLength < STRING_MAXLEN && bIsText) + { + ByteString aStr; + aStr.Expand(USHORT (nLength)); + m_aMemoStream.Read(aStr.AllocBuffer((USHORT)nLength),nLength); + aStr.ReleaseBufferAccess(); + aVariable = ::rtl::OUString(aStr.GetBuffer(),aStr.Len(), osl_getThreadTextEncoding()); + } + else + { +// ::Sequence<sal_Int8> aText(nLength); +// sal_Int8* pData = aText.getArray(); +// for (ULONG i = 0; i < nLength; i++) +// { +// m_aMemoStream.Read(&cChar,1); +// (*pData++) = cChar; +// } +// aVariable.setBytes(aText); + return sal_False; + } + } + } + return sal_True; +} +// ------------------------------------------------------------------------- +void ODbaseTable::FileClose() +{ + // falls noch nicht alles geschrieben wurde + if (m_aMemoStream.IsOpen() && m_aMemoStream.IsWritable()) + m_aMemoStream.Flush(); + + m_aMemoStream.Close(); + + if (m_aFileStream.IsOpen() && m_aFileStream.IsWritable()) + m_aFileStream.Flush(); + + m_aFileStream.Close(); + + if (m_pBuffer != NULL) + { + delete m_pBuffer; + m_pBuffer = NULL; + } +} +// ------------------------------------------------------------------------- +BOOL ODbaseTable::CreateImpl() +{ + OSL_ENSHURE(!m_aFileStream.IsOpen(), "SequenceError"); + + INetURLObject aURL; + aURL.SetSmartProtocol(INET_PROT_FILE); + aURL.SetSmartURL(getEntry(), INetURLObject::ENCODE_ALL); + + if(aURL.getExtension() != m_pConnection->getExtension()) + aURL.setExtension(m_pConnection->getExtension()); + + Content aContent(aURL.GetMainURL(),Reference<XCommandEnvironment>()); + + if (aContent.isDocument()) + { + // Hack fuer Bug #30609 , nur wenn das File existiert und die Laenge > 0 gibt es einen Fehler + SvFileStream m_aFileStream; + m_aFileStream.Open(aURL.GetMainURL(),STREAM_STD_READ); + + if (m_aFileStream.IsOpen() && m_aFileStream.Seek(STREAM_SEEK_TO_END)) + { + // aStatus.SetError(ERRCODE_IO_ALREADYEXISTS,TABLE,aFile.GetFull()); + return FALSE; + } + m_aFileStream.Close(); + } + + BOOL bMemoFile = FALSE; + + sal_Bool bOk = CreateFile(aURL, bMemoFile); + + FileClose(); + + if (!bOk) + { + aContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) ); + return FALSE; + } + + if (bMemoFile) + { + String aExt = aURL.getExtension(); + aURL.setExtension(String::CreateFromAscii("dbt")); // extension for memo file + Content aMemo1Content(aURL.GetMainURL(),Reference<XCommandEnvironment>()); + + if (aMemo1Content.isDocument()) + { + // aStatus.SetError(ERRCODE_IO_ALREADYEXISTS,MEMO,aFile.GetFull()); + aURL.setExtension(aExt); // kill dbf file + Content aMemoContent(aURL.GetMainURL(),Reference<XCommandEnvironment>()); + aMemoContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) ); + return FALSE; + } + if (!CreateMemoFile(aURL)) + { + aURL.setExtension(aExt); // kill dbf file + Content aMemoContent(aURL.GetMainURL(),Reference<XCommandEnvironment>()); + aMemoContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) ); + return FALSE; + } + m_aHeader.db_typ = dBaseIIIMemo; + } + else + m_aHeader.db_typ = dBaseIII; + +// if (GetDBFConnection()->GetShowDeleted()) +// nPrivileges = SDB_PR_READ | SDB_PR_INSERT | SDB_PR_UPDATE | +// SDB_PR_ALTER | SDB_PR_DROP; +// else + // nPrivileges = SDB_PR_READ | SDB_PR_INSERT | SDB_PR_UPDATE | + // SDB_PR_DELETE | SDB_PR_ALTER | SDB_PR_DROP; + + return TRUE; +} + +//------------------------------------------------------------------ +// erzeugt grundstzlich dBase IV Datei Format +BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) +{ + bCreateMemo = FALSE; + Date aDate; // aktuelles Datum + + m_aFileStream.Open(aFile.GetMainURL(), STREAM_READWRITE | STREAM_SHARE_DENYWRITE | STREAM_TRUNC); + if (!m_aFileStream.IsOpen()) + return FALSE; + + char aBuffer[21]; // write buffer + memset(aBuffer,0,sizeof(aBuffer)); + + m_aFileStream.Seek(0L); + m_aFileStream << (BYTE) dBaseIII; // dBase format + m_aFileStream << (BYTE) (aDate.GetYear() % 100); // aktuelles Datum + + + m_aFileStream << (BYTE) aDate.GetMonth(); + m_aFileStream << (BYTE) aDate.GetDay(); + m_aFileStream << 0L; // Anzahl der Datenstze + m_aFileStream << (USHORT)(m_pColumns->getCount() * 32 + 1); // Kopfinformationen, + // pColumns erhlt immer eine Spalte mehr + m_aFileStream << (USHORT) 0; // Satzlnge wird spter bestimmt + m_aFileStream.Write(aBuffer, 20); + + USHORT nRecLength = 1; // Lnge 1 fr deleted flag + ULONG nMaxFieldLength = m_pConnection->getMetaData()->getMaxColumnNameLength(); + Reference<XIndexAccess> xColumns(getColumns(),UNO_QUERY); + + ::rtl::OUString aName; + Reference<XFastPropertySet> xCol; + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + xColumns->getByIndex(i) >>= xCol; + OSL_ENSHURE(xCol.is(),"This should be a column!"); + + char cTyp; + + xCol->getFastPropertyValue(PROPERTY_ID_NAME) >>= aName; + + if (aName.getLength() > nMaxFieldLength) + { +// String aText = String(SdbResId(STR_DBF_INVALIDFIELDNAMELENGTH)); +// aText.SearchAndReplace(String::CreateFromAscii("#"),rColumn.GetName()); +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(aText), +// 0, String() ); + break; + } + + ByteString aCol(aName.getStr(),gsl_getSystemTextEncoding()); + m_aFileStream << aCol.GetBuffer(); + m_aFileStream.Write(aBuffer, 11 - aCol.Len()); + + switch (getINT32(xCol->getFastPropertyValue(PROPERTY_ID_TYPE))) + { + case DataType::CHAR: + case DataType::VARCHAR: + cTyp = 'C'; + break; + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + case DataType::BIGINT: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::REAL: + case DataType::DOUBLE: + cTyp = 'N'; // nur dBase 3 format + break; + case DataType::DATE: + cTyp = 'D'; + break; + case DataType::BIT: + cTyp = 'L'; + break; + case DataType::LONGVARBINARY: + case DataType::LONGVARCHAR: + cTyp = 'M'; + break; + default: + { +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(String(SdbResId(STR_DBF_INVALIDFORMAT))), +// 0, String() ); + break; + } + } + + m_aFileStream << cTyp; + m_aFileStream.Write(aBuffer, 4); + + sal_Int32 nPrecision = 0; + xCol->getFastPropertyValue(PROPERTY_ID_PRECISION) >>= nPrecision; + sal_Int32 nScale = 0; + xCol->getFastPropertyValue(PROPERTY_ID_SCALE) >>= nScale; + + switch(cTyp) + { + case 'C': + OSL_ENSHURE(nPrecision < 255, "ODbaseTable::Create: Column zu lang!"); + if (nPrecision > 254) + { +// String aText = String(SdbResId(STR_DBF_INVALIDFIELDLENGTH)); +// aText.SearchAndReplace(String::CreateFromAscii("#"),rColumn.GetName()); +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(aText), +// 0, String() ); + // break; + } + m_aFileStream << (BYTE) min(nPrecision, 255UL); //Feldlnge + nRecLength += (USHORT)min(nPrecision, 255UL); + m_aFileStream << (BYTE)0; //Nachkommastellen + break; + case 'F': + case 'N': + OSL_ENSHURE(nPrecision >= nScale, + "ODbaseTable::Create: Feldlnge mu grer Nachkommastellen sein!"); + if (nPrecision < nScale) + { +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(String(SdbResId(STR_DBF_INVALIDFORMAT))), +// 0, String() ); + break; + } + if (getBOOL(xCol->getFastPropertyValue(PROPERTY_ID_ISCURRENCY))) // Currency wird gesondert behandelt + { + m_aFileStream << (BYTE)10; // Standard Laenge + m_aFileStream << (BYTE)4; + nRecLength += 10; + } + else + { + UINT16 nPrec = SvDbaseConverter::ConvertPrecisionToDbase(nPrecision,nScale); + + m_aFileStream << (BYTE)( nPrec); + m_aFileStream << (BYTE)nScale; + nRecLength += (USHORT)nPrec; + } + break; + case 'L': + m_aFileStream << (BYTE)1; + m_aFileStream << (BYTE)0; + nRecLength++; + break; + case 'D': + m_aFileStream << (BYTE)8; + m_aFileStream << (BYTE)0; + nRecLength += 8; + break; + case 'M': + bCreateMemo = TRUE; + m_aFileStream << (BYTE)10; + m_aFileStream << (BYTE)0; + nRecLength += 10; + break; + default: +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(String(SdbResId(STR_DBF_INVALIDFORMAT))), +// 0, String() ); + break; + } + m_aFileStream.Write(aBuffer, 14); + } + +// if (aStatus.IsError()) +// return FALSE; + + m_aFileStream << (BYTE)0x0d; // kopf ende + m_aFileStream.Seek(10L); + m_aFileStream << nRecLength; // satzlnge nachtrglich eintragen + + if (bCreateMemo) + { + m_aFileStream.Seek(0L); + m_aFileStream << (BYTE) dBaseIIIMemo; + } + return TRUE; +} + +//------------------------------------------------------------------ +// erzeugt grundstzlich dBase III Datei Format +BOOL ODbaseTable::CreateMemoFile(const INetURLObject& aFile) +{ + // Makro zum Filehandling frs Erzeugen von Tabellen + m_aMemoStream.Open(aFile.GetMainURL(), STREAM_READWRITE | STREAM_SHARE_DENYWRITE); + if (!m_aMemoStream.IsOpen()) + return FALSE; + + char aBuffer[512]; // write buffer + memset(aBuffer,0,sizeof(aBuffer)); + +#ifdef WIN + m_aMemoStream.Seek(0L); + for (UINT16 i = 0; i < 512; i++) + { + m_aMemoStream << BYTE(0); + } +#else + m_aMemoStream.SetFiller('\0'); + m_aMemoStream.SetStreamSize(512); +#endif + + m_aMemoStream.Seek(0L); + m_aMemoStream << long(1); // Zeiger auf ersten freien Block + + m_aMemoStream.Close(); + return TRUE; +} +//------------------------------------------------------------------ +BOOL ODbaseTable::DropImpl() +{ +// NAMESPACE_VOS(OGuard) aGuard(m_pLock); +// +// if (InUse()) +// { +// aStatus.SetError(ERRCODE_IO_LOCKVIOLATION,TABLE,aName); +// return FALSE; +// } + + FileClose(); + + INetURLObject aURL; + aURL.SetSmartProtocol(INET_PROT_FILE); + aURL.SetSmartURL(getEntry(), INetURLObject::ENCODE_ALL); + + Content aContent(aURL.GetMainURL(),Reference<XCommandEnvironment>()); + aContent.executeCommand( rtl::OUString::createFromAscii( "delete" ), + makeAny( sal_Bool( sal_True ) ) ); + + if (HasMemoFields()) + { + aURL.setExtension(String::CreateFromAscii("dbt")); + Content aMemoContent(aURL.GetMainURL(),Reference<XCommandEnvironment>()); + aMemoContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) ); + } + + // jetzt noch die Indices loeschen + String aIndexName; + // aFile.SetExtension(String::CreateFromAscii("ndx")); + USHORT nCount = m_pIndexes->getCount(), + i = 0; + while (i < nCount) + { + m_pIndexes->dropByIndex(i); + } + // aFile.SetBase(m_Name); + aURL.setExtension(String::CreateFromAscii("inf")); + Content aInfContent(aURL.GetMainURL(),Reference<XCommandEnvironment>()); + aInfContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) ); + return TRUE; +} +//------------------------------------------------------------------ +BOOL ODbaseTable::InsertRow(ORefAssignValues& rRow, BOOL bFlush,const Reference<XIndexAccess>& _xCols) +{ + // Buffer mit Leerzeichen fllen + AllocBuffer(); + memset(m_pBuffer, ' ', m_aHeader.db_slng); + + // Gesamte neue Row uebernehmen: + // ... und am Ende als neuen Record hinzufuegen: + UINT32 nTempPos = m_nFilePos, + nFileSize, + nMemoFileSize; + + m_nFilePos = (ULONG)m_aHeader.db_anz + 1; + if (!UpdateBuffer(rRow.getBody(),NULL,_xCols)) + { + m_nFilePos = nTempPos; + return FALSE; + } + + String aName = m_aFileStream.GetFileName(); + + m_aFileStream.Seek(STREAM_SEEK_TO_END); + nFileSize = m_aFileStream.Tell(); + + if (HasMemoFields() && m_aMemoStream.IsOpen()) + { + m_aMemoStream.Seek(STREAM_SEEK_TO_END); + nMemoFileSize = m_aMemoStream.Tell(); + } + + if (!WriteBuffer()) + { + m_aFileStream.SetStreamSize(nFileSize); // alte Gre restaurieren + + if (HasMemoFields() && m_aMemoStream.IsOpen()) + m_aMemoStream.SetStreamSize(nMemoFileSize); // alte Gre restaurieren + m_nFilePos = nTempPos; // Fileposition restaurieren + } + else + { + // Anzahl Datensaetze im Header erhoehen: + m_aFileStream.Seek( 4L ); + m_aFileStream << (m_aHeader.db_anz + 1); + + // beim AppendOnly kein Flush! + if (bFlush) + m_aFileStream.Flush(); + + // bei Erfolg # erhhen + m_aHeader.db_anz++; + (*rRow)[0] = m_nFilePos; // BOOKmark setzen + m_nFilePos = nTempPos; + } + + return sal_True;; +} + +//------------------------------------------------------------------ +BOOL ODbaseTable::UpdateRow(file::OValueVector& rRow, OValueRow pOrgRow,const Reference<XIndexAccess>& _xCols) +{ + // Buffer mit Leerzeichen fllen + AllocBuffer(); + + // Auf gewuenschten Record positionieren: + long nPos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng; + m_aFileStream.Seek(nPos); + m_aFileStream.Read((char*)m_pBuffer, m_aHeader.db_slng); + + UINT32 nMemoFileSize; + if (HasMemoFields() && m_aMemoStream.IsOpen()) + { + m_aMemoStream.Seek(STREAM_SEEK_TO_END); + nMemoFileSize = m_aMemoStream.Tell(); + } + if (!UpdateBuffer(rRow, pOrgRow,_xCols) || !WriteBuffer()) + { + if (HasMemoFields() && m_aMemoStream.IsOpen()) + m_aMemoStream.SetStreamSize(nMemoFileSize); // alte Gre restaurieren + } + else + { + m_aFileStream.Flush(); + } + return sal_True; +} + +//------------------------------------------------------------------ +BOOL ODbaseTable::DeleteRow(const OSQLColumns& _rCols) +{ + // Einfach das Loesch-Flag setzen (egal, ob es schon gesetzt war + // oder nicht): + // Auf gewuenschten Record positionieren: + long nPos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng; + m_aFileStream.Seek(nPos); + + OValueRow aRow = new OValueVector(_rCols.size()); + + if (!fetchRow(aRow,_rCols,TRUE)) + return FALSE; + + Reference<XFastPropertySet> xCol; + ::rtl::OUString aColName; + ::utl::UStringMixEqual aCase(isCaseSensitive()); + for (USHORT i = 0; i < m_pColumns->getCount(); i++) + { + m_pColumns->getByIndex(i) >>= xCol; + // const SdbFILEColumn *pColumn = (const SdbFILEColumn *)(*aOriginalColumns)[i]; + + xCol->getFastPropertyValue(PROPERTY_ID_NAME) >>= aColName; + Reference<XFastPropertySet> xIndex = isUniqueByColumnName(aColName); + if (xIndex.is()) + { + Reference<XUnoTunnel> xTunnel(xIndex,UNO_QUERY); + OSL_ENSHURE(xTunnel.is(),"No TunnelImplementation!"); + ODbaseIndex* pIndex = (ODbaseIndex*)xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()); + OSL_ENSHURE(pIndex,"ODbaseTable::UpdateBuffer: No Index returned!"); + + OSQLColumns::const_iterator aIter = _rCols.begin(); + // sal_Int32 nPos = 0; + for(;aIter != _rCols.end();++aIter,++nPos) + { +// Reference<XFastPropertySet> xFindCol; +// _xCols->getByIndex(nPos) >>= xFindCol; + if(aCase(getString((*aIter)->getFastPropertyValue(PROPERTY_ID_REALNAME)),aColName)) + break; + } + if (aIter == _rCols.end()) + continue; + + pIndex->Delete(m_nFilePos,(*aRow)[nPos]); + } + } + + m_aFileStream.Seek(nPos); + m_aFileStream << (BYTE)'*'; + m_aFileStream.Flush(); + return sal_True;; +} + +//------------------------------------------------------------------ +BOOL ODbaseTable::WriteMemo(OFileValue& 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(aVariable.getString().getStr(), osl_getThreadTextEncoding()); + 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_aMemoStream.Seek(rBlockNr * m_aMemoHeader.db_size); + m_aMemoStream.SeekRel(4L); + m_aMemoStream.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_aMemoStream.Seek(STREAM_SEEK_TO_END); + // letzten block auffuellen + rBlockNr = (nStreamSize / m_aMemoHeader.db_size) + ((nStreamSize % m_aMemoHeader.db_size) > 0 ? 1 : 0); + + m_aMemoStream.SetStreamSize(rBlockNr * m_aMemoHeader.db_size); + m_aMemoStream.Seek(STREAM_SEEK_TO_END); + } + else + { + m_aMemoStream.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_aMemoStream.Write((const char*) pData->getConstArray(), pData->getLength()); +// } +// else +// { + m_aMemoStream.Write(aStr.GetBuffer(), aStr.Len()); + // } + + m_aMemoStream << cEOF << cEOF; + } break; + case MemoFoxPro: + case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe + { + m_aMemoStream << (BYTE)0xFF + << (BYTE)0xFF + << (BYTE)0x08; + + UINT32 nWriteSize = nSize; + if (m_aMemoHeader.db_typ == MemoFoxPro) + { + m_aMemoStream << (BYTE) 0x01; // ((pData = NULL) ? 0x01 : 0x00); + for (int i = 4; i > 0; nWriteSize >>= 8) + nHeader[--i] = (BYTE) (nWriteSize % 256); + } + else + { + m_aMemoStream << (BYTE) 0x00; + nWriteSize += 8; + for (int i = 0; i < 4; nWriteSize >>= 8) + nHeader[i++] = (BYTE) (nWriteSize % 256); + } + + m_aMemoStream.Write(nHeader,4); +// if (pData) +// { +// m_aMemoStream.Write((const char*) pData->getConstArray(), pData->getLength()); +// } +// else +// { + m_aMemoStream.Write(aStr.GetBuffer(), aStr.Len()); + // } + m_aMemoStream.Flush(); + } + } + + + // Schreiben der neuen Blocknummer + if (bAppend) + { + nStreamSize = m_aMemoStream.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_aMemoStream.Seek(0L); + m_aMemoStream << m_aMemoHeader.db_next; + m_aMemoStream.Flush(); + } + return sal_True; +} +//------------------------------------------------------------------ +void ODbaseTable::AllocBuffer() +{ + UINT16 nSize = m_aHeader.db_slng; + OSL_ENSHURE(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<XFastPropertySet> ODbaseTable::isUniqueByColumnName(const ::rtl::OUString& _rColName) +{ + if(!m_pIndexes) + refreshIndexes(); + Reference<XFastPropertySet> xIndex; + for(sal_Int32 i=0;i<m_pIndexes->getCount();++i) + { + m_pIndexes->getByIndex(i) >>= xIndex; + if(getBOOL(xIndex->getFastPropertyValue(PROPERTY_ID_ISUNIQUE))) + { + Reference<XNameAccess> xCols(Reference<XColumnsSupplier>(xIndex,UNO_QUERY)->getColumns()); + if(xCols->hasByName(_rColName)) + return xIndex; + + } + } + return Reference<XFastPropertySet>(); +} +//------------------------------------------------------------------ +double toDouble(const ByteString& rString) +{ + static International aInter(LANGUAGE_ENGLISH); + static int nErrno=0; + BOOL bInitialized = FALSE; + if (!bInitialized) + { // ensure that the two members we're interested in are really set + // (if the system doesn't know the locale en_US aIntl would be initialized with the + // system language which may be anything - which we don't want ...) + // 74342 - 21.03.00 - FS + aInter.SetNumThousandSep(','); + aInter.SetNumDecimalSep('.'); + bInitialized = TRUE; + } + return SolarMath::StringToDouble(UniString(rString,gsl_getSystemTextEncoding()).GetBuffer(),aInter,nErrno); +} + +//------------------------------------------------------------------ +BOOL ODbaseTable::UpdateBuffer(OValueVector& rRow, OValueRow pOrgRow,const Reference<XIndexAccess>& _xCols) +{ + USHORT nByteOffset = 1; + + // Felder aktualisieren: + Reference<XFastPropertySet> xCol; + Reference<XFastPropertySet> xIndex; + USHORT i; + ::rtl::OUString aColName; + ::std::vector< Reference<XFastPropertySet> > aIndexedCols(m_pColumns->getCount()); + + ::utl::UStringMixEqual aCase(isCaseSensitive()); + + // first search a key that exist already in the table + for (i = 0; i < m_pColumns->getCount(); i++) + { + m_pColumns->getByIndex(i) >>= xCol; + xCol->getFastPropertyValue(PROPERTY_ID_NAME) >>= aColName; + + // const SdbFILEColumn *pColumn = (const SdbFILEColumn *)(*aOriginalColumns)[i]; + sal_Int32 nPos = 0; + for(;nPos<_xCols->getCount();++nPos) + { + Reference<XFastPropertySet> xFindCol; + _xCols->getByIndex(nPos) >>= xFindCol; + if(aCase(getString(xFindCol->getFastPropertyValue(PROPERTY_ID_NAME)),aColName)) + break; + } + if (nPos >= _xCols->getCount()) + continue; + + ++nPos; + // ODbVariant* pVal = (*rRow)[nPos].getBodyPtr(); + xIndex = isUniqueByColumnName(aColName); + aIndexedCols[i] = xIndex; + if (xIndex.is()) + { + // Update !! + if(pOrgRow.isValid() && (rRow[nPos].isNull() || rRow[nPos] == (*pOrgRow)[nPos])) +// +// if (pOrgRow && (pVal == NULL || +// !pVal->isModified() || +// *pVal == *(*pOrgRow)[nPos])) + continue; + else + { + // ODbVariantRef xVar = (pVal == NULL) ? new ODbVariant() : pVal; + Reference<XUnoTunnel> xTunnel(xIndex,UNO_QUERY); + OSL_ENSHURE(xTunnel.is(),"No TunnelImplementation!"); + ODbaseIndex* pIndex = (ODbaseIndex*)xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()); + OSL_ENSHURE(pIndex,"ODbaseTable::UpdateBuffer: No Index returned!"); + + if (pIndex->Find(0,rRow[nPos])) + { + // es existiert kein eindeutiger Wert +// String aText = String(SdbResId(STR_VALUE_NOTUNIQUE)); +// aText.SearchAndReplace(String::CreateFromAscii("#"),pColumn->GetName()); +// String strDetailed = String(SdbResId(STR_DBF_DUPL_VALUE_INFO)); +// strDetailed.SearchAndReplace(String::CreateFromAscii("$col$"),pColumn->GetName()); +// aStatus.Set(SDB_STAT_ERROR, +// String::CreateFromAscii("01000"), +// aStatus.CreateErrorMessage(aText), +// 0, strDetailed ); + return FALSE; + } + } + } + } + + // when we are here there is no double key in the table + + for (i = 0; i < m_pColumns->getCount(); i++) + { + m_pColumns->getByIndex(i) >>= xCol; + xCol->getFastPropertyValue(PROPERTY_ID_NAME) >>= aColName; + + // Laengen je nach Datentyp: + // nyi: eine zentrale Funktion, die die Laenge liefert! + USHORT nLen = (USHORT)getINT32(xCol->getFastPropertyValue(PROPERTY_ID_PRECISION)); + sal_Int32 nType = getINT32(xCol->getFastPropertyValue(PROPERTY_ID_TYPE)); + switch (nType) + { + case DataType::DATE: nLen = 8; break; + case DataType::DECIMAL: + nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,getINT32(xCol->getFastPropertyValue(PROPERTY_ID_SCALE))); + break; // das Vorzeichen und das Komma + case DataType::BIT: nLen = 1; break; + case DataType::LONGVARCHAR:nLen = 10; break; + default: break; + + } + + sal_Int32 nPos = 0; + for(;nPos<_xCols->getCount();++nPos) + { + Reference<XFastPropertySet> xFindCol; + _xCols->getByIndex(nPos) >>= xFindCol; + if(aCase(getString(xFindCol->getFastPropertyValue(PROPERTY_ID_NAME)),aColName)) + break; + } + + if (nPos >= _xCols->getCount()) + { + nByteOffset += nLen; + continue; + } + + ++nPos; // the row values start at 1 + // ODbVariant* pVal = (*rRow)[nPos].getBodyPtr(); + if (aIndexedCols[i].is()) + { + Reference<XUnoTunnel> xTunnel(aIndexedCols[i],UNO_QUERY); + OSL_ENSHURE(xTunnel.is(),"No TunnelImplementation!"); + ODbaseIndex* pIndex = (ODbaseIndex*)xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()); + OSL_ENSHURE(pIndex,"ODbaseTable::UpdateBuffer: No Index returned!"); + // Update !! + if (pOrgRow.isValid() && !rRow[nPos].isNull() )//&& pVal->isModified()) + pIndex->Update(m_nFilePos,(*pOrgRow)[nPos],rRow[nPos]); + else + { + // ODbVariantRef xVar = (pVal == NULL) ? new ODbVariant() : pVal; + pIndex->Insert(m_nFilePos,rRow[nPos]); + } + } + + // Ist die Variable ueberhaupt gebunden? + if (!rRow[nPos].isBound() )//|| !pVal->isModified()) + { + // Nein - naechstes Feld. + nByteOffset += nLen; + continue; + } + + char* pData = (char *)(m_pBuffer + nByteOffset); + if (rRow[nPos].isNull()) + { + memset(pData,' ',nLen); // Zuruecksetzen auf NULL + nByteOffset += nLen; + continue; + } + try + { + switch (nType) + { + case DataType::DATE: + { + ::com::sun::star::util::Date aDate = DateConversion::toDate(rRow[nPos]); + char s[9]; + sprintf(s,"%04d%02d%02d", + (int)aDate.Year, + (int)aDate.Month, + (int)aDate.Day); + + // Genau 8 Byte kopieren: + strncpy(pData,s,sizeof s - 1); + } break; + case DataType::DECIMAL: + { + memset(pData,' ',nLen); // Zuruecksetzen auf NULL + + double n = rRow[nPos]; + + int nPrecision = (int)getINT32(xCol->getFastPropertyValue(PROPERTY_ID_PRECISION)); + int nScale = (int)getINT32(xCol->getFastPropertyValue(PROPERTY_ID_SCALE)); + // ein const_cast, da GetFormatPrecision am SvNumberFormat nicht const ist, obwohl es das eigentlich + // sein koennte und muesste + + String aString; + SolarMath::DoubleToString(aString,n,'F',nScale,'.'); + ByteString aDefaultValue(aString,gsl_getSystemTextEncoding()); + BOOL bValidLength = FALSE; + if (aDefaultValue.Len() <= nLen) + { + strncpy(pData,aDefaultValue.GetBuffer(),nLen); + // write the resulting double back + rRow[nPos] = toDouble(aDefaultValue); + bValidLength = TRUE; + } + if (!bValidLength) + { +// String strError(SdbResId(STR_DBF_INVALID_FIELD_VALUE)); +// strError.SearchAndReplace(String::CreateFromAscii("$name$"), pColumn->GetName()); +// +// String strDetailedInformation(SdbResId(STR_DBF_INVALID_FIELD_VALUE_DECIMAL)); +// strDetailedInformation.SearchAndReplace(String::CreateFromAscii("$name$"), pColumn->GetName()); +// strDetailedInformation.SearchAndReplace(String::CreateFromAscii("#length#"), nPrecision); +// strDetailedInformation.SearchAndReplace(String::CreateFromAscii("#scale#"), nScale); +// aStatus.Set(SDB_STAT_ERROR, String::CreateFromAscii("S1000"), aStatus.CreateErrorMessage(strError), 0, strDetailedInformation); + } + } break; + case DataType::BIT: + *pData = rRow[nPos].getBool() ? 'T' : 'F'; + break; + case DataType::LONGVARCHAR: + { + char cNext = pData[nLen]; // merken und temporaer durch 0 ersetzen + pData[nLen] = '\0'; // das geht, da der Puffer immer ein Zeichen groesser ist ... + + ULONG nBlockNo = strtol((const char *)pData,NULL,10); // Blocknummer lesen + + // Naechstes Anfangszeichen wieder restaurieren: + pData[nLen] = cNext; + if (!m_aMemoStream.IsOpen() || !WriteMemo(rRow[nPos], nBlockNo)) + break; + + ByteString aStr; + ByteString aBlock(ByteString::CreateFromInt32(nBlockNo)); + aStr.Expand(nLen - aBlock.Len(), '0'); + aStr += aBlock; + aStr.Convert(gsl_getSystemTextEncoding(),osl_getThreadTextEncoding()); + // Zeichen kopieren: + memset(pData,' ',nLen); // Zuruecksetzen auf NULL + memcpy(pData, aStr.GetBuffer(), nLen); + } break; + default: + { + memset(pData,' ',nLen); // Zuruecksetzen auf NULL + ByteString aStr(rRow[nPos].getString().getStr(),osl_getThreadTextEncoding()); + // Zeichen kopieren: + memcpy(pData, aStr.GetBuffer(), min(nLen,aStr.Len())); + } break; + } + } + catch ( ... ) + { +// String strError(SdbResId(STR_DBF_INVALID_FIELD_VALUE)); +// strError.SearchAndReplace(String::CreateFromAscii("$name$"), pColumn->GetName()); +// aStatus.Set(SDB_STAT_ERROR, String::CreateFromAscii("S1000"), aStatus.CreateErrorMessage(strError), 0, String()); + } +// if (aStatus.IsError()) +// break; + // Und weiter ... + nByteOffset += nLen; + } + return sal_True; +} + + +//------------------------------------------------------------------ +BOOL ODbaseTable::WriteBuffer() +{ + OSL_ENSHURE(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_aFileStream.Seek(nPos); + return m_aFileStream.Write((char*) m_pBuffer, m_aHeader.db_slng) > 0; +} + + diff --git a/connectivity/source/drivers/dbase/DTables.cxx b/connectivity/source/drivers/dbase/DTables.cxx new file mode 100644 index 000000000000..2585efa8a5c0 --- /dev/null +++ b/connectivity/source/drivers/dbase/DTables.cxx @@ -0,0 +1,176 @@ +/************************************************************************* + * + * $RCSfile: DTables.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_TABLES_HXX_ +#include "dbase/DTables.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_TABLE_HXX_ +#include "dbase/DTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.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 +#ifndef _CONNECTIVITY_FILE_CATALOG_HXX_ +#include "file/FCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_BCONNECTION_HXX_ +#include "file/FConnection.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::dbase; +using namespace connectivity::file; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; +namespace starutil = ::com::sun::star::util; + +Reference< XNamed > ODbaseTables::createObject(const ::rtl::OUString& _rName) +{ + ::rtl::OUString aName,aSchema; + ODbaseTable* pRet = new ODbaseTable((ODbaseConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(), + _rName,::rtl::OUString::createFromAscii("TABLE")); + + Reference< XNamed > xRet = pRet; + + return xRet; +} +// ------------------------------------------------------------------------- +void ODbaseTables::impl_refresh( ) throw(RuntimeException) +{ + // static_cast<OFileCatalog&>(m_rParent).refreshTables(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > ODbaseTables::createEmptyObject() +{ + ODbaseTable* pRet = new ODbaseTable((ODbaseConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection()); + Reference< XPropertySet > xRet = pRet; + return xRet; +} +typedef connectivity::sdbcx::OCollection ODbaseTables_BASE_BASE; +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL ODbaseTables::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); + ObjectMap::iterator aIter = m_aNameMap.find(aName); + if( aIter != m_aNameMap.end()) + throw ElementExistException(aName,*this); + + Reference<XUnoTunnel> xTunnel(descriptor,UNO_QUERY); + if(xTunnel.is()) + { + ODbaseTable* pTable = (ODbaseTable*)xTunnel->getSomething(ODbaseTable::getUnoTunnelImplementationId()); + if(pTable && pTable->CreateImpl()) + ODbaseTables_BASE_BASE::appendByDescriptor(descriptor); + } +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL ODbaseTables::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + Reference< XUnoTunnel> xTunnel(aIter->second.get(),UNO_QUERY); + if(xTunnel.is()) + { + ODbaseTable* pTable = (ODbaseTable*)xTunnel->getSomething(ODbaseTable::getUnoTunnelImplementationId()); + if(pTable && pTable->DropImpl()) + ODbaseTables_BASE_BASE::dropByName(elementName); + } + +} +// ------------------------------------------------------------------------- +void SAL_CALL ODbaseTables::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + dropByName((*m_aElements[index]).first); +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/dbase/Dservices.cxx b/connectivity/source/drivers/dbase/Dservices.cxx new file mode 100644 index 000000000000..8a0c200523f0 --- /dev/null +++ b/connectivity/source/drivers/dbase/Dservices.cxx @@ -0,0 +1,211 @@ +/************************************************************************* + * + * $RCSfile: Dservices.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_DDRIVER_HXX_ +#include "dbase/DDriver.hxx" +#endif +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +using namespace connectivity::dbase; +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::registry::XRegistryKey; +using ::com::sun::star::lang::XSingleServiceFactory; +using ::com::sun::star::lang::XMultiServiceFactory; + +typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) + ( + const Reference< XMultiServiceFactory > & rServiceManager, + const OUString & rComponentName, + ::cppu::ComponentInstantiation pCreateFunction, + const Sequence< OUString > & rServiceNames + ); + +//*************************************************************************************** +// +// Die vorgeschriebene C-Api muss erfuellt werden! +// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen. +// + +//--------------------------------------------------------------------------------------- +void REGISTER_PROVIDER( + const OUString& aServiceImplName, + const Sequence< OUString>& Services, + const Reference< ::com::sun::star::registry::XRegistryKey > & xKey) +{ + OUString aMainKeyName; + aMainKeyName = OUString::createFromAscii("/"); + aMainKeyName += aServiceImplName; + aMainKeyName += OUString::createFromAscii("/UNO/SERVICES"); + + Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) ); + OSL_ENSHURE(xNewKey.is(), "FILE::component_writeInfo : could not create a registry key !"); + + for (sal_uInt32 i=0; i<Services.getLength(); ++i) + xNewKey->createKey(Services[i]); +} + + +//--------------------------------------------------------------------------------------- +struct ProviderRequest +{ + Reference< XSingleServiceFactory > xRet; + Reference< XMultiServiceFactory > const xServiceManager; + OUString const sImplementationName; + + ProviderRequest( + void* pServiceManager, + sal_Char const* pImplementationName + ) + : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) + , sImplementationName(OUString::createFromAscii(pImplementationName)) + { + } + + inline + sal_Bool CREATE_PROVIDER( + const OUString& Implname, + const Sequence< OUString > & Services, + ::cppu::ComponentInstantiation Factory, + createFactoryFunc creator + ) + { + if (!xRet.is() && (Implname == sImplementationName)) + try + { + xRet = creator( xServiceManager, sImplementationName,Factory, Services); + } + catch(...) + { + } + return xRet.is(); + } + + void* getProvider() const { return xRet.get(); } +}; + +//--------------------------------------------------------------------------------------- + +extern "C" void SAL_CALL component_getImplementationEnvironment( + const sal_Char **ppEnvTypeName, + uno_Environment **ppEnv + ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//--------------------------------------------------------------------------------------- +extern "C" sal_Bool SAL_CALL component_writeInfo( + void* pServiceManager, + void* pRegistryKey + ) +{ + if (pRegistryKey) + try + { + Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey)); + + REGISTER_PROVIDER( + ODriver::getImplementationName_Static(), + ODriver::getSupportedServiceNames_Static(), xKey); + + return sal_True; + } + catch (::com::sun::star::registry::InvalidRegistryException& ) + { + OSL_ENSHURE(sal_False, "FILE::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !"); + } + + return sal_False; +} + +//--------------------------------------------------------------------------------------- +extern "C" void* SAL_CALL component_getFactory( + const sal_Char* pImplementationName, + void* pServiceManager, + void* pRegistryKey) +{ + void* pRet = 0; + if (pServiceManager) + { + ProviderRequest aReq(pServiceManager,pImplementationName); + + aReq.CREATE_PROVIDER( + ODriver::getImplementationName_Static(), + ODriver::getSupportedServiceNames_Static(), + ODriver_CreateInstance, ::cppu::createSingleFactory) + ; + + if(aReq.xRet.is()) + aReq.xRet->acquire(); + + pRet = aReq.getProvider(); + } + + return pRet; +}; + diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx new file mode 100644 index 000000000000..5401bc213d8c --- /dev/null +++ b/connectivity/source/drivers/dbase/dindexnode.cxx @@ -0,0 +1,1006 @@ +/************************************************************************* + * + * $RCSfile: dindexnode.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_INDEXNODE_HXX_ +#include "dbase/dindexnode.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _CONNECTIVITY_DBASE_INDEX_HXX_ +#include "dbase/DIndex.hxx" +#endif + + +using namespace connectivity; +using namespace connectivity::dbase; +using namespace connectivity::file; +using namespace com::sun::star::sdbc; +//================================================================== +// Index Seite +//================================================================== +ONDXPage::ONDXPage(ODbaseIndex& rInd, sal_uInt32 nPos, ONDXPage* pParent) + :rIndex(rInd) + ,nPagePos(nPos) + ,nCount(0) + ,bModified(FALSE) + ,ppNodes(NULL) + ,m_refCount(0) +{ + sal_uInt16 nT=rIndex.getHeader().db_maxkeys; + ppNodes = new ONDXNode[nT]; + aParent = new ONDXPagePtr(pParent); + aChild = new ONDXPagePtr(); +} + +//------------------------------------------------------------------ +ONDXPage::~ONDXPage() +{ + delete[] ppNodes; + delete aParent; + delete aChild; +} +// ------------------------------------------------------------------------- +void ONDXPage::release() +{ + if (! osl_decrementInterlockedCount( &m_refCount )) + { + QueryDelete(); + delete this; + } +} +//------------------------------------------------------------------ +void ONDXPage::QueryDelete() +{ + // Ablegen im GarbageCollector + if (IsModified()) + rIndex.m_aFileStream << *this; + + bModified = FALSE; + if (rIndex.UseCollector()) + { + if ((*aChild).Is()) + (*aChild)->Release(FALSE); + + for (USHORT i = 0; i < rIndex.getHeader().db_maxkeys;i++) + { + if (ppNodes[i].GetChild().Is()) + ppNodes[i].GetChild()->Release(FALSE); + + ppNodes[i] = ONDXNode(); + } + // RestoreNoDelete(); + + nCount = 0; + (*aParent).Clear(); + rIndex.Collect(this); + } +// else +// SvRefBase::QueryDelete(); +} +//------------------------------------------------------------------ +ONDXPagePtr& ONDXPage::GetChild(ODbaseIndex* pIndex) +{ + if (!(*aChild).Is() && pIndex) + { + (*aChild) = rIndex.CreatePage((*aChild).GetPagePos(),this,(*aChild).HasPage()); + } + return (*aChild); +} + +//------------------------------------------------------------------ +USHORT ONDXPage::FindPos(const ONDXKey& rKey) const +{ + // sucht nach Platz fuer den vorgegeben key auf einer Seite + USHORT i = 0; + while (i < nCount && rKey > ((*this)[i]).GetKey()) + i++; + + return i; +} + +//------------------------------------------------------------------ +BOOL ONDXPage::Find(const ONDXKey& rKey) +{ + // sucht den vorgegeben key + // Besonderheit: gelangt der Algorithmus ans Ende + // wird immer die aktuelle Seite und die Knotenposition vermerkt + // auf die die Bedingung <= zutrifft + // dieses findet beim Insert besondere Beachtung + USHORT i = 0; + while (i < nCount && rKey > ((*this)[i]).GetKey()) + i++; + + BOOL bResult = FALSE; + + if (!IsLeaf()) + { + // weiter absteigen + ONDXPagePtr aPage = (i==0) ? GetChild(&rIndex) : ((*this)[i-1]).GetChild(&rIndex, this); + bResult = aPage.Is() && aPage->Find(rKey); + } + else if (i == nCount) + { + rIndex.m_aCurLeaf = this; + rIndex.m_nCurNode = i - 1; + bResult = FALSE; + } + else + { + bResult = rKey == ((*this)[i]).GetKey(); + rIndex.m_aCurLeaf = this; + rIndex.m_nCurNode = bResult ? i : i - 1; + } + return bResult; +} + +//------------------------------------------------------------------ +BOOL ONDXPage::Insert(ONDXNode& rNode, sal_uInt32 nRowsLeft) +{ + // beim Erzeugen eines Index koennen auch mehrere Knoten eingefuegt werden + // diese sin dann aufsteigend sortiert + BOOL bAppend = nRowsLeft > 0; + if (IsFull()) + { + BOOL bResult = TRUE; + ONDXNode aSplitNode; + if (bAppend) + aSplitNode = rNode; + else + { + // merken des letzten Knotens + aSplitNode = (*this)[nCount-1]; + if(rNode.GetKey() <= aSplitNode.GetKey()) + { + + // und damit habe ich im folgenden praktisch eine Node weniger + if (IsLeaf() && this == rIndex.m_aCurLeaf.getBodyPtr()) + { + // geht davon aus, dass der Knoten, auf dem die Bedingung (<=) + // zutrifft, als m_nCurNode gesetzt ist + --nCount; // (sonst bekomme ich u.U. Assertions und GPFs - 60593) + bResult = Insert(rIndex.m_nCurNode + 1, rNode); + } + else // Position unbekannt + { + USHORT nPos = NODE_NOTFOUND; + while (++nPos < nCount && rNode.GetKey() > ((*this)[nPos]).GetKey()); + + --nCount; // (sonst bekomme ich u.U. Assertions und GPFs - 60593) + bResult = Insert(nPos, rNode); + } + + // konnte der neue Knoten eingefuegt werden + if (!bResult) + { + nCount++; + aSplitNode = rNode; + } + } + else + aSplitNode = rNode; + } + + sal_uInt32 nNewPagePos = rIndex.GetPageCount(); + sal_uInt32 nNewPageCount = nNewPagePos + 1; + + // Herausgeloesten Knoten beim Vater einfuegen + if (!HasParent()) + { + // Kein Vater, dann neue Wurzel + ONDXPagePtr aNewRoot = rIndex.CreatePage(nNewPagePos + 1); + aNewRoot->SetChild(this); + + rIndex.m_aRoot = aNewRoot; + rIndex.SetRootPos(nNewPagePos + 1); + rIndex.SetPageCount(++nNewPageCount); + } + + // neues blatt erzeugen und Seite aufteilen + ONDXPagePtr aNewPage = rIndex.CreatePage(nNewPagePos,(*aParent).getBodyPtr()); + rIndex.SetPageCount(nNewPageCount); + + // wieviele Knoten weren noch eingefuegt + // kommen noch ausreichend, dann koennen die Seiten bis zum Rand vollgestopft werden + + ONDXNode aInnerNode; + if (!IsLeaf() || nRowsLeft < (sal_uInt32)(rIndex.GetMaxNodes() / 2)) + aInnerNode = Split(*aNewPage); + else + { + aInnerNode = (*this)[nCount - 1]; + //aInnerNode = aSplitNode; + + // Knoten zeigt auf neue Seite + aInnerNode.SetChild(aNewPage); + + // innere Knoten haben keine Recordnummer + if (rIndex.isUnique()) + aInnerNode.GetKey().ResetRecord(); + + // neue Seite zeigt nun auf Seite des herausgelsten Knoten + if (!IsLeaf()) + aNewPage->SetChild(aInnerNode.GetChild()); + } + + aNewPage->Append(aSplitNode); + ONDXPagePtr aTempParent = (*aParent); + if (IsLeaf()) + { + rIndex.m_aCurLeaf = aNewPage; + rIndex.m_nCurNode = rIndex.m_aCurLeaf->Count() - 1; + + // Freigeben nicht benoetigter Seiten, danach besteht keine Referenz + // mehr auf die Seite, danach kann 'this' nicht mehr gueltig sein!!! + ReleaseFull(); + } + + // Einfuegen des herausgeloesten Knotens + return aTempParent->Insert(aInnerNode); + } + else // Seite einfach weiter auffuellen + { + if (bAppend) + { + if (IsLeaf()) + rIndex.m_nCurNode = nCount - 1; + return Append(rNode); + } + else + { + USHORT nNodePos = FindPos(rNode.GetKey()); + if (IsLeaf()) + rIndex.m_nCurNode = nNodePos; + + return Insert(nNodePos, rNode); + } + } +} + +//------------------------------------------------------------------ +BOOL ONDXPage::Insert(USHORT nPos, ONDXNode& rNode) +{ + USHORT nMaxCount = rIndex.getHeader().db_maxkeys; + if (nPos >= nMaxCount) + return FALSE; + + if (nCount) + { + ++nCount; + // nach rechts verschieben + for (USHORT i = min(nMaxCount-1, nCount-1); nPos < i; i--) + (*this)[i] = (*this)[i-1]; + } + else + if (nCount < nMaxCount) + nCount++; + + // einfuegen an der Position + ONDXNode& rInsertNode = (*this)[nPos]; + rInsertNode = rNode; + if (rInsertNode.GetChild().Is()) + { + rInsertNode.GetChild()->SetParent(this); + rNode.GetChild()->SetParent(this); + } + + bModified = TRUE; + + return TRUE; +} + +//------------------------------------------------------------------ +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) +{ + // freigeben der Pages + if ((*aChild).Is()) + (*aChild)->Release(bSave); + + // Pointer freigeben + (*aChild).Clear(); + + for (USHORT i = 0; i < rIndex.getHeader().db_maxkeys;i++) + { + if (ppNodes[i].GetChild().isValid()) + ppNodes[i].GetChild()->Release(bSave); + + ppNodes[i].GetChild().Clear(); + } + (*aParent) = NULL; +} +//------------------------------------------------------------------ +void ONDXPage::ReleaseFull(BOOL bSave) +{ + ONDXPagePtr aTempParent = (*aParent); + Release(bSave); + + if (aTempParent.Is()) + { + // Freigeben nicht benoetigter Seiten, danach besteht keine Referenz + // mehr auf die Seite, danach kann 'this' nicht mehr gueltig sein!!! + USHORT nParentPos = aTempParent->Search(this); + if (nParentPos != NODE_NOTFOUND) + (*aTempParent)[nParentPos].GetChild().Clear(); + else + 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->getBodyPtr(); + + 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().getBodyPtr() == 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) +{ + if (IsLeaf()) + { + // Letztes Element wird geloescht + if (nNodePos == (nCount - 1)) + { + ONDXNode aNode = (*this)[nNodePos]; + + // beim Parent muss nun der KeyValue ausgetauscht werden + if (HasParent()) + (*aParent)->SearchAndReplace(aNode.GetKey(), + (*this)[nNodePos-1].GetKey()); + } + } + + // Loeschen des Knoten + Remove(nNodePos); + + // Unterlauf + if (HasParent() && nCount < (rIndex.GetMaxNodes() / 2)) + { + // Feststellen, welcher Knoten auf die Seite zeigt + USHORT nParentNodePos = (*aParent)->Search(this); + // letzte Element auf Vaterseite + // -> zusammenlegen mit vorletzter Seite + if (nParentNodePos == ((*aParent)->Count() - 1)) + { + if (!nParentNodePos) + // zusammenlegen mit linken nachbarn + Merge(nParentNodePos,(*aParent)->GetChild(&rIndex)); + else + Merge(nParentNodePos,(*(*aParent))[nParentNodePos-1].GetChild(&rIndex,(*aParent).getBodyPtr())); + } + // sonst Seite mit naechster Seite zusammenlegen + else + { + // zusammenlegen mit rechten nachbarn + Merge(nParentNodePos + 1,((*(*aParent))[nParentNodePos + 1].GetChild(&rIndex,(*aParent).getBodyPtr()))); + nParentNodePos++; + } + if (HasParent() && !(*(*aParent))[nParentNodePos].HasChild()) + (*aParent)->Delete(nParentNodePos); +/* + // letzte Element auf Vaterseite + // -> zusammenlegen mit vorletzter Seite + if (nParentNodePos == ((*aParent)->Count() - 1)) + { + if (!nParentNodePos) + // zusammenlegen mit linken nachbarn + Merge(nParentNodePos,(*aParent)->GetChild(&rIndex)); + else + Merge(nParentNodePos,(*(*aParent))[nParentNodePos-1].GetChild(&rIndex,(*aParent))); + } + // sonst Seite mit naechster Seite zusammenlegen + else if(nParentNodePos != NODE_NOTFOUND) + { + // zusammenlegen mit rechten nachbarn + Merge(nParentNodePos + 1,((*(*aParent))[nParentNodePos + 1].GetChild(&rIndex,(*aParent)))); + nParentNodePos++; + } + else // Sonderbehandlung + { + // Page ist (*aChild) Page vom Parent => erste Page aus ppNodes an (*aChild) anhngen + Merge(0,(*(*aParent))[0].GetChild(&rIndex,(*aParent))); + nParentNodePos = 0; + } + + if (HasParent() && !(*(*aParent))[nParentNodePos].HasChild()) + (*aParent)->Delete(nParentNodePos); +*/ + + } + else if (IsRoot()) + // Sicherstellen das die Position der Wurzel festgehalten wird + rIndex.SetRootPos(nPagePos); + return TRUE; +} + + +//------------------------------------------------------------------ +ONDXNode ONDXPage::Split(ONDXPage& rPage) +{ + DBG_ASSERT(IsFull(), "Falsches Splitting"); + /* Aufteilen einer Seite auf zwei + Blatt: + Seite 1 behaelt (n - (n/2)) + Seite 2 erhaelt (n/2) + Knoten n/2 wird dupliziert + Innerer Knoten: + Seite 1 behaelt (n+1)/2 + Seite 2 erhaelt (n/2-1) + Knoten ((n+1)/2 + 1) : wird herausgenommen + */ + ONDXNode aResultNode; + if (IsLeaf()) + { + for (USHORT i = (nCount - (nCount / 2)), j = 0 ; i < nCount; i++) + rPage.Insert(j++,(*this)[i]); + + // dieser Knoten enthaelt einen Schluessel der noch einmal im Tree vorkommt + // und ersetzt werden muss + ONDXNode aLastNode = (*this)[nCount - 1]; + nCount = nCount - (nCount / 2); + aResultNode = (*this)[nCount - 1]; + + if (HasParent()) + (*aParent)->SearchAndReplace(aLastNode.GetKey(), + aResultNode.GetKey()); + } + else + { + for (USHORT i = (nCount + 1) / 2 + 1, j = 0 ; i < nCount; i++) + rPage.Insert(j++,(*this)[i]); + + aResultNode = (*this)[(nCount + 1) / 2]; + nCount = (nCount + 1) / 2; + + // neue Seite zeigt nun auf Seite des herausgelsten Knoten + rPage.SetChild(aResultNode.GetChild()); + } + // Knoten zeigt auf neue Seite + aResultNode.SetChild(&rPage); + + // innere Knoten haben keine Recordnummer + if (rIndex.isUnique()) + aResultNode.GetKey().ResetRecord(); + bModified = TRUE; + return aResultNode; +} + +//------------------------------------------------------------------ +void ONDXPage::Merge(USHORT nParentNodePos, ONDXPagePtr xPage) +{ + DBG_ASSERT(HasParent(), "kein Vater vorhanden"); + DBG_ASSERT(nParentNodePos != NODE_NOTFOUND, "Falscher Indexaufbau"); + + /* Zusammenlegen zweier Seiten */ + ONDXNode aResultNode; + USHORT nMaxNodes = rIndex.GetMaxNodes(), + nMaxNodes_2 = nMaxNodes / 2; + + // Feststellen ob Seite rechter oder linker Nachbar + BOOL bRight = ((*xPage)[0].GetKey() > (*this)[0].GetKey()); // TRUE, wenn xPage die rechte Seite ist + USHORT nNewCount = (*xPage).Count() + Count(); + + if (IsLeaf()) + { + // Bedingung fuers zusammenlegen + if (nNewCount < (nMaxNodes_2 * 2)) + { + USHORT nLastNode = bRight ? Count() - 1 : xPage->Count() - 1; + if (bRight) + { + DBG_ASSERT(xPage.getBodyPtr() != this,"xPage und THIS drfen nicht gleich sein: Endlosschleife"); + // alle Knoten aus xPage auf den linken Knoten verschieben (anhngen) + while (xPage->Count()) + { + Append((*xPage)[0]); + xPage->Remove(0); + } + } + else + { + DBG_ASSERT(xPage.getBodyPtr() != this,"xPage und THIS drfen nicht gleich sein: Endlosschleife"); + // xPage ist die linke Page und THIS die rechte + while (xPage->Count()) + { + Insert(0,(*xPage)[xPage->Count()-1]); + xPage->Remove(xPage->Count()-1); + } + // alte Position von xPage beim Parent mit this ersetzen + if (nParentNodePos) + (*(*aParent))[nParentNodePos-1].SetChild(this,(*aParent).getBodyPtr()); + else // oder als rechten Knoten setzen + (*aParent)->SetChild(this); + (*aParent)->SetModified(TRUE); + + } + + // Child beziehung beim Vaterknoten aufheben + (*(*aParent))[nParentNodePos].SetChild(); + // Austauschen des KnotenWertes, nur wenn geaenderte Page + // die linke ist, ansonsten werde + + if((*aParent)->IsRoot() && (*aParent)->Count() == 1) + { + (*(*aParent))[0].SetChild(); + (*aParent)->ReleaseFull(); + (*aParent) = NULL; + rIndex.SetRootPos(nPagePos); + rIndex.m_aRoot = this; + SetModified(TRUE); + } + else + (*aParent)->SearchAndReplace((*this)[nLastNode].GetKey(),(*this)[nCount-1].GetKey()); + + xPage->SetModified(FALSE); + xPage->ReleaseFull(); // wird nicht mehr benoetigt + } + // Ausgleichen der Elemente nNewCount >= (nMaxNodes_2 * 2) + else + { + if (bRight) + { + // alle Knoten aus xPage auf den linken Knoten verschieben (anhngen) + ONDXNode aReplaceNode = (*this)[nCount - 1]; + while (nCount < nMaxNodes_2) + { + Append((*xPage)[0]); + xPage->Remove(0); + } + // Austauschen des KnotenWertes: Setzt alten letzten Wert durch den letzten von xPage + (*aParent)->SearchAndReplace(aReplaceNode.GetKey(),(*this)[nCount-1].GetKey()); + } + else + { + // alle Knoten aus this vor die xPage Knoten einfgen + ONDXNode aReplaceNode = (*this)[nCount - 1]; + while (xPage->Count() < nMaxNodes_2) + { + xPage->Insert(0,(*this)[nCount-1]); + Remove(nCount-1); + } + // Austauschen des KnotenWertes + (*aParent)->SearchAndReplace(aReplaceNode.GetKey(),(*this)[Count()-1].GetKey()); + } + } + } + else // !IsLeaf() + { + // Bedingung fuers zusammenlegen + if (nNewCount < nMaxNodes_2 * 2) + { + if (bRight) + { + DBG_ASSERT(xPage.getBodyPtr() != this,"xPage und THIS drfen nicht gleich sein: Endlosschleife"); + // Vaterknoten wird mit integriert + // erhaelt zunaechst Child von xPage + (*(*aParent))[nParentNodePos].SetChild(xPage->GetChild(),(*aParent).getBodyPtr()); + Append((*(*aParent))[nParentNodePos]); + for (USHORT i = 0 ; i < xPage->Count(); i++) + Append((*xPage)[i]); + } + else + { + DBG_ASSERT(xPage.getBodyPtr() != this,"xPage und THIS drfen nicht gleich sein: Endlosschleife"); + // Vaterknoten wird mit integriert + // erhaelt zunaechst Child + (*(*aParent))[nParentNodePos].SetChild(GetChild(),(*aParent).getBodyPtr()); // Parent merkt sich mein Child + Insert(0,(*(*aParent))[nParentNodePos]); // Node vom Parent bei mir einfgen + while (xPage->Count()) + { + Insert(0,(*xPage)[xPage->Count()-1]); + xPage->Remove(xPage->Count()-1); + } + SetChild(xPage->GetChild()); + + if (nParentNodePos) + (*(*aParent))[nParentNodePos-1].SetChild(this,(*aParent).getBodyPtr()); + else + (*aParent)->SetChild(this); + } + + // danach wird der Vaterknoten zurueckgesetzt + (*(*aParent))[nParentNodePos].SetChild(); + (*aParent)->SetModified(TRUE); + + if((*aParent)->IsRoot() && (*aParent)->Count() == 1) + { + (*(*aParent)).SetChild(); + (*aParent)->ReleaseFull(); + (*aParent) = NULL; + rIndex.SetRootPos(nPagePos); + rIndex.m_aRoot = this; + SetModified(TRUE); + } + else if(nParentNodePos) + // Austauschen des KnotenWertes + // beim Append wird der Bereich erweitert, beim INsert verweist der alte Knoten von xPage auf this + // deshalb mu der Knoten auch hier aktualisiert werden + (*aParent)->SearchAndReplace((*(*aParent))[nParentNodePos-1].GetKey(),(*(*aParent))[nParentNodePos].GetKey()); + + xPage->SetModified(FALSE); + xPage->ReleaseFull(); + } + // Ausgleichen der Elemente + else + { + if (bRight) + { + while (nCount < nMaxNodes_2) + { + (*(*aParent))[nParentNodePos].SetChild(xPage->GetChild(),(*aParent).getBodyPtr()); + Append((*(*aParent))[nParentNodePos]); + (*(*aParent))[nParentNodePos] = (*xPage)[0]; + xPage->Remove(0); + } + xPage->SetChild((*(*aParent))[nParentNodePos].GetChild()); + (*(*aParent))[nParentNodePos].SetChild(xPage,(*aParent).getBodyPtr()); + } + else + { + while (nCount < nMaxNodes_2) + { + (*(*aParent))[nParentNodePos].SetChild(GetChild(),(*aParent).getBodyPtr()); + Insert(0,(*(*aParent))[nParentNodePos]); + (*(*aParent))[nParentNodePos] = (*xPage)[xPage->Count()-1]; + xPage->Remove(xPage->Count()-1); + } + SetChild((*(*aParent))[nParentNodePos].GetChild()); + (*(*aParent))[nParentNodePos].SetChild(this,(*aParent).getBodyPtr()); + + } + (*aParent)->SetModified(TRUE); + } + } +} +// ------------------------------------------------------------------------- +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().hasValue()) + { + 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(), getDouble(rKey.getValue()),rNode.GetChild().GetPagePos()); + } + else + { + DBG_TRACE3("SDB: [%d,%s,%d]",rKey.GetRecord(), (const char* )ByteString(getString(rKey.getValue()).getStr(), gsl_getSystemTextEncoding()).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 + if ((rPage.GetPagePos() + 1) * 512 > rStream.Seek(STREAM_SEEK_TO_END)) + rStream.SetStreamSize((rPage.GetPagePos() + 1) * 512); + rStream.Seek(rPage.GetPagePos() * 512); + + nValue = rPage.nCount; + rStream << nValue << (*rPage.aChild); + + for (USHORT i = 0; i < rPage.nCount; i++) + rPage[i].Write(rStream, rPage); + return rStream; +} + +//================================================================== +// ONDXNode +//================================================================== + +//------------------------------------------------------------------ +void ONDXNode::Read(SvStream &rStream, ODbaseIndex& rIndex) +{ + rStream >> 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((aBuf,osl_getThreadTextEncoding()) ,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 << aKey.nRecord; // schluessel + else + rStream << (sal_uInt32)0; // schluessel + + if (rIndex.getHeader().db_keytype) // double + { + if (!aKey.getValue().hasValue()) + { + memset(aNodeData.aData,0,rIndex.getHeader().db_keylen); + rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen); + } + else + rStream << (double) getDouble(aKey.getValue()); + } + else + { + memset(aNodeData.aData,0x20,rIndex.getHeader().db_keylen); + if (aKey.getValue().hasValue()) + { + // ODBFConnection *pCon = rIndex.GetDBFConnection(); + if (NULL) + { + ByteString aText(getString(aKey.getValue()).getStr(), gsl_getSystemTextEncoding());//pCon->GetCharacterSet()); + strncpy(aNodeData.aData,aText.GetBuffer(),min(rIndex.getHeader().db_keylen, aText.Len())); + } + else + { + DBG_ERROR("No Connection"); + ByteString aText(getString(aKey.getValue()).getStr(), gsl_getSystemTextEncoding()); + 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().getValue() || !getValue().hasValue()) + { + if (!rKey.getValue().getValue() || !rKey.getValue().hasValue() || (rKey.IsText(getDBType()) && !getString(rKey.getValue()).getLength())) + eResult = COMPARE_EQUAL; + else + eResult = COMPARE_LESS; + } + else if (!rKey.getValue().getValue() || !rKey.getValue().hasValue()) + { + if (!getValue().getValue() || !getValue().hasValue() || (IsText(getDBType()) && !getString(getValue()).getLength())) + eResult = COMPARE_EQUAL; + else + eResult = COMPARE_GREATER; + } + else if (IsText(getDBType())) + { + INT32 nRes = getString(getValue()).compareTo(getString(rKey.getValue())); + eResult = (nRes > 0) ? COMPARE_GREATER : (nRes == 0) ? COMPARE_EQUAL : COMPARE_LESS; + } + else + { + double m,n; + getValue() >>= m; + rKey.getValue() >>= n; + + 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; +} + diff --git a/connectivity/source/drivers/dbase/exports.dxp b/connectivity/source/drivers/dbase/exports.dxp new file mode 100644 index 000000000000..9630d7e06768 --- /dev/null +++ b/connectivity/source/drivers/dbase/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/connectivity/source/drivers/dbase/makefile.mk b/connectivity/source/drivers/dbase/makefile.mk new file mode 100644 index 000000000000..0de686b1f257 --- /dev/null +++ b/connectivity/source/drivers/dbase/makefile.mk @@ -0,0 +1,132 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=..$/.. +PRJNAME=connectivity +TARGET=dbase + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/version.mk + + +# --- Files ------------------------------------- + +SLOFILES=\ + $(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 + + + +# --- Library ----------------------------------- + +SHL1TARGET= $(DBASE_TARGET)$(DBASE_MAJOR) +SHL1OBJS=$(SLOFILES) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(OSLLIB) \ + $(SVLLIB) \ + $(SVLIB) \ + $(TOOLSLIB) \ + $(UCBHELPERLIB) \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(DBASE_TARGET) +SHL1LIBS= $(SLB)$/commontools.lib \ + $(SLB)$/resource.lib \ + $(SLB)$/sdbcx.lib \ + $(SLB)$/file.lib \ + $(SLB)$/sql.lib + +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + + diff --git a/connectivity/source/drivers/file/FCatalog.cxx b/connectivity/source/drivers/file/FCatalog.cxx new file mode 100644 index 000000000000..7e7a38415d8d --- /dev/null +++ b/connectivity/source/drivers/file/FCatalog.cxx @@ -0,0 +1,136 @@ +/************************************************************************* + * + * $RCSfile: FCatalog.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_BCONNECTION_HXX_ +#include "file/FConnection.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_TABLES_HXX_ +#include "file/FTables.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +//#ifndef _CONNECTIVITY_FILE_OEMPTYCOLLECTION_HXX_ +//#include "file/FEmptyCollection.hxx" +//#endif + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; + +// ------------------------------------------------------------------------- +using namespace connectivity::file; +// ------------------------------------------------------------------------- +OFileCatalog::OFileCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon) + ,m_pConnection(_pCon) + ,m_xMetaData(m_pConnection->getMetaData( )) +{ +} +// ------------------------------------------------------------------------- +void SAL_CALL OFileCatalog::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + typedef connectivity::sdbcx::OCatalog OFileCatalog_BASE; + m_xMetaData = NULL; + OFileCatalog_BASE::disposing(); +} +// ------------------------------------------------------------------------- +void OFileCatalog::refreshTables() +{ + ::std::vector< ::rtl::OUString> aVector; + Sequence< ::rtl::OUString > aTypes(1); + aTypes[0] = ::rtl::OUString::createFromAscii("%"); + Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), + ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(3)); + } + if(m_pTables) + delete m_pTables; + m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector); +} + +// ------------------------------------------------------------------------- +Any SAL_CALL OFileCatalog::queryInterface( const Type & rType ) throw(RuntimeException) +{ + if( rType == ::getCppuType((const Reference<XGroupsSupplier>*)0) || + rType == ::getCppuType((const Reference<XUsersSupplier>*)0) || + rType == ::getCppuType((const Reference<XViewsSupplier>*)0)) + return Any(); + + + typedef sdbcx::OCatalog OFileCatalog_BASE; + return OFileCatalog_BASE::queryInterface(rType); +} + diff --git a/connectivity/source/drivers/file/FColumns.cxx b/connectivity/source/drivers/file/FColumns.cxx new file mode 100644 index 000000000000..a80367236e50 --- /dev/null +++ b/connectivity/source/drivers/file/FColumns.cxx @@ -0,0 +1,142 @@ +/************************************************************************* + * + * $RCSfile: FColumns.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_COLUMNS_HXX_ +#include "file/FColumns.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _CONNECTIVITY_FILE_TABLE_HXX_ +#include "file/FTable.hxx" +#endif + +using namespace connectivity::file; +using namespace connectivity; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OColumns::createObject(const ::rtl::OUString& _rName) +{ + + Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(), + m_pTable->getSchema(),m_pTable->getName(),_rName); + + Reference< XNamed > xRet = NULL; + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + { + if(xRow->getString(4) == _rName) + { + sdbcx::OColumn* pRet = new sdbcx::OColumn(_rName, + xRow->getString(6), + xRow->getString(13), + xRow->getInt(11), + xRow->getInt(7), + xRow->getInt(9), + xRow->getInt(5), + sal_False, + sal_False, + sal_False, + m_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()); + xRet = pRet; + break; + } + } + } + + return xRet; +} + +// ------------------------------------------------------------------------- +void OColumns::impl_refresh() throw(RuntimeException) +{ + m_pTable->refreshColumns(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OColumns::createEmptyObject() +{ + sdbcx::OColumn* pRet = new sdbcx::OColumn(m_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()); + Reference< XPropertySet > xRet = pRet; + return xRet; +} + + diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx new file mode 100644 index 000000000000..13295d74c3bb --- /dev/null +++ b/connectivity/source/drivers/file/FConnection.cxx @@ -0,0 +1,451 @@ +/************************************************************************* + * + * $RCSfile: FConnection.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_OCONNECTION_HXX_ +#include "file/FConnection.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_ODATABASEMETADATA_HXX_ +#include "file/FDatabaseMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_RESOURCE_HRC_ +#include "Resource.hrc" +#endif +#ifndef _CONNECTIVITY_MODULECONTEXT_HXX_ +#include "ModuleContext.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_ODRIVER_HXX_ +#include "file/FDriver.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_OSTATEMENT_HXX_ +#include "file/FStatement.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_OPREPAREDSTATEMENT_HXX_ +#include "file/FPreparedStatement.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ +#include <com/sun/star/container/XChild.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_ +#include <com/sun/star/ucb/XContent.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_XCONTENTIDENTIFIER_HPP_ +#include <com/sun/star/ucb/XContentIdentifier.hpp> +#endif +#ifndef _URLOBJ_HXX //autogen wg. INetURLObject +#include <tools/urlobj.hxx> +#endif +#ifndef _FSYS_HXX //autogen +#include <tools/fsys.hxx> +#endif +#ifndef _CONNECTIVITY_FILE_CATALOG_HXX_ +#include "file/FCatalog.hxx" +#endif +#ifndef _COM_SUN_STAR_FRAME_XCONFIGMANAGER_HPP_ +#include <com/sun/star/frame/XConfigManager.hpp> +#endif +#ifndef _UCBHELPER_CONTENT_HXX +#include <ucbhelper/content.hxx> +#endif + +using namespace connectivity::file; + +//------------------------------------------------------------------------------ +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::container; +using namespace com::sun::star::ucb; +using namespace rtl; +// -------------------------------------------------------------------------------- +OConnection::OConnection(OFileDriver* _pDriver) + : OConnection_BASE(m_aMutex), + OSubComponent<OConnection>((::cppu::OWeakObject*)_pDriver), + m_pDriver(_pDriver), + m_bClosed(sal_False), + m_xMetaData(NULL) +{ + ModuleContext::AddRef(); +} +//----------------------------------------------------------------------------- +OConnection::~OConnection() +{ + if(!isClosed( )) + close(); + ModuleContext::ReleaseRef(); +} +//----------------------------------------------------------------------------- +void SAL_CALL OConnection::release() throw(RuntimeException) +{ + relase_ChildImpl(); + OConnection_BASE::release(); +} + +//----------------------------------------------------------------------------- +void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException) +{ + osl_incrementInterlockedCount( &m_refCount ); + + sal_Int32 nLen = url.indexOf(':'); + nLen = url.indexOf(':',nLen+1); + ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD; + + INetURLObject aURL; + aURL.SetSmartProtocol(INET_PROT_FILE); + aURL.SetURL(aDSN, INetURLObject::ENCODE_ALL); + + + // String aFileName = aURL.PathToFileName(); + String aFileName = aURL.GetMainURL(); + + if(!aFileName.Len()) + aFileName = aDSN; + String aWildcard; + + if (aURL.GetProtocol() == INET_PROT_FILE) + { + // $Inst mu gesetzt sein + // sehr umstaendlicher weg, um an den Inimanager zu kommen + // aber ohne Arme(Sfx) keine Kekse + Reference< ::com::sun::star::frame::XConfigManager > xSofficeIni( + m_pDriver->getFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.config.SpecialConfigManager")), UNO_QUERY); + + aFileName = xSofficeIni->substituteVariables(aDSN); + } + + ::rtl::OUString aExt; + const PropertyValue *pBegin = info.getConstArray(); + const PropertyValue *pEnd = pBegin + info.getLength(); + for(;pBegin != pEnd;++pBegin) + { + if(!pBegin->Name.compareToAscii("EXTENSTION")) + pBegin->Value >>= aExt; + } + + m_aFilenameExtension = aExt; + + ::ucb::Content aFile(aFileName,Reference< ::com::sun::star::ucb::XCommandEnvironment >()); + +// if (aFileStat.IsKind(FSYS_KIND_WILD)) +// { +// m_aDirectoryName = (DirEntry(aFileName).GetPath()).GetFull(); +// m_aFilenameExtension = DirEntry(aFileName).GetExtension(); +// +// // nyi: Verschiedene Extensions (aufgrund des angegebenen Wildcard) +// // (bisher keine Wildcard in der Extension moeglich!) +// aWildcard = DirEntry(aFileName).GetName(); +// } else + + // set fields to fetch + Sequence< OUString > aProps(1); + OUString* pProps = aProps.getArray(); + pProps[ 0 ] = OUString::createFromAscii( "Title" ); + + if (aFile.isFolder()) + { + m_xDir = aFile.createCursor(aProps, ::ucb::INCLUDE_DOCUMENTS_ONLY ); + m_xContent = aFile.get(); + } + else if (aFile.isDocument()) + { + Reference<XContent> xParent(Reference<XChild>(aFile.get(),UNO_QUERY)->getParent(),UNO_QUERY); + Reference<XContentIdentifier> xIdent = xParent->getIdentifier(); + m_xContent = xParent; + + ::ucb::Content aParent(xIdent->getContentIdentifier(),Reference< XCommandEnvironment >()); + m_xDir = aParent.createCursor(aProps, ::ucb::INCLUDE_DOCUMENTS_ONLY ); + } + else + throw SQLException(); + + if (m_aFilenameExtension.Search('*') != STRING_NOTFOUND || m_aFilenameExtension.Search('?') != STRING_NOTFOUND) + throw SQLException(); + + osl_decrementInterlockedCount( &m_refCount ); +} +// XServiceInfo +// -------------------------------------------------------------------------------- +IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.file.Connection", "com.sun.star.sdbc.Connection") + +// -------------------------------------------------------------------------------- +Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + OStatement* pStmt = new OStatement(this); + + m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + return pStmt; +} +// -------------------------------------------------------------------------------- +Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + OPreparedStatement* pStmt = new OPreparedStatement(this,m_aTypeInfo); + pStmt->construct(sql); + m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + return pStmt; +} +// -------------------------------------------------------------------------------- +Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + return NULL; +} +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sql; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_bAutoCommit = autoCommit; +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_bAutoCommit; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return OConnection_BASE::rBHelper.bDisposed; +} +// -------------------------------------------------------------------------------- +Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_xMetaData.is()) + m_xMetaData = new ODatabaseMetaData(this); + + return m_xMetaData; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_bReadOnly = readOnly; +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_bReadOnly; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); +} +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return ::rtl::OUString(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return 0; +} +// -------------------------------------------------------------------------------- +Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return NULL; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) +{ +} +// -------------------------------------------------------------------------------- +// XCloseable +void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + } + dispose(); +} +// -------------------------------------------------------------------------------- +// XWarningsSupplier +Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException) +{ + return Any(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException) +{ +} +//------------------------------------------------------------------------------ +void OConnection::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + + // m_aTables.disposing(); + for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i) + { + Reference< XComponent > xComp(i->get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + } + m_aStatements.clear(); + + m_bClosed = sal_True; + m_xMetaData = NULL; + m_xDir = NULL; + + dispose_ChildImpl(); + OConnection_BASE::disposing(); +} +//------------------------------------------------------------------------------ +::com::sun::star::uno::Reference< XTablesSupplier > OConnection::createCatalog() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + Reference< XTablesSupplier > xTab = m_xCatalog; + if(!m_xCatalog.get().is()) + { + OFileCatalog *pCat = new OFileCatalog(this); + xTab = pCat; + m_xCatalog = xTab; + } + return xTab; +} + + diff --git a/connectivity/source/drivers/file/FDatabaseMetaData.cxx b/connectivity/source/drivers/file/FDatabaseMetaData.cxx new file mode 100644 index 000000000000..393273b485c4 --- /dev/null +++ b/connectivity/source/drivers/file/FDatabaseMetaData.cxx @@ -0,0 +1,1327 @@ +/************************************************************************* + * + * $RCSfile: FDatabaseMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_ODATABASEMETADATA_HXX_ +#include "file/FDatabaseMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_ORESULTSET_HXX_ +#include "file/FDatabaseMetaDataResultSet.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_SEARCHRECURSION_HPP_ +#include <com/sun/star/ucb/SearchRecursion.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_SEARCHCOMMANDARGUMENT_HPP_ +#include <com/sun/star/ucb/SearchCommandArgument.hpp> +#endif +#ifndef _URLOBJ_HXX //autogen wg. INetURLObject +#include <tools/urlobj.hxx> +#endif + +using namespace com::sun::star::ucb; +using namespace connectivity::file; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::container; + +ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon) + : m_pConnection(_pCon) +{ + m_pConnection->acquire(); +} +// ------------------------------------------------------------------------- +ODatabaseMetaData::~ODatabaseMetaData() +{ + if (m_pConnection) + m_pConnection->release(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openTypeInfo(); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openCatalogs(); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogSeparator( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUString aVal; + return aVal; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openSchemas(); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, + const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openColumnPrivileges(catalog,schema,table,columnNamePattern); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, + const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openColumns(catalog,schemaPattern,tableNamePattern,columnNamePattern); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +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) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setTablesMap(); +#if 0 + ORows aRows; + + Reference<XContent> xContent = m_pConnection->getContent(); + + Sequence<RuleTerm> aRules(1); + aRules[0].Property = OUString::createFromAscii( "Title" ); + aRules[0].Operand <<= tableNamePattern; + aRules[0].Operator = + aRules[0].CaseSensitive + aRules[0].RegularExpression = sal_False; + + SearchCriterium aCrit(aRules); + + SearchInfo aInfo; + aInfo.Recursion = 0; + aInfo.IncludeBase = sal_False; + aInfo.RespectFolderViewRestrictions = sal_False; + aInfo.RespectDocViewRestrictions = sal_False; + aInfo.FollowIndirections = sal_False; + + Sequence<Property> aProps(1); + aProps[0].Name = OUString::createFromAscii( "Title" ); + aProps[0].Type = ::getCppuType((OUString*)0); + + SearchCommandArgument aArg(aInfo,aProps); + + String aFilenameExtension = m_pConnection->getExtension(); + + + pDir->SetSort(FSYS_SORT_NAME | FSYS_SORT_ASCENDING | FSYS_SORT_END); + pDir->Update(); + + ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE")); + for (sal_uInt16 nDirPos = 0; nDirPos < pDir->Count(); nDirPos++) + { + ORow aRow(3); + if (aFilenameExtension.Len()) + { + if(match(tableNamePattern,(*pDir)[nDirPos].GetBase().GetBuffer(),'\0')) + aRow.push_back(makeAny(::rtl::OUString((*pDir)[nDirPos].GetBase()))); + } + else // keine extension, dann selbst filtern + { + do + { + DirEntry aEntry = (*pDir)[nDirPos]; + if (!(*pDir)[nDirPos].GetExtension().Len()) + { + if(match(tableNamePattern,(*pDir)[nDirPos].GetBase().GetBuffer(),'\0')) + aRow.push_back(makeAny(::rtl::OUString((*pDir)[nDirPos].GetBase()))); + break; + } + else + nDirPos++; + } while ((unsigned int)nDirPos < pDir->Count()); + } + aRow.push_back(makeAny(aTable)); + aRow.push_back(Any()); + aRows.push_back(aRow); + } + + pResult->setRows(aRows); +#endif + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns( + const Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openProcedureColumns(catalog,schemaPattern,procedureNamePattern,columnNamePattern); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures( + const Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openProcedures(catalog,schemaPattern,procedureNamePattern); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openVersionColumns(catalog,schema,table); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return STRING_MAXLEN; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTablesInSelect( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 1; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openExportedKeys(catalog,schema,table); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openImportedKeys(catalog,schema,table); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openPrimaryKeys(catalog,schema,table); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +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) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openIndexInfo(catalog,schema,table,unique,approximate); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, + sal_Bool nullable ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openBestRowIdentifier(catalog,schema,table,scope,nullable); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openTablePrivileges(catalog,schemaPattern,tableNamePattern); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference( + const Any& primaryCatalog, const ::rtl::OUString& primarySchema, + const ::rtl::OUString& primaryTable, const Any& foreignCatalog, + const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +// OResultSet* pResult = new OResultSet(hStmt); +// Reference< XResultSet > xRef = pResult; +// pResult->openForeignKeys(primaryCatalog,primarySchema.toChar() == '%' ? &primarySchema : NULL,&primaryTable, +// foreignCatalog, foreignSchema.toChar() == '%' ? &foreignSchema : NULL,&foreignTable); +// return xRef; + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getIdentifierQuoteString( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString::createFromAscii("\""); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::isCatalogAtStart( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInDataManipulation( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInTableDefinitions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); + Reference< XResultSet > xRef = pResult; + pResult->setTableTypes(); + ORows aRows; + ORow aRow; + aRow.push_back(Any()); + aRow.push_back(makeAny(::rtl::OUString::createFromAscii("TABLE"))); + aRows.push_back(aRow); + pResult->setRows(aRows); + return xRef; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatements( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUString aValue = ::rtl::OUString::createFromAscii("sdbc:file:"); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString::valueOf((sal_Int32)1); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString::valueOf((sal_Int32)0); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + switch(setType) + { + case ResultSetType::FORWARD_ONLY: + return sal_True; + break; + case ResultSetType::SCROLL_INSENSITIVE: + break; + case ResultSetType::SCROLL_SENSITIVE: + break; + } + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return sal_False; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const Sequence< sal_Int32 >& types ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return (Reference< XConnection >)m_pConnection;//new OConnection(m_aConnectionHandle); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/file/FDriver.cxx b/connectivity/source/drivers/file/FDriver.cxx new file mode 100644 index 000000000000..254fd36a9238 --- /dev/null +++ b/connectivity/source/drivers/file/FDriver.cxx @@ -0,0 +1,219 @@ +/************************************************************************* + * + * $RCSfile: FDriver.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_ODRIVER_HXX_ +#include "file/FDriver.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_OCONNECTION_HXX_ +#include "file/FConnection.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + +using namespace connectivity::file; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::container; +// -------------------------------------------------------------------------------- +OFileDriver::OFileDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) + : ODriver_BASE(m_aMutex) + ,m_xFactory(_rxFactory) +{ +} +// -------------------------------------------------------------------------------- +void OFileDriver::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + + for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) + { + Reference< XComponent > xComp(i->get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + } + m_xConnections.clear(); + + ODriver_BASE::disposing(); +} + +// static ServiceInfo +//------------------------------------------------------------------------------ +rtl::OUString OFileDriver::getImplementationName_Static( ) throw(RuntimeException) +{ + return rtl::OUString::createFromAscii("com.sun.star.sdbc.driver.file.Driver"); +} +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > OFileDriver::getSupportedServiceNames_Static( ) throw (RuntimeException) +{ + Sequence< ::rtl::OUString > aSNS( 2 ); + aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver"); + aSNS[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Driver"); + return aSNS; +} + +//------------------------------------------------------------------ +::rtl::OUString SAL_CALL OFileDriver::getImplementationName( ) throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------ +sal_Bool SAL_CALL OFileDriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) + if (pSupported->equals(_rServiceName)) + return sal_True; + + return sal_False; +} + +//------------------------------------------------------------------ +Sequence< ::rtl::OUString > SAL_CALL OFileDriver::getSupportedServiceNames( ) throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +// -------------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL OFileDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODriver_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OConnection* pCon = new OConnection(this); + pCon->construct(url,info); + Reference< XConnection > xCon = pCon; + m_xConnections.push_back(WeakReferenceHelper(*pCon)); + + return xCon; +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OFileDriver::acceptsURL( const ::rtl::OUString& url ) + throw(SQLException, RuntimeException) +{ + if(!url.compareTo(::rtl::OUString::createFromAscii("sdbc:file:"),10)) + { + return sal_True; + } + return sal_False; +} +// -------------------------------------------------------------------------------- +Sequence< DriverPropertyInfo > SAL_CALL OFileDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) +{ + return Sequence< DriverPropertyInfo >(); +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL OFileDriver::getMajorVersion( ) throw(RuntimeException) +{ + return 1; +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL OFileDriver::getMinorVersion( ) throw(RuntimeException) +{ + return 0; +} +// -------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------- +// XDataDefinitionSupplier +Reference< XTablesSupplier > SAL_CALL OFileDriver::getDataDefinitionByConnection( const Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODriver_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OConnection* pConnection = NULL; + for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) + { + if ((OConnection*) Reference< XConnection >::query(i->get().get()).get() == (OConnection*)connection.get()) + { + pConnection = (OConnection*)connection.get(); + break; + } + } + + Reference< XTablesSupplier > xTab = NULL; + if(pConnection) + xTab = pConnection->createCatalog(); + return xTab; +} + +//------------------------------------------------------------------ +Any SAL_CALL OFileDriver::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType, static_cast<XDataDefinitionSupplier*>(this)); + if(aRet.hasValue()) + return aRet; + return ODriver_BASE::queryInterface(rType); +} +// -------------------------------------------------------------------------------- +Reference< XTablesSupplier > SAL_CALL OFileDriver::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + return getDataDefinitionByConnection(connect(url,info)); +} + + diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx new file mode 100644 index 000000000000..20203d7b643c --- /dev/null +++ b/connectivity/source/drivers/file/FPreparedStatement.cxx @@ -0,0 +1,473 @@ +/************************************************************************* + * + * $RCSfile: FPreparedStatement.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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 _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _CONNECTIVITY_FILE_OPREPAREDSTATEMENT_HXX_ +#include "file/FPreparedStatement.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _CONNECTIVITY_FILE_ORESULTSETMETADATA_HXX_ +#include "file/FResultSetMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ +#include "DateConversion.hxx" +#endif + +using namespace connectivity; +using namespace connectivity::file; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::container; +using namespace com::sun::star::util; + +IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbc.driver.file.PreparedStatement","com.sun.star.sdbc.PreparedStatement"); + +OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const ::std::vector<OTypeInfo>& _TypeInfo) + : OStatement_BASE2( _pConnection ) + ,m_pResultSet(NULL) +{ +} +// ------------------------------------------------------------------------- +void OPreparedStatement::construct(const ::rtl::OUString& sql) throw(SQLException, RuntimeException) +{ + String aErr; + m_pParseTree = m_aParser.parseTree(aErr,sql); + if(m_pParseTree) + { + m_aSQLIterator.setParseTree(m_pParseTree); + m_aSQLIterator.traverseAll(); + const OSQLTables& xTabs = m_aSQLIterator.getTables(); + if(xTabs.begin() == xTabs.end()) + throw SQLException(aErr,*this,::rtl::OUString(),0,Any()); + + m_pResultSet = new OResultSet(this,m_aSQLIterator); + if(m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT || + m_aSQLIterator.getStatementType() == SQL_STATEMENT_UPDATE) + m_pResultSet->describeParameter(); + m_aRow = new OValueVector(); + m_xRS = m_pResultSet; + + } + else + throw SQLException(aErr,*this,::rtl::OUString(),0,Any()); +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OStatement_BASE2::queryInterface(rType); + if(!aRet.hasValue()) + aRet = ::cppu::queryInterface( rType, + static_cast< XPreparedStatement*>(this), + static_cast< XParameters*>(this), + static_cast< XResultSetMetaDataSupplier*>(this)); + return aRet; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XResultSetMetaDataSupplier > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OStatement_BASE2::getTypes()); +} +// ------------------------------------------------------------------------- + +Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException) +{ + if(m_xMetaData.is()) + m_xMetaData = new OResultSetMetaData(m_aSQLIterator.getSelectColumns().getBody(),m_aSQLIterator.getTables().begin()->first); + return m_xMetaData; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::close( ) throw(SQLException, RuntimeException) +{ + m_xRS = NULL; + clearMyResultSet(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeException) +{ + sal_Bool hasResultSet = sal_False; + SQLWarning warning; + sal_Bool needData = sal_False; + + m_pResultSet->setParameterRow(m_aRow); + m_pResultSet->OpenImpl(); + return m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT || m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT_COUNT; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException) +{ + m_pResultSet->setParameterRow(m_aRow); + m_pResultSet->OpenImpl(); + return m_pResultSet->getRowCountResult(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + if(parameterIndex >= m_aRow->size()) + m_aRow->push_back(x); + else + (*m_aRow)[parameterIndex] = x; +} +// ------------------------------------------------------------------------- + +Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException) +{ + return (Reference< XConnection >)m_pConnection; +} +// ------------------------------------------------------------------------- + +Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException) +{ + Reference< XResultSet > rs = m_pResultSet; + m_pResultSet->setParameterRow(m_aRow); + m_pResultSet->OpenImpl(); + return rs; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + if(parameterIndex >= m_aRow->size()) + m_aRow->push_back(x); + else + (*m_aRow)[parameterIndex] = x; +} +// ------------------------------------------------------------------------- +void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + if(parameterIndex >= m_aRow->size()) + m_aRow->push_back((sal_Int32)x); + else + (*m_aRow)[parameterIndex] = (sal_Int32)x; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& aData ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + if(parameterIndex >= m_aRow->size()) + m_aRow->push_back(DateConversion::toDouble(aData)); + else + (*m_aRow)[parameterIndex] = DateConversion::toDouble(aData); +} +// ------------------------------------------------------------------------- + + +void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& aVal ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + if(parameterIndex >= m_aRow->size()) + m_aRow->push_back(DateConversion::toDouble(aVal)); + else + (*m_aRow)[parameterIndex] = DateConversion::toDouble(aVal); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& aVal ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + if(parameterIndex >= m_aRow->size()) + m_aRow->push_back(DateConversion::toDouble(aVal)); + else + (*m_aRow)[parameterIndex] = DateConversion::toDouble(aVal); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + if(parameterIndex >= m_aRow->size()) + m_aRow->push_back(x); + else + (*m_aRow)[parameterIndex] = x; +} + +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + if(parameterIndex >= m_aRow->size()) + m_aRow->push_back((double)x); + else + (*m_aRow)[parameterIndex] = (double)x; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + if(parameterIndex >= m_aRow->size()) + m_aRow->push_back(x); + else + (*m_aRow)[parameterIndex] = x; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 aVal ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex || parameterIndex > m_aRow->size()) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(SQLException, RuntimeException) +{ + // Get the buffer needed for the length + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + if(parameterIndex >= m_aRow->size()) + m_aRow->push_back(OFileValue()); + else + (*m_aRow)[parameterIndex].setNull(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex || parameterIndex >= m_aRow->size()) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex || parameterIndex >= m_aRow->size()) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setArray( sal_Int32 parameterIndex, const Reference< XArray >& x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex || parameterIndex >= m_aRow->size()) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setRef( sal_Int32 parameterIndex, const Reference< XRef >& x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex || parameterIndex >= m_aRow->size()) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + // For each known SQL Type, call the appropriate + // set routine + + switch (sqlType) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + (*m_aRow)[parameterIndex] = *(::rtl::OUString*) x.getValue(); + break; + case DataType::BIT: + (*m_aRow)[parameterIndex] = *(sal_Bool*) x.getValue(); + break; + + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + (*m_aRow)[parameterIndex] = *(sal_Int32*)x.getValue(); + break; + + case DataType::BIGINT: + case DataType::REAL: + case DataType::FLOAT: + case DataType::DOUBLE: + (*m_aRow)[parameterIndex] = *(double*)x.getValue(); + break; + + case DataType::BINARY: + break; + + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + break; + + case DataType::DATE: + (*m_aRow)[parameterIndex] = DateConversion::toDouble(*(Date*) x.getValue()); + break; + + case DataType::TIME: + (*m_aRow)[parameterIndex] = DateConversion::toDouble(*(Time*)x.getValue()); + break; + + case DataType::TIMESTAMP: + (*m_aRow)[parameterIndex] = DateConversion::toDouble(*(DateTime*)x.getValue()); + break; + + default: + { + ::rtl::OUString aVal = ::rtl::OUString::createFromAscii("Unknown SQL Type for PreparedStatement.setObject (SQL Type="); + aVal += ::rtl::OUString::valueOf(sqlType); + throw SQLException( aVal,*this,::rtl::OUString(),0,Any()); + } + + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + if(parameterIndex >= m_aRow->size()) + m_aRow->push_back(OFileValue()); + else + (*m_aRow)[parameterIndex].setNull(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex || parameterIndex >= m_aRow->size()) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + // setObject (parameterIndex, x, sqlType, 0); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + setInt(parameterIndex,x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex || parameterIndex >= m_aRow->size()) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); +} +// ------------------------------------------------------------------------- + + +void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex || parameterIndex >= m_aRow->size()) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + if( !parameterIndex || parameterIndex >= m_aRow->size()) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException) +{ + m_aRow->clear(); +} + + diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx new file mode 100644 index 000000000000..ee25dfe374a3 --- /dev/null +++ b/connectivity/source/drivers/file/FResultSet.cxx @@ -0,0 +1,2297 @@ +/************************************************************************* + * + * $RCSfile: FResultSet.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:21 $ + * + * 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_ORESULTSET_HXX_ +#include "file/FResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_ORESULTSETMETADATA_HXX_ +#include "file/FResultSetMetaData.hxx" +#endif +#ifndef _COM_SUN_STAR_SQLC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _UTL_PROPERTY_HXX_ +#include <unotools/property.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ +#include "DateConversion.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_INDEX_HXX_ +#include "dbase/DIndex.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_INDEXITER_HXX_ +#include "dbase/DIndexIter.hxx" +#endif +#ifndef _ITERATOR_ +#include <iterator> +#endif +using namespace connectivity; +using namespace connectivity::file; +using namespace cppu; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::container; + +// Maximale Anzahl von Rows, die mit ORDER BY sortiert durchlaufen werden koennen: +#if defined (WIN) +#define MAX_KEYSET_SIZE 0x3ff0 // Etwas weniger als ein Segment, damit + // noch Platz fuer Memory Debug-Informationen +#else +#define MAX_KEYSET_SIZE 0x40000 // 256K +#endif +//------------------------------------------------------------------------------ +IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.drivers.file.ResultSet","com.sun.star.sdbc.ResultSet"); +// ------------------------------------------------------------------------- +OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIterator) : OResultSet_BASE(m_aMutex) + ,connectivity::OSimplePropertyContainer(OResultSet_BASE::rBHelper) + ,m_aStatement((OWeakObject*)pStmt) + ,m_nRowPos(-1) + ,m_bLastRecord(sal_False) + ,m_bEOF(sal_False) + ,m_xDBMetaData(pStmt->getConnection()->getMetaData()) + ,m_xMetaData(NULL) + ,m_aSQLIterator(_aSQLIterator) + ,m_pTable(NULL) + ,m_nRowCountResult(-1) + ,m_nFilePos(0) + ,m_nLastVisitedPos(-1) + ,m_pParseTree(pStmt->getParseTree()) + ,m_pFileSet(NULL) + ,m_pEvaluationKeySet(NULL) + ,m_pSortIndex(NULL) + ,m_aAssignValues(NULL) +{ + osl_incrementInterlockedCount( &m_refCount ); + + + for (int jj = 0; jj < sizeof nOrderbyColumnNumber / sizeof (* nOrderbyColumnNumber); jj++) + { + nOrderbyColumnNumber[jj] = SQL_COLUMN_NOTFOUND; + bOrderbyAscending[jj] = TRUE; + } + construct(); + osl_decrementInterlockedCount( &m_refCount ); +} + +// ------------------------------------------------------------------------- +OResultSet::~OResultSet() +{ +} +// ------------------------------------------------------------------------- +void OResultSet::construct() +{ + registerProperty(PROPERTY_FETCHSIZE, PROPERTY_ID_FETCHSIZE, 0,&m_nFetchSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(PROPERTY_RESULTSETTYPE, PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY,&m_nResultSetType, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(PROPERTY_FETCHDIRECTION, PROPERTY_ID_FETCHDIRECTION, 0,&m_nFetchDirection, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::READONLY,&m_nResultSetConcurrency, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); +} +// ------------------------------------------------------------------------- +void OResultSet::disposing(void) +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + m_aStatement = NULL; + m_xMetaData = NULL; + m_pParseTree = NULL; + if(m_pTable) + { + m_pTable->release(); + m_pTable = NULL; + } + DELETEZ(m_pFileSet); + DELETEZ(m_pEvaluationKeySet); + DELETEZ(m_pSortIndex); + + m_aRow->clear(); + m_aEvaluateRow->clear(); + m_aAssignValues->clear(); + m_xParamColumns->clear(); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + Any aRet = OPropertySetHelper::queryInterface(rType); + if(!aRet.hasValue()) + aRet = OResultSet_BASE::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes()); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + Reference< XResultSetMetaData > xMeta = getMetaData(); + sal_Int32 nLen = xMeta->getColumnCount(); + sal_Int32 i = 1; + for(;i<=nLen;++i) + if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) : columnName.equalsIgnoreCase(xMeta->getColumnName(i))) + break; + return i; +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + return NULL; +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + return NULL; +} + +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + m_bWasNull = (*m_aRow)[columnIndex].isNull(); + return (*m_aRow)[columnIndex]; +} +// ------------------------------------------------------------------------- + +sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + m_bWasNull = (*m_aRow)[columnIndex].isNull(); + return (*m_aRow)[columnIndex].getInt32(); +} +// ------------------------------------------------------------------------- + +Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + return Sequence< sal_Int8 >(); +} +// ------------------------------------------------------------------------- + +::com::sun::star::util::Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + m_bWasNull = (*m_aRow)[columnIndex].isNull(); + + return DateConversion::toDate((*m_aRow)[columnIndex]); +} +// ------------------------------------------------------------------------- + +double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + m_bWasNull = (*m_aRow)[columnIndex].isNull(); + return (*m_aRow)[columnIndex]; +} +// ------------------------------------------------------------------------- + +float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + m_bWasNull = (*m_aRow)[columnIndex].isNull(); + return (*m_aRow)[columnIndex].getDouble(); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + m_bWasNull = (*m_aRow)[columnIndex].isNull(); + return (*m_aRow)[columnIndex]; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_nRowPos; +} +// ------------------------------------------------------------------------- + +sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + return sal_Int64(); +} +// ------------------------------------------------------------------------- + +Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + if(!m_xMetaData.is()) + m_xMetaData = new OResultSetMetaData(m_xColumns.getBody(),m_aSQLIterator.getTables().begin()->first); + return m_xMetaData; +} +// ------------------------------------------------------------------------- +Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + return NULL; +} + +// ------------------------------------------------------------------------- + +Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + return NULL; +} +// ------------------------------------------------------------------------- + +Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + return NULL; +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + return Any(); +} +// ------------------------------------------------------------------------- + +sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + m_bWasNull = (*m_aRow)[columnIndex].isNull(); + return (*m_aRow)[columnIndex].getInt32(); +} +// ------------------------------------------------------------------------- + + +::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + m_bWasNull = (*m_aRow)[columnIndex].isNull(); + return (*m_aRow)[columnIndex]; +} + +// ------------------------------------------------------------------------- + + +::com::sun::star::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + return DateConversion::toTime((*m_aRow)[columnIndex]); +} +// ------------------------------------------------------------------------- + + +::com::sun::star::util::DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + columnIndex = mapColumn(columnIndex); + return DateConversion::toDateTime((*m_aRow)[columnIndex]); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_nRowPos == 1; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_bEOF; +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(first()) + previous(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(last()) + next(); + m_bEOF = sal_True; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + } + dispose(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return Move(OFileTable::FILE_FIRST,1,sal_True); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + // here I know definitely that I stand on the last record + return Move(OFileTable::FILE_LAST,1,sal_True); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return Move(OFileTable::FILE_ABSOLUTE,row,sal_True); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return Move(OFileTable::FILE_RELATIVE,row,sal_True); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + --m_nRowPos; + return sal_True; +} +// ------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException) +{ + return m_aStatement.get(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException) +{ ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return sal_False; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_nRowPos == 0; +} +// ------------------------------------------------------------------------- +sal_Bool OResultSet::evaluate() +{ + sal_Bool bRet = sal_True; + while(!m_aSQLAnalyzer.evaluateRestriction()) + { + if(m_pEvaluationKeySet) + { + if(m_aEvaluateIter == m_pEvaluationKeySet->end()) + return sal_False; + bRet = m_pTable->seekRow(OFileTable::FILE_BOOKMARK,(*m_aEvaluateIter),m_nRowPos); + ++m_aEvaluateIter; + } + else + bRet = m_pTable->seekRow(OFileTable::FILE_NEXT,1,m_nRowPos); + if(bRet) + { + if(m_pEvaluationKeySet) + { + bRet = m_pTable->fetchRow(m_aEvaluateRow,m_pTable->getTableColumns().getBody(),sal_True); + evaluate(); + + } + else + bRet = m_pTable->fetchRow(m_aRow,m_xColumns.getBody(),sal_True); + } + } + + return bRet; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_pTable) + return sal_False; + + return Move(OFileTable::FILE_NEXT,1,sal_True); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_bWasNull; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::cancel( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- +Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException) +{ + return Any(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::deleteRow( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); + throw RuntimeException(); +} +// ----------------------------------------------------------------------- +void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 scale ) throw(SQLException, RuntimeException) +{ + columnIndex = mapColumn(columnIndex); + OSL_ENSHURE(0,"OResultSet::updateNumericObject: NYI"); +} +// ------------------------------------------------------------------------- +IPropertyArrayHelper* OResultSet::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +IPropertyArrayHelper & OResultSet::getInfoHelper() +{ + return *const_cast<OResultSet*>(this)->getArrayHelper(); +} + +//------------------------------------------------------------------ +BOOL OResultSet::ExecuteRow(OFileTable::FilePosition eFirstCursorPosition, + INT32 nFirstOffset, + BOOL bRebind, + BOOL bEvaluate, + BOOL bRetrieveData) +{ + + // Fuer weitere Fetch-Operationen werden diese Angaben ggf. veraendert ... + OFileTable::FilePosition eCursorPosition = eFirstCursorPosition; + INT32 nOffset = nFirstOffset; + UINT32 nLoopCount = 0; + +again: + + // protect from reading over the end when someboby is inserting while we are reading + // this method works only for dBase at the moment !!!! + if (eCursorPosition == OFileTable::FILE_NEXT && m_nFilePos == m_nLastVisitedPos) + { + return sal_False; + } + + if (!m_pTable->seekRow(eCursorPosition, nOffset, m_nFilePos)) + { + return sal_False; + } + + if (!bEvaluate) // Laeuft keine Auswertung, dann nur Ergebniszeile fuellen + { + m_pTable->fetchRow(m_aRow,m_pTable->getTableColumns().getBody(), bRetrieveData); + + // if (bShowDeleted && m_aRow->isDeleted()) + // m_aRow->setState(ROW_DELETED); + } + else + { + m_pTable->fetchRow(m_aEvaluateRow, m_pTable->getTableColumns().getBody(), TRUE); + + if (m_aSQLAnalyzer.hasRestriction() && //!bShowDeleted && m_aEvaluateRow->isDeleted() ||// keine Anzeige von geloeschten Stzen + !m_aSQLAnalyzer.evaluateRestriction()) // Auswerten der Bedingungen + { // naechsten Satz auswerten + // aktuelle Zeile loeschen im Keyset + OSL_ENSHURE(!m_pFileSet || + // !m_pFileSet->IsFrozen() || + eCursorPosition == OFileTable::FILE_NEXT, "Falsche CursorPosition!"); + + if (m_pEvaluationKeySet) + { + ++m_aEvaluateIter; + if (m_pEvaluationKeySet->end() != m_aEvaluateIter) + nOffset = (*m_aEvaluateIter); + else + { + return sal_False; + } + } + else if (m_pFileSet) + { + OSL_ENSHURE(//!m_pFileSet->IsFrozen() && + eCursorPosition == OFileTable::FILE_NEXT, "Falsche CursorPosition!"); + eCursorPosition = OFileTable::FILE_NEXT; + nOffset = 1; + } + else if (eCursorPosition == OFileTable::FILE_FIRST || + eCursorPosition == OFileTable::FILE_NEXT || + eCursorPosition == OFileTable::FILE_ABSOLUTE) + { + eCursorPosition = OFileTable::FILE_NEXT; + nOffset = 1; + } + else if (eCursorPosition == OFileTable::FILE_LAST || + eCursorPosition == OFileTable::FILE_PRIOR) + { + eCursorPosition = OFileTable::FILE_PRIOR; + nOffset = 1; + } + else if (eCursorPosition == OFileTable::FILE_RELATIVE) + { + eCursorPosition = (nOffset >= 0) ? OFileTable::FILE_NEXT : OFileTable::FILE_PRIOR; + } + else + { + // aStatus.Set(SQL_STAT_NO_DATA_FOUND); + return sal_False; + } + // Nochmal probieren ... + goto again; + } + } + // Evaluate darf nur gesetzt sein, + // wenn der Keyset weiter aufgebaut werden soll + if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT && + (m_pFileSet || m_pSortIndex) && bEvaluate) + { + if (m_pSortIndex) + { + OFILEKeyValue* pKeyValue = GetOrderbyKeyValue(m_aEvaluateRow); + if (!m_pSortIndex->AddKeyValue(pKeyValue)) + { + // Ueberwachung auf Ueberschreitung der Index-Kapazitaet: + } + } + else if (m_pFileSet) + { + // OSL_ENSHURE(!m_pFileSet->IsFrozen() , "Falsche CursorPosition!"); + sal_uInt32 nBookmarkValue = Abs((sal_Int32)(*m_aEvaluateRow)[0]); + m_pFileSet->push_back(nBookmarkValue); + } + } + else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_UPDATE) + { + sal_Bool bOK = sal_True; + if (bEvaluate) + { + // jetzt die eigentliche Ergebniszeile Lesen + bOK = m_pTable->fetchRow(m_aEvaluateRow, m_pTable->getTableColumns().getBody(), TRUE); + } + + if (bOK) + { + // Nur die zu aendernden Werte uebergeben: + if(!m_pTable->UpdateRow(m_aAssignValues.getBody(),m_aEvaluateRow,Reference<XIndexAccess>(m_xColNames,UNO_QUERY))) + return sal_False; + } + } + else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_DELETE) + { + sal_Bool bOK = sal_True; + if (bEvaluate) + { + bOK = m_pTable->fetchRow(m_aEvaluateRow, m_pTable->getTableColumns().getBody(), TRUE); + } + if (bOK) + { + if(!m_pTable->DeleteRow(m_xColumns.getBody())) + return sal_False; + } + } + return sal_True; +} + +//------------------------------------------------------------------- +BOOL OResultSet::Move(OFileTable::FilePosition eCursorPosition, INT32 nOffset, BOOL bRetrieveData) +{ + +IgnoreDeletedRows: + + INT32 nTempPos = m_nRowPos; + // exclusiver zugriff auf die Tabelle + // NAMESPACE_VOS(OGuard)* pGuard = m_pTable->Lock(); + + if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT) + { + if (m_pFileSet == NULL) // kein Index verfuegbar + { + // Normales FETCH + ExecuteRow(eCursorPosition,nOffset,TRUE,FALSE,bRetrieveData); + + // now set the bookmark for outside + (*m_aRow->begin()) = sal_Int32(m_nRowPos + 1); + } + else + { + switch(eCursorPosition) + { + case OFileTable::FILE_NEXT: + m_nRowPos++; + break; + case OFileTable::FILE_PRIOR: + if (m_nRowPos >= 0) + m_nRowPos--; + break; + case OFileTable::FILE_FIRST: + m_nRowPos = 0; + break; + case OFileTable::FILE_LAST: + // OSL_ENSHURE(IsRowCountFinal(), "Fehler im Keyset!"); // mu eingefroren sein, sonst Fehler beim SQLCursor + m_nRowPos = m_pFileSet->size() - 1; + break; + case OFileTable::FILE_RELATIVE: + m_nRowPos += nOffset; + break; + case OFileTable::FILE_ABSOLUTE: + m_nRowPos = nOffset - 1; + break; + case OFileTable::FILE_BOOKMARK: + m_nRowPos = nOffset - 1; + break; + } + + // OffRange? + // Der FileCursor ist auerhalb des gueltigen Bereichs, wenn + // a.) m_nRowPos < 1 + // b.) Ein KeySet besteht und m_nRowPos > m_pFileSet->size() + if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != OFileTable::FILE_BOOKMARK && m_nRowPos >= (INT32)m_pFileSet->size() )) // && m_pFileSet->IsFrozen() + { + // aStatus.Set(SQL_STAT_NO_DATA_FOUND); + goto Error; + } + else + { + if (m_nRowPos < (INT32)m_pFileSet->size()) + { + // Fetch ueber Index + ExecuteRow(OFileTable::FILE_BOOKMARK,(*m_pFileSet)[m_nRowPos],TRUE,FALSE,bRetrieveData); + + // now set the bookmark for outside + (*m_aRow->begin()) = sal_Int32(m_nRowPos + 1); + } + else // Index mu weiter aufgebaut werden + { + // Zunaechst auf die letzte bekannte Zeile setzen + if (m_pFileSet->size()) + { + m_aFileSetIter = m_pFileSet->end()-1; + // m_pFileSet->SeekPos(m_pFileSet->size()-1); + m_pTable->seekRow(OFileTable::FILE_BOOKMARK, *m_aFileSetIter, m_nFilePos); + } + sal_Bool bOK = sal_True; + // Ermitteln der Anzahl weiterer Fetches + while (bOK && m_nRowPos >= (INT32)m_pFileSet->size()) + { + if (m_pEvaluationKeySet) + { + if (m_nRowPos >= (INT32)m_pEvaluationKeySet->size()) + return sal_False; + // aStatus.Set(SQL_STAT_NO_DATA_FOUND); + else if (m_nRowPos == 0) + { + m_aEvaluateIter = m_pEvaluationKeySet->begin(); + bOK = ExecuteRow(OFileTable::FILE_BOOKMARK,*m_aEvaluateIter,FALSE,TRUE, bRetrieveData); + } + else + { + ++m_aEvaluateIter; + bOK = ExecuteRow(OFileTable::FILE_BOOKMARK,*m_aEvaluateIter,FALSE,TRUE, bRetrieveData); + } + } + else + bOK = ExecuteRow(OFileTable::FILE_NEXT,1,FALSE,TRUE, bRetrieveData); + } + + if (bOK) + { + // jetzt nochmal die Ergebnisse lesen + m_pTable->fetchRow(m_aRow, m_pTable->getTableColumns().getBody(), bRetrieveData); + + // now set the bookmark for outside + (*m_aRow->begin()) = sal_Int32(m_nRowPos + 1); + } + else if (!m_pFileSet->isFrozen()) // keinen gueltigen Satz gefunden + { + //m_pFileSet->Freeze(); + m_pFileSet->setFrozen(); + + DELETEZ(m_pEvaluationKeySet); + // aStatus.Set(SQL_STAT_NO_DATA_FOUND); + goto Error; + } + } + } + } + } + else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT_COUNT) + { + // Fetch des COUNT(*) + switch (eCursorPosition) + { + case OFileTable::FILE_NEXT: + m_nRowPos++; + break; + case OFileTable::FILE_PRIOR: + m_nRowPos--; + break; + case OFileTable::FILE_FIRST: + m_nRowPos = 0; + break; + case OFileTable::FILE_LAST: + m_nRowPos = 0; + break; + case OFileTable::FILE_RELATIVE: + m_nRowPos += nOffset; + break; + case OFileTable::FILE_BOOKMARK: + case OFileTable::FILE_ABSOLUTE: + m_nRowPos = nOffset - 1; + break; + } + + if (m_nRowPos == 0) + { + // COUNT(*) in Ergebnisrow packen + // (muss die erste und einzige Variable in der Row sein) + if (m_aRow->size() == 2) + { + (*m_aRow)[1] = m_nRowCountResult; + (*m_aRow)[0] = sal_Int32(1); + } + } + else + { + goto Error; + } + } + else + // Fetch nur bei SELECT moeglich! + return sal_False; + + if(m_aRow->isDeleted()) + goto IgnoreDeletedRows; + return sal_True; + +Error: + // steht der Cursor vor dem ersten Satz + // dann wird die position beibehalten + if (nTempPos == -1) + m_nRowPos = nTempPos; + else + { + switch(eCursorPosition) + { + case OFileTable::FILE_PRIOR: + case OFileTable::FILE_FIRST: + m_nRowPos = -1; + break; + case OFileTable::FILE_LAST: + case OFileTable::FILE_NEXT: + case OFileTable::FILE_ABSOLUTE: + case OFileTable::FILE_RELATIVE: + if (nOffset > 0) + m_nRowPos = (m_pFileSet) ? m_pFileSet->size() : -1; + else if (nOffset < 0) + m_nRowPos = -1; + break; + case OFileTable::FILE_BOOKMARK: + m_nRowPos = nTempPos; // vorherige Position + } + } + // delete pGuard; + // rMode = (!bShowDeleted && aStatus.IsSuccessful() && m_aRow->isDeleted()) ? // keine Anzeige von gelschten Stzen + // OCursor::SQL_MOD_INVALID : OCursor::SQL_MOD_NONE; + return sal_False; +} +// ------------------------------------------------------------------------- +OFILEKeyValue* OResultSet::GetOrderbyKeyValue(OValueRow _rRow) +{ + UINT32 nBookmarkValue = Abs((sal_Int32)(*_rRow)[0]); + + OFILEKeyValue* pKeyValue = new OFILEKeyValue((UINT32)nBookmarkValue); + for (int i = 0; i < sizeof nOrderbyColumnNumber / sizeof (* nOrderbyColumnNumber); i++) + { + if (nOrderbyColumnNumber[i] == SQL_COLUMN_NOTFOUND) break; + + OFileValue xKey = (*_rRow)[nOrderbyColumnNumber[i]]; + switch (xKey.getType()) + { + 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, CharSet 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 + + ppKeyValueArray = new OFILEKeyValuePtr[nMaxCount]; + + for (INT32 i = 0; i < nMaxCount; i++) + ppKeyValueArray[i] = NULL; +} + +//------------------------------------------------------------------ +OFILESortIndex::~OFILESortIndex() +{ + +// Nicht mehr noetig - wird durch Freeze() erledigt ... +// for (INT32 i = 0; i < nCount; i++) { +// delete ppKeyValueArray[i]; +// } + + __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_ENSHURE(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_ENSHURE(! 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_ENSHURE(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_ENSHURE(nPos > 0,"OFILESortIndex::GetValue: nPos == 0"); + OSL_ENSHURE(nPos <= nCount,"OFILESortIndex::GetValue: Zugriff ausserhalb der Array-Grenzen"); + +// OSL_ENSHURE(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_ENSHURE(! 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_ENSHURE(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() +{ + const OSQLTables& xTabs = m_aSQLIterator.getTables(); + OSL_ENSHURE(xTabs.begin() != xTabs.end(),"NO table in statement!"); + + OSQLTable xTable = xTabs.begin()->second; + m_xColumns = m_aSQLIterator.getSelectColumns(); + + m_xColNames = xTable->getColumns(); + + Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); + + m_aRow = new OValueVector(xNames->getCount()); + m_aEvaluateRow = new OValueVector(xNames->getCount()); + // m_aParameterRow = new OValueVector(); + m_aAssignValues = new OAssignValues(); + + if(!m_xParamColumns.isValid()) + m_xParamColumns = new OSQLColumns(); + + m_aSQLAnalyzer.clean(); + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(xTable,UNO_QUERY); + if(xTunnel.is()) + { + m_pTable = (OFileTable*)xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()); + if(m_pTable) + m_pTable->acquire(); + } + + GetAssignValues(); // assign values and describe parameter columns + m_aSQLAnalyzer.setParameterColumns(m_xParamColumns); + anylizeSQL(); + // m_aSQLAnalyzer.describeParam(m_xParamColumns); + + + // now check which columns are bound + OValueVector::iterator aRowIter = m_aRow->begin(); + ::utl::UStringMixEqual aCase(m_xDBMetaData->storesMixedCaseQuotedIdentifiers()); + sal_Int32 i=0; + Reference<XFastPropertySet> xProp; + ++aRowIter; + for(OSQLColumns::iterator aIter = m_xColumns->begin();aIter != m_xColumns->end();++aIter,++i,++aRowIter) + { + xNames->getByIndex(i) >>= xProp; + try + { + aRowIter->setBound(aCase(connectivity::getString(xProp->getFastPropertyValue(PROPERTY_ID_NAME)),connectivity::getString((*aIter)->getFastPropertyValue(PROPERTY_ID_REALNAME)))); + sal_Int32 nType; + xProp->getFastPropertyValue(PROPERTY_ID_TYPE) >>= nType; + aRowIter->setType(nType); + } + catch(...) + { + } + } + + + + + // Parameter substituieren (AssignValues und Kriterien): + if (m_xParamColumns->size()) + { + // Zunchst AssignValues + USHORT nParaCount=0; // gibt die aktuelle Anzahl der bisher gesetzen Parameter an + + // Nach zu substituierenden Parametern suchen: + UINT16 nCount = m_aAssignValues.isValid() ? m_aAssignValues->size() : 1; // 1 ist wichtig fr die Kriterien + for (UINT16 j = 1; j < nCount; j++) + { +// if ((*m_aAssignValues)[j].isNull()) +// continue; + + UINT32 nParameter = (*m_aAssignValues).getParameterIndex(j); + if (nParameter == SQL_NO_PARAMETER) + continue; // dieser AssignValue ist kein Parameter + + ++nParaCount; // ab hier ist der Parameter gueltig + // Parameter ersetzen. Wenn Parameter nicht verfuegbar, + // Value auf NULL setzen. + (*m_aAssignValues)[j] = (*m_aParameterRow)[(UINT16)nParameter]; + } + + if (m_aParameterRow.isValid() && nParaCount < m_aParameterRow->size()) + m_aSQLAnalyzer.bindParameterRow(m_aParameterRow); + } + + // Neuen Index aufbauen: + DELETEZ(m_pFileSet); + DELETEZ(m_pEvaluationKeySet); + + // if (!aEvaluateRow.Is()) + { + // aEvaluateRow = new ODbRow(*aFileColumns, FALSE); + // (*aEvaluateRow)[0] = new ODbVariant(); + + // Row zur Auswertung binden, wenn Preprocessing erfolg, dann bereits ein Keyset + m_pEvaluationKeySet = m_aSQLAnalyzer.bindResultRow(m_aEvaluateRow); // Werte im Code des Compilers setzen + // (Verbindung zur ResultRow herstellen) + } + + // An den Anfang positionieren + m_nRowPos = -1; + m_nFilePos = 0; + m_nRowCountResult = -1; + + // exclusiver zugriff auf die Tabelle + // NAMESPACE_VOS(OGuard)* pGuard = pTable->Lock(); + m_nLastVisitedPos = m_pTable->getCurrentLastPos(); + + UINT32 nLoopCount = 0; + switch(m_aSQLIterator.getStatementType()) + { + case SQL_STATEMENT_SELECT: + { + INT32 nMaxRowCount = m_pTable->getCurrentLastPos(); + + BOOL bDistinct = FALSE; + BOOL bWasSorted = FALSE; + OSQLParseNode *pDistinct = m_pParseTree->getChild(1); + if (pDistinct && pDistinct->getTokenID() == SQL_TOKEN_DISTINCT ) + { + if(!IsSorted()) + { + nOrderbyColumnNumber[0] = 1; + bOrderbyAscending[0] = FALSE; + } + else + bWasSorted = TRUE; + bDistinct = TRUE; + } + // Ohne Restriction und Sortierung RowCount bekannt. + // if (!HasRestriction() && !IsSorted() && bShowDeleted) + // SetRowCount(MaxRowCount()); + + OSL_ENSHURE(sizeof nOrderbyColumnNumber / sizeof (* nOrderbyColumnNumber) == SQL_ORDERBYKEYS,"Maximale Anzahl der ORDER BY Columns muss derzeit genau 3 sein!"); + OKeyType eKeyType[SQL_ORDERBYKEYS]; + aRowIter = m_aRow->begin(); + for (int i = 0; i < SQL_ORDERBYKEYS; i++) + { + if (nOrderbyColumnNumber[i] == SQL_COLUMN_NOTFOUND) + eKeyType[i] = SQL_ORDERBYKEY_NONE; + else + { + switch (aRowIter->getType()) + { + case DataType::CHAR: + case DataType::VARCHAR: + eKeyType[i] = SQL_ORDERBYKEY_STRING; + break; + + case DataType::OTHER: + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::REAL: + case DataType::DOUBLE: + case DataType::DATE: + case DataType::TIME: + case DataType::TIMESTAMP: + case DataType::BIT: + eKeyType[i] = SQL_ORDERBYKEY_DOUBLE; + break; + + // Andere Typen sind nicht implementiert (und damit immer FALSE) + default: + eKeyType[i] = SQL_ORDERBYKEY_NONE; + OSL_ASSERT("OFILECursor::Execute: Datentyp nicht implementiert"); + break; + } + (*m_aEvaluateRow)[nOrderbyColumnNumber[i]].setBound(sal_True); + } + } + + // Nur wenn Sortierung gewuenscht, ueber alle Datensaetze iterieren und + // dabei den "Key", nach dem sortiert werden soll, in den Index eintragen: + if (IsSorted()) + { + if (!m_aSQLAnalyzer.hasRestriction() && nOrderbyColumnNumber[1] == SQL_COLUMN_NOTFOUND) + { + // Ist nur ein Feld fuer die Sortierung angegeben + // Und diese Feld ist indiziert, dann den Index ausnutzen + Reference<XIndexesSupplier> xIndexSup(xTable,UNO_QUERY); + Reference<XIndexAccess> xIndexes; + if(xIndexSup.is()) + { + xIndexes = Reference<XIndexAccess>(xIndexSup->getIndexes(),UNO_QUERY); + Reference<XFastPropertySet> xColProp; + xNames->getByIndex(nOrderbyColumnNumber[0]) >>= xColProp; + // iterate through the indexes to find the matching column + for(sal_Int32 i=0;i<xIndexes->getCount();++i) + { + Reference<XColumnsSupplier> xIndex; + xIndexes->getByIndex(i) >>= xIndex; + Reference<XNameAccess> xIndexCols = xIndex->getColumns(); + if(xIndexCols->hasByName(connectivity::getString(xColProp->getFastPropertyValue(PROPERTY_ID_NAME)))) + { + m_pFileSet = new OKeySet(); + + Reference<XUnoTunnel> xTunnel(xIndex,UNO_QUERY); + if(xTunnel.is()) + { + dbase::ODbaseIndex* pIndex = (dbase::ODbaseIndex*)xTunnel->getSomething(dbase::ODbaseIndex::getUnoTunnelImplementationId()); + if(pIndex) + { + dbase::OIndexIterator* pIter = pIndex->createIterator(NULL,NULL); + + if (pIter) + { + sal_uInt32 nRec = pIter->First(); + while (nRec != SQL_COLUMN_NOTFOUND) + { + if (bOrderbyAscending[0]) + m_pFileSet->push_back(nRec); + else + m_pFileSet->insert(m_pFileSet->begin(),nRec); + nRec = pIter->Next(); + } + m_pFileSet->setFrozen(); + // m_bFileSetFrozen = sal_True; + // if(!bDistinct) + // SetRowCount(pFileSet->count()); + goto DISTINCT; + } + + delete pIter; + } + } + } + } + } + } + + m_pSortIndex = new OFILESortIndex(eKeyType, + bOrderbyAscending, + nMaxRowCount,RTL_TEXTENCODING_MS_1252); + + sal_Bool bOK = sal_True; + if (m_pEvaluationKeySet) + { + if (m_pEvaluationKeySet->size()) + m_aEvaluateIter = m_pEvaluationKeySet->begin(); + + } + while (bOK) + { + if (m_pEvaluationKeySet) + { + ExecuteRow(OFileTable::FILE_BOOKMARK,(*m_aEvaluateIter),FALSE,TRUE); + ++m_aEvaluateIter; + bOK = m_aEvaluateIter == m_pEvaluationKeySet->end(); + } + else + bOK = ExecuteRow(OFileTable::FILE_NEXT,1,FALSE,TRUE); + } + + // Sortiertes Keyset erzeugen + DELETEZ(m_pEvaluationKeySet); + m_pFileSet = m_pSortIndex->CreateKeySet(); + // if(!bDistinct) + // SetRowCount(pFileSet->count()); + DELETEZ(m_pSortIndex); + // Nun kann ueber den Index sortiert zugegriffen werden. + } + + if (!m_pFileSet) + { + m_pFileSet = new OKeySet(); + + if (!m_aSQLAnalyzer.hasRestriction()) + // jetzt kann das Keyset schon gefuellt werden! + // Aber Achtung: es wird davon ausgegangen, das die FilePositionen als Folge 1..n + // abgelegt werden! + { + for (sal_uInt32 i = 0; i < m_pTable->getCurrentLastPos(); i++) + m_pFileSet->push_back(i + 1); + } + } + OSL_ENSHURE(m_pFileSet,"Kein KeySet vorhanden! :-("); +DISTINCT: if(bDistinct && m_pFileSet) // sicher ist sicher + { + OValueRow aSearchRow;//(m_aRow); + // ODbRowRef aSearchRow = new ODbRow(*aFileRow); // nach dieser wird gesucht + // const ODbRow &rSearchRow = *aSearchRow, + // &rFileRow = *aFileRow; + INT32 nPos; + UINT16 nMaxRow = m_pFileSet->size(); + if (nMaxRow) + { +#if DEBUG + INT32 nFound=0; +#endif + vector<BOOL> nWasAllwaysFound(nMaxRow,FALSE); + INT32 nPrev_i; + for(INT32 j= nMaxRow-1;j >= 0;j--) + { + nPos = (*m_pFileSet)[j]; // aktuell zu lschender Key + if(!nWasAllwaysFound[j] && nPos) // nur falls noch nicht nach dieser Row gesucht wurde + { + ExecuteRow(OFileTable::FILE_BOOKMARK,nPos,TRUE,FALSE); + aSearchRow = m_aRow; + // jetzt den Rest nach doppelten durchsuchen + INT32 nKey; + nPrev_i = j; + for(INT32 i = j-1; i >= 0 ;i--) + { + nKey = (*m_pFileSet)[i]; + ExecuteRow(OFileTable::FILE_BOOKMARK,nKey ,TRUE,FALSE); + if(!nWasAllwaysFound[i] && aSearchRow == m_aRow) + { + // gefunden + // Key an der Stelle 0 setzen. + (*m_pFileSet)[nPrev_i] = 0; + // und altes i merken + nPrev_i = i; + nPos = nKey; // auf naechste gltige Position setzen + nWasAllwaysFound[i] = TRUE; + + } + } + } +#if DEBUG + else + nFound++; +#endif + } + vector<INT32>::iterator aIter = m_pFileSet->end()-1; + while(aIter != m_pFileSet->begin()) + { + if(!(*aIter)) + m_pFileSet->erase(aIter); + aIter--; + } + if (!bWasSorted) + { + nOrderbyColumnNumber[0] = SQL_COLUMN_NOTFOUND; + sort(m_pFileSet->begin(),m_pFileSet->end()); + } + } + // SetRowCount(m_pFileSet->count()); + } + } break; + + case SQL_STATEMENT_SELECT_COUNT: + case SQL_STATEMENT_UPDATE: + case SQL_STATEMENT_DELETE: + // waehrend der Bearbeitung die Anzahl der bearbeiteten Rows zaehlen: + m_nRowCountResult = 0; + // Vorlaeufig einfach ueber alle Datensaetze iterieren und + // dabei die Aktionen bearbeiten (bzw. einfach nur zaehlen): + { + + sal_Bool bOK = sal_True; + if (m_pEvaluationKeySet) + { + m_aEvaluateIter = m_pEvaluationKeySet->begin(); + bOK = m_aEvaluateIter == m_pEvaluationKeySet->end(); + + } + while (bOK) + { + if (m_pEvaluationKeySet) + ExecuteRow(OFileTable::FILE_BOOKMARK,(*m_aEvaluateIter),FALSE,TRUE); + else + bOK = ExecuteRow(OFileTable::FILE_NEXT,1,FALSE,TRUE); + + if (bOK) + { + m_nRowCountResult++; + if(m_pEvaluationKeySet) + { + ++m_aEvaluateIter; + bOK = m_aEvaluateIter == m_pEvaluationKeySet->end(); + } + } + } + + // Ergebnis von COUNT(*) in nRowCountResult merken. + // nRowCount, also die Anzahl der Rows in der Ergebnismenge, ist bei dieser + // Anfrage = 1! + DELETEZ(m_pEvaluationKeySet); + } + // SetRowCount(1); + break; + case SQL_STATEMENT_INSERT: + m_nRowCountResult = 0; + + if(!m_pTable->InsertRow(m_aAssignValues, TRUE,Reference<XIndexAccess>(m_xColNames,UNO_QUERY))) + { + m_nFilePos = 0; + return sal_False; + } + + m_nRowCountResult = 1; + break; + } + + // FilePos zuruecksetzen + m_nFilePos = 0; + + return sal_True; +} +//------------------------------------------------------------------ +void OResultSet::anylizeSQL() +{ + // start analysing the statement + m_aSQLAnalyzer.setOrigColumns(m_xColNames); + m_aSQLAnalyzer.start(m_pParseTree); + + const OSQLParseNode* pOrderbyClause = m_aSQLIterator.getOrderTree(); + if(pOrderbyClause) + { + OSQLParseNode * pOrderingSpecCommalist = pOrderbyClause->getChild(2); + OSL_ENSHURE(SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OResultSet: Fehler im Parse Tree"); + + for (sal_uInt32 m = 0; m < pOrderingSpecCommalist->count(); m++) + { + OSQLParseNode * pOrderingSpec = pOrderingSpecCommalist->getChild(m); + OSL_ENSHURE(SQL_ISRULE(pOrderingSpec,ordering_spec),"OResultSet: Fehler im Parse Tree"); + OSL_ENSHURE(pOrderingSpec->count() == 2,"OResultSet: Fehler im Parse Tree"); + + OSQLParseNode * pColumnRef = pOrderingSpec->getChild(0); + if(!SQL_ISRULE(pColumnRef,column_ref)) + { + // aStatus.SetStatementTooComplex(); + return; + } + OSQLParseNode * pAscendingDescending = pOrderingSpec->getChild(1); + setOrderbyColumn((UINT16)m,pColumnRef,pAscendingDescending); + } + } +} + + +//------------------------------------------------------------------ +void OResultSet::setOrderbyColumn(UINT16 nOrderbyColumnNo, + OSQLParseNode* pColumnRef, + OSQLParseNode* pAscendingDescending) +{ + if (nOrderbyColumnNo >= (sizeof nOrderbyColumnNumber / sizeof (* nOrderbyColumnNumber))) + { + // aStatus.SetStatementTooComplex(); + return; + } + + String aColumnName; + if (pColumnRef->count() == 1) + aColumnName = pColumnRef->getChild(0)->getTokenValue(); + else if (pColumnRef->count() == 3) + { + // Nur die Table Range-Variable darf hier vorkommen: +// if (!(pColumnRef->getChild(0)->getTokenValue() == aTableRange)) +// { +// aStatus.Set(SQL_STAT_ERROR, +// String::CreateFromAscii("S1000"), +// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_INVALID_RANGE_VAR))), +// 0, String() ); + // return; + // } + aColumnName = pColumnRef->getChild(2)->getTokenValue(); + } + else + { + // aStatus.SetStatementTooComplex(); + return; + } + + Reference<XColumnLocate> xColLocate(m_xColNames,UNO_QUERY); + if(!xColLocate.is()) + return; + // Alles geprueft und wir haben den Namen der Column. + // Die wievielte Column ist das? + nOrderbyColumnNumber[nOrderbyColumnNo] = xColLocate->findColumn(aColumnName)-1; + + // Ascending or Descending? + bOrderbyAscending[nOrderbyColumnNo] = (SQL_ISTOKEN(pAscendingDescending,DESC)) ? + FALSE : TRUE; +} + +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OResultSet::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OResultSet::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; +} +//------------------------------------------------------------------ +void OResultSet::GetAssignValues() +{ + if (m_pParseTree == NULL) + { + // aStatus.SetInvalidStatement(); + return; + } + + if (SQL_ISRULE(m_pParseTree,select_statement)) + // Keine zu setzenden Werte bei SELECT + return; + else if (SQL_ISRULE(m_pParseTree,insert_statement)) + { + // Row fuer die zu setzenden Werte anlegen (Referenz durch new) + m_aAssignValues = new OAssignValues(Reference<XIndexAccess>(m_xColNames,UNO_QUERY)->getCount()); + + // Liste der Columns-Namen, die in der column_commalist vorkommen (mit ; getrennt): + ::std::vector<String> aColumnNameList; + + OSL_ENSHURE(m_pParseTree->count() >= 4,"OResultSet: Fehler im Parse Tree"); + + OSQLParseNode * pOptColumnCommalist = m_pParseTree->getChild(3); + OSL_ENSHURE(pOptColumnCommalist != NULL,"OResultSet: Fehler im Parse Tree"); + OSL_ENSHURE(SQL_ISRULE(pOptColumnCommalist,opt_column_commalist),"OResultSet: Fehler im Parse Tree"); + if (pOptColumnCommalist->count() == 0) + { + const Sequence< ::rtl::OUString>& aNames = m_xColNames->getElementNames(); + const ::rtl::OUString* pBegin = aNames.getConstArray(); + aColumnNameList.insert(aColumnNameList.begin(),::std::vector<String>::const_iterator(pBegin),::std::vector<String>::const_iterator(pBegin + aNames.getLength())); + } + else + { + OSL_ENSHURE(pOptColumnCommalist->count() == 3,"OResultSet: Fehler im Parse Tree"); + + OSQLParseNode * pColumnCommalist = pOptColumnCommalist->getChild(1); + OSL_ENSHURE(pColumnCommalist != NULL,"OResultSet: Fehler im Parse Tree"); + OSL_ENSHURE(SQL_ISRULE(pColumnCommalist,column_commalist),"OResultSet: Fehler im Parse Tree"); + OSL_ENSHURE(pColumnCommalist->count() > 0,"OResultSet: Fehler im Parse Tree"); + + // Alle Columns in der column_commalist ... + for (sal_uInt32 i = 0; i < pColumnCommalist->count(); i++) + { + OSQLParseNode * pCol = pColumnCommalist->getChild(i); + OSL_ENSHURE(pCol != NULL,"OResultSet: Fehler im Parse Tree"); + aColumnNameList.push_back(pCol->getTokenValue()); + } + } + if(!aColumnNameList.size()) + throw SQLException(); + + // Werte ... + OSQLParseNode * pValuesOrQuerySpec = m_pParseTree->getChild(4); + OSL_ENSHURE(pValuesOrQuerySpec != NULL,"OResultSet: pValuesOrQuerySpec darf nicht NULL sein!"); + OSL_ENSHURE(SQL_ISRULE(pValuesOrQuerySpec,values_or_query_spec),"OResultSet: ! SQL_ISRULE(pValuesOrQuerySpec,values_or_query_spec)"); + OSL_ENSHURE(pValuesOrQuerySpec->count() > 0,"OResultSet: pValuesOrQuerySpec->count() <= 0"); + + // nur "VALUES" ist erlaubt ... + if (! SQL_ISTOKEN(pValuesOrQuerySpec->getChild(0),VALUES)) + throw SQLException(); + + OSL_ENSHURE(pValuesOrQuerySpec->count() == 2,"OResultSet: pValuesOrQuerySpec->count() != 2"); + + // Liste von Werten + OSQLParseNode * pInsertAtomCommalist = pValuesOrQuerySpec->getChild(1); + OSL_ENSHURE(pInsertAtomCommalist != NULL,"OResultSet: pInsertAtomCommalist darf nicht NULL sein!"); + OSL_ENSHURE(pInsertAtomCommalist->count() > 0,"OResultSet: pInsertAtomCommalist <= 0"); + + String aColumnName; + OSQLParseNode * pRow_Value_Const; + xub_StrLen nIndex=0; + for (sal_uInt32 i = 0; i < pInsertAtomCommalist->count(); i++) + { + pRow_Value_Const = pInsertAtomCommalist->getChild(i); // row_value_constructor + if(pRow_Value_Const->count() == 3) // '(' row_value_const_list ')' + { + pRow_Value_Const = pRow_Value_Const->getChild(1); // row_value_const_list + OSL_ENSHURE(pRow_Value_Const != NULL,"OResultSet: pRow_Value_Const darf nicht NULL sein!"); + if(pRow_Value_Const->count() == 0) + { + if(pRow_Value_Const->count() == (aColumnNameList.size()-1)) + ParseAssignValues(aColumnNameList,pRow_Value_Const,nIndex++); // kann nur ein Columnname vorhanden sein pro Schleife + else + { +// aStatus.Set(SQL_STAT_ERROR, +// String::CreateFromAscii("S1000"), +// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_SYNTAX_ERROR))), +// 0, String() ); + throw SQLException(); + } + } + else + { + if(pRow_Value_Const->count() == aColumnNameList.size()) + { + for (sal_uInt32 j = 0; j < pRow_Value_Const->count(); ++j) + ParseAssignValues(aColumnNameList,pRow_Value_Const->getChild(j),nIndex++); + } + else + { +// aStatus.Set(SQL_STAT_ERROR, +// String::CreateFromAscii("S1000"), +// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_SYNTAX_ERROR))), +// 0, String() ); + throw SQLException(); + } + + } + } + else + { + // aStatus.SetStatementTooComplex(); + throw SQLException(); + } + } + } + else if (SQL_ISRULE(m_pParseTree,update_statement_positioned) || + SQL_ISRULE(m_pParseTree,update_statement_searched)) + { + m_aAssignValues = new OAssignValues(Reference<XIndexAccess>(m_xColNames,UNO_QUERY)->getCount()); + + OSL_ENSHURE(m_pParseTree->count() >= 4,"OResultSet: Fehler im Parse Tree"); + + OSQLParseNode * pAssignmentCommalist = m_pParseTree->getChild(3); + OSL_ENSHURE(pAssignmentCommalist != NULL,"OResultSet: pAssignmentCommalist == NULL"); + OSL_ENSHURE(SQL_ISRULE(pAssignmentCommalist,assignment_commalist),"OResultSet: Fehler im Parse Tree"); + OSL_ENSHURE(pAssignmentCommalist->count() > 0,"OResultSet: pAssignmentCommalist->count() <= 0"); + + // Alle Zuweisungen (Kommaliste) bearbeiten ... + ::std::vector< String> aList(1); + for (sal_uInt32 i = 0; i < pAssignmentCommalist->count(); i++) + { + OSQLParseNode * pAssignment = pAssignmentCommalist->getChild(i); + OSL_ENSHURE(pAssignment != NULL,"OResultSet: pAssignment == NULL"); + OSL_ENSHURE(SQL_ISRULE(pAssignment,assignment),"OResultSet: Fehler im Parse Tree"); + OSL_ENSHURE(pAssignment->count() == 3,"OResultSet: pAssignment->count() != 3"); + + OSQLParseNode * pCol = pAssignment->getChild(0); + OSL_ENSHURE(pCol != NULL,"OResultSet: pCol == NULL"); + + OSQLParseNode * pComp = pAssignment->getChild(1); + OSL_ENSHURE(pComp != NULL,"OResultSet: pComp == NULL"); + OSL_ENSHURE(pComp->getNodeType() == SQL_NODE_EQUAL,"OResultSet: pComp->getNodeType() != SQL_NODE_COMPARISON"); + if (pComp->getTokenValue().GetChar(0) != '=') + { + // aStatus.SetInvalidStatement(); + throw SQLException(); + } + + OSQLParseNode * pVal = pAssignment->getChild(2); + OSL_ENSHURE(pVal != NULL,"OResultSet: pVal == NULL"); + aList[0] = pCol->getTokenValue(); + ParseAssignValues(aList,pVal,0); + } + + } +} +// ------------------------------------------------------------------------- +void OResultSet::ParseAssignValues(const ::std::vector< String>& aColumnNameList,OSQLParseNode* pRow_Value_Constructor_Elem,xub_StrLen nIndex) +{ + OSL_ENSHURE(nIndex <= aColumnNameList.size(),"SdbFileCursor::ParseAssignValues: nIndex > aColumnNameList.GetTokenCount()"); + String aColumnName(aColumnNameList[nIndex]); + OSL_ENSHURE(aColumnName.Len() > 0,"OResultSet: Column-Name nicht gefunden"); + OSL_ENSHURE(pRow_Value_Constructor_Elem != NULL,"OResultSet: pRow_Value_Constructor_Elem darf nicht NULL sein!"); + + if (pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_STRING || + pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_INTNUM || + pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_APPROXNUM) + { + // Wert setzen: + SetAssignValue(aColumnName, pRow_Value_Constructor_Elem->getTokenValue()); + } + else if (SQL_ISTOKEN(pRow_Value_Constructor_Elem,NULL)) + { + // NULL setzen + SetAssignValue(aColumnName, String(), TRUE); + } + else if (SQL_ISRULE(pRow_Value_Constructor_Elem,parameter)) + { + // Parameter hinzufuegen, Typ ... entsprechend der Column, der der Wert zugewiesen wird + Reference<XFastPropertySet> xCol; + m_xColNames->getByName(aColumnName) >>= xCol; + sal_Int32 nParameter = -1; + if(m_xParamColumns.isValid()) + { + OSQLColumns::const_iterator aIter = find(m_xParamColumns->begin(),m_xParamColumns->end(),aColumnName,::utl::UStringMixEqual(m_pTable->isCaseSensitive())); + if(aIter != m_xParamColumns->end()) + nParameter = m_xParamColumns->size() - (m_xParamColumns->end() - aIter) +1;// +1 because the rows start at 1 + } + if(nParameter == -1) + nParameter = AddParameter(pRow_Value_Constructor_Elem,xCol); + // Nr. des Parameters in der Variablen merken: + SetAssignValue(aColumnName, String(), TRUE, nParameter); + } + else + { + // aStatus.SetStatementTooComplex(); + throw SQLException(); + } +} +//------------------------------------------------------------------ +void OResultSet::SetAssignValue(const String& aColumnName, + const String& aValue, + BOOL bSetNull, + UINT32 nParameter) +{ + Reference<XFastPropertySet> xCol; + m_xColNames->getByName(aColumnName) >>= xCol; + sal_Int32 nId = Reference<XColumnLocate>(m_xColNames,UNO_QUERY)->findColumn(aColumnName); + // Kommt diese Column ueberhaupt in der Datei vor? + + if (!xCol.is()) + { + // Diese Column gibt es nicht! +// aStatus.Set(SQL_STAT_ERROR, +// String::CreateFromAscii("S0022"), +// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_COLUMN_NOT_FOUND))), +// 0, String() ); + throw SQLException(); + } + + // Value an die Row mit den zuzuweisenden Werten binden: + // const ODbVariantRef& xValue = (*aAssignValues)[pFileColumn->GetId()]; + + // Alles geprueft und wir haben den Namen der Column. + // Jetzt eine Value allozieren, den Wert setzen und die Value an die Row binden. + if (bSetNull) + (*m_aAssignValues)[nId].setNull(); + else + { + switch (getINT32(xCol->getFastPropertyValue(PROPERTY_ID_TYPE))) + { + // Kriterium je nach Typ als String oder double in die Variable packen ... + case DataType::CHAR: + case DataType::VARCHAR: + (*m_aAssignValues)[nId] = aValue; + // Zeichensatz ist bereits konvertiert, da ja das gesamte Statement konvertiert wurde + break; + + case DataType::BIT: + { + // nyi: gemischte Gross-/Kleinschreibung??? + if (aValue.EqualsIgnoreCaseAscii("TRUE") || aValue.GetChar(0) == '1') + (*m_aAssignValues)[nId] = sal_True; + else if (aValue.EqualsIgnoreCaseAscii("FALSE") || aValue.GetChar(0) == '0') + (*m_aAssignValues)[nId] = sal_False; + else + { + // aStatus.Set(SQL_STAT_ERROR); // nyi: genauer! + throw SQLException(); + } + } + break; + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::REAL: + case DataType::DOUBLE: + case DataType::DATE: + case DataType::TIME: + case DataType::TIMESTAMP: + { + (*m_aAssignValues)[nId] = aValue.ToDouble(); +// try +// { +// double n = xValue->toDouble(); +// xValue->setDouble(n); +// } +// catch ( ... ) +// { +// aStatus.SetDriverNotCapableError(); +// } + } break; + default: + throw SQLException(); + } + } + + // Parameter-Nr. merken (als User Data) + // SQL_NO_PARAMETER = kein Parameter. + m_aAssignValues->setParameterIndex(nId,nParameter); + // ((ODbAssignRow*)aAssignValues.getBodyPtr())->setAssignedIndex(pFileColumn->GetId(), nParameter); +} + +//------------------------------------------------------------------ +UINT32 OResultSet::AddParameter(OSQLParseNode * pParameter, const Reference<XFastPropertySet>& _xCol) +{ + + // Nr. des neu hinzuzufuegenden Parameters: + UINT32 nParameter = m_xParamColumns->size()+1; + + OSL_ENSHURE(SQL_ISRULE(pParameter,parameter),"OResultSet::AddParameter: Argument ist kein Parameter"); + OSL_ENSHURE(pParameter->count() > 0,"OResultSet: Fehler im Parse Tree"); + OSQLParseNode * pMark = pParameter->getChild(0); + + String aParameterName; + if (SQL_ISPUNCTUATION(pMark,"?")) + aParameterName = '?'; + else if (SQL_ISPUNCTUATION(pMark,":")) + aParameterName = pParameter->getChild(1)->getTokenValue(); + else if (SQL_ISPUNCTUATION(pMark,"[")) + aParameterName = pParameter->getChild(1)->getTokenValue(); + else + { + OSL_ASSERT("OResultSet: Fehler im Parse Tree"); + } + + // Parameter-Column aufsetzen: + sal_Int32 eType = DataType::VARCHAR; + UINT32 nPrecision = 255; + UINT16 nScale = 0; + sal_Int32 nNullable = ColumnValue::NULLABLE; + + if (_xCol.is()) + { + // Typ, Precision, Scale ... der angegebenen Column verwenden, + // denn dieser Column wird der Wert zugewiesen bzw. mit dieser + // Column wird der Wert verglichen. + eType = getINT32(_xCol->getFastPropertyValue(PROPERTY_ID_TYPE)); + nPrecision = getINT32(_xCol->getFastPropertyValue(PROPERTY_ID_PRECISION)); + nScale = getINT32(_xCol->getFastPropertyValue(PROPERTY_ID_SCALE)); + nNullable = getINT32(_xCol->getFastPropertyValue(PROPERTY_ID_ISNULLABLE));; + } + + Reference<XFastPropertySet> xParaColumn; + sdbcx::OColumn* pRet = new sdbcx::OColumn(aParameterName + ,::rtl::OUString() + ,::rtl::OUString() + ,nNullable + , nPrecision + ,nScale + ,eType + ,sal_False + ,sal_False + ,sal_False + ,m_aSQLIterator.isCaseSensitive()); + xParaColumn = pRet; + m_xParamColumns->push_back(xParaColumn); + return nParameter; +} +// ------------------------------------------------------------------------- +void OResultSet::describeParameter() +{ + ::std::vector< OSQLParseNode*> aParseNodes; + scanParameter(m_pParseTree,aParseNodes); + if(aParseNodes.size()) + { + m_xParamColumns = new OSQLColumns(); + const OSQLTables& xTabs = m_aSQLIterator.getTables(); + OSQLTable xTable = xTabs.begin()->second; + + String aTabName,aTmp,aColName,aParameterName; + ::std::vector< OSQLParseNode*>::iterator aIter = aParseNodes.begin(); + for(;aIter != aParseNodes.end();++aIter) + { + BOOL bNotFound(TRUE); + OSQLParseNode* pParseNode = *aIter; + pParseNode = pParseNode->getParent(); + pParseNode = pParseNode->getChild(0); + + m_aSQLIterator.getColumnRange(pParseNode,aColName,aTabName); + Reference<XFastPropertySet> xCol; + xTable->getColumns()->getByName(aColName) >>= xCol; + m_xParamColumns->push_back(xCol); + } + } +} +//------------------------------------------------------------------ +void OResultSet::scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes) +{ + DBG_ASSERT(pParseNode != NULL,"SdbCursor: 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); +} + + diff --git a/connectivity/source/drivers/file/FResultSetMetaData.cxx b/connectivity/source/drivers/file/FResultSetMetaData.cxx new file mode 100644 index 000000000000..d595da005387 --- /dev/null +++ b/connectivity/source/drivers/file/FResultSetMetaData.cxx @@ -0,0 +1,201 @@ +/************************************************************************* + * + * $RCSfile: FResultSetMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_ORESULTSETMETADATA_HXX_ +#include "file/FResultSetMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity; +using namespace connectivity::file; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +// ------------------------------------------------------------------------- +OResultSetMetaData::~OResultSetMetaData() +{ +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getINT32(m_rColumns[column-1]->getFastPropertyValue(PROPERTY_ID_PRECISION)); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getINT32(m_rColumns[column-1]->getFastPropertyValue(PROPERTY_ID_TYPE)); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException) +{ + return m_rColumns.size(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + Any aName(m_rColumns[column-1]->getFastPropertyValue(PROPERTY_ID_REALNAME)); + return aName.hasValue() ? getString(aName) : getString(m_rColumns[column-1]->getFastPropertyValue(PROPERTY_ID_NAME)); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return m_aTableName; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getString(m_rColumns[column-1]->getFastPropertyValue(PROPERTY_ID_TYPENAME)); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getString(m_rColumns[column-1]->getFastPropertyValue(PROPERTY_ID_NAME)); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getBOOL(m_rColumns[column-1]->getFastPropertyValue(PROPERTY_ID_TYPE)); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getBOOL(m_rColumns[column-1]->getFastPropertyValue(PROPERTY_ID_ISAUTOINCREMENT)); +} +// ------------------------------------------------------------------------- + + +sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getINT32(m_rColumns[column-1]->getFastPropertyValue(PROPERTY_ID_PRECISION)); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return getINT32(m_rColumns[column-1]->getFastPropertyValue(PROPERTY_ID_SCALE)); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getINT32(m_rColumns[column-1]->getFastPropertyValue(PROPERTY_ID_ISNULLABLE)); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return sal_False; +; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx new file mode 100644 index 000000000000..8dfbb1fd9521 --- /dev/null +++ b/connectivity/source/drivers/file/FStatement.cxx @@ -0,0 +1,358 @@ +/************************************************************************* + * + * $RCSfile: FStatement.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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 _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _CONNECTIVITY_FILE_OSTATEMENT_HXX_ +#include "file/FStatement.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_OCONNECTION_HXX_ +#include "file/FConnection.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_ORESULTSET_HXX_ +#include "file/FResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _UTL_PROPERTY_HXX_ +#include <unotools/property.hxx> +#endif +#ifndef _UTL_UNO3_HXX_ +#include <unotools/uno3.hxx> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif + +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif + +#define THROW_SQL(x) \ + OTools::ThrowException(x,m_aStatementHandle,SQL_HANDLE_STMT,*this) + +using namespace connectivity::file; +using namespace connectivity; +//------------------------------------------------------------------------------ +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::container; +//------------------------------------------------------------------------------ +OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE(m_aMutex) + ,connectivity::OSimplePropertyContainer(OStatement_BASE::rBHelper) + ,rBHelper(OStatement_BASE::rBHelper) + ,m_pConnection(_pConnection) + ,m_pParseTree(NULL) + ,m_aSQLIterator(_pConnection->createCatalog()->getTables(),_pConnection->getMetaData(),NULL) +{ + m_pConnection->acquire(); + + sal_Int32 nAttrib = 0; + + registerProperty(PROPERTY_CURSORNAME, PROPERTY_ID_CURSORNAME, nAttrib,&m_aCursorName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(PROPERTY_MAXFIELDSIZE, PROPERTY_ID_MAXFIELDSIZE, nAttrib,&m_nMaxFieldSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(PROPERTY_MAXROWS, PROPERTY_ID_MAXROWS, nAttrib,&m_nMaxRows, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(PROPERTY_QUERYTIMEOUT, PROPERTY_ID_QUERYTIMEOUT, nAttrib,&m_nQueryTimeOut, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(PROPERTY_FETCHSIZE, PROPERTY_ID_FETCHSIZE, nAttrib,&m_nFetchSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(PROPERTY_RESULTSETTYPE, PROPERTY_ID_RESULTSETTYPE, nAttrib,&m_nResultSetType, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(PROPERTY_FETCHDIRECTION, PROPERTY_ID_FETCHDIRECTION, nAttrib,&m_nFetchDirection, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(PROPERTY_ESCAPEPROCESSING, PROPERTY_ID_ESCAPEPROCESSING, nAttrib,&m_bEscapeProcessing,::getCppuBooleanType()); + + registerProperty(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY, nAttrib,&m_nResultSetConcurrency, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); +} +//------------------------------------------------------------------------------ +void OStatement_Base::disposeResultSet() +{ + // free the cursor if alive + Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + m_xResultSet = Reference< XResultSet>(); +} +//------------------------------------------------------------------------------ +void OStatement_BASE2::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + disposeResultSet(); + + if (m_pConnection) + m_pConnection->release(); + + dispose_ChildImpl(); + OStatement_Base::disposing(); +} +//----------------------------------------------------------------------------- +void SAL_CALL OStatement_BASE2::release() throw(RuntimeException) +{ + relase_ChildImpl(); +} +//----------------------------------------------------------------------------- +Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OStatement_BASE::queryInterface(rType); + if(!aRet.hasValue()) + aRet = OPropertySetHelper::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), + ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), + ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes()); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + } + dispose(); +} +// ------------------------------------------------------------------------- + +void OStatement_Base::reset() throw (SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + clearWarnings (); + + if (m_xResultSet.get().is()) + clearMyResultSet(); +} +//-------------------------------------------------------------------- +// clearMyResultSet +// If a ResultSet was created for this Statement, close it +//-------------------------------------------------------------------- + +void OStatement_Base::clearMyResultSet () throw (SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + Reference<XCloseable> xCloseable; + if(::utl::query_interface(m_xResultSet.get(),xCloseable)) + xCloseable->close(); + m_xResultSet = Reference< XResultSet>(); +} +//-------------------------------------------------------------------- +// setWarning +// Sets the warning +//-------------------------------------------------------------------- + +void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_aLastWarning = ex; +} + +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + // ::rtl::OString aSql(::rtl::OUStringToOString(sql,osl_getThreadTextEncoding())); + Reference< XResultSet > xRS = executeQuery(sql); + + return m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT || m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT_COUNT; +} + +// ------------------------------------------------------------------------- + +Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + Reference< XResultSet > xRS = NULL; + + String aErr; + m_pParseTree = m_aParser.parseTree(aErr,sql); + if(m_pParseTree) + { + m_aSQLIterator.setParseTree(m_pParseTree); + m_aSQLIterator.traverseAll(); + const OSQLTables& xTabs = m_aSQLIterator.getTables(); + if(xTabs.begin() == xTabs.end()) + throw SQLException(aErr,*this,::rtl::OUString(),0,Any()); + + OResultSet* pResult = new OResultSet(this,m_aSQLIterator); + pResult->OpenImpl(); + xRS = pResult; + + } + else + throw SQLException(aErr,*this,::rtl::OUString(),0,Any()); + + + + // Execute the statement. If execute returns true, a result + // set exists. + return xRS; +} +// ------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException) +{ + return (Reference< XConnection >)m_pConnection; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + Reference< XResultSet > xRS = NULL; + + String aErr; + m_pParseTree = m_aParser.parseTree(aErr,sql); + if(m_pParseTree) + { + m_aSQLIterator.setParseTree(m_pParseTree); + m_aSQLIterator.traverseAll(); + const OSQLTables& xTabs = m_aSQLIterator.getTables(); + if(xTabs.begin() == xTabs.end()) + throw SQLException(aErr,*this,::rtl::OUString(),0,Any()); + + OResultSet* pResult = new OResultSet(this,m_aSQLIterator); + pResult->OpenImpl(); + xRS = pResult; + return pResult->getRowCountResult(); + } + else + throw SQLException(aErr,*this,::rtl::OUString(),0,Any()); + + return 0; +} +// ------------------------------------------------------------------------- +Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return makeAny(m_aLastWarning); +} +// ------------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_aLastWarning = SQLWarning(); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} + +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper() +{ + return *const_cast<OStatement_Base*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbc.driver.file.Statement","com.sun.star.sdbc.Statement"); + diff --git a/connectivity/source/drivers/file/FTable.cxx b/connectivity/source/drivers/file/FTable.cxx new file mode 100644 index 000000000000..9036acdde05c --- /dev/null +++ b/connectivity/source/drivers/file/FTable.cxx @@ -0,0 +1,201 @@ +/************************************************************************* + * + * $RCSfile: FTable.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_TABLE_HXX_ +#include "file/FTable.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_COLUMNS_HXX_ +#include "file/FColumns.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif + +using namespace connectivity::file; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; + +OFileTable::OFileTable(OConnection* _pConnection) : OTable_TYPEDEF(_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()) + ,m_pConnection(_pConnection) + ,m_nFilePos(0) + ,m_nBufferSize(0) + ,m_pBuffer(NULL) +{ + construct(); + ::std::vector< ::rtl::OUString> aVector; + m_pColumns = new OColumns(this,m_aMutex,aVector); + m_aColumns = new OSQLColumns(); +} +// ------------------------------------------------------------------------- +OFileTable::OFileTable( OConnection* _pConnection, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description , + const ::rtl::OUString& _SchemaName, + const ::rtl::OUString& _CatalogName + ) : OTable_TYPEDEF(_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers(), + _Name, + _Type, + _Description, + _SchemaName, + _CatalogName) + ,m_pConnection(_pConnection) + ,m_nFilePos(0) + ,m_nBufferSize(0) + ,m_pBuffer(NULL) +{ + m_aColumns = new OSQLColumns(); + construct(); + // refreshColumns(); +} +// ------------------------------------------------------------------------- +void OFileTable::refreshColumns() +{ + ::std::vector< ::rtl::OUString> aVector; + Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(Any(), + m_SchemaName,m_Name,::rtl::OUString::createFromAscii("%")); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(4)); + } + + if(m_pColumns) + delete m_pColumns; + m_pColumns = new OColumns(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +void OFileTable::refreshKeys() +{ +} +// ------------------------------------------------------------------------- +void OFileTable::refreshIndexes() +{ +} +// ------------------------------------------------------------------------- +Any SAL_CALL OFileTable::queryInterface( const Type & rType ) throw(RuntimeException) +{ + if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) || + rType == ::getCppuType((const Reference<XRename>*)0) || + rType == ::getCppuType((const Reference<XAlterTable>*)0) || + rType == ::getCppuType((const Reference<XIndexesSupplier>*)0) || + rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0)) + return Any(); + + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); + if(aRet.hasValue()) + return aRet; + + return OTable_TYPEDEF::queryInterface(rType); +} +// ------------------------------------------------------------------------- +void SAL_CALL OFileTable::disposing(void) +{ + OTable::disposing(); + ::osl::MutexGuard aGuard(m_aMutex); + m_xMetaData = NULL; + delete m_pBuffer; + m_pBuffer = NULL; +} +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OFileTable::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OFileTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; +} + + diff --git a/connectivity/source/drivers/file/FTables.cxx b/connectivity/source/drivers/file/FTables.cxx new file mode 100644 index 000000000000..6150ed228b39 --- /dev/null +++ b/connectivity/source/drivers/file/FTables.cxx @@ -0,0 +1,161 @@ +/************************************************************************* + * + * $RCSfile: FTables.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_TABLES_HXX_ +#include "file/FTables.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_TABLE_HXX_ +#include "file/FTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.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 +#ifndef _CONNECTIVITY_FILE_CATALOG_HXX_ +#include "file/FCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_BCONNECTION_HXX_ +#include "file/FConnection.hxx" +#endif +//#ifndef _CONNECTIVITY_FILE_OEMPTYCOLLECTION_HXX_ +//#include "file/FEmptyCollection.hxx" +//#endif + +using namespace connectivity::file; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; + +namespace starutil = ::com::sun::star::util; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OTables::createObject(const ::rtl::OUString& _rName) +{ +// ::rtl::OUString aName,aSchema; +// sal_Int32 nLen = _rName.indexOf('.'); +// aSchema = _rName.copy(0,nLen); +// aName = _rName.copy(nLen+1); +// +// Sequence< ::rtl::OUString > aTypes(1); +// aTypes[0] = ::rtl::OUString::createFromAscii("%"); +// // aTypes[0] = ::rtl::OUString::createFromAscii("TABLE"); +// // aTypes[1] = ::rtl::OUString::createFromAscii("SYSTEMTABLE"); +// +// Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), +// aSchema,aName,aTypes); + + Reference< XNamed > xRet = NULL; +// if(xResult.is()) +// { +// Reference< XRow > xRow(xResult,UNO_QUERY); +// if(xResult->next()) // there can be only one table with this name +// { +// OFileTable* pRet = new OFileTable(static_cast<OFileCatalog&>(m_rParent).getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(), +// static_cast<OFileCatalog&>(m_rParent).getConnection(), +// aName,xRow->getString(4),xRow->getString(5),aSchema); +// xRet = pRet; +// } +// } +// + return xRet; +} +// ------------------------------------------------------------------------- +void OTables::impl_refresh( ) throw(RuntimeException) +{ + static_cast<OFileCatalog&>(m_rParent).refreshTables(); +} +// ------------------------------------------------------------------------- +void OTables::disposing(void) +{ + m_xMetaData = NULL; + OCollection::disposing(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OTables::createEmptyObject() +{ + return Reference< XPropertySet >(); +} +//------------------------------------------------------------------ +Any SAL_CALL OTables::queryInterface( const Type & rType ) throw(RuntimeException) +{ + if( rType == ::getCppuType((const Reference<XColumnLocate>*)0) || + rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0) || + rType == ::getCppuType((const Reference<XAppend>*)0) || + rType == ::getCppuType((const Reference<XDrop>*)0)) + return Any(); + + typedef sdbcx::OCollection OTables_BASE; + return OTables_BASE::queryInterface(rType); +} + diff --git a/connectivity/source/drivers/file/file.xml b/connectivity/source/drivers/file/file.xml new file mode 100644 index 000000000000..253bccb84c4c --- /dev/null +++ b/connectivity/source/drivers/file/file.xml @@ -0,0 +1,70 @@ +<?xml version='1.0' encoding="UTF-8"?> +<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//W3C//DTD HTML 3.2//EN" "componentdependencies.dtd"> +<COMPONENTDESCRIPTION> + +<Name> com.sun.star.sdbc.ODBCDriver </Name> + +<Description> + This is the implementation of the sdbc-odbc bridge. +</Description> + +<ModuleName> odbc </ModuleName> + +<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName> + +<SupportedService> com.sun.star.sdbc.Driver </SupportedService> + +<ServiceDependency> ... </ServiceDependency> + +<ProjectBuildDependency> cppuhelper </ProjectBuildDependency> +<ProjectBuildDependency> cppu </ProjectBuildDependency> +<ProjectBuildDependency> sal </ProjectBuildDependency> +<ProjectBuildDependency> vos </ProjectBuildDependency> + +<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency> +<RuntimeModuleDependency> cppu1 </RuntimeModuleDependency> +<RuntimeModuleDependency> sal1 </RuntimeModuleDependency> +<RuntimeModuleDependency> vos </RuntimeModuleDependency> + +<Language> c++ </Language> + +<Status StatusValue="final"/> + +<Type> com.sun.star.util.XCancellable </Type> +<Type> com.sun.star.util.XNumberFormatter </Type> +<Type> com.sun.star.uno.TypeClass </Type> +<Type> com.sun.star.uno.XWeak </Type> +<Type> com.sun.star.uno.XAggregation </Type> +<Type> com.sun.star.beans.XPropertyState </Type> +<Type> com.sun.star.beans.XPropertySet </Type> +<Type> com.sun.star.beans.PropertyValue </Type> +<Type> com.sun.star.beans.XMultiPropertySet </Type> +<Type> com.sun.star.beans.XFastPropertySet </Type> +<Type> com.sun.star.lang.XTypeProvider </Type> +<Type> com.sun.star.lang.EventObject </Type> +<Type> com.sun.star.lang.XComponent </Type> +<Type> com.sun.star.lang.IllegalArgumentException </Type> +<Type> com.sun.star.lang.XMultiServiceFactory </Type> +<Type> com.sun.star.java.XJavaThreadRegister_11 </Type> +<Type> com.sun.star.java.XJavaVM </Type> +<Type> com.sun.star.sdbc.XConnection </Type> +<Type> com.sun.star.sdbc.XStatement </Type> +<Type> com.sun.star.sdbc.XResultSet </Type> +<Type> com.sun.star.sdbc.XResultSetMetaDataSupplier</Type> +<Type> com.sun.star.sdbc.XColumnLocate </Type> +<Type> com.sun.star.sdbc.XResultSetUpdate </Type> +<Type> com.sun.star.sdbc.XWarningsSupplier </Type> +<Type> com.sun.star.sdbc.XRowUpdate </Type> +<Type> com.sun.star.sdbc.XMultipleResults </Type> +<Type> com.sun.star.sdbc.XBatchExecution </Type> +<Type> com.sun.star.sdbc.XPreparedBatchExecution </Type> +<Type> com.sun.star.sdbc.XParameters </Type> +<Type> com.sun.star.sdbc.XOutParameters </Type> +<Type> com.sun.star.sdbc.DriverPropertyInfo </Type> +<Type> com.sun.star.sdbc.XRow </Type> +<Type> com.sun.star.sdb.XColumnUpdate </Type> +<Type> com.sun.star.sdb.XColumn </Type> + +</COMPONENTDESCRIPTION> + + diff --git a/connectivity/source/drivers/file/makefile.mk b/connectivity/source/drivers/file/makefile.mk new file mode 100644 index 000000000000..6497fcde76d3 --- /dev/null +++ b/connectivity/source/drivers/file/makefile.mk @@ -0,0 +1,158 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=..$/.. +PRJNAME=connectivity +TARGET=file + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/version.mk + +# --- Types ------------------------------------- + + +UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb + +UNOUCROUT=$(OUT)$/inc +INCPRE+=$(UNOUCROUT) + +# --- Types ------------------------------------- + +UNOTYPES+= \ + com.sun.star.util.XCancellable \ + com.sun.star.util.XNumberFormatter \ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XWeak \ + com.sun.star.uno.XAggregation \ + com.sun.star.beans.XPropertyState \ + com.sun.star.beans.XPropertySet \ + com.sun.star.beans.PropertyValue \ + com.sun.star.beans.XMultiPropertySet \ + com.sun.star.beans.XFastPropertySet \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.EventObject \ + com.sun.star.lang.XComponent \ + com.sun.star.lang.IllegalArgumentException \ + com.sun.star.lang.DisposedException \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.java.XJavaThreadRegister_11 \ + com.sun.star.java.XJavaVM \ + com.sun.star.sdbc.XConnection \ + com.sun.star.sdbc.XStatement \ + com.sun.star.sdbc.XResultSet \ + com.sun.star.sdbc.XResultSetMetaDataSupplier \ + com.sun.star.sdbc.XColumnLocate \ + com.sun.star.sdbc.XResultSetUpdate \ + com.sun.star.sdbc.XWarningsSupplier \ + com.sun.star.sdbc.XRowUpdate \ + com.sun.star.sdbc.XMultipleResults \ + com.sun.star.sdbc.XBatchExecution \ + com.sun.star.sdbc.XPreparedBatchExecution \ + com.sun.star.sdbc.XParameters \ + com.sun.star.sdbc.XOutParameters \ + com.sun.star.sdbc.DriverPropertyInfo \ + com.sun.star.sdbc.XDriver \ + com.sun.star.sdbc.XRow \ + com.sun.star.sdbc.SQLWarning \ + com.sun.star.sdbc.ColumnSearch \ + com.sun.star.sdbc.DataType \ + com.sun.star.sdbc.ResultSetConcurrency \ + com.sun.star.sdbc.ResultSetType \ + com.sun.star.sdbc.ColumnValue \ + com.sun.star.sdb.XColumnUpdate \ + com.sun.star.sdb.XColumn \ + com.sun.star.lang.XServiceInfo + +# --- Files ------------------------------------- + +SLOFILES=\ + $(SLO)$/FConnection.obj \ + $(SLO)$/FValue.obj \ + $(SLO)$/FDatabaseMetaDataResultSetMetaData.obj \ + $(SLO)$/FDatabaseMetaDataResultSet.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 + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + + diff --git a/connectivity/source/drivers/jdbc/Array.cxx b/connectivity/source/drivers/jdbc/Array.cxx new file mode 100644 index 000000000000..21566a30afc3 --- /dev/null +++ b/connectivity/source/drivers/jdbc/Array.cxx @@ -0,0 +1,238 @@ +/************************************************************************* + * + * $RCSfile: Array.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_SQL_ARRAY_HXX_ +#include "java/sql/Array.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_RESULTSET_HXX_ +#include "java/sql/ResultSet.hxx" +#endif + +using namespace connectivity; +//************************************************************** +//************ Class: java.sql.Array +//************************************************************** + +jclass java_sql_Array::theClass = 0; + +java_sql_Array::~java_sql_Array() +{} + +jclass java_sql_Array::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass( "java/sql/Array" ); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_sql_Array::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} +::rtl::OUString SAL_CALL java_sql_Array::getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jstring out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/lang/String;"; + char * cMethodName = "getBaseTypeName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} + +sal_Int32 SAL_CALL java_sql_Array::getBaseType( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getBaseType"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int32)out; +} + +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL java_sql_Array::getArray( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jobjectArray out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jobject obj = XNameAccess2Map(t.pEnv,typeMap); + char * cSignature = "(Ljava/util/Map;)[Ljava/lang/Object;"; + char * cMethodName = "getArray"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jobjectArray)t.pEnv->CallObjectMethod( object, mID, obj); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + t.pEnv->DeleteLocalRef(obj); + } //mID + } //t.pEnv + return ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >();//copyArrayAndDelete< ::com::sun::star::uno::Any,jobject>(t.pEnv,out); +} + +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL java_sql_Array::getArrayAtIndex( sal_Int32 index, sal_Int32 count, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jobjectArray out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jobject obj = XNameAccess2Map(t.pEnv,typeMap); + char * cSignature = "(IILjava/util/Map;)[Ljava/lang/Object;"; + char * cMethodName = "getArray"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jobjectArray)t.pEnv->CallObjectMethod( object, mID, index,count,obj); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + t.pEnv->DeleteLocalRef(obj); + } //mID + } //t.pEnv + return ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >();//copyArrayAndDelete< ::com::sun::star::uno::Any,jobject>(t.pEnv,out); +} + +::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Array::getResultSet( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].l = XNameAccess2Map(t.pEnv,typeMap); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;"; + char * cMethodName = "getResultSet"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + t.pEnv->DeleteLocalRef((jobjectArray)args[0].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + // return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); + return NULL; +} + +::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Array::getResultSetAtIndex( sal_Int32 index, sal_Int32 count, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].l = XNameAccess2Map(t.pEnv,typeMap); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;"; + char * cMethodName = "getResultSet"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, index,count,args[0].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + t.pEnv->DeleteLocalRef((jobjectArray)args[0].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + // return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); + return NULL; +} + + + diff --git a/connectivity/source/drivers/jdbc/Blob.cxx b/connectivity/source/drivers/jdbc/Blob.cxx new file mode 100644 index 000000000000..7a2b3ab808a5 --- /dev/null +++ b/connectivity/source/drivers/jdbc/Blob.cxx @@ -0,0 +1,221 @@ +/************************************************************************* + * + * $RCSfile: Blob.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_SQL_BLOB_HXX_ +#include "java/sql/Blob.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_IO_INPUTSTREAM_HXX_ +#include "java/io/InputStream.hxx" +#endif +#ifndef _INC_MEMORY +#include <memory.h> +#endif + +using namespace connectivity; +//************************************************************** +//************ Class: java.sql.Blob +//************************************************************** + +jclass java_sql_Blob::theClass = 0; + +java_sql_Blob::~java_sql_Blob() +{} + +jclass java_sql_Blob::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass( "java/sql/Blob" ); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_sql_Blob::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +sal_Int64 SAL_CALL java_sql_Blob::length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jlong out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()J"; + char * cMethodName = "length"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallLongMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int64)out; +} +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL java_sql_Blob::getBytes( sal_Int64 pos, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::com::sun::star::uno::Sequence< sal_Int8 > aSeq; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(JI)[B"; + char * cMethodName = "getBytes"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jbyteArray out = (jbyteArray)t.pEnv->CallObjectMethod( object, mID,pos,length); + ThrowSQLException(t.pEnv,*this); + if(out) + { + jboolean p = sal_False; + aSeq.realloc(t.pEnv->GetArrayLength(out)); + memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength()); + t.pEnv->DeleteLocalRef(out); + } + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aSeq; +} + +::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_Blob::getBinaryStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()Ljava/io/InputStream;"; + char * cMethodName = "getBinaryStream"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_io_InputStream( t.pEnv, out ); +} + +sal_Int64 SAL_CALL java_sql_Blob::position( const ::com::sun::star::uno::Sequence< sal_Int8 >& pattern, sal_Int64 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jlong out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jvalue args[1]; + // Parameter konvertieren + jbyteArray pByteArray = t.pEnv->NewByteArray(pattern.getLength()); + t.pEnv->SetByteArrayRegion(pByteArray,0,pattern.getLength(),(jbyte*)pattern.getConstArray()); + args[0].l = pByteArray; + // temporaere Variable initialisieren + char * cSignature = "([BI)J"; + char * cMethodName = "position"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallLongMethod( object, mID, args[0].l,start ); + ThrowSQLException(t.pEnv,*this); + t.pEnv->DeleteLocalRef((jbyteArray)args[0].l); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int64)out; +} + +sal_Int64 SAL_CALL java_sql_Blob::positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& pattern, sal_Int64 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jlong out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jvalue args[1]; + // Parameter konvertieren + args[0].l = 0; + // temporaere Variable initialisieren + char * cSignature = "(Ljava/sql/Blob;I)J"; + char * cMethodName = "position"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallLongMethod( object, mID,args[0].l,start ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int64)out; +} + diff --git a/connectivity/source/drivers/jdbc/Boolean.cxx b/connectivity/source/drivers/jdbc/Boolean.cxx new file mode 100644 index 000000000000..0d72ac908689 --- /dev/null +++ b/connectivity/source/drivers/jdbc/Boolean.cxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * $RCSfile: Boolean.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_LANG_BOOLEAN_HXX_ +#include "java/lang/Boolean.hxx" +#endif +using namespace connectivity; +//************************************************************** +//************ Class: java.lang.Boolean +//************************************************************** + +jclass java_lang_Boolean::theClass = 0; + +java_lang_Boolean::~java_lang_Boolean() +{} + +jclass java_lang_Boolean::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass("java/lang/Boolean"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_lang_Boolean::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +java_lang_Boolean::java_lang_Boolean( sal_Bool _par0 ): java_lang_Object( NULL, (jobject)NULL ){ + SDBThreadAttach t; + if( !t.pEnv ) + return; + jvalue args[1]; + // Parameter konvertieren + args[0].z = _par0; + // Java-Call fuer den Konstruktor absetzen + // temporaere Variable initialisieren + char * cSignature = "(Z)V"; + jobject tempObj; + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature ); + tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args ); + saveRef( t.pEnv, tempObj ); + t.pEnv->DeleteLocalRef( tempObj ); + // und aufraeumen +} + + diff --git a/connectivity/source/drivers/jdbc/CallableStatement.cxx b/connectivity/source/drivers/jdbc/CallableStatement.cxx new file mode 100644 index 000000000000..be6616d4b0ae --- /dev/null +++ b/connectivity/source/drivers/jdbc/CallableStatement.cxx @@ -0,0 +1,590 @@ +/************************************************************************* + * + * $RCSfile: CallableStatement.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_SQL_CALLABLESTATEMENT_HXX_ +#include "java/sql/CallableStatement.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_ARRAY_HXX_ +#include "java/sql/Array.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_CLOB_HXX_ +#include "java/sql/Clob.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_BLOB_HXX_ +#include "java/sql/Blob.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_REF_HXX_ +#include "java/sql/Ref.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_TIMESTAMP_HXX_ +#include "java/sql/Timestamp.hxx" +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif + +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + + +IMPLEMENT_SERVICE_INFO(java_sql_CallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement"); + +//************************************************************** +//************ Class: java.sql.CallableStatement +//************************************************************** +Any SAL_CALL java_sql_CallableStatement::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = java_sql_PreparedStatement::queryInterface(rType); + if(!aRet.hasValue()) + aRet = ::cppu::queryInterface(rType,static_cast< starsdbc::XRow*>(this),static_cast< starsdbc::XOutParameters*>(this)); + return aRet; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_CallableStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< starsdbc::XRow > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< starsdbc::XOutParameters > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),java_sql_PreparedStatement::getTypes()); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_CallableStatement::wasNull( ) throw(starsdbc::SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "wasNull"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} + +sal_Bool SAL_CALL java_sql_CallableStatement::getBoolean( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "getBoolean"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID, columnIndex ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +sal_Int8 SAL_CALL java_sql_CallableStatement::getByte( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jbyte out; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "(I)B"; + char * cMethodName = "getByte"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallByteMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +Sequence< sal_Int8 > SAL_CALL java_sql_CallableStatement::getBytes( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + Sequence< sal_Int8 > aSeq; + + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + char * cSignature = "(I)[B"; + char * cMethodName = "getBytes"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jbyteArray out(0); + out = (jbyteArray)t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + if (out) + { + jboolean p = sal_False; + aSeq.realloc(t.pEnv->GetArrayLength(out)); + memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength()); + t.pEnv->DeleteLocalRef(out); + } + // und aufraeumen + } //mID + } //t.pEnv + return aSeq; +} +::com::sun::star::util::Date SAL_CALL java_sql_CallableStatement::getDate( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Date;"; + char * cMethodName = "getDate"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return java_sql_Date( t.pEnv, out ); +} +double SAL_CALL java_sql_CallableStatement::getDouble( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jdouble out; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + jvalue args[1]; + args[0].i = (sal_Int32)columnIndex; + // temporaere Variable initialisieren + char * cSignature = "(I)D"; + char * cMethodName = "getDouble"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallDoubleMethod( object, mID, args[0].i); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} + +float SAL_CALL java_sql_CallableStatement::getFloat( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jfloat out; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "(I)F"; + char * cMethodName = "getFloat"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallFloatMethod( object, mID, columnIndex ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} + +sal_Int32 SAL_CALL java_sql_CallableStatement::getInt( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "(I)I"; + char * cMethodName = "getInt"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID, columnIndex ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int32)out; +} + +sal_Int64 SAL_CALL java_sql_CallableStatement::getLong( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jlong out; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)columnIndex; + // temporaere Variable initialisieren + char * cSignature = "(I)J"; + char * cMethodName = "getLong"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallLongMethod( object, mID, args[0].i ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} + +Any SAL_CALL java_sql_CallableStatement::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(starsdbc::SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)columnIndex; + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/lang/Object;"; + char * cMethodName = "getObject"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].i); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return Any(); //out==0 ? 0 : new java_lang_Object( t.pEnv, out ); +} + +sal_Int16 SAL_CALL java_sql_CallableStatement::getShort( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jshort out; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)columnIndex; + // temporaere Variable initialisieren + char * cSignature = "(I)S"; + char * cMethodName = "getShort"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallShortMethod( object, mID, args[0].i); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int16)out; +} + +::rtl::OUString SAL_CALL java_sql_CallableStatement::getString( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jstring out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)columnIndex; + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/lang/String;"; + char * cMethodName = "getString"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID, columnIndex ); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} + + ::com::sun::star::util::Time SAL_CALL java_sql_CallableStatement::getTime( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Time;"; + char * cMethodName = "getTime"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return java_sql_Time( t.pEnv, out ); +} + + ::com::sun::star::util::DateTime SAL_CALL java_sql_CallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)columnIndex; + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Timestamp;"; + char * cMethodName = "getTimestamp"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].i); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return java_sql_Timestamp( t.pEnv, out ); +} + +void SAL_CALL java_sql_CallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(starsdbc::SQLException, RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jvalue args[3]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].i = (sal_Int32)sqlType; + args[2].l = convertwchar_tToJavaString(t.pEnv,typeName); + // temporaere Variable initialisieren + char * cSignature = "(IILjava/lang/String;)V"; + char * cMethodName = "registerOutParameter"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].i,args[2].l); + ThrowSQLException(t.pEnv,*this); + t.pEnv->DeleteLocalRef((jstring)args[2].l); + } + } +} +void SAL_CALL java_sql_CallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jvalue args[3]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].i = (sal_Int32)sqlType; + args[2].i = scale; + // temporaere Variable initialisieren + char * cSignature = "(III)V"; + char * cMethodName = "registerOutParameter"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].i,args[2].i); + ThrowSQLException(t.pEnv,*this); + } + } +} + +jclass java_sql_CallableStatement::theClass = 0; + +jclass java_sql_CallableStatement::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( !t.pEnv ) return (jclass)0; + jclass tempClass = t.pEnv->FindClass("java/sql/CallableStatement"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_sql_CallableStatement::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==0 ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_CallableStatement::getBinaryStream( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + Reference< starsdbc::XBlob > xBlob = getBlob(columnIndex); + return xBlob.is() ? xBlob->getBinaryStream() : Reference< ::com::sun::star::io::XInputStream >(); +} +Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_CallableStatement::getCharacterStream( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + Reference< starsdbc::XClob > xClob = getClob(columnIndex); + return xClob.is() ? xClob->getCharacterStream() : Reference< ::com::sun::star::io::XInputStream >(); +} + +Reference< starsdbc::XArray > SAL_CALL java_sql_CallableStatement::getArray( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Ref;"; + char * cMethodName = "getArray"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_Array( t.pEnv, out ); +} + +Reference< starsdbc::XClob > SAL_CALL java_sql_CallableStatement::getClob( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Ref;"; + char * cMethodName = "getClob"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_Clob( t.pEnv, out ); +} +Reference< starsdbc::XBlob > SAL_CALL java_sql_CallableStatement::getBlob( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Ref;"; + char * cMethodName = "getBlob"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_Blob( t.pEnv, out ); +} + +Reference< starsdbc::XRef > SAL_CALL java_sql_CallableStatement::getRef( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Ref;"; + char * cMethodName = "getRef"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_Ref( t.pEnv, out ); +} + + diff --git a/connectivity/source/drivers/jdbc/Class.cxx b/connectivity/source/drivers/jdbc/Class.cxx new file mode 100644 index 000000000000..e11dbd3a3b15 --- /dev/null +++ b/connectivity/source/drivers/jdbc/Class.cxx @@ -0,0 +1,185 @@ +/************************************************************************* + * + * $RCSfile: Class.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_LANG_CLASS_HXX_ +#include "java/lang/Class.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif + +using namespace connectivity; +//************************************************************** +//************ Class: java.lang.Class +//************************************************************** + +jclass java_lang_Class::theClass = 0; + +java_lang_Class::~java_lang_Class() +{} + +jclass java_lang_Class::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass("java/lang/Class"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_lang_Class::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +java_lang_Class * java_lang_Class::forName( const ::rtl::OUString& _par0 ) +{ + jobject out(NULL); + SDBThreadAttach t; + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].l = convertwchar_tToJavaString(t.pEnv,_par0); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;)Ljava/lang/Class;"; + char * cMethodName = "forName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetStaticMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l ); + ThrowSQLException(t.pEnv,0); + // und aufraeumen + t.pEnv->DeleteLocalRef((jstring)args[0].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? NULL : new java_lang_Class( t.pEnv, out ); +} + +sal_Bool java_lang_Class::isAssignableFrom( java_lang_Class * _par0 ) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].l = _par0 != NULL ? ((java_lang_Object *)_par0)->getJavaObject() : NULL; + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/Class;)Z"; + char * cMethodName = "isAssignableFrom"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID, args[0].l ); + ThrowSQLException(t.pEnv,0); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} + +java_lang_Object * java_lang_Class::newInstance() +{ + jobject out(NULL); + SDBThreadAttach t; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/Object;"; + char * cMethodName = "newInstance"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,0); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? NULL : new java_lang_Object( t.pEnv, out ); +} + +::rtl::OUString java_lang_Class::getName() +{ + jstring out = (jstring)NULL; + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,0); + aStr = JavaString2String(t.pEnv, (jstring)out ); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} + diff --git a/connectivity/source/drivers/jdbc/Clob.cxx b/connectivity/source/drivers/jdbc/Clob.cxx new file mode 100644 index 000000000000..661b86541385 --- /dev/null +++ b/connectivity/source/drivers/jdbc/Clob.cxx @@ -0,0 +1,212 @@ +/************************************************************************* + * + * $RCSfile: Clob.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_SQL_CLOB_HXX_ +#include "java/sql/Clob.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_IO_READER_HXX_ +#include "java/io/Reader.hxx" +#endif +using namespace connectivity; +//************************************************************** +//************ Class: java.sql.Clob +//************************************************************** + +jclass java_sql_Clob::theClass = 0; + +java_sql_Clob::~java_sql_Clob() +{} + +jclass java_sql_Clob::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass( "java/sql/Clob" ); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_sql_Clob::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jlong out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()J"; + char * cMethodName = "length"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallLongMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int64)out; +} + +::rtl::OUString SAL_CALL java_sql_Clob::getSubString( sal_Int64 pos, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jstring out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(JI)Ljava/lang/String;"; + char * cMethodName = "getBaseTypeName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID,pos,length); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} + +::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_Clob::getCharacterStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()Ljava/io/Reader;"; + char * cMethodName = "getCharacterStream"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_io_Reader( t.pEnv, out ); +} + +sal_Int64 SAL_CALL java_sql_Clob::position( const ::rtl::OUString& searchstr, sal_Int32 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jlong out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jvalue args[1]; + // Parameter konvertieren + args[0].l = convertwchar_tToJavaString(t.pEnv,searchstr); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;I)J"; + char * cMethodName = "position"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallLongMethod( object, mID, args[0].l,start ); + ThrowSQLException(t.pEnv,*this); + t.pEnv->DeleteLocalRef((jstring)args[0].l); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int64)out; +} + +sal_Int64 SAL_CALL java_sql_Clob::positionOfClob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& pattern, sal_Int64 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jlong out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jvalue args[1]; + // Parameter konvertieren + args[0].l = 0; + // temporaere Variable initialisieren + char * cSignature = "(Ljava/sql/Clob;I)J"; + char * cMethodName = "position"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallLongMethod( object, mID,args[0].l,start ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int64)out; +} + + diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx new file mode 100644 index 000000000000..ff93e7751a38 --- /dev/null +++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx @@ -0,0 +1,3269 @@ +/************************************************************************* + * + * $RCSfile: DatabaseMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_SQL_DATABASEMETADATA_HXX_ +#include "java/sql/DatabaseMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_ +#include "java/sql/Connection.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_RESULTSET_HXX_ +#include "java/sql/ResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_LANG_STRING_HXX_ +#include "java/lang/String.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +//#ifndef _UTL_TYPES_HXX_ +//#include <unotools/types.hxx> +//#endif + +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +//************************************************************** +//************ Class: java.sql.DatabaseMetaData +//************************************************************** + +jclass java_sql_DatabaseMetaData::theClass = 0; + +java_sql_DatabaseMetaData::~java_sql_DatabaseMetaData() +{} + +jclass java_sql_DatabaseMetaData::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( !t.pEnv ) return (jclass)0; + jclass tempClass = t.pEnv->FindClass("java/sql/DatabaseMetaData"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} +// ------------------------------------------------------------------------- + + +void java_sql_DatabaseMetaData::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==0 ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()Ljava/sql/ResultSet;"; + char * cMethodName = "getTypeInfo"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()Ljava/sql/ResultSet;"; + char * cMethodName = "getCatalogs"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getCatalogSeparator( ) throw(SQLException, RuntimeException) +{ + jstring out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getCatalogSeparator"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + char * cSignature = "()Ljava/sql/ResultSet;"; + char * cMethodName = "getSchemas"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out ? new java_sql_ResultSet( t.pEnv, out ) : 0; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumnPrivileges( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[4]; + // temporaere Variable initialisieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema); + args[2].l = convertwchar_tToJavaString(t.pEnv,table); + args[3].l = convertwchar_tToJavaString(t.pEnv,columnNamePattern); + + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getTables"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l,args[3].l); + ThrowSQLException(t.pEnv,*this); + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(table.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + if(columnNamePattern.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[3].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out ? new java_sql_ResultSet( t.pEnv, out ) : 0; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumns( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[3]; + // temporaere Variable initialisieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schemaPattern.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schemaPattern); + args[2].l = convertwchar_tToJavaString(t.pEnv,tableNamePattern); + + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getTables"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l); + ThrowSQLException(t.pEnv,*this); + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(tableNamePattern.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out ? new java_sql_ResultSet( t.pEnv, out ) : 0; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[4]; + sal_Int32 len = types.getLength(); + if(len) + { + jobjectArray pObjArray = t.pEnv->NewObjectArray((jsize) len, java_lang_String::getMyClass(), 0); + const ::rtl::OUString* pBegin = types.getConstArray(); + for(sal_Int32 i=0;i<len;i++,++pBegin) + { + jstring aT = convertwchar_tToJavaString(t.pEnv,*pBegin); + //jstring aT = t.pEnv->NewStringUTF(_par3.GetToken(i)); + t.pEnv->SetObjectArrayElement(pObjArray,(jsize)i,aT); + } + args[3].l = pObjArray; + }else + args[3].l = 0; + // temporaere Variable initialisieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schemaPattern.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schemaPattern); + args[2].l = convertwchar_tToJavaString(t.pEnv,tableNamePattern); + + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getTables"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l,args[3].l); + ThrowSQLException(t.pEnv,*this); + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(tableNamePattern.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + //for(INT16 i=0;i<len;i++) + t.pEnv->DeleteLocalRef((jobjectArray)args[3].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out ? new java_sql_ResultSet( t.pEnv, out ) : 0; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getProcedureColumns( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jvalue args[4]; + // Parameter konvertieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schemaPattern.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schemaPattern); + args[2].l = convertwchar_tToJavaString(t.pEnv,procedureNamePattern); + args[3].l = convertwchar_tToJavaString(t.pEnv,columnNamePattern); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getProcedures"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(procedureNamePattern.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + if(columnNamePattern.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[3].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getProcedures( const Any& + catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jvalue args[3]; + // Parameter konvertieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schemaPattern.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schemaPattern); + args[2].l = convertwchar_tToJavaString(t.pEnv,procedureNamePattern); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getProcedures"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(procedureNamePattern.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getVersionColumns( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[3]; + // Parameter konvertieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema); + args[2].l = convertwchar_tToJavaString(t.pEnv,table); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getVersionColumns"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(table.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxBinaryLiteralLength"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxRowSize"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxCatalogNameLength"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxCharLiteralLength"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxColumnNameLength"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxColumnsInIndex"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxCursorNameLength"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxConnections"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxColumnsInTable"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxStatementLength"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxTableNameLength"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxTablesInSelect( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxTablesInSelect"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getExportedKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[3]; + // Parameter konvertieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema); + args[2].l = convertwchar_tToJavaString(t.pEnv,table); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getExportedKeys"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(table.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getImportedKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[3]; + // Parameter konvertieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema); + args[2].l = convertwchar_tToJavaString(t.pEnv,table); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getImportedKeys"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(table.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getPrimaryKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[3]; + // Parameter konvertieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema); + args[2].l = convertwchar_tToJavaString(t.pEnv,table); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getPrimaryKeys"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(table.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getIndexInfo( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, + sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[5]; + // Parameter konvertieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema); + args[2].l = convertwchar_tToJavaString(t.pEnv,table); + args[3].z = unique; + args[4].z = approximate; + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/sql/ResultSet;"; + char * cMethodName = "getIndexInfo"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l,args[3].z,args[4].z ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(table.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getBestRowIdentifier( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, + sal_Bool nullable ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[3]; + // Parameter konvertieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema); + args[2].l = convertwchar_tToJavaString(t.pEnv,table); + + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getTablePrivileges"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l,scope,nullable); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(table.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTablePrivileges( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[3]; + // Parameter konvertieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schemaPattern.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schemaPattern); + args[2].l = convertwchar_tToJavaString(t.pEnv,tableNamePattern); + + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getTablePrivileges"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(tableNamePattern.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getCrossReference( + const Any& primaryCatalog, const ::rtl::OUString& primarySchema, + const ::rtl::OUString& primaryTable, const Any& foreignCatalog, + const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[6]; + // Parameter konvertieren + args[0].l = primaryCatalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(primaryCatalog)) : 0; + args[1].l = primarySchema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,primarySchema); + args[2].l = convertwchar_tToJavaString(t.pEnv,primaryTable); + args[3].l = foreignCatalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(foreignCatalog)) : 0; + args[4].l = foreignSchema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,foreignSchema); + args[5].l = convertwchar_tToJavaString(t.pEnv,foreignTable); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getCrossReference"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[2].l,args[2].l,args[3].l,args[4].l,args[5].l ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + if(primaryCatalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(args[1].l) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(primaryTable.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + if(foreignCatalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[3].l); + if(args[4].l) + t.pEnv->DeleteLocalRef((jstring)args[4].l); + if(foreignTable.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[5].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "doesMaxRowSizeIncludeBlobs"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "storesLowerCaseQuotedIdentifiers"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "storesLowerCaseIdentifiers"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "storesMixedCaseQuotedIdentifiers"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "storesMixedCaseIdentifiers"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "storesUpperCaseQuotedIdentifiers"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "storesUpperCaseIdentifiers"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsAlterTableWithAddColumn"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsAlterTableWithDropColumn"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxIndexLength"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsNonNullableColumns"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)0; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getCatalogTerm"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getIdentifierQuoteString( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)0; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getIdentifierQuoteString"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)0; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getExtraNameCharacters"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsDifferentTableCorrelationNames"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::isCatalogAtStart( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "isCatalogAtStart"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "dataDefinitionIgnoredInTransactions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "dataDefinitionCausesTransactionCommit"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsDataManipulationTransactionsOnly"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsDataDefinitionAndDataManipulationTransactions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsPositionedDelete"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsPositionedUpdate"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsOpenStatementsAcrossRollback"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsOpenStatementsAcrossCommit"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsOpenCursorsAcrossCommit"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsOpenCursorsAcrossRollback"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "supportsTransactionIsolationLevel"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID, level); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInDataManipulation( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsSchemasInDataManipulation"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsANSI92FullSQL"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsANSI92EntryLevelSQL"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsIntegrityEnhancementFacility"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsSchemasInIndexDefinitions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInTableDefinitions( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsSchemasInTableDefinitions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsCatalogsInTableDefinitions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsCatalogsInIndexDefinitions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsCatalogsInDataManipulation"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsOuterJoins"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/sql/ResultSet;"; + char * cMethodName = "getTableTypes"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxStatements( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxStatements"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxProcedureNameLength"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxSchemaNameLength"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsTransactions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "allProceduresAreCallable"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsStoredProcedures"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsSelectForUpdate"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "allTablesAreSelectable"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "isReadOnly"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "usesLocalFiles"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "usesLocalFilePerTable"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsTypeConversion"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "nullPlusNonNullIsNull"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsColumnAliasing"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsTableCorrelationNames"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)fromType; + args[1].i = (sal_Int32)toType; + // temporaere Variable initialisieren + char * cSignature = "(II)Z"; + char * cMethodName = "supportsConvert"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID, args[0].i,args[0].i ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsExpressionsInOrderBy"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsGroupBy"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsGroupByBeyondSelect"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsGroupByUnrelated"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsMultipleTransactions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsMultipleResultSets"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsLikeEscapeClause"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsOrderByUnrelated"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsUnion"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsUnionAll"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsMixedCaseIdentifiers"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsMixedCaseQuotedIdentifiers"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "nullsAreSortedAtEnd"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "nullsAreSortedAtStart"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "nullsAreSortedHigh"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "nullsAreSortedLow"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsSchemasInProcedureCalls"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsSchemasInPrivilegeDefinitions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsCatalogsInProcedureCalls"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsCatalogsInPrivilegeDefinitions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsCorrelatedSubqueries"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsSubqueriesInComparisons"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsSubqueriesInExists"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsSubqueriesInIns"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsSubqueriesInQuantifieds"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsANSI92IntermediateSQL"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) +{ + + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getURL"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getUserName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)NULL; + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getDriverName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDriverVersion( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)NULL; + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getDriverVersion"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getDatabaseProductVersion"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getDatabaseProductName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)NULL; + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getProcedureTerm"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)NULL; + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getSchemaTerm"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException) +{ + jint out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getDriverMajorVersion"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException) +{ + jint out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getDefaultTransactionIsolation"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException) +{ + jint out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getDriverMinorVersion"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)NULL; + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getSQLKeywords"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)NULL; + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getSearchStringEscape"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)NULL; + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getStringFunctions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)NULL; + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getTimeDateFunctions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)NULL; + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getSystemFunctions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException) +{ + jstring out = (jstring)NULL; + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getNumericFunctions"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsExtendedSQLGrammar"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsCoreSQLGrammar"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsMinimumSQLGrammar"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsFullOuterJoins"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException) +{ + jboolean out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsLimitedOuterJoins"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException) +{ + jint out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxColumnsInGroupBy"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException) +{ + jint out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxColumnsInOrderBy"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException) +{ + jint out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxColumnsInSelect"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException) +{ + jint out; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMaxUserNameLength"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "supportsResultSetType"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,setType); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(II)Z"; + char * cMethodName = "supportsResultSetConcurrency"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,setType,concurrency); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "ownUpdatesAreVisible"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,setType); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "ownDeletesAreVisible"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,setType); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "ownInsertsAreVisible"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,setType); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "othersUpdatesAreVisible"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,setType); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "othersDeletesAreVisible"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,setType); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "othersInsertsAreVisible"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,setType); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::updatesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "updatesAreDetected"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,setType); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::deletesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "deletesAreDetected"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,setType); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::insertsAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "insertsAreDetected"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,setType); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "supportsBatchUpdates"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getUDTs( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, + const Sequence< sal_Int32 >& types ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[4]; + // temporaere Variable initialisieren + args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,connectivity::getString(catalog)) : 0; + args[1].l = schemaPattern.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schemaPattern); + args[2].l = convertwchar_tToJavaString(t.pEnv,typeNamePattern); + jintArray pArray = t.pEnv->NewIntArray(types.getLength()); + t.pEnv->SetIntArrayRegion(pArray,0,types.getLength(),(jint*)types.getConstArray()); + args[3].l = pArray; + + char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;"; + char * cMethodName = "getTables"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l,args[3].l); + ThrowSQLException(t.pEnv,*this); + if(catalog.hasValue()) + t.pEnv->DeleteLocalRef((jstring)args[0].l); + if(schemaPattern.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[1].l); + if(typeNamePattern.getLength()) + t.pEnv->DeleteLocalRef((jstring)args[2].l); + if(args[3].l) + t.pEnv->DeleteLocalRef((jintArray)args[3].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out ? new java_sql_ResultSet( t.pEnv, out ) : 0; +} +// ------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL java_sql_DatabaseMetaData::getConnection( ) throw(SQLException, RuntimeException) +{ +// jobject out(0); +// SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); +// if( t.pEnv ){ +// char * cSignature = "()Ljava/sql/Connection;"; +// char * cMethodName = "getConnection"; +// // Java-Call absetzen +// jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); +// if( mID ) +// { +// out = t.pEnv->CallObjectMethod( object, mID); +// ThrowSQLException(t.pEnv,*this); +// } //mID +// } //t.pEnv +// // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! +// return out ? new java_sql_Connection( t.pEnv, out,this ) : 0; + return (Reference< XConnection >)m_pConnection; +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/jdbc/Date.cxx b/connectivity/source/drivers/jdbc/Date.cxx new file mode 100644 index 000000000000..d024ae0ddbed --- /dev/null +++ b/connectivity/source/drivers/jdbc/Date.cxx @@ -0,0 +1,225 @@ +/************************************************************************* + * + * $RCSfile: Date.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_UTIL_DATE_HXX_ +#include "java/util/Date.hxx" +#endif + +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ +#include "DateConversion.hxx" +#endif + +using namespace connectivity; +//************************************************************** +//************ Class: java.util.Date +//************************************************************** + +jclass java_util_Date::theClass = 0; + +java_util_Date::java_util_Date( const ::com::sun::star::util::Date& _rOut ) //: java_lang_Object( NULL, (jobject)NULL ){ +{ + SDBThreadAttach t; + if( !t.pEnv ) + return; + jvalue args[1]; + // Parameter konvertieren + args[0].j = DateConversion::toINT32(_rOut); + // Java-Call fuer den Konstruktor absetzen + // temporaere Variable initialisieren + char * cSignature = "(J)V"; + jobject tempObj; + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature ); + tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args ); + saveRef( t.pEnv, tempObj ); + t.pEnv->DeleteLocalRef( tempObj ); + // und aufraeumen +} + +java_util_Date::~java_util_Date() +{} + +jclass java_util_Date::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass( "java/util/Date" ); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_util_Date::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +sal_Int32 java_util_Date::getMinutes() +{ + jint out(0); + SDBThreadAttach t; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMinutes"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + } //mID + } //t.pEnv + return (sal_Int32)out; +} + +sal_Int32 java_util_Date::getMonth() +{ + jint out(0); + SDBThreadAttach t; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMonth"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + } //mID + } //t.pEnv + return (sal_Int32)out; +} + +sal_Int32 java_util_Date::getSeconds() +{ + jint out(0); + SDBThreadAttach t; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getSeconds"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + } //mID + } //t.pEnv + return (sal_Int32)out; +} + +sal_Int32 java_util_Date::getYear() +{ + jint out(0); + SDBThreadAttach t; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getYear"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + } //mID + } //t.pEnv + return (sal_Int32)out; +} + +sal_Int32 java_util_Date::getDate() +{ + jint out(0); + SDBThreadAttach t; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getDate"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + } //mID + } //t.pEnv + return (sal_Int32)out; +} + +sal_Int32 java_util_Date::getHours() +{ + jint out(0); + SDBThreadAttach t; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getHours"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + } //mID + } //t.pEnv + return (sal_Int32)out; +} + diff --git a/connectivity/source/drivers/jdbc/DriverManager.cxx b/connectivity/source/drivers/jdbc/DriverManager.cxx new file mode 100644 index 000000000000..bc20c0147e97 --- /dev/null +++ b/connectivity/source/drivers/jdbc/DriverManager.cxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * $RCSfile: DriverManager.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_SQL_DRIVERMANAGER_HXX_ +#include "java/sql/DriverManager.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif + +using namespace connectivity; +//************************************************************** +//************ Class: java.sql.DriverManager +//************************************************************** + +jclass java_sql_DriverManager::theClass = 0; + +java_sql_DriverManager::~java_sql_DriverManager() +{} + +jclass java_sql_DriverManager::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( !t.pEnv ) return (jclass)0; + jclass tempClass = t.pEnv->FindClass("java/sql/DriverManager"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_sql_DriverManager::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==0 ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +jobject java_sql_DriverManager::getDriver(const ::rtl::OUString &url) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jvalue args[1]; + // Parameter konvertieren + args[0].l = convertwchar_tToJavaString(t.pEnv,url); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;)Ljava/sql/Driver;"; + char * cMethodName = "getDriver"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetStaticMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l ); + ThrowSQLException(t.pEnv,0); + // und aufraeumen + t.pEnv->DeleteLocalRef((jstring)args[0].l); + } //mID + return t.pEnv->NewGlobalRef( out ); + } //t.pEnv + + return out; +} + + +void java_sql_DriverManager::setLoginTimeout(sal_Int32 _par0) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + jobject out(0); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)V"; + char * cMethodName = "setLoginTimeout"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + t.pEnv->CallStaticVoidMethod(getMyClass(), mID, _par0); + ThrowSQLException(t.pEnv,0); + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! +} + + diff --git a/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx b/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx new file mode 100644 index 000000000000..b38b2dbfb92b --- /dev/null +++ b/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx @@ -0,0 +1,191 @@ +/************************************************************************* + * + * $RCSfile: DriverPropertyInfo.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_SQL_DRIVERPOPERTYINFO_HXX_ +#include "java/sql/DriverPropertyInfo.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_LANG_BOOLEAN_HXX_ +#include "java/lang/Boolean.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_LANG_STRING_HXX_ +#include "java/lang/String.hxx" +#endif +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + + +//************************************************************** +//************ Class: java.sql.Driver +//************************************************************** + +jclass java_sql_DriverPropertyInfo::theClass = 0; +// -------------------------------------------------------------------------------- +java_sql_DriverPropertyInfo::~java_sql_DriverPropertyInfo() +{} +// -------------------------------------------------------------------------------- +jclass java_sql_DriverPropertyInfo::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ) + { + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( !t.pEnv ) return (jclass)0; + jclass tempClass = t.pEnv->FindClass("java/sql/DriverPropertyInfo"); + OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} +// -------------------------------------------------------------------------------- +void java_sql_DriverPropertyInfo::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==0 ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} +// -------------------------------------------------------------------------------- +java_sql_DriverPropertyInfo::operator starsdbc::DriverPropertyInfo() +{ + starsdbc::DriverPropertyInfo aInfo; + aInfo.Name = name(); + aInfo.Description = description(); + aInfo.IsRequired = required(); + aInfo.Value = value(); + aInfo.Choices = choices(); + + return aInfo; +} +// -------------------------------------------------------------------------------- +::rtl::OUString java_sql_DriverPropertyInfo::name() const +{ + ::rtl::OUString aStr; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jfieldID id = t.pEnv->GetFieldID(java_lang_Boolean::getMyClass(),"name","Ljava/lang/String;"); + if(id) + aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id)); + } //t.pEnv + return aStr; +} +// -------------------------------------------------------------------------------- +::rtl::OUString java_sql_DriverPropertyInfo::description() const +{ + ::rtl::OUString aStr; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jfieldID id = t.pEnv->GetFieldID(java_lang_Boolean::getMyClass(),"description","Ljava/lang/String;"); + if(id) + aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id)); + } //t.pEnv + return aStr; +} +// -------------------------------------------------------------------------------- +::rtl::OUString java_sql_DriverPropertyInfo::value() const +{ + ::rtl::OUString aStr; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jfieldID id = t.pEnv->GetFieldID(java_lang_Boolean::getMyClass(),"value","Ljava/lang/String;"); + if(id) + aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id)); + } //t.pEnv + return aStr; +} +// -------------------------------------------------------------------------------- +sal_Bool java_sql_DriverPropertyInfo::required() const +{ + jboolean out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jfieldID id = t.pEnv->GetFieldID(java_lang_Boolean::getMyClass(),"required","B"); + if(id) + out = t.pEnv->GetBooleanField( object, id); + } //t.pEnv + return out; +} +// -------------------------------------------------------------------------------- +Sequence< ::rtl::OUString> java_sql_DriverPropertyInfo::choices() const +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jfieldID id = t.pEnv->GetFieldID(java_lang_Boolean::getMyClass(),"choices","[Ljava/lang/String"); + if(id) + return copyArrayAndDelete(t.pEnv,(jobjectArray)t.pEnv->GetObjectField( object, id), ::rtl::OUString(),java_lang_String(NULL,NULL)); + } //t.pEnv + return Sequence< ::rtl::OUString>(); +} +// -------------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/jdbc/Exception.cxx b/connectivity/source/drivers/jdbc/Exception.cxx new file mode 100644 index 000000000000..9d579b2f226f --- /dev/null +++ b/connectivity/source/drivers/jdbc/Exception.cxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * $RCSfile: Exception.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ +#include "java/lang/Exception.hxx" +using namespace connectivity; +//************************************************************** +//************ Class: java.lang.Exception +//************************************************************** + +jclass java_lang_Exception::theClass = 0; + +java_lang_Exception::~java_lang_Exception() +{} + +jclass java_lang_Exception::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass("java/lang/Exception"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_lang_Exception::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + diff --git a/connectivity/source/drivers/jdbc/InputStream.cxx b/connectivity/source/drivers/jdbc/InputStream.cxx new file mode 100644 index 000000000000..566c0dd02df7 --- /dev/null +++ b/connectivity/source/drivers/jdbc/InputStream.cxx @@ -0,0 +1,187 @@ +/************************************************************************* + * + * $RCSfile: InputStream.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_IO_INPUTSTREAM_HXX_ +#include "java/io/InputStream.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _INC_MEMORY +#include <memory.h> +#endif + +using namespace connectivity; +//************************************************************** +//************ Class: java.io.InputStream +//************************************************************** + +jclass java_io_InputStream::theClass = 0; + +java_io_InputStream::~java_io_InputStream() +{} + +jclass java_io_InputStream::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass( "java/io/InputStream" ); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_io_InputStream::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +sal_Int32 SAL_CALL java_io_InputStream::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + return readBytes(aData,nMaxBytesToRead); +} + +void SAL_CALL java_io_InputStream::skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + char * cSignature = "(I)I"; + char * cMethodName = "skip"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = t.pEnv->CallIntMethod( object, mID,nBytesToSkip); + ThrowSQLException(t.pEnv,*this); + } + } //t.pEnv +} + +sal_Int32 SAL_CALL java_io_InputStream::available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + char * cSignature = "()Z"; + char * cMethodName = "available"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } + } //t.pEnv + return out; +} +void SAL_CALL java_io_InputStream::closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + char * cSignature = "()V"; + char * cMethodName = "close"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } + } //t.pEnv +} +// ----------------------------------------------------- +sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jbyteArray pByteArray = t.pEnv->NewByteArray(nBytesToRead); + char * cSignature = "([BII)I"; + char * cMethodName = "read"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + while(!(out = t.pEnv->CallIntMethod( object, mID,pByteArray,0,nBytesToRead))) + ThrowSQLException(t.pEnv,*this); + if(out > 0) + { + jboolean p = sal_False; + memcpy(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out); + } + } + t.pEnv->DeleteLocalRef((jbyteArray)pByteArray); + } //t.pEnv + return out; +} + + diff --git a/connectivity/source/drivers/jdbc/JDriver.cxx b/connectivity/source/drivers/jdbc/JDriver.cxx new file mode 100644 index 000000000000..80e1a7013623 --- /dev/null +++ b/connectivity/source/drivers/jdbc/JDriver.cxx @@ -0,0 +1,295 @@ +/************************************************************************* + * + * $RCSfile: JDriver.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_SQL_DRIVER_HXX_ +#include "java/sql/Driver.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_DRIVERMANAGER_HXX_ +#include "java/sql/DriverManager.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_DRIVERPOPERTYINFO_HXX_ +#include "java/sql/DriverPropertyInfo.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_ +#include "java/sql/Connection.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif + +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +// ------------------------------------------------------------------------- +java_sql_Driver::java_sql_Driver(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) + : java_lang_Object(_rxFactory) +{ +} +// -------------------------------------------------------------------------------- +jclass java_sql_Driver::theClass = 0; +// -------------------------------------------------------------------------------- +java_sql_Driver::~java_sql_Driver() +{} +// static ServiceInfo +//------------------------------------------------------------------------------ +rtl::OUString java_sql_Driver::getImplementationName_Static( ) throw(RuntimeException) +{ + return ::rtl::OUString::createFromAscii("com.sun.star.sdbc.JDriver"); +} +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > java_sql_Driver::getSupportedServiceNames_Static( ) throw (RuntimeException) +{ + Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver"); + return aSNS; +} +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::java_sql_Driver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ) +{ + return *(new java_sql_Driver(_rxFactory)); +} +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_Driver::getImplementationName( ) throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_Driver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) + if (pSupported->equals(_rServiceName)) + return sal_True; + + return sal_False; +} + +// -------------------------------------------------------------------------------- +Sequence< ::rtl::OUString > SAL_CALL java_sql_Driver::getSupportedServiceNames( ) throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +// -------------------------------------------------------------------------------- +jclass java_sql_Driver::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ) + { + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( !t.pEnv ) return (jclass)0; + jclass tempClass = t.pEnv->FindClass("java/sql/Driver"); + OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} +// -------------------------------------------------------------------------------- +void java_sql_Driver::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==0 ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} +// ------------------------------------------------------------------------- +Reference< starsdbc::XConnection > SAL_CALL java_sql_Driver::connect( const ::rtl::OUString& url, const + Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(starsdbc::SQLException, RuntimeException) +{ + Reference< starsdbc::XConnection > xRet; + + object = java_sql_DriverManager::getDriver(url); + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jvalue args[2]; + // Parameter konvertieren + args[0].l = convertwchar_tToJavaString(t.pEnv,url); + args[1].l = createStringPropertyArray(t.pEnv,info); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;Ljava/util/Properties)Ljava/sql/Connection;"; + char * cMethodName = "connect"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = t.pEnv->CallObjectMethodA( getMyClass(), mID, args ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + t.pEnv->DeleteLocalRef((jstring)args[0].l); + t.pEnv->DeleteLocalRef((jstring)args[1].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + Reference< starsdbc::XConnection > xOut; + return out==0 ? 0 : new java_sql_Connection( t.pEnv, out,this ); + // return xOut; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_Driver::acceptsURL( const ::rtl::OUString& url ) throw(starsdbc::SQLException, RuntimeException) +{ + if(!object) + object = java_sql_DriverManager::getDriver(url); + + jboolean out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + if(!object) + ThrowSQLException(t.pEnv,*this); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;)Z"; + char * cMethodName = "acceptsURL"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +Sequence< starsdbc::DriverPropertyInfo > SAL_CALL java_sql_Driver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(starsdbc::SQLException, RuntimeException) +{ + if(!object) + object = java_sql_DriverManager::getDriver(url); + + jobjectArray out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jvalue args[2]; + // Parameter konvertieren + args[0].l = convertwchar_tToJavaString(t.pEnv,url); + args[1].l = createStringPropertyArray(t.pEnv,info); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;Ljava/util/Properties)[Ljava/sql/DriverPropertyInfo;"; + char * cMethodName = "getPropertyInfo"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = (jobjectArray)t.pEnv->CallObjectMethodA( getMyClass(), mID, args ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + t.pEnv->DeleteLocalRef((jstring)args[0].l); + t.pEnv->DeleteLocalRef((jstring)args[1].l); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return copyArrayAndDelete( t.pEnv, out, starsdbc::DriverPropertyInfo(),java_sql_DriverPropertyInfo(NULL,NULL)); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_Driver::getMajorVersion( ) throw(RuntimeException) +{ + if(!object) + throw RuntimeException(); + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMajorVersion"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_Driver::getMinorVersion( ) throw(RuntimeException) +{ + if(!object) + throw RuntimeException(); + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getMinorVersion"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx new file mode 100644 index 000000000000..c1caef75578e --- /dev/null +++ b/connectivity/source/drivers/jdbc/Object.cxx @@ -0,0 +1,396 @@ +/************************************************************************* + * + * $RCSfile: Object.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_LANG_OBJJECT_HXX_ +#include "java/lang/Class.hxx" +#endif + +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include <com/sun/star/uno/Exception.hpp> +#endif +#ifndef _COM_SUN_STAR_JAVA_XJAVATHREADREGISTER_11_HPP_ +#include <com/sun/star/java/XJavaThreadRegister_11.hpp> +#endif +#ifndef _COM_SUN_STAR_JAVA_XJAVAVM_HPP_ +#include <com/sun/star/java/XJavaVM.hpp> +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_SQLEXCEPTION_HXX_ +#include "java/sql/SQLException.hxx" +#endif +#ifndef _VOS_MODULE_HXX_ +#include <vos/module.hxx> +#endif +#ifndef _VOS_PROCESS_HXX_ +#include <vos/process.hxx> +#endif +#ifndef _VOS_MUTEX_HXX_ +#include <vos/mutex.hxx> +#endif +#ifndef _VOS_DYNLOAD_HXX_ +#include <vos/dynload.hxx> +#endif + +#ifndef _RTL_PROCESS_H_ +#include <rtl/process.h> +#endif + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif + +using namespace connectivity; + +namespace starjava = com::sun::star::java; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + + +JavaVM * pJVM; +Reference< ::starjava::XJavaThreadRegister_11 > xRG11Ref; +sal_Bool bJRE_Error = sal_False; +JavaVM_ * pJRE_javaVM = NULL; + +int SDB_JRE_InitJava(const Reference<XMultiServiceFactory >& _rxFactory) +{ + int result = 0; + JNIEnv * pEnv = NULL; + + try + { + Reference< ::starjava::XJavaVM > xVM(_rxFactory->createInstance( + rtl::OUString::createFromAscii("com.sun.star.java.JavaVirtualMachine")), UNO_QUERY); + + OSL_ENSHURE(_rxFactory.is(),"SDB_JRE_InitJava: I have no factory!"); + if (!xVM.is() || !_rxFactory.is()) + throw Exception(); // -2; + + Sequence<sal_Int8> processID(16); + rtl_getGlobalProcessId( (sal_uInt8*) processID.getArray() ); + + Any uaJVM = xVM->getJavaVM( processID ); + + if (!uaJVM.hasValue()) + throw Exception(); // -5 + else + { + sal_Int32 nValue; + uaJVM >>= nValue; + pJVM = (JavaVM *)nValue; + } + + xRG11Ref = Reference< ::starjava::XJavaThreadRegister_11 >(xVM, UNO_QUERY); + if (xRG11Ref.is()) + xRG11Ref->registerThread(); + + pJVM->AttachCurrentThread(reinterpret_cast<void**>(&pEnv), NULL); + + /** + * Ist zur Zeit nicht funktionsfaehig, wegen Solaris Deadlock. + */ +// initStreamObserver(pEnv); +// if(pEnv->ExceptionOccurred()) +// { +// pEnv->ExceptionDescribe(); +// pEnv->ExceptionClear(); +// } + + } + catch (Exception e) + { + if (pEnv && pEnv->ExceptionOccurred()) + { + pEnv->ExceptionDescribe(); + pEnv->ExceptionClear(); + } + + result = -1; + } + + if(pEnv) + { + if(xRG11Ref.is()) + xRG11Ref->revokeThread(); + + if(!xRG11Ref.is() || !xRG11Ref->isThreadAttached()) + pJVM->DetachCurrentThread(); + } + + return result; +} + +SDBThreadAttach::SDBThreadAttach() : bDetach(sal_False), pEnv(NULL) +{ + attachThread(pEnv); +} + +SDBThreadAttach::SDBThreadAttach(const Reference<XMultiServiceFactory >& _rxFactory) : bDetach(sal_False), pEnv(NULL) +{ + attachThread(pEnv,_rxFactory); +} + +SDBThreadAttach::~SDBThreadAttach() +{ + detachThread(); +} + +void SDBThreadAttach::attachThread(JNIEnv * &pEnv,const Reference<XMultiServiceFactory >& _rxFactory) +{ + xInit(_rxFactory); + + if(xRG11Ref.is()) + { + xRG11Ref->registerThread(); + pJVM->AttachCurrentThread(reinterpret_cast<void**>(&pEnv), NULL); + } +} + +void SDBThreadAttach::detachThread() +{ + xInit(); + + if(xRG11Ref.is()) + { + xRG11Ref->revokeThread(); + if(!xRG11Ref->isThreadAttached()) + pJVM->DetachCurrentThread(); + } +} + +void SDBThreadAttach::xInit(const Reference<XMultiServiceFactory >& _rxFactory) +{ + StartJava(_rxFactory); +} + +sal_Bool SDBThreadAttach::IsJavaErrorOccured() +{ + return bJRE_Error; +} + +void SDBThreadAttach::setError() +{ + bJRE_Error = sal_True; +} + +static sal_Bool bStarted = sal_False; +int SDBThreadAttach::StartJava(const Reference<XMultiServiceFactory >& _rxFactory) +{ + static sal_Bool bRecFlag = sal_False; + static int err = 0; + if( !bStarted ) + { + vos::OGuard aGuard( vos::OMutex::getGlobalMutex() ); + if( !bStarted && !bRecFlag) + { + bRecFlag = sal_True; + // Application::EnterMultiThread(); + // bStarted = sal_True must set after the VM is complete initialized + err = SDB_JRE_InitJava(_rxFactory); + if(err) + setError(); + bStarted = sal_True; + } + } +// return bJRE_Error ? -1 : 0; + return err; +} + +// statische Variablen der Klasse: +jclass java_lang_Object::theClass = 0; +sal_uInt32 java_lang_Object::nObjCount = 0; + +jclass java_lang_Object::getMyClass() +{ + if( !theClass ) + { +// JNIEnv * pEnv = SDBThreadAttach::GetEnv(); + SDBThreadAttach t; + + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass( "java/lang/Object" ); + theClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + } + return theClass; +} +// der eigentliche Konstruktor +java_lang_Object::java_lang_Object(const Reference<XMultiServiceFactory >& _rxFactory) + : object( 0 ),m_xFactory(_rxFactory) +{ + SDBThreadAttach t(m_xFactory); + if( !t.pEnv ) + return; + + // Java-Call fuer den Konstruktor absetzen + // temporaere Variable initialisieren + char * cSignature = "()V"; + jclass tempClass; + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature ); + tempClass = (jclass)t.pEnv->NewObjectA( getMyClass(), mID, NULL ); + saveRef( t.pEnv, tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); +} + +// der protected-Konstruktor fuer abgeleitete Klassen +java_lang_Object::java_lang_Object( JNIEnv * pXEnv, jobject myObj ) + : object( NULL ) +{ + SDBThreadAttach t; + if( t.pEnv && myObj ) + object = t.pEnv->NewGlobalRef( myObj ); +} + +java_lang_Object::~java_lang_Object() +{ + if( object ) + { + SDBThreadAttach t; + if( t.pEnv ) + t.pEnv->DeleteGlobalRef( object ); + } +} + +// der protected-Konstruktor fuer abgeleitete Klassen +void java_lang_Object::saveRef( JNIEnv * pXEnv, jobject myObj ) +{ + OSL_ENSHURE( myObj, "object in c++ -> Java Wrapper" ); + SDBThreadAttach t; + if( t.pEnv && myObj ) + object = t.pEnv->NewGlobalRef( myObj ); +} + + +java_lang_Class * java_lang_Object::getClass() +{ + jobject out; + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/Class;"; + char * cMethodName = "getClass"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = t.pEnv->CallObjectMethodA( object, mID, NULL ); + + return new java_lang_Class( t.pEnv, out ); + } //mID + } //pEnv + return NULL; +} + +::rtl::OUString java_lang_Object::toString() +{ + + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "toString"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + jstring out(0); + out = (jstring)t.pEnv->CallObjectMethod( object, mID); + + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //pEnv + return aStr; +} +// -------------------------------------------------------------------------------- +void java_lang_Object::ThrowSQLException(JNIEnv * pEnv,const Reference< XInterface> & _rContext) throw(SQLException, RuntimeException) +{ + jthrowable jThrow = NULL; + if(pEnv && (jThrow = pEnv->ExceptionOccurred())) + { + if(pEnv->IsInstanceOf(jThrow,java_sql_SQLException_BASE::getMyClass())) + { + throw java_sql_SQLException(java_sql_SQLException_BASE(pEnv,jThrow),_rContext); + } + else if(pEnv->IsInstanceOf(jThrow,java_lang_Throwable::getMyClass())) + { + java_lang_Throwable *pThrow = new java_lang_Throwable(pEnv,jThrow); + ::rtl::OUString aMsg = pThrow->getMessage(); + delete pThrow; + throw RuntimeException(aMsg,_rContext); + } + pEnv->ExceptionClear(); + } +} + + diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx new file mode 100644 index 000000000000..4b7a5dd70e07 --- /dev/null +++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx @@ -0,0 +1,842 @@ +/************************************************************************* + * + * $RCSfile: PreparedStatement.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_SQL_PREPAREDSTATEMENT_HXX_ +#include "java/sql/PreparedStatement.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_RESULTSET_HXX_ +#include "java/sql/ResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_ +#include "java/sql/Connection.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_TIMESTAMP_HXX_ +#include "java/sql/Timestamp.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif + +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +//************************************************************** +//************ Class: java.sql.PreparedStatement +//************************************************************** +IMPLEMENT_SERVICE_INFO(java_sql_PreparedStatement,"com.sun.star.sdbcx.JPreparedStatement","com.sun.star.sdbc.PreparedStatement"); + +jclass java_sql_PreparedStatement::theClass = 0; + +java_sql_PreparedStatement::~java_sql_PreparedStatement() +{} + +jclass java_sql_PreparedStatement::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( !t.pEnv ) return (jclass)0; + jclass tempClass = t.pEnv->FindClass("java/sql/PreparedStatement"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} +// ------------------------------------------------------------------------- + +void java_sql_PreparedStatement::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==0 ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} +// ------------------------------------------------------------------------- + +::com::sun::star::uno::Any SAL_CALL java_sql_PreparedStatement::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = OStatement_BASE2::queryInterface(rType); + if(!aRet.hasValue()) + aRet = ::cppu::queryInterface( rType, + static_cast< XPreparedStatement*>(this), + static_cast< XParameters*>(this), + static_cast< XPreparedBatchExecution*>(this)); + return aRet; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_PreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedBatchExecution > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OStatement_BASE2::getTypes()); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_PreparedStatement::execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "execute"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL java_sql_PreparedStatement::executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "executeUpdate"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = parameterIndex; + args[1].l = convertwchar_tToJavaString(t.pEnv,x); + // temporaere Variable initialisieren + char * cSignature = "(ILjava/lang/String;)V"; + char * cMethodName = "setString"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + t.pEnv->DeleteLocalRef((jstring)args[1].l); + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL java_sql_PreparedStatement::getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ +// jobject out(0); +// SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); +// if( t.pEnv ){ +// +// // temporaere Variable initialisieren +// char * cSignature = "()Ljava/sql/Connection;"; +// char * cMethodName = "getConnection"; +// // Java-Call absetzen +// jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); +// if( mID ){ +// out = t.pEnv->CallObjectMethod( object, mID); +// ThrowSQLException(t.pEnv,*this); +// } //mID +// } //t.pEnv +// // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! +// return out==0 ? 0 : new java_sql_Connection( t.pEnv, out ); + return (Reference< XConnection >)m_pConnection; +} +// ------------------------------------------------------------------------- + +::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_PreparedStatement::executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/sql/ResultSet;"; + char * cMethodName = "executeQuery"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].z = x; + // temporaere Variable initialisieren + char * cSignature = "(IZ)V"; + char * cMethodName = "setBoolean"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].z); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].b = x; + // temporaere Variable initialisieren + char * cSignature = "(IB)V"; + char * cMethodName = "setByte"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].b); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = parameterIndex; + java_sql_Date aT(x); + args[1].l = aT.getJavaObject(); + // temporaere Variable initialisieren + char * cSignature = "(ILjava/sql/Date;)V"; + char * cMethodName = "setDate"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + + +void SAL_CALL java_sql_PreparedStatement::setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + java_sql_Time aT(x); + args[1].l = aT.getJavaObject(); + // temporaere Variable initialisieren + char * cSignature = "(ILjava/sql/Time;)V"; + char * cMethodName = "setTime"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + java_sql_Timestamp aT(x); + args[1].l = aT.getJavaObject(); + // temporaere Variable initialisieren + char * cSignature = "(ILjava/sql/Timestamp;)V"; + char * cMethodName = "setTimestamp"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + + + +void SAL_CALL java_sql_PreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].d = x; + // temporaere Variable initialisieren + char * cSignature = "(ID)V"; + char * cMethodName = "setDouble"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].d); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].f = x; + // temporaere Variable initialisieren + char * cSignature = "(IF)V"; + char * cMethodName = "setFloat"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ +t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].f); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].i = (sal_Int32)x; + // temporaere Variable initialisieren + char * cSignature = "(II)V"; + char * cMethodName = "setInt"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].i); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].j = x; + // temporaere Variable initialisieren + char * cSignature = "(IJ)V"; + char * cMethodName = "setLong"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ +t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].j); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].i = (sal_Int32)sqlType; + // temporaere Variable initialisieren + char * cSignature = "(II)V"; + char * cMethodName = "setNull"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].i); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].l = 0; + // temporaere Variable initialisieren + char * cSignature = "(ILjava/sql/Clob;)V"; + char * cMethodName = "setClob"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].l = 0; + // temporaere Variable initialisieren + char * cSignature = "(ILjava/sql/Blob;)V"; + char * cMethodName = "setBlob"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].l = 0; + // temporaere Variable initialisieren + char * cSignature = "(ILjava/sql/Array;)V"; + char * cMethodName = "setArray"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].l = 0; + // temporaere Variable initialisieren + char * cSignature = "(ILjava/sql/Ref;)V"; + char * cMethodName = "setRef"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].l = 0; + // temporaere Variable initialisieren + char * cSignature = "(ILjava/lang/Object;II)V"; + char * cMethodName = "setObject"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].l,targetSqlType,scale); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].l = 0; + // temporaere Variable initialisieren + char * cSignature = "(ILjava/lang/Object;)V"; + char * cMethodName = "setObject"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].l = 0; + // temporaere Variable initialisieren + char * cSignature = "(ILjava/lang/Object;)V"; + char * cMethodName = "setObject"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + args[1].s = (sal_Int16)x; + // temporaere Variable initialisieren + char * cSignature = "(IS)V"; + char * cMethodName = "setShort"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].s); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + jbyteArray pByteArray = t.pEnv->NewByteArray(x.getLength()); + t.pEnv->SetByteArrayRegion(pByteArray,0,x.getLength(),(jbyte*)x.getConstArray()); + args[1].l = pByteArray; + // temporaere Variable initialisieren + char * cSignature = "(I[B)V"; + char * cMethodName = "setBytes"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i,args[1].l); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + t.pEnv->DeleteLocalRef(pByteArray); + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + jvalue args2[3]; + jbyteArray pByteArray = t.pEnv->NewByteArray(length); + Sequence< sal_Int8> aSeq; + x->readBytes(aSeq,length); + t.pEnv->SetByteArrayRegion(pByteArray,0,length,(jbyte*)aSeq.getConstArray()); + args2[0].l = pByteArray; + args2[1].i = 0; + args2[2].i = (sal_Int32)length; + + // temporaere Variable initialisieren + char * cSignatureStream = "([BII)V"; + // Java-Call absetzen + jclass aClass = t.pEnv->FindClass("java/io/CharArrayInputStream"); + jmethodID mID2 = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream ); + jobject tempObj = NULL; + if(mID2) + tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 ); + + // + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + // temporaere Variable initialisieren + char * cSignature = "(ILjava/io/InputStream;I)V"; + char * cMethodName = "setCharacterStream"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + t.pEnv->CallVoidMethod( object, mID, args[0].i,tempObj,length); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + t.pEnv->DeleteLocalRef(pByteArray); + t.pEnv->DeleteLocalRef(tempObj); + t.pEnv->DeleteLocalRef(aClass); + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + jvalue args2[3]; + jbyteArray pByteArray = t.pEnv->NewByteArray(length); + Sequence< sal_Int8> aSeq; + x->readBytes(aSeq,length); + t.pEnv->SetByteArrayRegion(pByteArray,0,length,(jbyte*)aSeq.getConstArray()); + args2[0].l = pByteArray; + args2[1].i = 0; + args2[2].i = (sal_Int32)length; + + // temporaere Variable initialisieren + char * cSignatureStream = "([BII)V"; + // Java-Call absetzen + jclass aClass = t.pEnv->FindClass("java/io/ByteArrayInputStream"); + jmethodID mID2 = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream ); + jobject tempObj = NULL; + if(mID2) + tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 ); + + // + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)parameterIndex; + // temporaere Variable initialisieren + char * cSignature = "(ILjava/io/InputStream;I)V"; + char * cMethodName = "setBinaryStream"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + t.pEnv->CallVoidMethod( object, mID, args[0].i,tempObj,(sal_Int32)length); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + t.pEnv->DeleteLocalRef(pByteArray); + t.pEnv->DeleteLocalRef(tempObj); + t.pEnv->DeleteLocalRef(aClass); + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "clearParameters"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- +void SAL_CALL java_sql_PreparedStatement::clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "clearBatch"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_PreparedStatement::addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "addBatch"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL java_sql_PreparedStatement::executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Sequence< sal_Int32 > aSeq; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()[I"; + char * cMethodName = "executeBatch"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jintArray out = (jintArray)t.pEnv->CallObjectMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + if(out) + { + jboolean p = sal_False; + aSeq.realloc(t.pEnv->GetArrayLength(out)); + memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength()); + t.pEnv->DeleteLocalRef(out); + } + } //mID + } //t.pEnv + return aSeq; +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/jdbc/Reader.cxx b/connectivity/source/drivers/jdbc/Reader.cxx new file mode 100644 index 000000000000..11ba4fa816e2 --- /dev/null +++ b/connectivity/source/drivers/jdbc/Reader.cxx @@ -0,0 +1,187 @@ +/************************************************************************* + * + * $RCSfile: Reader.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_IO_READER_HXX_ +#include "java/io/Reader.hxx" +#endif +#ifndef _INC_MEMORY +#include <memory.h> +#endif +using namespace connectivity; +//************************************************************** +//************ Class: java.io.Reader +//************************************************************** + +jclass java_io_Reader::theClass = 0; + +java_io_Reader::~java_io_Reader() +{} + +jclass java_io_Reader::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass( "java/io/Reader" ); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_io_Reader::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +sal_Int32 SAL_CALL java_io_Reader::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + return readBytes(aData,nMaxBytesToRead); +} + +void SAL_CALL java_io_Reader::skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + char * cSignature = "(I)I"; + char * cMethodName = "skip"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = t.pEnv->CallIntMethod( object, mID,nBytesToSkip); + ThrowSQLException(t.pEnv,*this); + } + } //t.pEnv +} + +sal_Int32 SAL_CALL java_io_Reader::available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + char * cSignature = "()Z"; + char * cMethodName = "available"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } + } //t.pEnv + return out; +} +void SAL_CALL java_io_Reader::closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + char * cSignature = "()V"; + char * cMethodName = "close"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } + } //t.pEnv +} +// ----------------------------------------------------- +sal_Int32 SAL_CALL java_io_Reader::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + OSL_ENSHURE(aData.getLength() < nBytesToRead," Sequence is smaller than BytesToRead"); + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + jcharArray pCharArray = t.pEnv->NewCharArray(nBytesToRead); + char * cSignature = "([CII)I"; + char * cMethodName = "read"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + while(!(out = t.pEnv->CallIntMethod( object, mID,pCharArray,0,nBytesToRead))) + ThrowSQLException(t.pEnv,*this); + if(out > 0) + { + jboolean p = sal_False; + if(aData.getLength() < out) + aData.realloc(out-aData.getLength()); + + memcpy(aData.getArray(),t.pEnv->GetCharArrayElements(pCharArray,&p),out); + } + } + t.pEnv->DeleteLocalRef((jcharArray)pCharArray); + } //t.pEnv + return out; +} + diff --git a/connectivity/source/drivers/jdbc/Ref.cxx b/connectivity/source/drivers/jdbc/Ref.cxx new file mode 100644 index 000000000000..50d9c39bb548 --- /dev/null +++ b/connectivity/source/drivers/jdbc/Ref.cxx @@ -0,0 +1,121 @@ +/************************************************************************* + * + * $RCSfile: Ref.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_SQL_REF_HXX_ +#include "java/sql/Ref.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +using namespace connectivity; +//************************************************************** +//************ Class: java.sql.Ref +//************************************************************** + +jclass java_sql_Ref::theClass = 0; + +java_sql_Ref::~java_sql_Ref() +{} + +jclass java_sql_Ref::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass( "java/sql/Ref" ); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_sql_Ref::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +::rtl::OUString SAL_CALL java_sql_Ref::getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getBaseTypeName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} + diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx new file mode 100644 index 000000000000..94bd7aa197b4 --- /dev/null +++ b/connectivity/source/drivers/jdbc/ResultSet.cxx @@ -0,0 +1,1842 @@ +/************************************************************************* + * + * $RCSfile: ResultSet.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_SQL_RESULTSET_HXX_ +#include "java/sql/ResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_STATEMENT_HXX_ +#include "java/sql/Statement.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_SQLWARNING_HXX_ +#include "java/sql/SQLWarning.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_ARRAY_HXX_ +#include "java/sql/Array.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_REF_HXX_ +#include "java/sql/Ref.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_CLOB_HXX_ +#include "java/sql/Clob.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_TIMESTAMP_HXX_ +#include "java/sql/Timestamp.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_BLOB_HXX_ +#include "java/sql/Blob.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_RESULTSETMETADATA_HXX_ +#include "java/sql/ResultSetMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_IO_INPUTSTREAM_HXX_ +#include "java/io/InputStream.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _UTL_PROPERTY_HXX_ +#include <unotools/property.hxx> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif + + +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +IMPLEMENT_SERVICE_INFO(java_sql_ResultSet,"com.sun.star.sdbcx.JResultSet","com.sun.star.sdbc.ResultSet"); +//************************************************************** +//************ Class: java.sql.ResultSet +//************************************************************** + +jclass java_sql_ResultSet::theClass = 0; + +java_sql_ResultSet::~java_sql_ResultSet() +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + char * cSignature = "()V"; + char * cMethodName = "close"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + t.pEnv->CallVoidMethod( object, mID); + } +} + +jclass java_sql_ResultSet::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( !t.pEnv ) return (jclass)0; + jclass tempClass = t.pEnv->FindClass("java/sql/ResultSet"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_sql_ResultSet::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==0 ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} +// ------------------------------------------------------------------------- +void java_sql_ResultSet::disposing(void) +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + m_xMetaData = NULL; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Any SAL_CALL java_sql_ResultSet::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = OPropertySetHelper::queryInterface(rType); + if(!aRet.hasValue()) + aRet = java_sql_ResultSet_BASE::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_ResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),java_sql_ResultSet_BASE::getTypes()); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL java_sql_ResultSet::findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].l = convertwchar_tToJavaString(t.pEnv,columnName); + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;)I"; + char * cMethodName = "findColumn"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID, args[0].l ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + t.pEnv->DeleteLocalRef((jstring)args[0].l); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- + + +Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_ResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/io/InputStream;"; + char * cMethodName = "getBinaryStream"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_io_InputStream( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_ResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/io/InputStream;"; + char * cMethodName = "getCharacterStream"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_io_InputStream( t.pEnv, out ); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "getBoolean"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID, columnIndex ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +sal_Int8 SAL_CALL java_sql_ResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jbyte out; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)B"; + char * cMethodName = "getByte"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallByteMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +Sequence< sal_Int8 > SAL_CALL java_sql_ResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + Sequence< sal_Int8 > aSeq; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + char * cSignature = "(I)[B"; + char * cMethodName = "getBytes"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jbyteArray out = (jbyteArray)t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + if (out) + { + jboolean p = sal_False; + aSeq.realloc(t.pEnv->GetArrayLength(out)); + memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength()); + t.pEnv->DeleteLocalRef(out); + } + // und aufraeumen + } //mID + } //t.pEnv + return aSeq; +} +// ------------------------------------------------------------------------- + +::com::sun::star::util::Date SAL_CALL java_sql_ResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Date;"; + char * cMethodName = "getDate"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return java_sql_Date( t.pEnv, out ); +} +// ------------------------------------------------------------------------- + +double SAL_CALL java_sql_ResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jdouble out; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)D"; + char * cMethodName = "getDouble"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallDoubleMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +float SAL_CALL java_sql_ResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jfloat out; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)F"; + char * cMethodName = "getFloat"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallFloatMethod( object, mID, columnIndex ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL java_sql_ResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)I"; + char * cMethodName = "getInt"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID, columnIndex ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL java_sql_ResultSet::getRow( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getRow"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- + +sal_Int64 SAL_CALL java_sql_ResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jlong out; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)J"; + char * cMethodName = "getLong"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallLongMethod( object, mID, columnIndex ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL java_sql_ResultSet::getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()Ljava/sql/ResultSetMetaData;"; + char * cMethodName = "getMetaData"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_ResultSetMetaData( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +Reference< XArray > SAL_CALL java_sql_ResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Ref;"; + char * cMethodName = "getArray"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_Array( t.pEnv, out ); +} +// ------------------------------------------------------------------------- + +Reference< XClob > SAL_CALL java_sql_ResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Ref;"; + char * cMethodName = "getClob"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_Clob( t.pEnv, out ); +} +// ------------------------------------------------------------------------- +Reference< XBlob > SAL_CALL java_sql_ResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Ref;"; + char * cMethodName = "getBlob"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_Blob( t.pEnv, out ); +} +// ------------------------------------------------------------------------- + +Reference< XRef > SAL_CALL java_sql_ResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Ref;"; + char * cMethodName = "getRef"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? 0 : new java_sql_Ref( t.pEnv, out ); +} +// ------------------------------------------------------------------------- + +Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[2]; + // Parameter konvertieren + args[0].i = (sal_Int32)columnIndex; + args[1].l = XNameAccess2Map(t.pEnv,typeMap); + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/lang/Object;"; + char * cMethodName = "getObject"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethodA( object, mID, args); + ThrowSQLException(t.pEnv,*this); + t.pEnv->DeleteLocalRef((jstring)args[1].l); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out==0 ? Any() : Any();//new java_lang_Object( t.pEnv, out ); +} +// ------------------------------------------------------------------------- + +sal_Int16 SAL_CALL java_sql_ResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jshort out; + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)S"; + char * cMethodName = "getShort"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallShortMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int16)out; +} +// ------------------------------------------------------------------------- + + +::rtl::OUString SAL_CALL java_sql_ResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jstring out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/lang/String;"; + char * cMethodName = "getString"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring)t.pEnv->CallObjectMethod( object, mID, columnIndex ); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +// ------------------------------------------------------------------------- + + +::com::sun::star::util::Time SAL_CALL java_sql_ResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Time;"; + char * cMethodName = "getTime"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, columnIndex); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return java_sql_Time( t.pEnv, out ); +} +// ------------------------------------------------------------------------- + + +::com::sun::star::util::DateTime SAL_CALL java_sql_ResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + jobject out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)columnIndex; + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/sql/Timestamp;"; + char * cMethodName = "getTimestamp"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID, args[0].i); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return java_sql_Timestamp( t.pEnv, out ); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSet::isAfterLast( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "isAfterLast"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_ResultSet::isFirst( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "isFirst"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_ResultSet::isLast( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "isLast"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +void SAL_CALL java_sql_ResultSet::beforeFirst( ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "isBeforeFirst"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- +void SAL_CALL java_sql_ResultSet::afterLast( ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "afterLast"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "close"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSet::first( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "first"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSet::last( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "last"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_ResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "absolute"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,row); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_ResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "relative"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID,row); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_ResultSet::previous( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "previous"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL java_sql_ResultSet::getStatement( ) throw(SQLException, RuntimeException) +{ +// jobject out(0); +// SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); +// if( t.pEnv ) +// { +// // temporaere Variable initialisieren +// char * cSignature = "()Ljava/sql/Statement;"; +// char * cMethodName = "getStatement"; +// // Java-Call absetzen +// jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); +// if( mID ){ +// out = t.pEnv->CallObjectMethod( object, mID ); +// ThrowSQLException(t.pEnv,*this); +// } //mID +// } //t.pEnv +// // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! +// return out==0 ? 0 : (::cppu::OWeakObject*)new java_sql_Statement( t.pEnv, out ); + return m_aStatement.get(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSet::rowDeleted( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "rowDeleted"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_ResultSet::rowInserted( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "rowInserted"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_ResultSet::rowUpdated( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "rowUpdated"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "isBeforeFirst"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSet::next( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "next"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSet::wasNull( ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Z"; + char * cMethodName = "wasNull"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::cancel( ) throw(::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "cancel"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID ); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv +} +// ------------------------------------------------------------------------- +// ------------------------------------------------------------------------- +void SAL_CALL java_sql_ResultSet::clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "clearWarnings"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Any SAL_CALL java_sql_ResultSet::getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jobject out(NULL); + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Ljava/sql/SQLWarning;"; + char * cMethodName = "getWarnings"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out ? makeAny(java_sql_SQLWarning(java_sql_SQLWarning_BASE( t.pEnv, out ),*this)) : ::com::sun::star::uno::Any(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "insertRow"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- +void SAL_CALL java_sql_ResultSet::updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "updateRow"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- +void SAL_CALL java_sql_ResultSet::deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "deleteRow"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "cancelRowUpdates"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "moveToInsertRow"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "moveToCurrentRow"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(I)V"; + char * cMethodName = "updateNull"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(IZ)V"; + char * cMethodName = "updateNull"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,x); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- +void SAL_CALL java_sql_ResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(IB)V"; + char * cMethodName = "updateByte"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,x); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(IS)V"; + char * cMethodName = "updateShort"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,x); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- +void SAL_CALL java_sql_ResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(II)V"; + char * cMethodName = "updateInt"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,x); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- +void SAL_CALL java_sql_ResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(IJ)V"; + char * cMethodName = "updateLong"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,x); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- + +// ----------------------------------------------------------------------- +void SAL_CALL java_sql_ResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(IF)V"; + char * cMethodName = "updateFloat"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,x); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "(ID)V"; + char * cMethodName = "updateDouble"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,x); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + jvalue args[1]; + // Parameter konvertieren + args[0].l = convertwchar_tToJavaString(t.pEnv,x); + // temporaere Variable initialisieren + char * cSignature = "(ILjava/lang/String)V"; + char * cMethodName = "updateString"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l); + ThrowSQLException(t.pEnv,*this); + t.pEnv->DeleteLocalRef((jstring)args[0].l); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + jvalue args[1]; + jbyteArray aArray = t.pEnv->NewByteArray(x.getLength()); + t.pEnv->SetByteArrayRegion(aArray,0,x.getLength(),(jbyte*)x.getConstArray()); + + // Parameter konvertieren + args[0].l = aArray; + // temporaere Variable initialisieren + char * cSignature = "(I[B)V"; + char * cMethodName = "updateBytes"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l); + ThrowSQLException(t.pEnv,*this); + t.pEnv->DeleteLocalRef((jbyteArray)args[0].l); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + jvalue args[1]; + // Parameter konvertieren + java_sql_Date aD(x); + args[0].l = aD.getJavaObject(); + // temporaere Variable initialisieren + char * cSignature = "(ILjava/sql/Date;)V"; + char * cMethodName = "updateDate"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + jvalue args[1]; + // Parameter konvertieren + java_sql_Time aD(x); + args[0].l = aD.getJavaObject(); + // temporaere Variable initialisieren + char * cSignature = "(ILjava/sql/Time;)V"; + char * cMethodName = "updateTime"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + jvalue args[1]; + java_sql_Timestamp aD(x); + // Parameter konvertieren + args[0].l = aD.getJavaObject(); + // temporaere Variable initialisieren + char * cSignature = "(I;Ljava/sql/Timestamp;)V"; + char * cMethodName = "updateTimestamp"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l); + ThrowSQLException(t.pEnv,*this); + } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + jvalue args[1]; + // Parameter konvertieren + args[0].l = 0; + // temporaere Variable initialisieren + char * cSignature = "(ILjava/io/InputStream;I)V"; + char * cMethodName = "updateBinaryStream"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l,length); + ThrowSQLException(t.pEnv,*this); + t.pEnv->DeleteLocalRef((jobject)args[0].l); + } + } +} +// ------------------------------------------------------------------------- +void SAL_CALL java_sql_ResultSet::updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + jvalue args[1]; + // Parameter konvertieren + args[0].l = 0; + // temporaere Variable initialisieren + char * cSignature = "(ILjava/io/InputStream;I)V"; + char * cMethodName = "updateCharacterStream"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l,length); + ThrowSQLException(t.pEnv,*this); + t.pEnv->DeleteLocalRef((jobject)args[0].l); + } + } +} +// ------------------------------------------------------------------------- +void SAL_CALL java_sql_ResultSet::updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; + if( t.pEnv ) + { + jvalue args[1]; + switch(x.getValueTypeClass()) + { + case TypeClass_VOID: + args[0].l = NULL; + break; + + case TypeClass_BOOLEAN: + { + sal_Bool f; + x >>= f; + updateBoolean(columnIndex,f); + } + break; + case TypeClass_BYTE: + { + sal_Int8 f; + x >>= f; + updateByte(columnIndex,f); + } + break; + case TypeClass_SHORT: + case TypeClass_UNSIGNED_SHORT: + { + sal_Int16 f; + x >>= f; + updateShort(columnIndex,f); + } + break; + case TypeClass_LONG: + case TypeClass_UNSIGNED_LONG: + { + sal_Int32 f; + x >>= f; + updateInt(columnIndex,f); + } + break; + case TypeClass_HYPER: + case TypeClass_UNSIGNED_HYPER: + { + sal_Int64 f; + x >>= f; + updateLong(columnIndex,f); + } + break; + case TypeClass_FLOAT: + { + float f; + x >>= f; + updateFloat(columnIndex,f); + } + break; + case TypeClass_DOUBLE: + updateDouble(columnIndex,connectivity::getDouble(x)); + break; + case TypeClass_CHAR: + case TypeClass_STRING: + updateString(columnIndex,connectivity::getString(x)); + break; + case TypeClass_ENUM: + default: + OSL_ENSHURE(0,"UNKOWN TYPE for java_sql_ResultSet::updateObject"); + } + return; + // Parameter konvertieren + // temporaere Variable initialisieren + char * cSignature = "(ILjava/lang/Object;)V"; + char * cMethodName = "updateObject"; + // Java-Call absetzen +// jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); +// if( mID ){ +// t.pEnv->CallVoidMethodA( object, mID,columnIndex,args); + ThrowSQLException(t.pEnv,*this); +// switch(x.getValueTypeClass()) +// { +// case TypeClass_CHAR: +// case TypeClass_STRING: +// t.pEnv->DeleteLocalRef((jobject)args[0].l); +// break; +// } +// } + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL java_sql_ResultSet::updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + OSL_ENSHURE(0,"java_sql_ResultSet::updateNumericObject: NYI"); +// SDBThreadAttach t; +// if( t.pEnv ) +// { +// jvalue args[1]; +// // Parameter konvertieren +// args[0].l = +// // temporaere Variable initialisieren +// char * cSignature = "(I;Ljava/lang/Object;I)V"; +// char * cMethodName = "updateObject"; +// // Java-Call absetzen +// jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); +// if( mID ){ +// t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l,scale); + // ThrowSQLException(t.pEnv,*this); +// t.pEnv->DeleteLocalRef((jobject)args[0].l); +// } +// } +} +// ------------------------------------------------------------------------- +//------------------------------------------------------------------------------ +sal_Int32 java_sql_ResultSet::getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getResultSetConcurrency"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*(::cppu::OWeakObject*)this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +//------------------------------------------------------------------------------ +sal_Int32 java_sql_ResultSet::getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getResultSetType"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*(::cppu::OWeakObject*)this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +//------------------------------------------------------------------------------ +sal_Int32 java_sql_ResultSet::getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getFetchDirection"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*(::cppu::OWeakObject*)this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +//------------------------------------------------------------------------------ +sal_Int32 java_sql_ResultSet::getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getFetchSize"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*(::cppu::OWeakObject*)this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +//------------------------------------------------------------------------------ +::rtl::OUString java_sql_ResultSet::getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getCursorName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,*(::cppu::OWeakObject*)this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} + +//------------------------------------------------------------------------------ +void java_sql_ResultSet::setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)V"; + char * cMethodName = "setFetchDirection"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,_par0); + ThrowSQLException(t.pEnv,*(::cppu::OWeakObject*)this); + } //mID + } //t.pEnv + +} +//------------------------------------------------------------------------------ +void SAL_CALL java_sql_ResultSet::refreshRow( ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ) + { + // temporaere Variable initialisieren + char * cSignature = "()V"; + char * cMethodName = "refreshRow"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID); + ThrowSQLException(t.pEnv,*(::cppu::OWeakObject*)this); + } //mID + } //t.pEnv +} +//------------------------------------------------------------------------------ +void java_sql_ResultSet::setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)V"; + char * cMethodName = "setFetchSize"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID,_par0); + ThrowSQLException(t.pEnv,*(::cppu::OWeakObject*)this); + } //mID + } //t.pEnv + +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* java_sql_ResultSet::createArrayHelper( ) const +{ + Sequence< Property > aProps(5); + Property* pProperties = aProps.getArray(); + sal_Int32 nPos = 0; + DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY); + DECL_PROP0(FETCHDIRECTION, sal_Int32); + DECL_PROP0(FETCHSIZE, sal_Int32); + DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY); + DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY); + + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & java_sql_ResultSet::getInfoHelper() +{ + return *const_cast<java_sql_ResultSet*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +sal_Bool java_sql_ResultSet::convertFastPropertyValue( + ::com::sun::star::uno::Any & rConvertedValue, + ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException) +{ + switch(nHandle) + { + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + throw ::com::sun::star::lang::IllegalArgumentException(); + break; + case PROPERTY_ID_FETCHDIRECTION: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); + case PROPERTY_ID_FETCHSIZE: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); + default: + ; + } + return sal_False; +} +// ------------------------------------------------------------------------- +void java_sql_ResultSet::setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception) +{ + switch(nHandle) + { + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + throw ::com::sun::star::uno::Exception(); + break; + case PROPERTY_ID_FETCHDIRECTION: + setFetchDirection(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_FETCHSIZE: + setFetchSize(connectivity::getINT32(rValue)); + break; + default: + ; + } +} +// ------------------------------------------------------------------------- +void java_sql_ResultSet::getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle + ) const +{ + switch(nHandle) + { + case PROPERTY_ID_CURSORNAME: + rValue <<= getCursorName(); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + rValue <<= getResultSetConcurrency(); + break; + case PROPERTY_ID_RESULTSETTYPE: + rValue <<= getResultSetType(); + break; + case PROPERTY_ID_FETCHDIRECTION: + rValue <<= getFetchDirection(); + break; + case PROPERTY_ID_FETCHSIZE: + rValue <<= getFetchSize(); + break; + } +} + + + diff --git a/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx b/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx new file mode 100644 index 000000000000..b44bc920b6ef --- /dev/null +++ b/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx @@ -0,0 +1,563 @@ +/************************************************************************* + * + * $RCSfile: ResultSetMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_JAVA_SQL_RESULTSETMETADATA_HXX_ +#include "java/sql/ResultSetMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +//************************************************************** +//************ Class: java.sql.ResultSetMetaData +//************************************************************** + +jclass java_sql_ResultSetMetaData::theClass = 0; + +java_sql_ResultSetMetaData::~java_sql_ResultSetMetaData() +{} + +jclass java_sql_ResultSetMetaData::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( !t.pEnv ) return (jclass)0; + jclass tempClass = t.pEnv->FindClass("java/sql/ResultSetMetaData"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} +// ------------------------------------------------------------------------- + +void java_sql_ResultSetMetaData::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==0 ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "(I)I"; + char * cMethodName = "getColumnDisplaySize"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID,column); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "(I)I"; + char * cMethodName = "getColumnType"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID,column); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getColumnCount"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,*this); + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)column; + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "isCaseSensitive"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + out = (sal_Bool)t.pEnv->CallIntMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/lang/String;"; + char * cMethodName = "getSchemaName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } + + // und aufraeumen + } //t.pEnv + return aStr; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/lang/String;"; + char * cMethodName = "getColumnName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } + + // und aufraeumen + } //t.pEnv + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/lang/String;"; + char * cMethodName = "getTableName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } + + // und aufraeumen + } //t.pEnv + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/lang/String;"; + char * cMethodName = "getCatalogName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } + + // und aufraeumen + } //t.pEnv + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/lang/String;"; + char * cMethodName = "getColumnTypeName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } + + // und aufraeumen + } //t.pEnv + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/lang/String;"; + char * cMethodName = "getColumnLabel"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } + + // und aufraeumen + } //t.pEnv + return aStr; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + ::rtl::OUString aStr; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Ljava/lang/String;"; + char * cMethodName = "getColumnClassName"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + { + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + if(out) + aStr = JavaString2String(t.pEnv,out); + } + + // und aufraeumen + } //t.pEnv + return aStr; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)column; + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "isCurrency"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + out = (sal_Bool)t.pEnv->CallIntMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)column; + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "isAutoIncrement"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + out = (sal_Bool)t.pEnv->CallIntMethod( object, mID, column); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + + +sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)column; + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "isSigned"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ) + out = (sal_Bool)t.pEnv->CallIntMethod( object, mID, column); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)column; + // temporaere Variable initialisieren + char * cSignature = "(I)I"; + char * cMethodName = "getPrecision"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)column; + // temporaere Variable initialisieren + char * cSignature = "(I)I"; + char * cMethodName = "getScale"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL java_sql_ResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)column; + // temporaere Variable initialisieren + char * cSignature = "(I)I"; + char * cMethodName = "isNullable"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return (sal_Int32)out; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "isSearchable"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "isReadOnly"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL java_sql_ResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "isDefinitelyWritable"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL java_sql_ResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + jboolean out(sal_False); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "(I)Z"; + char * cMethodName = "isWritable"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallBooleanMethod( object, mID, column ); + ThrowSQLException(t.pEnv,*this); + // und aufraeumen + } //mID + } //t.pEnv + return out; +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/jdbc/SQLException.cxx b/connectivity/source/drivers/jdbc/SQLException.cxx new file mode 100644 index 000000000000..1a83ce996314 --- /dev/null +++ b/connectivity/source/drivers/jdbc/SQLException.cxx @@ -0,0 +1,186 @@ +/************************************************************************* + * + * $RCSfile: SQLException.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:22 $ + * + * 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_JAVA_SQL_SQLEXCEPTION_HXX_ +#include "java/sql/SQLException.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif + +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +//************************************************************** +//************ Class: java.sql.SQLException +//************************************************************** +java_sql_SQLException::java_sql_SQLException( const java_sql_SQLException_BASE& _rException,const Reference< XInterface> & _rContext) + : starsdbc::SQLException( _rException.getMessage(), + _rContext, + _rException.getSQLState(), + _rException.getErrorCode(), + makeAny(_rException.getNextException()) + ) +{ +} + +java_sql_SQLException_BASE::java_sql_SQLException_BASE( JNIEnv * pEnv, jobject myObj ) : java_lang_Exception( pEnv, myObj ) +{ +} + +jclass java_sql_SQLException_BASE::theClass = 0; + +java_sql_SQLException_BASE::~java_sql_SQLException_BASE() +{} + + +jclass java_sql_SQLException_BASE::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass("java/sql/SQLException"); + OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + if(!tempClass) + { + t.pEnv->ExceptionDescribe(); + t.pEnv->ExceptionClear(); + } + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_sql_SQLException_BASE::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +starsdbc::SQLException java_sql_SQLException_BASE::getNextException() const +{ + jobject out = NULL; + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/sql/Exception;"; + char * cMethodName = "getNextException"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,0); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return out ? (starsdbc::SQLException)java_sql_SQLException(java_sql_SQLException_BASE(t.pEnv,out),0) : starsdbc::SQLException(); +} + +::rtl::OUString java_sql_SQLException_BASE::getSQLState() const +{ + jstring out = (jstring)NULL; + SDBThreadAttach t; + ::rtl::OUString aStr; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getSQLState"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = (jstring) t.pEnv->CallObjectMethod( object, mID); + ThrowSQLException(t.pEnv,0); + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +sal_Int32 java_sql_SQLException_BASE::getErrorCode() const +{ + jint out(0); + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getErrorCode"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + ThrowSQLException(t.pEnv,0); + } //mID + } //t.pEnv + return (sal_Int32)out; +} + diff --git a/connectivity/source/drivers/jdbc/SQLWarning.cxx b/connectivity/source/drivers/jdbc/SQLWarning.cxx new file mode 100644 index 000000000000..aec20eeeb495 --- /dev/null +++ b/connectivity/source/drivers/jdbc/SQLWarning.cxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * $RCSfile: SQLWarning.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_JAVA_SQL_SQLWARNING_HXX_ +#include "java/sql/SQLWarning.hxx" +#endif +using namespace connectivity; +//************************************************************** +//************ Class: java.sql.SQLWarning +//************************************************************** + +jclass java_sql_SQLWarning_BASE::theClass = 0; + +java_sql_SQLWarning_BASE::~java_sql_SQLWarning_BASE() +{} + +jclass java_sql_SQLWarning_BASE::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass( "java/sql/SQLWarning" ); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_sql_SQLWarning_BASE::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + diff --git a/connectivity/source/drivers/jdbc/String.cxx b/connectivity/source/drivers/jdbc/String.cxx new file mode 100644 index 000000000000..a25472d00a52 --- /dev/null +++ b/connectivity/source/drivers/jdbc/String.cxx @@ -0,0 +1,126 @@ +/************************************************************************* + * + * $RCSfile: String.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_JAVA_LANG_STRING_HXX_ +#include "java/lang/String.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +using namespace connectivity; +//************************************************************** +//************ Class: java.lang.String +//************************************************************** + +jclass java_lang_String::theClass = 0; + +java_lang_String::~java_lang_String() +{} + +jclass java_lang_String::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass("java/lang/String"); + OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} +//-------------------------------------------------------------------------- +void java_lang_String::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} +//-------------------------------------------------------------------------- +java_lang_String::java_lang_String( const ::rtl::OUString& _par0 ): java_lang_Object( NULL, (jobject)NULL ) +{ + SDBThreadAttach t; + if( !t.pEnv ) + return; + jvalue args[1]; + // Parameter konvertieren + args[0].l = convertwchar_tToJavaString(t.pEnv,_par0); + // Java-Call fuer den Konstruktor absetzen + // temporaere Variable initialisieren + char * cSignature = "(Ljava/lang/String;)V"; + jobject tempObj; + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature ); + tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args ); + saveRef( t.pEnv, tempObj ); + t.pEnv->DeleteLocalRef( tempObj ); + t.pEnv->DeleteLocalRef((jstring)args[0].l); +} +//-------------------------------------------------------------------------- +java_lang_String::operator ::rtl::OUString() +{ + SDBThreadAttach t; + if(!t.pEnv) + return ::rtl::OUString(); + return JavaString2String(t.pEnv,(jstring)object); +} + diff --git a/connectivity/source/drivers/jdbc/Throwable.cxx b/connectivity/source/drivers/jdbc/Throwable.cxx new file mode 100644 index 000000000000..336425836cb6 --- /dev/null +++ b/connectivity/source/drivers/jdbc/Throwable.cxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * $RCSfile: Throwable.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_JAVA_LANG_THROWABLE_HXX_ +#include "java/lang/Throwable.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +using namespace connectivity; +//************************************************************** +//************ Class: java.lang.Throwable +//************************************************************** + +jclass java_lang_Throwable::theClass = 0; + +java_lang_Throwable::~java_lang_Throwable() +{} + +jclass java_lang_Throwable::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; + if( !t.pEnv ) return (jclass)NULL; + jclass tempClass = t.pEnv->FindClass("java/lang/Throwable"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_lang_Throwable::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==NULL ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +::rtl::OUString java_lang_Throwable::getMessage() const +{ + ::rtl::OUString aStr; + SDBThreadAttach t; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getMessage"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID); + + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} + +::rtl::OUString java_lang_Throwable::getLocalizedMessage() const +{ + ::rtl::OUString aStr; + SDBThreadAttach t; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "getLocalizedMessage"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID); + + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} +::rtl::OUString java_lang_Throwable::toString() const +{ + ::rtl::OUString aStr; + SDBThreadAttach t; + if( t.pEnv ){ + // temporaere Variable initialisieren + char * cSignature = "()Ljava/lang/String;"; + char * cMethodName = "toString"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID); + + if(out) + aStr = JavaString2String(t.pEnv,out); + } //mID + } //t.pEnv + // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! + return aStr; +} + diff --git a/connectivity/source/drivers/jdbc/Timestamp.cxx b/connectivity/source/drivers/jdbc/Timestamp.cxx new file mode 100644 index 000000000000..6da40bc40653 --- /dev/null +++ b/connectivity/source/drivers/jdbc/Timestamp.cxx @@ -0,0 +1,240 @@ +/************************************************************************* + * + * $RCSfile: Timestamp.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_JAVA_SQL_TIMESTAMP_HXX_ +#include "java/sql/Timestamp.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ +#include "DateConversion.hxx" +#endif +using namespace connectivity; +//************************************************************** +//************ Class: java.sql.Date +//************************************************************** + +jclass java_sql_Date::theClass = 0; + +java_sql_Date::~java_sql_Date() +{} + +jclass java_sql_Date::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( !t.pEnv ) return (jclass)0; + jclass tempClass = t.pEnv->FindClass("java/sql/Date"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_sql_Date::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==0 ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +//************************************************************** +//************ Class: java.sql.Time +//************************************************************** + +jclass java_sql_Time::theClass = 0; + +java_sql_Time::~java_sql_Time() +{} + +jclass java_sql_Time::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( !t.pEnv ) return (jclass)0; + jclass tempClass = t.pEnv->FindClass("java/sql/Time"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_sql_Time::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==0 ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_util_Date( NULL, (jobject)NULL ) +{ + SDBThreadAttach t; + if( !t.pEnv ) + return; + jvalue args[1]; + // Parameter konvertieren + args[0].j = DateConversion::toINT32(_rOut); + // Java-Call fuer den Konstruktor absetzen + // temporaere Variable initialisieren + char * cSignature = "(J)V"; + jobject tempObj; + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature ); + tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args ); + saveRef( t.pEnv, tempObj ); + t.pEnv->DeleteLocalRef( tempObj ); + // und aufraeumen +} + +//************************************************************** +//************ Class: java.sql.Timestamp +//************************************************************** + +jclass java_sql_Timestamp::theClass = 0; + +java_sql_Timestamp::~java_sql_Timestamp() +{} + +jclass java_sql_Timestamp::getMyClass() +{ + // die Klasse muss nur einmal geholt werden, daher statisch + if( !theClass ){ + SDBThreadAttach t; OSL_ENSHURE(t.pEnv,"Java Enviroment gelscht worden!"); + if( !t.pEnv ) return (jclass)0; + jclass tempClass = t.pEnv->FindClass("java/sql/Timestamp"); OSL_ENSHURE(tempClass,"Java : FindClass nicht erfolgreich!"); + jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); + t.pEnv->DeleteLocalRef( tempClass ); + saveClassRef( globClass ); + } + return theClass; +} + +void java_sql_Timestamp::saveClassRef( jclass pClass ) +{ + if( SDBThreadAttach::IsJavaErrorOccured() || pClass==0 ) + return; + // der uebergebe Klassen-Handle ist schon global, daher einfach speichern + theClass = pClass; +} + +java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _rOut) + :java_util_Date( NULL, (jobject)NULL ) +{ + SDBThreadAttach t; + if( !t.pEnv ) + return; + jvalue args[1]; + // Parameter konvertieren + args[0].j = (jlong)DateConversion::toINT64(_rOut); + // Java-Call fuer den Konstruktor absetzen + // temporaere Variable initialisieren + char * cSignature = "(J)V"; + jobject tempObj; + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature ); + tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args ); + saveRef( t.pEnv, tempObj ); + t.pEnv->DeleteLocalRef( tempObj ); + // und aufraeumen +} + +sal_Int32 java_sql_Timestamp::getNanos() +{ + jint out(0); + SDBThreadAttach t; + if( t.pEnv ){ + + // temporaere Variable initialisieren + char * cSignature = "()I"; + char * cMethodName = "getNanos"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + out = t.pEnv->CallIntMethod( object, mID); + } //mID + } //t.pEnv + return (sal_Int32)out; +} + +void java_sql_Timestamp::setNanos( sal_Int32 _par0 ) +{ + SDBThreadAttach t; + if( t.pEnv ){ + jvalue args[1]; + // Parameter konvertieren + args[0].i = (sal_Int32)_par0; + // temporaere Variable initialisieren + char * cSignature = "(I)V"; + char * cMethodName = "setNanos"; + // Java-Call absetzen + jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); + if( mID ){ + t.pEnv->CallVoidMethod( object, mID, args[0].i ); + // und aufraeumen + } //mID + } //t.pEnv +} + diff --git a/connectivity/source/drivers/jdbc/exports.dxp b/connectivity/source/drivers/jdbc/exports.dxp new file mode 100644 index 000000000000..9630d7e06768 --- /dev/null +++ b/connectivity/source/drivers/jdbc/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/connectivity/source/drivers/jdbc/jdbc.xml b/connectivity/source/drivers/jdbc/jdbc.xml new file mode 100644 index 000000000000..5ed71581fd54 --- /dev/null +++ b/connectivity/source/drivers/jdbc/jdbc.xml @@ -0,0 +1,69 @@ +<?xml version='1.0' encoding="UTF-8"?> +<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//W3C//DTD HTML 3.2//EN" "componentdependencies.dtd"> +<COMPONENTDESCRIPTION> + +<Name> com.sun.star.sdbc.JDBCDriver </Name> + +<Description> + This component provides ... +</Description> + +<ModuleName> jdbc </ModuleName> + +<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName> + +<SupportedService> com.sun.star.sdbc.Driver </SupportedService> + +<ServiceDependency> ... </ServiceDependency> + +<ProjectBuildDependency> cppuhelper </ProjectBuildDependency> +<ProjectBuildDependency> cppu </ProjectBuildDependency> +<ProjectBuildDependency> sal </ProjectBuildDependency> +<ProjectBuildDependency> vos </ProjectBuildDependency> + +<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency> +<RuntimeModuleDependency> cppu1 </RuntimeModuleDependency> +<RuntimeModuleDependency> sal1 </RuntimeModuleDependency> +<RuntimeModuleDependency> vos </RuntimeModuleDependency> + +<Language> c++ </Language> + +<Status StatusValue="final"/> + +<Type> com.sun.star.util.XCancellable </Type> +<Type> com.sun.star.util.XNumberFormatter </Type> +<Type> com.sun.star.uno.TypeClass </Type> +<Type> com.sun.star.uno.XWeak </Type> +<Type> com.sun.star.uno.XAggregation </Type> +<Type> com.sun.star.beans.XPropertyState </Type> +<Type> com.sun.star.beans.XPropertySet </Type> +<Type> com.sun.star.beans.PropertyValue </Type> +<Type> com.sun.star.beans.XMultiPropertySet </Type> +<Type> com.sun.star.beans.XFastPropertySet </Type> +<Type> com.sun.star.lang.XTypeProvider </Type> +<Type> com.sun.star.lang.EventObject </Type> +<Type> com.sun.star.lang.XComponent </Type> +<Type> com.sun.star.lang.IllegalArgumentException </Type> +<Type> com.sun.star.lang.XMultiServiceFactory </Type> +<Type> com.sun.star.java.XJavaThreadRegister_11 </Type> +<Type> com.sun.star.java.XJavaVM </Type> +<Type> com.sun.star.sdbc.XConnection </Type> +<Type> com.sun.star.sdbc.XStatement </Type> +<Type> com.sun.star.sdbc.XResultSet </Type> +<Type> com.sun.star.sdbc.XResultSetMetaDataSupplier</Type> +<Type> com.sun.star.sdbc.XColumnLocate </Type> +<Type> com.sun.star.sdbc.XResultSetUpdate </Type> +<Type> com.sun.star.sdbc.XWarningsSupplier </Type> +<Type> com.sun.star.sdbc.XRowUpdate </Type> +<Type> com.sun.star.sdbc.XMultipleResults </Type> +<Type> com.sun.star.sdbc.XBatchExecution </Type> +<Type> com.sun.star.sdbc.XPreparedBatchExecution </Type> +<Type> com.sun.star.sdbc.XParameters </Type> +<Type> com.sun.star.sdbc.XOutParameters </Type> +<Type> com.sun.star.sdbc.DriverPropertyInfo </Type> +<Type> com.sun.star.sdbc.XRow </Type> +<Type> com.sun.star.sdb.XColumnUpdate </Type> +<Type> com.sun.star.sdb.XColumn </Type> + +</COMPONENTDESCRIPTION> + diff --git a/connectivity/source/drivers/jdbc/jservices.cxx b/connectivity/source/drivers/jdbc/jservices.cxx new file mode 100644 index 000000000000..a24b49c290ec --- /dev/null +++ b/connectivity/source/drivers/jdbc/jservices.cxx @@ -0,0 +1,209 @@ +/************************************************************************* + * + * $RCSfile: jservices.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_JAVA_SQL_DRIVER_HXX_ +#include "java/sql/Driver.hxx" +#endif +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> +#endif + +using namespace connectivity; +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::registry::XRegistryKey; +using ::com::sun::star::lang::XSingleServiceFactory; +using ::com::sun::star::lang::XMultiServiceFactory; + +typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) + ( + const Reference< XMultiServiceFactory > & rServiceManager, + const OUString & rComponentName, + ::cppu::ComponentInstantiation pCreateFunction, + const Sequence< OUString > & rServiceNames + ); + +//*************************************************************************************** +// +// Die vorgeschriebene C-Api muss erfuellt werden! +// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen. +// + +//--------------------------------------------------------------------------------------- +void REGISTER_PROVIDER( + const OUString& aServiceImplName, + const Sequence< OUString>& Services, + const Reference< ::com::sun::star::registry::XRegistryKey > & xKey) +{ + OUString aMainKeyName; + aMainKeyName = OUString::createFromAscii("/"); + aMainKeyName += aServiceImplName; + aMainKeyName += OUString::createFromAscii("/UNO/SERVICES"); + + Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) ); + OSL_ENSHURE(xNewKey.is(), "SBA::component_writeInfo : could not create a registry key !"); + + for (sal_uInt32 i=0; i<Services.getLength(); ++i) + xNewKey->createKey(Services[i]); +} + + +//--------------------------------------------------------------------------------------- +struct ProviderRequest +{ + Reference< XSingleServiceFactory > xRet; + Reference< XMultiServiceFactory > const xServiceManager; + OUString const sImplementationName; + + ProviderRequest( + void* pServiceManager, + sal_Char const* pImplementationName + ) + : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) + , sImplementationName(OUString::createFromAscii(pImplementationName)) + { + } + + inline + sal_Bool CREATE_PROVIDER( + const OUString& Implname, + const Sequence< OUString > & Services, + ::cppu::ComponentInstantiation Factory, + createFactoryFunc creator + ) + { + if (!xRet.is() && (Implname == sImplementationName)) + try + { + xRet = creator( xServiceManager, sImplementationName,Factory, Services); + } + catch(...) + { + } + return xRet.is(); + } + + void* getProvider() const { return xRet.get(); } +}; + +//--------------------------------------------------------------------------------------- + +extern "C" void SAL_CALL component_getImplementationEnvironment( + const sal_Char **ppEnvTypeName, + uno_Environment **ppEnv + ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//--------------------------------------------------------------------------------------- +extern "C" sal_Bool SAL_CALL component_writeInfo( + void* pServiceManager, + void* pRegistryKey + ) +{ + if (pRegistryKey) + try + { + Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey)); + + REGISTER_PROVIDER( + java_sql_Driver::getImplementationName_Static(), + java_sql_Driver::getSupportedServiceNames_Static(), xKey); + + return sal_True; + } + catch (::com::sun::star::registry::InvalidRegistryException& ) + { + OSL_ENSHURE(sal_False, "SBA::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !"); + } + + return sal_False; +} + +//--------------------------------------------------------------------------------------- +extern "C" void* SAL_CALL component_getFactory( + const sal_Char* pImplementationName, + void* pServiceManager, + void* pRegistryKey) +{ + void* pRet = 0; + if (pServiceManager) + { + ProviderRequest aReq(pServiceManager,pImplementationName); + + aReq.CREATE_PROVIDER( + java_sql_Driver::getImplementationName_Static(), + java_sql_Driver::getSupportedServiceNames_Static(), + java_sql_Driver_CreateInstance, + ::cppu::createSingleFactory); + + if(aReq.xRet.is()) + aReq.xRet->acquire(); + pRet = aReq.getProvider(); + } + + return pRet; +}; + + + diff --git a/connectivity/source/drivers/jdbc/makefile.mk b/connectivity/source/drivers/jdbc/makefile.mk new file mode 100644 index 000000000000..00621c73d2ee --- /dev/null +++ b/connectivity/source/drivers/jdbc/makefile.mk @@ -0,0 +1,187 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=..$/.. +PRJNAME=connectivity +TARGET=jdbc + +USE_DEFFILE=TRUE +NO_BSYMBOLIC=TRUE + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/version.mk + +# --- Types ------------------------------------- + + +UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb + +UNOUCROUT=$(OUT)$/inc +INCPRE+=$(UNOUCROUT) + +# --- Types ------------------------------------- + +UNOTYPES+= \ + com.sun.star.util.XCancellable \ + com.sun.star.util.XNumberFormatter \ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XWeak \ + com.sun.star.uno.XAggregation \ + com.sun.star.beans.XPropertyState \ + com.sun.star.beans.XPropertySet \ + com.sun.star.beans.PropertyValue \ + com.sun.star.beans.XMultiPropertySet \ + com.sun.star.beans.XFastPropertySet \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.EventObject \ + com.sun.star.lang.XComponent \ + com.sun.star.lang.IllegalArgumentException \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.java.XJavaThreadRegister_11 \ + com.sun.star.java.XJavaVM \ + com.sun.star.sdbc.XConnection \ + com.sun.star.sdbc.XStatement \ + com.sun.star.sdbc.XResultSet \ + com.sun.star.sdbc.XResultSetMetaDataSupplier \ + com.sun.star.sdbc.XColumnLocate \ + com.sun.star.sdbc.XResultSetUpdate \ + com.sun.star.sdbc.XWarningsSupplier \ + com.sun.star.sdbc.XRowUpdate \ + com.sun.star.sdbc.XMultipleResults \ + com.sun.star.sdbc.XBatchExecution \ + com.sun.star.sdbc.XPreparedBatchExecution \ + com.sun.star.sdbc.XParameters \ + com.sun.star.sdbc.XOutParameters \ + com.sun.star.sdbc.DriverPropertyInfo \ + com.sun.star.sdbc.XRow \ + com.sun.star.sdb.XColumnUpdate \ + com.sun.star.sdb.XColumn + + + +# --- Files ------------------------------------- + +SLOFILES=\ + $(SLO)$/Array.obj \ + $(SLO)$/Blob.obj \ + $(SLO)$/Boolean.obj \ + $(SLO)$/CallableStatement.obj \ + $(SLO)$/Class.obj \ + $(SLO)$/Clob.obj \ + $(SLO)$/Connection.obj \ + $(SLO)$/DatabaseMetaData.obj \ + $(SLO)$/Date.obj \ + $(SLO)$/DriverManager.obj \ + $(SLO)$/DriverPropertyInfo.obj \ + $(SLO)$/Exception.obj \ + $(SLO)$/InputStream.obj \ + $(SLO)$/JDriver.obj \ + $(SLO)$/Object.obj \ + $(SLO)$/PreparedStatement.obj \ + $(SLO)$/Reader.obj \ + $(SLO)$/Ref.obj \ + $(SLO)$/ResultSet.obj \ + $(SLO)$/ResultSetMetaData.obj \ + $(SLO)$/SQLException.obj \ + $(SLO)$/SQLWarning.obj \ + $(SLO)$/Statement.obj \ + $(SLO)$/String.obj \ + $(SLO)$/Throwable.obj \ + $(SLO)$/Timestamp.obj \ + $(SLO)$/tools.obj \ + $(SLO)$/jservices.obj + +# --- Library ----------------------------------- + +SHL1TARGET= $(JDBC_TARGET)$(JDBC_MAJOR) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(OSLLIB) \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(SHL1TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib \ + $(SLB)$/commontools.lib \ + $(SLB)$/resource.lib + +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + + diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx new file mode 100644 index 000000000000..c8e0f97c351c --- /dev/null +++ b/connectivity/source/drivers/jdbc/tools.cxx @@ -0,0 +1,159 @@ +/************************************************************************* + * + * $RCSfile: tools.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_JAVA_TOOLS_HXX_ +#include "java/tools.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_LANG_STRING_HXX_ +#include "java/lang/String.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_LANG_CLASS_HXX_ +#include "java/lang/Class.hxx" +#endif + +#ifndef _COM_SUN_STAR_SDBC_DRIVERPROPERTYINFO_HPP_ +#include <com/sun/star/sdbc/DriverPropertyInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif + +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +// -------------------------------------------------------------------------------- +jstring connectivity::convertwchar_tToJavaString(JNIEnv *pEnv,const ::rtl::OUString& Temp) +{ + if (pEnv) + { + ::rtl::OString aT = ::rtl::OUStringToOString(Temp,RTL_TEXTENCODING_UTF8); + return pEnv->NewString((const unsigned short *)aT.getStr(), aT.getLength()); + } + return NULL; +} + +// -------------------------------------------------------------------------------- +jobjectArray connectivity::createStringPropertyArray(JNIEnv *pEnv,const Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(starsdbc::SQLException, RuntimeException) +{ + jobjectArray aArray = pEnv->NewObjectArray(info.getLength(),java_lang_String::getMyClass(),pEnv->NewStringUTF("")); + + const ::com::sun::star::beans::PropertyValue* pBegin = info.getConstArray(); + const ::com::sun::star::beans::PropertyValue* pEnd = pBegin + info.getLength(); + + sal_Bool bFound = sal_False; + for(jsize i=0;pBegin != pEnd;++pBegin) + { + if(!bFound || pBegin->Name.compareToAscii("JDBCDRV")) + { + java_sql_SQLException_BASE::getMyClass(); + java_lang_Throwable::getMyClass(); + + ::rtl::OUString aStr; + pBegin->Value >>= aStr; + //Datenbanktreiber wird ueber einen Klassennamen erzeugt + java_lang_Class *pDrvClass = java_lang_Class::forName(aStr); + bFound = sal_True; + } + else + { + ::rtl::OUString aStr; + pBegin->Value >>= aStr; + jstring a = convertwchar_tToJavaString(pEnv,aStr.getStr()); + pEnv->SetObjectArrayElement(aArray,i++,a); + } + } + return aArray; +} +// -------------------------------------------------------------------------------- +::rtl::OUString connectivity::JavaString2String(JNIEnv *pEnv,jstring _Str) +{ + ::rtl::OUString aStr; + if(_Str) + { + jboolean bCopy(sal_True); + const jchar* pChar = pEnv->GetStringChars(_Str,&bCopy); + jsize len = pEnv->GetStringLength(_Str); + aStr = ::rtl::OUString(pChar,RTL_TEXTENCODING_UTF8); + + if(bCopy) + pEnv->ReleaseStringChars(_Str,pChar); + pEnv->DeleteLocalRef(_Str); + } + return aStr; +} +// -------------------------------------------------------------------------------- +jobject connectivity::XNameAccess2Map(JNIEnv *pEnv,const Reference< ::com::sun::star::container::XNameAccess > & _rMap) +{ + ::com::sun::star::uno::Sequence< ::rtl::OUString > aSeq = _rMap->getElementNames(); + const ::rtl::OUString *pBegin = aSeq.getConstArray(); + const ::rtl::OUString *pEnd = pBegin + aSeq.getLength(); + for(;pBegin != pEnd;++pBegin) + { + } + return 0; +} + + diff --git a/connectivity/source/drivers/odbc/OConnection.cxx b/connectivity/source/drivers/odbc/OConnection.cxx new file mode 100644 index 000000000000..db68e9948559 --- /dev/null +++ b/connectivity/source/drivers/odbc/OConnection.cxx @@ -0,0 +1,539 @@ +/************************************************************************* + * + * $RCSfile: OConnection.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_OTOOLS_HXX_ +#include "odbc/OTools.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OCONNECTION_HXX_ +#include "odbc/OConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_ODATABASEMETADATA_HXX_ +#include "odbc/ODatabaseMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_RESOURCE_HRC_ +#include "Resource.hrc" +#endif +#ifndef _CONNECTIVITY_MODULECONTEXT_HXX_ +#include "ModuleContext.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_ +#include "odbc/OFunctions.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_ODRIVER_HXX_ +#include "odbc/ODriver.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OSTATEMENT_HXX_ +#include "odbc/OStatement.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OPREPAREDSTATEMENT_HXX_ +#include "odbc/OPreparedStatement.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + +using namespace connectivity::odbc; + +//------------------------------------------------------------------------------ +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +// -------------------------------------------------------------------------------- +OConnection::OConnection(const SQLHANDLE _pDriverHandle,ODBCDriver* _pDriver) + : OConnection_BASE(m_aMutex), + OSubComponent<OConnection>((::cppu::OWeakObject*)_pDriver), + m_pDriverHandleCopy(_pDriverHandle), + m_pDriver(_pDriver), + m_bClosed(sal_False), + m_xMetaData(NULL) +{ + ModuleContext::AddRef(); +} +//----------------------------------------------------------------------------- +OConnection::~OConnection() +{ + if(!isClosed( )) + close(); + ModuleContext::ReleaseRef(); +} +//----------------------------------------------------------------------------- +void SAL_CALL OConnection::release() throw(RuntimeException) +{ + relase_ChildImpl(); + OConnection_BASE::release(); +} + +//----------------------------------------------------------------------------- +SQLRETURN OConnection::OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, sal_Bool bSilent) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + if (m_aConnectionHandle == SQL_NULL_HANDLE) + return -1; + + sal_Bool bReadOnly; //weil Methode statisch hier noch einmal ein lokales bReadOnly + SQLRETURN nSQLRETURN = 0; + SDB_ODBC_CHAR szConnStrOut[4096]; + SDB_ODBC_CHAR szConnStrIn[2048]; + SWORD cbConnStrOut; + memset(szConnStrOut,'\0',4096); + memset(szConnStrIn,'\0',2048); + ::rtl::OString aConStr(::rtl::OUStringToOString(aConnectStr,osl_getThreadTextEncoding())); + memcpy(szConnStrIn, (SDB_ODBC_CHAR*) aConStr.getStr(), ::std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength())); + + + N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_LOGIN_TIMEOUT,(SQLPOINTER)nTimeOut,SQL_IS_INTEGER); + // Verbindung aufbauen + +#ifdef LINUX + + nSQLRETURN = N3SQLDriverConnect(m_aConnectionHandle, + NULL, + szConnStrIn, + (SQLSMALLINT) ::std::min((sal_Int32)2048,aConStr.getLength()), + szConnStrOut, + (SQLSMALLINT) sizeof szConnStrOut, + &cbConnStrOut, + SQL_DRIVER_NOPROMPT); + if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA || SQL_SUCCESS_WITH_INFO == nSQLRETURN) + return nSQLRETURN; +#else + + SQLUSMALLINT nSilent = bSilent ? SQL_DRIVER_NOPROMPT : SQL_DRIVER_COMPLETE; + nSQLRETURN = N3SQLDriverConnect(m_aConnectionHandle, + NULL, + szConnStrIn, + (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength()), + szConnStrOut, + (SQLSMALLINT) sizeof szConnStrOut, + &cbConnStrOut, + nSilent); + if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA) + return nSQLRETURN; + +#endif //LINUX + + try + { + ::rtl::OUString aVal; + OTools::GetInfo(m_aConnectionHandle,SQL_DATA_SOURCE_READ_ONLY,aVal,*this); + bReadOnly = !aVal.compareToAscii("Y"); + } + catch(...) + { + bReadOnly = sal_True; + } + +#ifndef MAC + // autocoomit ist immer default + + if (!bReadOnly) + N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_AUTOCOMMIT,(SQLPOINTER)SQL_AUTOCOMMIT_ON,SQL_IS_INTEGER); +#endif + + return nSQLRETURN; +} +//----------------------------------------------------------------------------- +SQLRETURN OConnection::Construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException) +{ + osl_incrementInterlockedCount( &m_refCount ); + m_aConnectionHandle = SQL_NULL_HANDLE; + + // Connection allozieren + N3SQLAllocHandle(SQL_HANDLE_DBC,m_pDriverHandleCopy,&m_aConnectionHandle); + if(m_aConnectionHandle == SQL_NULL_HANDLE) + throw SQLException(); + + sal_Int32 nLen = url.indexOf(':'); + nLen = url.indexOf(':',nLen+1); + ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD; + + sal_Int32 nTimeout = 20; + sal_Bool bSilent = sal_True; + const PropertyValue *pBegin = info.getConstArray(); + const PropertyValue *pEnd = pBegin + info.getLength(); + for(;pBegin != pEnd;++pBegin) + { + if(!pBegin->Name.compareToAscii("Timeout")) + pBegin->Value >>= nTimeout; + else if(!pBegin->Name.compareToAscii("Silent")) + pBegin->Value >>= bSilent; + else if(!pBegin->Name.compareToAscii("user")) + { + pBegin->Value >>= aUID; + aDSN = aDSN + ::rtl::OUString::createFromAscii(";UID=") + aUID; + } + else if(!pBegin->Name.compareToAscii("password")) + { + pBegin->Value >>= aPWD; + aDSN = aDSN + ::rtl::OUString::createFromAscii(";PWD=") + aPWD; + } + } + + SQLRETURN nSQLRETURN = OpenConnection(aDSN,nTimeout, bSilent); + if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA) + { + OTools::ThrowException(nSQLRETURN,m_aConnectionHandle,SQL_HANDLE_DBC,*this); + } + else if(SQL_SUCCESS_WITH_INFO == nSQLRETURN) // this driver does not support odbc3 + { + } + osl_decrementInterlockedCount( &m_refCount ); + return nSQLRETURN; +} +// XServiceInfo +// -------------------------------------------------------------------------------- +IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.odbc.OConnection", "com.sun.star.sdbc.Connection") + +// -------------------------------------------------------------------------------- +Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + OStatement* pStmt = new OStatement(this); + m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + return pStmt; +} +// -------------------------------------------------------------------------------- +Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + if(m_aTypeInfo.empty()) + buildTypeInfo(); + OPreparedStatement* pStmt = new OPreparedStatement(this,m_aTypeInfo,sql); + m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + return pStmt; +} +// -------------------------------------------------------------------------------- +Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + return NULL; +} +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OString aSql(::rtl::OUStringToOString(sql.getStr(),osl_getThreadTextEncoding())); + char pOut[2048]; + SQLINTEGER nOutLen; + OTools::ThrowException(N3SQLNativeSql(m_aConnectionHandle,(SDB_ODBC_CHAR*)aSql.getStr(),aSql.getLength(),(SDB_ODBC_CHAR*)pOut,2048,&nOutLen),m_aConnectionHandle,SQL_HANDLE_DBC,*this); + return ::rtl::OUString(pOut,nOutLen,osl_getThreadTextEncoding()); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OTools::ThrowException(N3SQLSetConnectAttr(m_aConnectionHandle, + SQL_ATTR_AUTOCOMMIT, + (SQLPOINTER)((autoCommit) ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF) ,SQL_IS_INTEGER), + m_aConnectionHandle,SQL_HANDLE_DBC,*this); +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_uInt32 nOption = 0; + OTools::ThrowException(N3SQLGetConnectAttr(m_aConnectionHandle, + SQL_ATTR_AUTOCOMMIT, &nOption,0,0),m_aConnectionHandle,SQL_HANDLE_DBC,*this); + return nOption == SQL_AUTOCOMMIT_ON ; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OTools::ThrowException(N3SQLEndTran(SQL_HANDLE_DBC,m_aConnectionHandle,SQL_COMMIT),m_aConnectionHandle,SQL_HANDLE_DBC,*this); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OTools::ThrowException(N3SQLEndTran(SQL_HANDLE_DBC,m_aConnectionHandle,SQL_ROLLBACK),m_aConnectionHandle,SQL_HANDLE_DBC,*this); +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return OConnection_BASE::rBHelper.bDisposed; +} +// -------------------------------------------------------------------------------- +Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_xMetaData.is()) + m_xMetaData = new ODatabaseMetaData(m_aConnectionHandle,this); + + return m_xMetaData; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OTools::ThrowException( + N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_ACCESS_MODE,(SQLPOINTER)readOnly,SQL_IS_INTEGER), + m_aConnectionHandle,SQL_HANDLE_DBC,*this); +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_DATA_SOURCE_READ_ONLY,aValue,*this); + return aValue == ::rtl::OUString::createFromAscii("Y"); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ::rtl::OString aCat(::rtl::OUStringToOString(catalog.getStr(),osl_getThreadTextEncoding())); + OTools::ThrowException( + N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_CURRENT_CATALOG,(SDB_ODBC_CHAR*)aCat.getStr(),SQL_NTS), + m_aConnectionHandle,SQL_HANDLE_DBC,*this); +} +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 nValueLen; + char pCat[1024]; + OTools::ThrowException( + N3SQLGetConnectAttr(m_aConnectionHandle,SQL_ATTR_CURRENT_CATALOG,(SDB_ODBC_CHAR*)pCat,1024,&nValueLen), + m_aConnectionHandle,SQL_HANDLE_DBC,*this); + + return ::rtl::OUString(pCat,nValueLen,osl_getThreadTextEncoding()); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OTools::ThrowException(N3SQLSetConnectAttr(m_aConnectionHandle, + SQL_ATTR_TXN_ISOLATION, + (SQLPOINTER)level,SQL_IS_INTEGER), + m_aConnectionHandle,SQL_HANDLE_DBC,*this); +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 nTxn = 0; + SQLINTEGER nValueLen; + OTools::ThrowException( + N3SQLGetConnectAttr(m_aConnectionHandle,SQL_ATTR_TXN_ISOLATION,&nTxn,sizeof nTxn,&nValueLen), + m_aConnectionHandle,SQL_HANDLE_DBC,*this); + return nTxn; +} +// -------------------------------------------------------------------------------- +Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return NULL; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) +{ +} +// -------------------------------------------------------------------------------- +// XCloseable +void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE::rBHelper.bDisposed) + throw DisposedException(); + } + dispose(); +} +// -------------------------------------------------------------------------------- +// XWarningsSupplier +Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException) +{ + return Any(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException) +{ +} +//-------------------------------------------------------------------- +void OConnection::buildTypeInfo() throw( SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + Reference< XResultSet> xRs = getMetaData ()->getTypeInfo (); + Reference< XRow> xRow(xRs,UNO_QUERY); + // Information for a single SQL type + + // Loop on the result set until we reach end of file + + while (xRs->next ()) + { + OTypeInfo aInfo; + aInfo.aTypeName = xRow->getString (1); + aInfo.nType = xRow->getShort (2); + aInfo.nPrecision = xRow->getInt (3); + aInfo.aLiteralPrefix = xRow->getString (4); + aInfo.aLiteralSuffix = xRow->getString (5); + aInfo.aCreateParams = xRow->getString (6); + aInfo.bNullable = xRow->getBoolean (7) == ColumnValue::NULLABLE; + aInfo.bCaseSensitive = xRow->getBoolean (8); + aInfo.nSearchType = xRow->getShort (9); + aInfo.bUnsigned = xRow->getBoolean (10); + aInfo.bCurrency = xRow->getBoolean (11); + aInfo.bAutoIncrement = xRow->getBoolean (12); + aInfo.aLocalTypeName = xRow->getString (13); + aInfo.nMinimumScale = xRow->getShort (14); + aInfo.nMaximumScale = xRow->getShort (15); + aInfo.nNumPrecRadix = xRow->getInt (18); + + + + // Now that we have the type info, save it + // in the Hashtable if we don't already have an + // entry for this SQL type. + + m_aTypeInfo.push_back(aInfo); + } + + // Close the result set/statement. + + Reference< XCloseable> xClose(xRs,UNO_QUERY); + xClose->close(); +} +//------------------------------------------------------------------------------ +void OConnection::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + + // m_aTables.disposing(); + for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i) + { + Reference< XComponent > xComp(i->get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + } + m_aStatements.clear(); + + OTools::ThrowException(N3SQLDisconnect(m_aConnectionHandle),m_aConnectionHandle,SQL_HANDLE_DBC,*this); + m_bClosed = sal_True; + m_xMetaData = NULL; + + dispose_ChildImpl(); + OConnection_BASE::disposing(); + +// for (OWeakRefArray::iterator j = m_aComposers.begin(); m_aComposers.end() != j; j++) +// { +// Reference< XComponent > xComp(j->get(), UNO_QUERY); +// if (xComp.is()) +// xComp->dispose(); +// } +// m_aComposers.clear(); +} + + diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaData.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaData.cxx new file mode 100644 index 000000000000..e9b81e3dd70f --- /dev/null +++ b/connectivity/source/drivers/odbc/ODatabaseMetaData.cxx @@ -0,0 +1,1593 @@ +/************************************************************************* + * + * $RCSfile: ODatabaseMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_ODBC_ODATABASEMETADATA_HXX_ +#include "odbc/ODatabaseMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_OTOOLS_HXX_ +#include "odbc/OTools.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_ORESULTSET_HXX_ +#include "odbc/OResultSet.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _CONNECTIVITY_OFUNCTIONDEFS_HXX_ +#include "odbc/OFunctiondefs.hxx" +#endif + + +using namespace connectivity::odbc; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +ODatabaseMetaData::ODatabaseMetaData(const SQLHANDLE _pHandle,OConnection* _pCon) + : m_aConnectionHandle(_pHandle),m_pConnection(_pCon) +{ + m_pConnection->acquire(); +} +// ------------------------------------------------------------------------- +ODatabaseMetaData::~ODatabaseMetaData() +{ + if (m_pConnection) + m_pConnection->release(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openTypeInfo(); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openCatalogs(); + return xRef; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogSeparator( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aVal; + OTools::GetInfo(m_aConnectionHandle,SQL_CATALOG_NAME_SEPARATOR,aVal,*this); + + return aVal; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openSchemas(); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, + const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openColumnPrivileges(catalog,schema,table,columnNamePattern); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, + const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openColumns(catalog,schemaPattern,tableNamePattern,columnNamePattern); + return xRef; +} +// ------------------------------------------------------------------------- +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) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openTables(catalog,schemaPattern,tableNamePattern,types); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns( + const Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openProcedureColumns(catalog,schemaPattern,procedureNamePattern,columnNamePattern); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures( + const Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openProcedures(catalog,schemaPattern,procedureNamePattern); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openVersionColumns(catalog,schema,table); + return xRef; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_BINARY_LITERAL_LEN,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_ROW_SIZE,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_CATALOG_NAME_LEN,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_CHAR_LITERAL_LEN,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_COLUMN_NAME_LEN,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_COLUMNS_IN_INDEX,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_CURSOR_NAME_LEN,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_ACTIVE_CONNECTIONS,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_COLUMNS_IN_TABLE,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_STATEMENT_LEN,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_TABLE_NAME_LEN,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTablesInSelect( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_TABLES_IN_SELECT,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openExportedKeys(catalog,schema,table); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openImportedKeys(catalog,schema,table); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openPrimaryKeys(catalog,schema,table); + return xRef; +} +// ------------------------------------------------------------------------- +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) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openIndexInfo(catalog,schema,table,unique,approximate); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, + sal_Bool nullable ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openBestRowIdentifier(catalog,schema,table,scope,nullable); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openTablePrivileges(catalog,schemaPattern,tableNamePattern); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference( + const Any& primaryCatalog, const ::rtl::OUString& primarySchema, + const ::rtl::OUString& primaryTable, const Any& foreignCatalog, + const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openForeignKeys(primaryCatalog,primarySchema.toChar() == '%' ? &primarySchema : NULL,&primaryTable, + foreignCatalog, foreignSchema.toChar() == '%' ? &foreignSchema : NULL,&foreignTable); + return xRef; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aVal; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_ROW_SIZE_INCLUDES_LONG,aVal,*this); + return aVal.toChar() == 'Y'; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this); + return nValue == SQL_IC_LOWER; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this); + return nValue == SQL_IC_LOWER; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this); + return nValue == SQL_IC_MIXED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this); + return nValue == SQL_IC_MIXED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this); + return nValue == SQL_IC_UPPER; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this); + return nValue == SQL_IC_UPPER; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_ALTER_TABLE,nValue,*this); + return nValue == SQL_AT_ADD_COLUMN; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_ALTER_TABLE,nValue,*this); + return nValue == SQL_AT_DROP_COLUMN; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_INDEX_SIZE,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_NON_NULLABLE_COLUMNS,nValue,*this); + return nValue == SQL_NNC_NON_NULL; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aVal; + OTools::GetInfo(m_aConnectionHandle,SQL_CATALOG_TERM,aVal,*this); + return aVal; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getIdentifierQuoteString( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aVal; + OTools::GetInfo(m_aConnectionHandle,SQL_IDENTIFIER_QUOTE_CHAR,aVal,*this); + return aVal; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aVal; + OTools::GetInfo(m_aConnectionHandle,SQL_SPECIAL_CHARACTERS,aVal,*this); + return aVal; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); + return nValue != SQL_CN_NONE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::isCatalogAtStart( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CATALOG_LOCATION,nValue,*this); + return nValue == SQL_CL_START; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this); + return nValue == SQL_TC_DDL_IGNORE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this); + return nValue == SQL_TC_DDL_COMMIT; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this); + return nValue == SQL_TC_DML; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this); + return nValue == SQL_TC_ALL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this); + return (nValue & SQL_CA1_POS_DELETE) == SQL_CA1_POS_DELETE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this); + return (nValue & SQL_CA1_POS_UPDATE) == SQL_CA1_POS_UPDATE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CURSOR_ROLLBACK_BEHAVIOR,nValue,*this); + return nValue == SQL_CB_PRESERVE || nValue == SQL_CB_CLOSE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CURSOR_COMMIT_BEHAVIOR,nValue,*this); + return nValue == SQL_CB_PRESERVE || nValue == SQL_CB_CLOSE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CURSOR_COMMIT_BEHAVIOR,nValue,*this); + return nValue == SQL_CB_PRESERVE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CURSOR_ROLLBACK_BEHAVIOR,nValue,*this); + return nValue == SQL_CB_PRESERVE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_TXN_ISOLATION_OPTION,nValue,*this); + return (nValue & level) == level; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInDataManipulation( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this); + return (nValue & SQL_SU_DML_STATEMENTS) == SQL_SU_DML_STATEMENTS; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this); + return nValue == SQL_SC_SQL92_FULL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this); + return nValue == SQL_SC_SQL92_ENTRY; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aStr; + OTools::GetInfo(m_aConnectionHandle,SQL_INTEGRITY,aStr,*this); + return aStr.toChar() == 'Y'; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this); + return (nValue & SQL_SU_INDEX_DEFINITION) == SQL_SU_INDEX_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInTableDefinitions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this); + return (nValue & SQL_SU_TABLE_DEFINITION) == SQL_SU_TABLE_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this); + return (nValue & SQL_CU_TABLE_DEFINITION) == SQL_CU_TABLE_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this); + return (nValue & SQL_CU_INDEX_DEFINITION) == SQL_CU_INDEX_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this); + return (nValue & SQL_CU_DML_STATEMENTS) == SQL_CU_DML_STATEMENTS; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_OJ_CAPABILITIES,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException) +{ + SQLHANDLE hStmt; + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); + + OResultSet* pResult = new OResultSet(hStmt); + Reference< XResultSet > xRef = pResult; + pResult->openTablesTypes(); + return xRef; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatements( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_CONCURRENT_ACTIVITIES,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_PROCEDURE_NAME_LEN,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_SCHEMA_NAME_LEN,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this); + return nValue != SQL_TC_NONE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_ACCESSIBLE_PROCEDURES,aValue,*this); + return aValue.toChar() == 'Y'; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_PROCEDURES,aValue,*this); + return aValue.toChar() == 'Y'; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this); + return (nValue & SQL_CA1_POSITIONED_UPDATE) == SQL_CA1_POSITIONED_UPDATE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_ACCESSIBLE_TABLES,aValue,*this); + return aValue.toChar() == 'Y'; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException) +{ + sal_Bool bValue; + OTools::GetInfo(m_aConnectionHandle,SQL_DATA_SOURCE_READ_ONLY,bValue,*this); + return bValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_FILE_USAGE,nValue,*this); + return nValue == SQL_FILE_CATALOG; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_FILE_USAGE,nValue,*this); + return nValue == SQL_FILE_TABLE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_FUNCTIONS,nValue,*this); + return (nValue & SQL_FN_CVT_CONVERT) == SQL_FN_CVT_CONVERT; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CONCAT_NULL_BEHAVIOR,nValue,*this); + return nValue == SQL_CB_NULL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_COLUMN_ALIAS,aValue,*this); + return aValue.toChar() == 'Y'; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); + return nValue != SQL_CN_NONE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(SQLException, RuntimeException) +{ + if(fromType == toType) + return sal_True; + + sal_Int32 nValue=0; + switch(fromType) + { + case DataType::BIT: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_BIT,nValue,*this); + break; + case DataType::TINYINT: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_TINYINT,nValue,*this); + break; + case DataType::SMALLINT: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_SMALLINT,nValue,*this); + break; + case DataType::INTEGER: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_INTEGER,nValue,*this); + break; + case DataType::BIGINT: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_BIGINT,nValue,*this); + break; + case DataType::FLOAT: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_FLOAT,nValue,*this); + break; + case DataType::REAL: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_REAL,nValue,*this); + break; + case DataType::DOUBLE: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_DOUBLE,nValue,*this); + break; + case DataType::NUMERIC: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_NUMERIC,nValue,*this); + break; + case DataType::DECIMAL: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_DECIMAL,nValue,*this); + break; + case DataType::CHAR: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_CHAR,nValue,*this); + break; + case DataType::VARCHAR: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_VARCHAR,nValue,*this); + break; + case DataType::LONGVARCHAR: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_LONGVARCHAR,nValue,*this); + break; + case DataType::DATE: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_DATE,nValue,*this); + break; + case DataType::TIME: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_TIME,nValue,*this); + break; + case DataType::TIMESTAMP: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_TIMESTAMP,nValue,*this); + break; + case DataType::BINARY: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_BINARY,nValue,*this); + break; + case DataType::VARBINARY: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_VARBINARY,nValue,*this); + break; + case DataType::LONGVARBINARY: + OTools::GetInfo(m_aConnectionHandle,SQL_CONVERT_LONGVARBINARY,nValue,*this); + break; + case DataType::SQLNULL: + // OTools::GetInfo(m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); + break; + case DataType::OTHER: + // OTools::GetInfo(m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); + break; + case DataType::OBJECT: + // OTools::GetInfo(m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); + break; + case DataType::DISTINCT: + // OTools::GetInfo(m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); + break; + case DataType::STRUCT: + // OTools::GetInfo(m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); + break; + case DataType::ARRAY: + // OTools::GetInfo(m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); + break; + case DataType::BLOB: + // OTools::GetInfo(m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); + break; + case DataType::CLOB: + // OTools::GetInfo(m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); + break; + case DataType::REF: + // OTools::GetInfo(m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); + break; + } + sal_Bool bConvert = sal_False; + switch(toType) + { + case DataType::BIT: + bConvert = (nValue & SQL_CVT_BIT) == SQL_CVT_BIT; + break; + case DataType::TINYINT: + bConvert = (nValue & SQL_CVT_TINYINT) == SQL_CVT_TINYINT; + break; + case DataType::SMALLINT: + bConvert = (nValue & SQL_CVT_SMALLINT) == SQL_CVT_SMALLINT; + break; + case DataType::INTEGER: + bConvert = (nValue & SQL_CVT_INTEGER) == SQL_CVT_INTEGER; + break; + case DataType::BIGINT: + bConvert = (nValue & SQL_CVT_BIGINT) == SQL_CVT_BIGINT; + break; + case DataType::FLOAT: + bConvert = (nValue & SQL_CVT_FLOAT) == SQL_CVT_FLOAT; + break; + case DataType::REAL: + bConvert = (nValue & SQL_CVT_REAL) == SQL_CVT_REAL; + break; + case DataType::DOUBLE: + bConvert = (nValue & SQL_CVT_DOUBLE) == SQL_CVT_DOUBLE; + break; + case DataType::NUMERIC: + bConvert = (nValue & SQL_CVT_NUMERIC) == SQL_CVT_NUMERIC; + break; + case DataType::DECIMAL: + bConvert = (nValue & SQL_CVT_DECIMAL) == SQL_CVT_DECIMAL; + break; + case DataType::CHAR: + bConvert = (nValue & SQL_CVT_CHAR) == SQL_CVT_CHAR; + break; + case DataType::VARCHAR: + bConvert = (nValue & SQL_CVT_VARCHAR) == SQL_CVT_VARCHAR; + break; + case DataType::LONGVARCHAR: + bConvert = (nValue & SQL_CVT_LONGVARCHAR) == SQL_CVT_LONGVARCHAR; + break; + case DataType::DATE: + bConvert = (nValue & SQL_CVT_DATE) == SQL_CVT_DATE; + break; + case DataType::TIME: + bConvert = (nValue & SQL_CVT_TIME) == SQL_CVT_TIME; + break; + case DataType::TIMESTAMP: + bConvert = (nValue & SQL_CVT_TIMESTAMP) == SQL_CVT_TIMESTAMP; + break; + case DataType::BINARY: + bConvert = (nValue & SQL_CVT_BINARY) == SQL_CVT_BINARY; + break; + case DataType::VARBINARY: + bConvert = (nValue & SQL_CVT_VARBINARY) == SQL_CVT_VARBINARY; + break; + case DataType::LONGVARBINARY: + bConvert = (nValue & SQL_CVT_LONGVARBINARY) == SQL_CVT_LONGVARBINARY; + break; + } + + return bConvert; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_EXPRESSIONS_IN_ORDERBY,aValue,*this); + return aValue.toChar() == 'Y'; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_GROUP_BY,nValue,*this); + return nValue != SQL_GB_NOT_SUPPORTED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_GROUP_BY,nValue,*this); + return nValue != SQL_GB_GROUP_BY_CONTAINS_SELECT; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_GROUP_BY,nValue,*this); + return nValue == SQL_GB_NO_RELATION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MULTIPLE_ACTIVE_TXN,aValue,*this); + return aValue.toChar() == 'Y'; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MULT_RESULT_SETS,aValue,*this); + return aValue.toChar() == 'Y'; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_LIKE_ESCAPE_CLAUSE,aValue,*this); + return aValue.toChar() == 'Y'; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_ORDER_BY_COLUMNS_IN_SELECT,aValue,*this); + return aValue.toChar() == 'N'; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_UNION,nValue,*this); + return (nValue & SQL_U_UNION) == SQL_U_UNION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_UNION,nValue,*this); + return (nValue & SQL_U_UNION_ALL) == SQL_U_UNION_ALL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this); + return nValue == SQL_IC_MIXED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this); + return nValue == SQL_IC_MIXED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this); + return nValue == SQL_NC_END; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this); + return nValue == SQL_NC_START; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this); + return nValue == SQL_NC_HIGH; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this); + return nValue == SQL_NC_LOW; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this); + return nValue & SQL_SU_PROCEDURE_INVOCATION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this); + return nValue & SQL_SU_PRIVILEGE_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this); + return nValue & SQL_CU_PROCEDURE_INVOCATION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this); + return nValue & SQL_CU_PRIVILEGE_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this); + return (nValue & SQL_SQ_CORRELATED_SUBQUERIES) == SQL_SQ_CORRELATED_SUBQUERIES; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this); + return (nValue & SQL_SQ_COMPARISON) == SQL_SQ_COMPARISON; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this); + return (nValue & SQL_SQ_EXISTS) == SQL_SQ_EXISTS; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this); + return (nValue & SQL_SQ_IN) == SQL_SQ_IN; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this); + return (nValue & SQL_SQ_QUANTIFIED) == SQL_SQ_QUANTIFIED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this); + return nValue == SQL_SC_SQL92_INTERMEDIATE; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue = ::rtl::OUString::createFromAscii("sdbc:odbc:"); + OTools::GetInfo(m_aConnectionHandle,SQL_DATA_SOURCE_NAME,aValue,*this); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_USER_NAME,aValue,*this); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_DRIVER_NAME,aValue,*this); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_DRIVER_ODBC_VER,aValue,*this); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_DBMS_NAME,aValue,*this); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_PROCEDURE_TERM,aValue,*this); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SCHEMA_TERM,aValue,*this); + return aValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this); + return aValue.copy(0,aValue.indexOf('.')).toInt32(); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this); + return aValue.copy(0,aValue.lastIndexOf('.')).toInt32(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_KEYWORDS,aValue,*this); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SEARCH_PATTERN_ESCAPE,aValue,*this); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_STRING_FUNCTIONS,nValue,*this); + if(nValue & SQL_FN_STR_ASCII) + aValue = ::rtl::OUString::createFromAscii("ASCII,"); + if(nValue & SQL_FN_STR_BIT_LENGTH) + aValue += ::rtl::OUString::createFromAscii("BIT_LENGTH,"); + if(nValue & SQL_FN_STR_CHAR) + aValue += ::rtl::OUString::createFromAscii("CHAR,"); + if(nValue & SQL_FN_STR_CHAR_LENGTH) + aValue += ::rtl::OUString::createFromAscii("CHAR_LENGTH,"); + if(nValue & SQL_FN_STR_CHARACTER_LENGTH) + aValue += ::rtl::OUString::createFromAscii("CHARACTER_LENGTH,"); + if(nValue & SQL_FN_STR_CONCAT) + aValue += ::rtl::OUString::createFromAscii("CONCAT,"); + if(nValue & SQL_FN_STR_DIFFERENCE) + aValue += ::rtl::OUString::createFromAscii("DIFFERENCE,"); + if(nValue & SQL_FN_STR_INSERT) + aValue += ::rtl::OUString::createFromAscii("INSERT,"); + if(nValue & SQL_FN_STR_LCASE) + aValue += ::rtl::OUString::createFromAscii("LCASE,"); + if(nValue & SQL_FN_STR_LEFT) + aValue += ::rtl::OUString::createFromAscii("LEFT,"); + if(nValue & SQL_FN_STR_LENGTH) + aValue += ::rtl::OUString::createFromAscii("LENGTH,"); + if(nValue & SQL_FN_STR_LOCATE) + aValue += ::rtl::OUString::createFromAscii("LOCATE,"); + if(nValue & SQL_FN_STR_LOCATE_2) + aValue += ::rtl::OUString::createFromAscii("LOCATE_2,"); + if(nValue & SQL_FN_STR_LTRIM) + aValue += ::rtl::OUString::createFromAscii("LTRIM,"); + if(nValue & SQL_FN_STR_OCTET_LENGTH) + aValue += ::rtl::OUString::createFromAscii("OCTET_LENGTH,"); + if(nValue & SQL_FN_STR_POSITION) + aValue += ::rtl::OUString::createFromAscii("POSITION,"); + if(nValue & SQL_FN_STR_REPEAT) + aValue += ::rtl::OUString::createFromAscii("REPEAT,"); + if(nValue & SQL_FN_STR_REPLACE) + aValue += ::rtl::OUString::createFromAscii("REPLACE,"); + if(nValue & SQL_FN_STR_RIGHT) + aValue += ::rtl::OUString::createFromAscii("RIGHT,"); + if(nValue & SQL_FN_STR_RTRIM) + aValue += ::rtl::OUString::createFromAscii("RTRIM,"); + if(nValue & SQL_FN_STR_SOUNDEX) + aValue += ::rtl::OUString::createFromAscii("SOUNDEX,"); + if(nValue & SQL_FN_STR_SPACE) + aValue += ::rtl::OUString::createFromAscii("SPACE,"); + if(nValue & SQL_FN_STR_SUBSTRING) + aValue += ::rtl::OUString::createFromAscii("SUBSTRING,"); + if(nValue & SQL_FN_STR_UCASE) + aValue += ::rtl::OUString::createFromAscii("UCASE,"); + + + return aValue.copy(0,aValue.lastIndexOf(',')); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_TIMEDATE_FUNCTIONS,nValue,*this); + + if(nValue & SQL_FN_TD_CURRENT_DATE) + aValue = ::rtl::OUString::createFromAscii("CURRENT_DATE,"); + if(nValue & SQL_FN_TD_CURRENT_TIME) + aValue += ::rtl::OUString::createFromAscii("CURRENT_TIME,"); + if(nValue & SQL_FN_TD_CURRENT_TIMESTAMP) + aValue += ::rtl::OUString::createFromAscii("CURRENT_TIMESTAMP,"); + if(nValue & SQL_FN_TD_CURDATE) + aValue += ::rtl::OUString::createFromAscii("CURDATE,"); + if(nValue & SQL_FN_TD_CURTIME) + aValue += ::rtl::OUString::createFromAscii("CURTIME,"); + if(nValue & SQL_FN_TD_DAYNAME) + aValue += ::rtl::OUString::createFromAscii("DAYNAME,"); + if(nValue & SQL_FN_TD_DAYOFMONTH) + aValue += ::rtl::OUString::createFromAscii("DAYOFMONTH,"); + if(nValue & SQL_FN_TD_DAYOFWEEK) + aValue += ::rtl::OUString::createFromAscii("DAYOFWEEK,"); + if(nValue & SQL_FN_TD_DAYOFYEAR) + aValue += ::rtl::OUString::createFromAscii("DAYOFYEAR,"); + if(nValue & SQL_FN_TD_EXTRACT) + aValue += ::rtl::OUString::createFromAscii("EXTRACT,"); + if(nValue & SQL_FN_TD_HOUR) + aValue += ::rtl::OUString::createFromAscii("HOUR,"); + if(nValue & SQL_FN_TD_MINUTE) + aValue += ::rtl::OUString::createFromAscii("MINUTE,"); + if(nValue & SQL_FN_TD_MONTH) + aValue += ::rtl::OUString::createFromAscii("MONTH,"); + if(nValue & SQL_FN_TD_MONTHNAME) + aValue += ::rtl::OUString::createFromAscii("MONTHNAME,"); + if(nValue & SQL_FN_TD_NOW) + aValue += ::rtl::OUString::createFromAscii("NOW,"); + if(nValue & SQL_FN_TD_QUARTER) + aValue += ::rtl::OUString::createFromAscii("QUARTER,"); + if(nValue & SQL_FN_TD_SECOND) + aValue += ::rtl::OUString::createFromAscii("SECOND,"); + if(nValue & SQL_FN_TD_TIMESTAMPADD) + aValue += ::rtl::OUString::createFromAscii("TIMESTAMPADD,"); + if(nValue & SQL_FN_TD_TIMESTAMPDIFF) + aValue += ::rtl::OUString::createFromAscii("TIMESTAMPDIFF,"); + if(nValue & SQL_FN_TD_WEEK) + aValue += ::rtl::OUString::createFromAscii("WEEK,"); + if(nValue & SQL_FN_TD_YEAR) + aValue += ::rtl::OUString::createFromAscii("YEAR,"); + + return aValue.copy(0,aValue.lastIndexOf(',')); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_SYSTEM_FUNCTIONS,nValue,*this); + + if(nValue & SQL_FN_SYS_DBNAME) + aValue += ::rtl::OUString::createFromAscii("DBNAME,"); + if(nValue & SQL_FN_SYS_IFNULL) + aValue += ::rtl::OUString::createFromAscii("IFNULL,"); + if(nValue & SQL_FN_SYS_USERNAME) + aValue += ::rtl::OUString::createFromAscii("USERNAME,"); + + return aValue.copy(0,aValue.lastIndexOf(',')); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + ::rtl::OUString aValue; + OTools::GetInfo(m_aConnectionHandle,SQL_NUMERIC_FUNCTIONS,nValue,*this); + + if(nValue & SQL_FN_NUM_ABS) + aValue += ::rtl::OUString::createFromAscii("ABS,"); + if(nValue & SQL_FN_NUM_ACOS) + aValue += ::rtl::OUString::createFromAscii("ACOS,"); + if(nValue & SQL_FN_NUM_ASIN) + aValue += ::rtl::OUString::createFromAscii("ASIN,"); + if(nValue & SQL_FN_NUM_ATAN) + aValue += ::rtl::OUString::createFromAscii("ATAN,"); + if(nValue & SQL_FN_NUM_ATAN2) + aValue += ::rtl::OUString::createFromAscii("ATAN2,"); + if(nValue & SQL_FN_NUM_CEILING) + aValue += ::rtl::OUString::createFromAscii("CEILING,"); + if(nValue & SQL_FN_NUM_COS) + aValue += ::rtl::OUString::createFromAscii("COS,"); + if(nValue & SQL_FN_NUM_COT) + aValue += ::rtl::OUString::createFromAscii("COT,"); + if(nValue & SQL_FN_NUM_DEGREES) + aValue += ::rtl::OUString::createFromAscii("DEGREES,"); + if(nValue & SQL_FN_NUM_EXP) + aValue += ::rtl::OUString::createFromAscii("EXP,"); + if(nValue & SQL_FN_NUM_FLOOR) + aValue += ::rtl::OUString::createFromAscii("FLOOR,"); + if(nValue & SQL_FN_NUM_LOG) + aValue += ::rtl::OUString::createFromAscii("LOGF,"); + if(nValue & SQL_FN_NUM_LOG10) + aValue += ::rtl::OUString::createFromAscii("LOG10,"); + if(nValue & SQL_FN_NUM_MOD) + aValue += ::rtl::OUString::createFromAscii("MOD,"); + if(nValue & SQL_FN_NUM_PI) + aValue += ::rtl::OUString::createFromAscii("PI,"); + if(nValue & SQL_FN_NUM_POWER) + aValue += ::rtl::OUString::createFromAscii("POWER,"); + if(nValue & SQL_FN_NUM_RADIANS) + aValue += ::rtl::OUString::createFromAscii("RADIANS,"); + if(nValue & SQL_FN_NUM_RAND) + aValue += ::rtl::OUString::createFromAscii("RAND,"); + if(nValue & SQL_FN_NUM_ROUND) + aValue += ::rtl::OUString::createFromAscii("ROUND,"); + if(nValue & SQL_FN_NUM_SIGN) + aValue += ::rtl::OUString::createFromAscii("SIGN,"); + if(nValue & SQL_FN_NUM_SIN) + aValue += ::rtl::OUString::createFromAscii("SIN,"); + if(nValue & SQL_FN_NUM_SQRT) + aValue += ::rtl::OUString::createFromAscii("SQRT,"); + if(nValue & SQL_FN_NUM_TAN) + aValue += ::rtl::OUString::createFromAscii("TAN,"); + if(nValue & SQL_FN_NUM_TRUNCATE) + aValue += ::rtl::OUString::createFromAscii("TRUNCATE,"); + + + return aValue.copy(0,aValue.lastIndexOf(',')); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this); + return nValue == SQL_OIC_LEVEL2; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this); + return nValue == SQL_OIC_CORE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this); + return nValue == SQL_OIC_LEVEL1; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_OJ_CAPABILITIES,nValue,*this); + return (nValue & SQL_OJ_FULL) == SQL_OJ_FULL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException) +{ + return supportsFullOuterJoins( ); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_COLUMNS_IN_GROUP_BY,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_COLUMNS_IN_ORDER_BY,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_COLUMNS_IN_SELECT,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_MAX_USER_NAME_LEN,nValue,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + OTools::GetInfo(m_aConnectionHandle,SQL_CURSOR_SENSITIVITY,nValue,*this); + return (nValue & setType) == setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + SQLUSMALLINT nAskFor; + switch(setType) + { + case ResultSetType::FORWARD_ONLY: + nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2; + break; + case ResultSetType::SCROLL_INSENSITIVE: + nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2; + break; + case ResultSetType::SCROLL_SENSITIVE: + nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2; + break; + } + + OTools::GetInfo(m_aConnectionHandle,nAskFor,nValue,*this); + sal_Bool bRet = sal_False; + switch(concurrency) + { + case ResultSetConcurrency::READ_ONLY: + bRet = (nValue & SQL_CA2_READ_ONLY_CONCURRENCY) == SQL_CA2_READ_ONLY_CONCURRENCY; + break; + case ResultSetConcurrency::UPDATABLE: + bRet = (nValue & SQL_CA2_OPT_VALUES_CONCURRENCY) == SQL_CA2_OPT_VALUES_CONCURRENCY; + break; + } + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + SQLUSMALLINT nAskFor; + switch(setType) + { + case ResultSetType::FORWARD_ONLY: + nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2; + break; + case ResultSetType::SCROLL_INSENSITIVE: + nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2; + break; + case ResultSetType::SCROLL_SENSITIVE: + nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2; + break; + } + + OTools::GetInfo(m_aConnectionHandle,nAskFor,nValue,*this); + return (nValue & SQL_CA2_SENSITIVITY_UPDATES) == SQL_CA2_SENSITIVITY_UPDATES; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + SQLUSMALLINT nAskFor; + switch(setType) + { + case ResultSetType::FORWARD_ONLY: + nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2; + break; + case ResultSetType::SCROLL_INSENSITIVE: + nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2; + break; + case ResultSetType::SCROLL_SENSITIVE: + nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2; + break; + } + + OTools::GetInfo(m_aConnectionHandle,nAskFor,nValue,*this); + return (nValue & SQL_CA2_SENSITIVITY_DELETIONS) == SQL_CA2_SENSITIVITY_DELETIONS; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue; + SQLUSMALLINT nAskFor; + switch(setType) + { + case ResultSetType::FORWARD_ONLY: + nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2; + break; + case ResultSetType::SCROLL_INSENSITIVE: + nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2; + break; + case ResultSetType::SCROLL_SENSITIVE: + nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2; + break; + } + + OTools::GetInfo(m_aConnectionHandle,nAskFor,nValue,*this); + return (nValue & SQL_CA2_SENSITIVITY_ADDITIONS) == SQL_CA2_SENSITIVITY_ADDITIONS; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ownUpdatesAreVisible(setType); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ownDeletesAreVisible(setType); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ownInsertsAreVisible(setType); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const Sequence< sal_Int32 >& types ) throw(SQLException, RuntimeException) +{ + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection( ) throw(SQLException, RuntimeException) +{ + return (Reference< XConnection >)m_pConnection;//new OConnection(m_aConnectionHandle); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/odbc/ODriver.cxx b/connectivity/source/drivers/odbc/ODriver.cxx new file mode 100644 index 000000000000..c3f1c3489082 --- /dev/null +++ b/connectivity/source/drivers/odbc/ODriver.cxx @@ -0,0 +1,209 @@ +/************************************************************************* + * + * $RCSfile: ODriver.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_ODBC_ODRIVER_HXX_ +#include "odbc/ODriver.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OCONNECTION_HXX_ +#include "odbc/OConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_ +#include "odbc/OFunctions.hxx" +#endif + +using namespace connectivity::odbc; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +// -------------------------------------------------------------------------------- +ODBCDriver::ODBCDriver() : ODriver_BASE(m_aMutex),m_pDriverHandle(SQL_NULL_HANDLE) +{ +} +// -------------------------------------------------------------------------------- +void ODBCDriver::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + + for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) + { + Reference< XComponent > xComp(i->get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + } + m_xConnections.clear(); + + ODriver_BASE::disposing(); +} + +// static ServiceInfo +//------------------------------------------------------------------------------ +rtl::OUString ODBCDriver::getImplementationName_Static( ) throw(RuntimeException) +{ + return rtl::OUString::createFromAscii("com.sun.star.sdbc.ODBCDriver"); +} +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > ODBCDriver::getSupportedServiceNames_Static( ) throw (RuntimeException) +{ + Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver"); + return aSNS; +} + +//------------------------------------------------------------------ +::rtl::OUString SAL_CALL ODBCDriver::getImplementationName( ) throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------ +sal_Bool SAL_CALL ODBCDriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) + if (pSupported->equals(_rServiceName)) + return sal_True; + + return sal_False; +} + +//------------------------------------------------------------------ +Sequence< ::rtl::OUString > SAL_CALL ODBCDriver::getSupportedServiceNames( ) throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::odbc::ODBCDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ) +{ + return *(new ODBCDriver()); +} +// -------------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL ODBCDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) +{ + if(!m_pDriverHandle) + { + ::rtl::OUString aPath; + if(!EnvironmentHandle(aPath)) + throw SQLException(aPath,*this,::rtl::OUString(),1000,Any()); + } + OConnection* pCon = new OConnection(m_pDriverHandle,this); + pCon->Construct(url,info); + Reference< XConnection > xCon = pCon; + m_xConnections.push_back(WeakReferenceHelper(*pCon)); + + return xCon; +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL ODBCDriver::acceptsURL( const ::rtl::OUString& url ) + throw(SQLException, RuntimeException) +{ + if(!url.compareTo(::rtl::OUString::createFromAscii("sdbc:odbc:"),10)) + { + return sal_True; + } + return sal_False; +} +// -------------------------------------------------------------------------------- +Sequence< DriverPropertyInfo > SAL_CALL ODBCDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) +{ + return Sequence< DriverPropertyInfo >(); +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODBCDriver::getMajorVersion( ) throw(RuntimeException) +{ + return 1; +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODBCDriver::getMinorVersion( ) throw(RuntimeException) +{ + return 0; +} +// -------------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// ODBC Environment (gemeinsam fuer alle Connections): +SQLHANDLE ODBCDriver::EnvironmentHandle(::rtl::OUString &_rPath) +{ + // Ist (fuer diese Instanz) bereits ein Environment erzeugt worden? + if (!m_pDriverHandle) + { + SQLHANDLE h = SQL_NULL_HANDLE; + // Environment allozieren + + // ODBC-DLL jetzt laden: + if (!LoadLibrary_ODBC3(_rPath)) + return SQL_NULL_HANDLE; + + if (N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS) + return SQL_NULL_HANDLE; + + // In globaler Struktur merken ... + m_pDriverHandle = (void *) h; + SQLRETURN nError = N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION,(SQLPOINTER) SQL_OV_ODBC3, SQL_IS_UINTEGER); + //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER); + } + + return m_pDriverHandle; +} + + diff --git a/connectivity/source/drivers/odbc/OFunctions.cxx b/connectivity/source/drivers/odbc/OFunctions.cxx new file mode 100644 index 000000000000..5a50bf38bc7d --- /dev/null +++ b/connectivity/source/drivers/odbc/OFunctions.cxx @@ -0,0 +1,338 @@ +/************************************************************************* + * + * $RCSfile: OFunctions.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_ODBC_OFUNCTIONS_HXX_ +#include "odbc/OFunctions.hxx" +#endif + +// Implib-Definitionen fuer ODBC-DLL/shared library: + +using namespace connectivity; + +// ------------------------------------------------------------------------- +sal_Bool connectivity::LoadLibrary_ADABAS(::rtl::OUString &_rPath) +{ + static sal_Bool bLoaded = sal_False; + static oslModule pODBCso = NULL; + + if (bLoaded) + return TRUE; + + char *pPath =getenv("DBROOT"); + if(pPath) + { + +#if ( defined(SOLARIS) && defined(SPARC)) || defined(LINUX) + _rPath = ::rtl::OUString::createFromAscii(pPath); + _rPath += ::rtl::OUString::createFromAscii("/lib/"); +#endif + } +#if defined(WIN) || defined(WNT) + _rPath += ::rtl::OUString::createFromAscii("SQLOD32.DLL"); +#elif ( defined(SOLARIS) && defined(SPARC)) || defined(LINUX) + _rPath += ::rtl::OUString::createFromAscii("odbclib.so"); +#else + return sal_False; +#endif + + pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW ); + if( !pODBCso) + return sal_False; + + + return bLoaded = LoadFunctions(pODBCso,sal_False); +} +// ------------------------------------------------------------------------- +// Dynamisches Laden der DLL/shared lib und Adressen der Funktionen besorgen: +// Liefert TRUE bei Erfolg. +sal_Bool connectivity::LoadLibrary_ODBC3(::rtl::OUString &_rPath) +{ + static sal_Bool bLoaded = sal_False; + static oslModule pODBCso = NULL; + + if (bLoaded) + return TRUE; +#ifdef WIN + _rPath = ::rtl::OUString::createFromAscii("ODBC.DLL"); + +#endif +#ifdef WNT + _rPath = ::rtl::OUString::createFromAscii("ODBC32.DLL"); +#endif +#ifdef UNX + _rPath = ::rtl::OUString::createFromAscii("libodbc.so"); +#endif +#ifdef OS2 + _rPath = ::rtl::OUString::createFromAscii("ODBC"); +#endif + + pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW ); + if( !pODBCso) +#ifdef OS2 + { + delete pODBCso; + _rPath = ::rtl::OUString::createFromAscii("WOD402"); + pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW ); + if( !pODBCso) + return sal_False; + } +#else + return sal_False; +#endif + + return bLoaded = connectivity::LoadFunctions(pODBCso); +} +// ------------------------------------------------------------------------- + +sal_Bool connectivity::LoadFunctions(oslModule pODBCso, sal_Bool _bDS) +{ + + if( ( connectivity::pODBC3SQLAllocHandle = (T3SQLAllocHandle)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLAllocHandle").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLConnect = (T3SQLConnect)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLConnect").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLDriverConnect = (T3SQLDriverConnect)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDriverConnect").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLBrowseConnect = (T3SQLBrowseConnect)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBrowseConnect").pData )) == NULL ) + return sal_False; + if(_bDS && ( connectivity::pODBC3SQLDataSources = (T3SQLDataSources)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDataSources").pData )) == NULL ) + return sal_False; + if(_bDS && ( connectivity::pODBC3SQLDrivers = (T3SQLDrivers)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDrivers").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLGetInfo = (T3SQLGetInfo)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetInfo").pData )) == NULL ) + return sal_False; + if(_bDS && ( connectivity::pODBC3SQLGetFunctions = (T3SQLGetFunctions)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetFunctions").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLGetTypeInfo = (T3SQLGetTypeInfo)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetTypeInfo").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLSetConnectAttr = (T3SQLSetConnectAttr)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetConnectAttr").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLGetConnectAttr = (T3SQLGetConnectAttr)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetConnectAttr").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLSetEnvAttr = (T3SQLSetEnvAttr)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetEnvAttr").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLGetEnvAttr = (T3SQLGetEnvAttr)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetEnvAttr").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLSetStmtAttr = (T3SQLSetStmtAttr)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetStmtAttr").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLGetStmtAttr = (T3SQLGetStmtAttr)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetStmtAttr").pData )) == NULL ) + return sal_False; + /*if( ( connectivity::pODBC3SQLSetDescField = (T3SQLSetDescField)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetDescField").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLGetDescField = (T3SQLGetDescField)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDescField").pData )) == NULL ) + return sal_False;*/ + /*if( ( connectivity::pODBC3SQLGetDescRec = (T3SQLGetDescRec)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDescRec").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLSetDescRec = (T3SQLSetDescRec)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetDescRec").pData )) == NULL ) + return sal_False;*/ + if( ( connectivity::pODBC3SQLPrepare = (T3SQLPrepare)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPrepare").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLBindParameter = (T3SQLBindParameter)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBindParameter").pData )) == NULL ) + return sal_False; +// if( ( connectivity::pODBC3SQLGetCursorName = (T3SQLGetCursorName)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetCursorName").pData )) == NULL ) +// return sal_False; + if( ( connectivity::pODBC3SQLSetCursorName = (T3SQLSetCursorName)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetCursorName").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLExecute = (T3SQLExecute)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLExecute").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLExecDirect = (T3SQLExecDirect)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLExecDirect").pData )) == NULL ) + return sal_False; + /*if( ( connectivity::pODBC3SQLNativeSql = (T3SQLNativeSql)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNativeSql").pData )) == NULL ) + return sal_False;*/ + if( ( connectivity::pODBC3SQLDescribeParam = (T3SQLDescribeParam)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDescribeParam").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLNumParams = (T3SQLNumParams)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNumParams").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLParamData = (T3SQLParamData)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLParamData").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLPutData = (T3SQLPutData)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPutData").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLRowCount = (T3SQLRowCount)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLRowCount").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLNumResultCols = (T3SQLNumResultCols)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNumResultCols").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLDescribeCol = (T3SQLDescribeCol)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDescribeCol").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLColAttribute = (T3SQLColAttribute)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColAttribute").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLBindCol = (T3SQLBindCol)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBindCol").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLFetch = (T3SQLFetch)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFetch").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLFetchScroll = (T3SQLFetchScroll)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFetchScroll").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLGetData = (T3SQLGetData)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetData").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLSetPos = (T3SQLSetPos)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetPos").pData )) == NULL ) + return sal_False; + if( _bDS && ( connectivity::pODBC3SQLBulkOperations = (T3SQLBulkOperations)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBulkOperations").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLMoreResults = (T3SQLMoreResults)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLMoreResults").pData )) == NULL ) + return sal_False; + /*if( ( connectivity::pODBC3SQLGetDiagField = (T3SQLGetDiagField)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDiagField").pData )) == NULL ) + return sal_False;*/ + if( ( connectivity::pODBC3SQLGetDiagRec = (T3SQLGetDiagRec)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDiagRec").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLColumnPrivileges = (T3SQLColumnPrivileges)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColumnPrivileges").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLColumns = (T3SQLColumns)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColumns").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLForeignKeys = (T3SQLForeignKeys)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLForeignKeys").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLPrimaryKeys = (T3SQLPrimaryKeys)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPrimaryKeys").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLProcedureColumns = (T3SQLProcedureColumns)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLProcedureColumns").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLProcedures = (T3SQLProcedures)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLProcedures").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLSpecialColumns = (T3SQLSpecialColumns)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSpecialColumns").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLStatistics = (T3SQLStatistics)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLStatistics").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLTablePrivileges = (T3SQLTablePrivileges)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLTablePrivileges").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLTables = (T3SQLTables)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLTables").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLFreeStmt = (T3SQLFreeStmt)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFreeStmt").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLCloseCursor = (T3SQLCloseCursor)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLCloseCursor").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLCancel = (T3SQLCancel)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLCancel").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLEndTran = (T3SQLEndTran)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLEndTran").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLDisconnect = (T3SQLDisconnect)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDisconnect").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLFreeHandle = (T3SQLFreeHandle)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFreeHandle").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLGetCursorName = (T3SQLGetCursorName)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetCursorName").pData )) == NULL ) + return sal_False; + if( ( connectivity::pODBC3SQLNativeSql = (T3SQLNativeSql)osl_getSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNativeSql").pData )) == NULL ) + return sal_False; + + return sal_True; +} +// ------------------------------------------------------------------------- + +connectivity::T3SQLAllocHandle connectivity::pODBC3SQLAllocHandle; +connectivity::T3SQLConnect connectivity::pODBC3SQLConnect; +connectivity::T3SQLDriverConnect connectivity::pODBC3SQLDriverConnect; +connectivity::T3SQLBrowseConnect connectivity::pODBC3SQLBrowseConnect; +connectivity::T3SQLDataSources connectivity::pODBC3SQLDataSources; +connectivity::T3SQLDrivers connectivity::pODBC3SQLDrivers; +connectivity::T3SQLGetInfo connectivity::pODBC3SQLGetInfo; +connectivity::T3SQLGetFunctions connectivity::pODBC3SQLGetFunctions; +connectivity::T3SQLGetTypeInfo connectivity::pODBC3SQLGetTypeInfo; +connectivity::T3SQLSetConnectAttr connectivity::pODBC3SQLSetConnectAttr; +connectivity::T3SQLGetConnectAttr connectivity::pODBC3SQLGetConnectAttr; +connectivity::T3SQLSetEnvAttr connectivity::pODBC3SQLSetEnvAttr; +connectivity::T3SQLGetEnvAttr connectivity::pODBC3SQLGetEnvAttr; +connectivity::T3SQLSetStmtAttr connectivity::pODBC3SQLSetStmtAttr; +connectivity::T3SQLGetStmtAttr connectivity::pODBC3SQLGetStmtAttr; +//connectivity::T3SQLSetDescField connectivity::pODBC3SQLSetDescField; +//connectivity::T3SQLGetDescField connectivity::pODBC3SQLGetDescField; +//connectivity::T3SQLGetDescRec connectivity::pODBC3SQLGetDescRec; +//connectivity::T3SQLSetDescRec connectivity::pODBC3SQLSetDescRec; +connectivity::T3SQLPrepare connectivity::pODBC3SQLPrepare; +connectivity::T3SQLBindParameter connectivity::pODBC3SQLBindParameter; +//connectivity::T3SQLGetCursorName connectivity::pODBC3SQLGetCursorName; +connectivity::T3SQLSetCursorName connectivity::pODBC3SQLSetCursorName; +connectivity::T3SQLExecute connectivity::pODBC3SQLExecute; +connectivity::T3SQLExecDirect connectivity::pODBC3SQLExecDirect; +//connectivity::T3SQLNativeSql connectivity::pODBC3SQLNativeSql; +connectivity::T3SQLDescribeParam connectivity::pODBC3SQLDescribeParam; +connectivity::T3SQLNumParams connectivity::pODBC3SQLNumParams; +connectivity::T3SQLParamData connectivity::pODBC3SQLParamData; +connectivity::T3SQLPutData connectivity::pODBC3SQLPutData; +connectivity::T3SQLRowCount connectivity::pODBC3SQLRowCount; +connectivity::T3SQLNumResultCols connectivity::pODBC3SQLNumResultCols; +connectivity::T3SQLDescribeCol connectivity::pODBC3SQLDescribeCol; +connectivity::T3SQLColAttribute connectivity::pODBC3SQLColAttribute; +connectivity::T3SQLBindCol connectivity::pODBC3SQLBindCol; +connectivity::T3SQLFetch connectivity::pODBC3SQLFetch; +connectivity::T3SQLFetchScroll connectivity::pODBC3SQLFetchScroll; +connectivity::T3SQLGetData connectivity::pODBC3SQLGetData; +connectivity::T3SQLSetPos connectivity::pODBC3SQLSetPos; +connectivity::T3SQLBulkOperations connectivity::pODBC3SQLBulkOperations; +connectivity::T3SQLMoreResults connectivity::pODBC3SQLMoreResults; +//connectivity::T3SQLGetDiagField connectivity::pODBC3SQLGetDiagField; +connectivity::T3SQLGetDiagRec connectivity::pODBC3SQLGetDiagRec; +connectivity::T3SQLColumnPrivileges connectivity::pODBC3SQLColumnPrivileges; +connectivity::T3SQLColumns connectivity::pODBC3SQLColumns; +connectivity::T3SQLForeignKeys connectivity::pODBC3SQLForeignKeys; +connectivity::T3SQLPrimaryKeys connectivity::pODBC3SQLPrimaryKeys; +connectivity::T3SQLProcedureColumns connectivity::pODBC3SQLProcedureColumns; +connectivity::T3SQLProcedures connectivity::pODBC3SQLProcedures; +connectivity::T3SQLSpecialColumns connectivity::pODBC3SQLSpecialColumns; +connectivity::T3SQLStatistics connectivity::pODBC3SQLStatistics; +connectivity::T3SQLTablePrivileges connectivity::pODBC3SQLTablePrivileges; +connectivity::T3SQLTables connectivity::pODBC3SQLTables; +connectivity::T3SQLFreeStmt connectivity::pODBC3SQLFreeStmt; +connectivity::T3SQLCloseCursor connectivity::pODBC3SQLCloseCursor; +connectivity::T3SQLCancel connectivity::pODBC3SQLCancel; +connectivity::T3SQLEndTran connectivity::pODBC3SQLEndTran; +connectivity::T3SQLDisconnect connectivity::pODBC3SQLDisconnect; +connectivity::T3SQLFreeHandle connectivity::pODBC3SQLFreeHandle; +connectivity::T3SQLGetCursorName connectivity::pODBC3SQLGetCursorName; +connectivity::T3SQLNativeSql connectivity::pODBC3SQLNativeSql; + + diff --git a/connectivity/source/drivers/odbc/OPreparedStatement.cxx b/connectivity/source/drivers/odbc/OPreparedStatement.cxx new file mode 100644 index 000000000000..40da2368fb93 --- /dev/null +++ b/connectivity/source/drivers/odbc/OPreparedStatement.cxx @@ -0,0 +1,1063 @@ +/************************************************************************* + * + * $RCSfile: OPreparedStatement.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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 _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _CONNECTIVITY_ODBC_OPREPAREDSTATEMENT_HXX_ +#include "odbc/OPreparedStatement.hxx" +#endif +#ifndef _CONNECTIVITY_OBOUNPARAM_HXX_ +#include "odbc/OBoundParam.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _CONNECTIVITY_OTOOLS_HXX_ +#include "odbc/OTools.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_ +#include "odbc/OResultSetMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + +using namespace connectivity; +using namespace connectivity::odbc; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::container; +using namespace com::sun::star::io; +using namespace com::sun::star::util; + +int OBoundParam::ASCII = 1; +int OBoundParam::UNICODE = 2; +int OBoundParam::BINARY = 3; + +IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.OPreparedStatement","com.sun.star.sdbc.PreparedStatement"); + +OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const ::std::vector<OTypeInfo>& _TypeInfo,const ::rtl::OUString& sql) + : OStatement_BASE2( _pConnection ),m_aTypeInfo(_TypeInfo) +{ + ::rtl::OString aSql(::rtl::OUStringToOString(sql,osl_getThreadTextEncoding())); + N3SQLPrepare(m_aStatementHandle,(SDB_ODBC_CHAR *) aSql.getStr(),aSql.getLength()); + initBoundParam(); +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OStatement_BASE2::queryInterface(rType); + if(!aRet.hasValue()) + aRet = ::cppu::queryInterface( rType, + static_cast< XPreparedStatement*>(this), + static_cast< XParameters*>(this), + static_cast< XPreparedBatchExecution*>(this), + static_cast< XResultSetMetaDataSupplier*>(this)); + return aRet; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XResultSetMetaDataSupplier > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedBatchExecution > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OStatement_BASE2::getTypes()); +} +// ------------------------------------------------------------------------- + +Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException) +{ + if(m_xMetaData.is()) + m_xMetaData = new OResultSetMetaData(m_aStatementHandle); + return m_xMetaData; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::close( ) throw(SQLException, RuntimeException) +{ + // Close/clear our result set + clearMyResultSet (); + + // Reset last warning message + + try { + clearWarnings (); + if (m_aStatementHandle != SQL_NULL_HSTMT) + { + N3SQLFreeStmt (m_aStatementHandle, SQL_DROP); + m_aStatementHandle = SQL_NULL_HSTMT; + FreeParams(); + } + } + catch (SQLException & ex) { + // If we get an error, ignore + } + + // Remove this Statement object from the Connection object's + // list +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeException) +{ + sal_Bool hasResultSet = sal_False; + SQLWarning warning; + sal_Bool needData = sal_False; + + // Reset warnings + + clearWarnings (); + + // Reset the statement handle, warning and saved Resultset + + reset(); + + // Call SQLExecute + + try + { + SQLRETURN nReturn = N3SQLExecute(m_aStatementHandle); + + OTools::ThrowException(nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this); + needData = nReturn == SQL_NEED_DATA; + + // Now loop while more data is needed (i.e. a data-at- + // execution parameter was given). For each parameter + // that needs data, put the data from the input stream. + + while (needData) { + + // Get the parameter number that requires data + + sal_Int32* paramIndex = 0; + nReturn = N3SQLParamData(m_aStatementHandle,(SQLPOINTER*)¶mIndex); + + // If the parameter index is -1, there is no + // more data required + + if (*paramIndex == -1) + needData = sal_False; + else + { + // Now we have the proper parameter + // index, get the data from the input + // stream and do a SQLPutData + putParamData (*paramIndex); + } + } + + } + catch (SQLWarning& ex) + { + + // Save pointer to warning and save with ResultSet + // object once it is created. + + warning = ex; + } + + // Now loop while more data is needed (i.e. a data-at- + // execution parameter was given). For each parameter + // that needs data, put the data from the input stream. + + while (needData) { + + // Get the parameter number that requires data + + sal_Int32* paramIndex = 0; + N3SQLParamData (m_aStatementHandle,(SQLPOINTER*)¶mIndex); + + // If the parameter index is -1, there is no more + // data required + + if (*paramIndex == -1) { + needData = sal_False; + } + else { + // Now we have the proper parameter index, + // get the data from the input stream + // and do a SQLPutData + putParamData(*paramIndex); + } + } + + // Now determine if there is a result set associated with + // the SQL statement that was executed. Get the column + // count, and if it is not zero, there is a result set. + + if (getColumnCount () > 0) + hasResultSet = sal_True; + + + return hasResultSet; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException) +{ + sal_Int32 numRows = -1; + + // Execute the statement. If execute returns sal_False, a + // row count exists. + + if (!execute()) + numRows = getUpdateCount (); + else { + + // No update count was produced (a ResultSet was). Raise + // an exception + + throw SQLException(::rtl::OUString::createFromAscii("No row count was produced"), + *this, + ::rtl::OUString(),0,Any()); + } + return numRows; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException) +{ + setChar(parameterIndex, DataType::CHAR, 0, x); +} +// ------------------------------------------------------------------------- + +Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException) +{ + return (Reference< XConnection >)m_pConnection; +} +// ------------------------------------------------------------------------- + +Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException) +{ + Reference< XResultSet > rs = NULL; + + if (execute()) + rs = getResultSet(sal_False); + + else { + + // No ResultSet was produced. Raise an exception + + throw SQLException(::rtl::OUString::createFromAscii("No ResultSet was produced"), + *this, + ::rtl::OUString(),0,Any()); + } + return rs; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException) +{ + sal_Int32 value = 0; + + // If the parameter is sal_True, set the value to 1 + if (x) { + value = 1; + } + + // Set the parameter as if it were an integer + setInt (parameterIndex, value); +} +// ------------------------------------------------------------------------- +#define PREP_BIND_PARAM(_ty,_jt) \ + bindParameter( m_aStatementHandle, \ + parameterIndex, \ + bindBuf,getLengthBuf(parameterIndex), \ + _jt, \ + sal_False,sal_False,&x,(Reference <XInterface>)*this) + + + +void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException) +{ + // Allocate a buffer to be used in binding. This will be + // a 'permanent' buffer that the bridge will fill in with + // the bound data in native format. + if( !parameterIndex || parameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + sal_Int8* bindBuf = allocBindBuf(parameterIndex, 4); + PREP_BIND_PARAM(sal_Int8,SQL_TINYINT); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& aData ) throw(SQLException, RuntimeException) +{ + // Allocate a buffer to be used in binding. This will be + // a 'permanent' buffer that the bridge will fill in with + // the bound data in native format. + + if( !parameterIndex || parameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + sal_Int8* bindBuf = allocBindBuf (parameterIndex, 32); + + + DATE_STRUCT x = OTools::DateToOdbcDate(aData); + PREP_BIND_PARAM(DATE_STRUCT,DataType::DATE); +} +// ------------------------------------------------------------------------- + + +void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& aVal ) throw(SQLException, RuntimeException) +{ + // Allocate a buffer to be used in binding. This will be + // a 'permanent' buffer that the bridge will fill in with + // the bound data in native format. + if( !parameterIndex || parameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + sal_Int8* bindBuf = allocBindBuf (parameterIndex, 32); + + TIME_STRUCT x = OTools::TimeToOdbcTime(aVal); + PREP_BIND_PARAM(TIME_STRUCT,DataType::TIME); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& aVal ) throw(SQLException, RuntimeException) +{ + // Allocate a buffer to be used in binding. This will be + // a 'permanent' buffer that the bridge will fill in with + // the bound data in native format. + if( !parameterIndex || parameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + sal_Int8* bindBuf = allocBindBuf (parameterIndex, 32); + + TIMESTAMP_STRUCT x = OTools::DateTimeToTimestamp(aVal); + PREP_BIND_PARAM(TIMESTAMP_STRUCT,DataType::TIMESTAMP); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException) +{ + // Allocate a buffer to be used in binding. This will be + // a 'permanent' buffer that the bridge will fill in with + // the bound data in native format. + if( !parameterIndex || parameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + sal_Int8* bindBuf = allocBindBuf (parameterIndex, 8); + PREP_BIND_PARAM(double,DataType::DOUBLE); +} + +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException) +{ + // Allocate a buffer to be used in binding. This will be + // a 'permanent' buffer that the bridge will fill in with + // the bound data in native format. + if( !parameterIndex || parameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + sal_Int8* bindBuf = allocBindBuf (parameterIndex, 8); + PREP_BIND_PARAM(float,DataType::FLOAT); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException) +{ + // Allocate a buffer to be used in binding. This will be + // a 'permanent' buffer that the bridge will fill in with + // the bound data in native format. + if( !parameterIndex || parameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + sal_Int8* bindBuf = allocBindBuf (parameterIndex, 4); + PREP_BIND_PARAM(sal_Int32,DataType::INTEGER); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 aVal ) throw(SQLException, RuntimeException) +{ + // Allocate a buffer to be used in binding. This will be + // a 'permanent' buffer that the bridge will fill in with + // the bound data in native format. + + if( !parameterIndex || parameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + sal_Int8 *bindBuf = allocBindBuf (parameterIndex, 8); + float x = (float)aVal; + PREP_BIND_PARAM(float,DataType::BIGINT); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(SQLException, RuntimeException) +{ + // Get the buffer needed for the length + if( !parameterIndex || parameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + sal_Int8* lenBuf = getLengthBuf (parameterIndex); + *lenBuf = SQL_NULL_DATA; + UDWORD prec = 0; + if (sqlType == SQL_CHAR) + prec = 1; + + N3SQLBindParameter(m_aStatementHandle, + parameterIndex, + SQL_PARAM_INPUT, + SQL_C_DEFAULT, + sqlType, + prec, + 0, + NULL, + 0, + (SDWORD*)lenBuf + ); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setArray( sal_Int32 parameterIndex, const Reference< XArray >& x ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setRef( sal_Int32 parameterIndex, const Reference< XRef >& x ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException) +{ + // For each known SQL Type, call the appropriate + // set routine + + switch (sqlType) + { + case DataType::CHAR: + setString (parameterIndex, *(::rtl::OUString*) x.getValue()); + break; + + case DataType::VARCHAR: + setChar (parameterIndex, sqlType, 0, *(::rtl::OUString*) x.getValue()); + break; + + case DataType::LONGVARCHAR: + setChar (parameterIndex, sqlType, 0, *(::rtl::OUString*) x.getValue()); + break; + + case DataType::BIT: + setBoolean (parameterIndex,*(sal_Bool*) x.getValue()); + break; + + case DataType::TINYINT: + setByte (parameterIndex, *(sal_Int8*)x.getValue()); + break; + + case DataType::SMALLINT: + setShort (parameterIndex, *(short*)x.getValue()); + break; + + case DataType::INTEGER: + setInt (parameterIndex,*(sal_Int32*)x.getValue ()); + break; + + case DataType::BIGINT: + // setLong (parameterIndex,((sal_Int32) x).longValue ()); + break; + + case DataType::REAL: + setFloat (parameterIndex, *(float*)x.getValue ()); + break; + + case DataType::FLOAT: + setFloat (parameterIndex, *(float*)x.getValue ()); + break; + + case DataType::DOUBLE: + setDouble (parameterIndex,*(double*)x.getValue ()); + break; + + case DataType::BINARY: + setBytes (parameterIndex, *(Sequence<sal_Int8>*)x.getValue()); + break; + + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + { + Sequence<sal_Int8> y; + x >>= y; + + if ( y.getLength() > 2000 ) + { + // setBinaryStream (parameterIndex, y, y.getLength()); + } + else + { + setBinary (parameterIndex, sqlType, y); + } + } + + break; + + case DataType::DATE: + setDate (parameterIndex,*(Date*) x.getValue()); + break; + + case DataType::TIME: + setTime (parameterIndex, *(Time*)x.getValue()); + break; + + case DataType::TIMESTAMP: + setTimestamp (parameterIndex,*(DateTime*)x.getValue()); + break; + + default: + { + ::rtl::OUString aVal = ::rtl::OUString::createFromAscii("Unknown SQL Type for PreparedStatement.setObject (SQL Type="); + aVal += ::rtl::OUString::valueOf(sqlType); + throw SQLException( aVal, + *this, + ::rtl::OUString(),0,Any()); + } + + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(SQLException, RuntimeException) +{ + setNull(parameterIndex,sqlType); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException) +{ + // setObject (parameterIndex, x, sqlType, 0); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException) +{ + // Allocate a buffer to be used in binding. This will be + // a 'permanent' buffer that the bridge will fill in with + // the bound data in native format. + if( !parameterIndex || parameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + sal_Int8* bindBuf = allocBindBuf (parameterIndex, 4); + PREP_BIND_PARAM(sal_Int16,DataType::SMALLINT); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) +{ + if ( x.getLength() > 2000 ) + { + // setBinaryStream (parameterIndex, new java.io.ByteArrayInputStream(x), x.length); + } + else + { + setBinary (parameterIndex, DataType::BINARY, x); + } +} +// ------------------------------------------------------------------------- + + +void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + setStream (parameterIndex, x, length, DataType::LONGVARCHAR,OBoundParam::ASCII); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + setStream (parameterIndex, x, length, DataType::LONGVARBINARY,OBoundParam::BINARY); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException) +{ + N3SQLFreeStmt (m_aStatementHandle, SQL_RESET_PARAMS); +} +// ------------------------------------------------------------------------- +void SAL_CALL OPreparedStatement::clearBatch( ) throw(SQLException, RuntimeException) +{ + // clearParameters( ); + // m_aBatchList.erase(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::addBatch( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +Sequence< sal_Int32 > SAL_CALL OPreparedStatement::executeBatch( ) throw(SQLException, RuntimeException) +{ + return Sequence< sal_Int32 > (); +} +// ------------------------------------------------------------------------- + +//==================================================================== +// methods +//==================================================================== + +//-------------------------------------------------------------------- +// initBoundParam +// Initialize the bound parameter objects +//-------------------------------------------------------------------- + +void OPreparedStatement::initBoundParam () throw(SQLException) +{ + // Get the number of parameters + numParams = 0; + N3SQLNumParams (m_aStatementHandle,(short*)&numParams); + + // There are parameter markers, allocate the bound + // parameter objects + + if (numParams > 0) + { + // Allocate an array of bound parameter objects + + boundParams = new OBoundParam[numParams]; + + // Allocate and initialize each bound parameter + + for (sal_Int32 i = 0; i < numParams; i++) + { + boundParams[i] = OBoundParam(); + boundParams[i].initialize (); + } + } +} +// ------------------------------------------------------------------------- + +//-------------------------------------------------------------------- +// allocBindBuf +// Allocate storage for the permanent data buffer for the bound +// parameter. +//-------------------------------------------------------------------- + +sal_Int8* OPreparedStatement::allocBindBuf( sal_Int32 index,sal_Int32 bufLen) +{ + sal_Int8* b = NULL; + + // Sanity check the parameter number + + if ((index >= 1) && + (index <= numParams)) + { + b = boundParams[index - 1].allocBindDataBuffer(bufLen); + } + + return b; +} +// ------------------------------------------------------------------------- + +//-------------------------------------------------------------------- +// getDataBuf +// Gets the data buffer for the given parameter index +//-------------------------------------------------------------------- + +sal_Int8* OPreparedStatement::getDataBuf (sal_Int32 index) +{ + sal_Int8* b = NULL; + + // Sanity check the parameter number + + if ((index >= 1) && + (index <= numParams)) + { + b = boundParams[index - 1].getBindDataBuffer (); + } + + return b; +} +// ------------------------------------------------------------------------- + +//-------------------------------------------------------------------- +// getLengthBuf +// Gets the length buffer for the given parameter index +//-------------------------------------------------------------------- + +sal_Int8* OPreparedStatement::getLengthBuf (sal_Int32 index) +{ + sal_Int8* b = NULL; + + // Sanity check the parameter number + + if ((index >= 1) && + (index <= numParams)) + { + b = boundParams[index - 1].getBindLengthBuffer (); + } + + return b; +} +// ------------------------------------------------------------------------- + +//-------------------------------------------------------------------- +// getParamLength +// Returns the length of the given parameter number. When each +// parameter was bound, a 4-sal_Int8 buffer was given to hold the +// length (stored in native format). Get the buffer, convert the +// buffer from native format, and return it. If the length is -1, +// the column is considered to be NULL. +//-------------------------------------------------------------------- + +sal_Int32 OPreparedStatement::getParamLength ( sal_Int32 index) +{ + sal_Int32 paramLen = SQL_NULL_DATA; + + // Sanity check the parameter number + + if ((index >= 1) && + (index <= numParams)) { + + // Now get the length of the parameter from the + // bound param array. -1 is returned if it is NULL. + long n = 0; + memcpy (&n, boundParams[index -1].getBindLengthBuffer (), sizeof (n)); + paramLen = n; + } + return paramLen; +} +// ------------------------------------------------------------------------- + +//-------------------------------------------------------------------- +// putParamData +// Puts parameter data from a previously bound input stream. The +// input stream was bound using SQL_LEN_DATA_AT_EXEC. +//-------------------------------------------------------------------- + +void OPreparedStatement::putParamData (sal_Int32 index) throw(SQLException) +{ + // We'll transfer up to maxLen at a time + sal_Int32 maxLen = MAX_PUT_DATA_LENGTH; + sal_Int32 bufLen; + sal_Int32 realLen; + // sal_Int8* buf = new sal_Int8[maxLen]; + Sequence< sal_Int8 > buf(maxLen); + sal_Bool endOfStream = sal_False; + + // Sanity check the parameter index + if ((index < 1) || + (index > numParams)) + { + return; + } + + // Get the information about the input stream + + Reference< XInputStream> inputStream = boundParams[index - 1].getInputStream (); + sal_Int32 inputStreamLen = boundParams[index - 1].getInputStreamLen (); + sal_Int32 inputStreamType = boundParams[index - 1].getStreamType (); + + // Loop while more data from the input stream + + while (!endOfStream) + { + + // Read some data from the input stream + + try { + bufLen = inputStream->readBytes(buf,maxLen); + } + catch (IOException& ex) { + + // If an I/O exception was generated, turn + // it into a SQLException + + throw SQLException(ex.Message,*this,::rtl::OUString(),0,Any()); + } + + // -1 as the number of bytes read indicates that + // there is no more data in the input stream + + if (bufLen == -1) + { + + // Sanity check to ensure that all the data we said we + // had was read. If not, raise an exception + + if (inputStreamLen != 0) { + throw SQLException (::rtl::OUString::createFromAscii("End of InputStream reached before satisfying length specified when InputStream was set"), + *this, + ::rtl::OUString(),0,Any()); + } + endOfStream = sal_True; + break; + } + + // If we got more bytes than necessary, truncate + // the buffer by re-setting the buffer length. Also, + // indicate that we don't need to read any more. + + if (bufLen > inputStreamLen) + { + bufLen = inputStreamLen; + endOfStream = sal_True; + } + + realLen = bufLen; + + // For UNICODE streams, strip off the high sal_Int8 and set the + // number of actual bytes present. It is assumed that + // there are 2 bytes present for every UNICODE character - if + // not, then that's not our problem + + if (inputStreamType == OBoundParam::UNICODE) + { + realLen = bufLen / 2; + + for (sal_Int32 ii = 0; ii < realLen; ii++) + buf[ii] = buf[(ii * 2) + 1]; + } + + // Put the data + + N3SQLPutData (m_aStatementHandle, buf.getArray(), realLen); + + // Decrement the number of bytes still needed + + inputStreamLen -= bufLen; + + + // If there is no more data to be read, exit loop + + if (inputStreamLen == 0) + endOfStream = sal_True; + } +} +// ------------------------------------------------------------------------- +//-------------------------------------------------------------------- +// getPrecision +// Given a SQL type, return the maximum precision for the column. +// Returns -1 if not known +//-------------------------------------------------------------------- + +sal_Int32 OPreparedStatement::getPrecision ( sal_Int32 sqlType) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 prec = -1; + OTypeInfo aInfo; + aInfo.nType = sqlType; + if (m_aTypeInfo.size()) + { + ::std::vector<OTypeInfo>::const_iterator aIter = ::std::find(m_aTypeInfo.begin(),m_aTypeInfo.end(),aInfo); + if(aIter != m_aTypeInfo.end()) + prec = (*aIter).nPrecision; + } + return prec; +} + +//-------------------------------------------------------------------- +// setStream +// Sets an input stream as a parameter, using the given SQL type +//-------------------------------------------------------------------- + +void OPreparedStatement::setStream ( + sal_Int32 ParameterIndex, + const Reference< XInputStream>& x, + sal_Int32 length, + sal_Int32 SQLtype, + sal_Int32 streamType) + throw(SQLException) +{ + if( !ParameterIndex || ParameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + // Get the buffer needed for the length + + sal_Int8* lenBuf = getLengthBuf(ParameterIndex); + + // Allocate a new buffer for the parameter data. This buffer + // will be returned by SQLParamData (it is set to the parameter + // number, a 4-sal_Int8 integer) + + sal_Int8* dataBuf = allocBindBuf (ParameterIndex, 4); + + // Bind the parameter with SQL_LEN_DATA_AT_EXEC + SWORD Ctype = SQL_C_CHAR; + SDWORD atExec = SQL_LEN_DATA_AT_EXEC (length); + memcpy (dataBuf, &ParameterIndex, sizeof(ParameterIndex)); + memcpy (lenBuf, &atExec, sizeof (atExec)); + + if ((SQLtype == SQL_BINARY) || (SQLtype == SQL_VARBINARY) || (SQLtype == SQL_LONGVARBINARY)) + Ctype = SQL_C_BINARY; + + + N3SQLBindParameter(m_aStatementHandle, ParameterIndex,SQL_PARAM_INPUT,Ctype, + SQLtype, length,0, dataBuf, sizeof(ParameterIndex),(SDWORD*)lenBuf); + + // Save the input stream + + boundParams[ParameterIndex - 1].setInputStream (x, length); + + // Set the stream type + + boundParams[ParameterIndex - 1].setStreamType (streamType); +} +// ------------------------------------------------------------------------- + +//-------------------------------------------------------------------- +// setChar +// Binds the given string to the given SQL type +//-------------------------------------------------------------------- +void OPreparedStatement::setChar(sal_Int32 parameterIndex, + sal_Int32 SQLtype, + sal_Int32 scale, + const ::rtl::OUString& x) + throw(SQLException) +{ + // ::rtl::OString x1(::rtl::OUStringToOString(x,osl_getThreadTextEncoding())); + + if( !parameterIndex || parameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + sal_Int8* bindBuf = allocBindBuf (parameterIndex,x.getLength()); + + // Get the precision for this SQL type. If the precision + // is out of bounds, set it to our default + +// sal_Int32 precision = getPrecision (SQLtype); +// +// if ((precision < 0) || (precision > 2000)) +// precision = 2000; +// + // bindParameter(m_aStatementHandle,parameterIndex,bindBuf); + PREP_BIND_PARAM(char*,SQLtype); + +// // Make a copy of the data +// SDWORD lBuf = x.getLength(); +// memcpy (bindBuf, x.getStr(), lBuf); +// bindBuf[lBuf] = '\0'; +// precision = lBuf; +// +// SQLINTEGER nNTS = SQL_NTS; +// +// SQLRETURN nRet = N3SQLBindParameter(m_aStatementHandle, parameterIndex,SQL_PARAM_INPUT, +// SQLtype,SQL_C_CHAR, precision, scale, bindBuf,lBuf, &nNTS); +// +} +// ------------------------------------------------------------------------- + +//-------------------------------------------------------------------- +// setBinary +// Binds the given sal_Int8 array to the given SQL type +//-------------------------------------------------------------------- + +void OPreparedStatement::setBinary (sal_Int32 parameterIndex,sal_Int32 SQLtype, + const Sequence< sal_Int8 >& x) throw(SQLException) +{ + // Allocate a buffer to be used in binding. This will be + // a 'permanent' buffer that the bridge will fill in with + // the bound data in native format. + if( !parameterIndex || parameterIndex > numParams) + throw SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,Any()); + + sal_Int8* bindBuf = allocBindBuf (parameterIndex,x.getLength()); + + // Get the buffer needed for the length + + // sal_Int8* lenBuf = getLengthBuf (parameterIndex); + bindParameter< Sequence< sal_Int8 > >( m_aStatementHandle, + parameterIndex, + bindBuf,getLengthBuf(parameterIndex), + SQLtype, + sal_False,sal_False,&x,(Reference <XInterface>)*this); + + + // N3SQLBindInParameterBinary (m_aStatementHandle, parameterIndex, + // SQLtype, x.getConstArray(), bindBuf, lenBuf, buffers); + +} +// ------------------------------------------------------------------------- + +void OPreparedStatement::FreeParams() +{ + delete boundParams; +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/odbc/OResultSet.cxx b/connectivity/source/drivers/odbc/OResultSet.cxx new file mode 100644 index 000000000000..fbf4538f6d56 --- /dev/null +++ b/connectivity/source/drivers/odbc/OResultSet.cxx @@ -0,0 +1,2051 @@ +/************************************************************************* + * + * $RCSfile: OResultSet.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_ODBC_ORESULTSET_HXX_ +#include "odbc/OResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _CONNECTIVITY_OTOOLS_HXX_ +#include "odbc/OTools.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_ +#include "odbc/OResultSetMetaData.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_ +#include <com/sun/star/sdbcx/CompareBookmark.hpp> +#endif +#ifndef _UTL_PROPERTY_HXX_ +#include <unotools/property.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif +//#ifndef _CONNECTIVITY_OTOOLS_HXX_ +//#include "odbc/OTools.hxx" +//#endif + +using namespace connectivity::odbc; +using namespace cppu; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::container; +using namespace com::sun::star::io; +using namespace com::sun::star::util; +//------------------------------------------------------------------------------ +// IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet"); +::rtl::OUString SAL_CALL OResultSet::getImplementationName( ) throw ( RuntimeException) \ +{ + return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.odbc.ResultSet"); +} +// ------------------------------------------------------------------------- + Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames( ) throw( RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(2); + aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet"); + aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet"); + return aSupported; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) + if (pSupported->equals(_rServiceName)) + return sal_True; + + return sal_False; +} + +// ------------------------------------------------------------------------- +OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) : OResultSet_BASE(m_aMutex) + ,OPropertySetHelper(OResultSet_BASE::rBHelper) + ,m_aStatement((OWeakObject*)pStmt) + ,m_aStatementHandle(_pStatementHandle) + ,m_aConnectionHandle(pStmt->getConnectionHandle()) + ,m_nRowPos(0) + ,m_bLastRecord(sal_False) + ,m_bEOF(sal_False) + ,m_bFreeHandle(sal_False) + ,m_xMetaData(NULL) + ,m_bInserting(sal_False) + ,m_nLastColumnPos(0) +{ + osl_incrementInterlockedCount( &m_refCount ); + m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value + N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER); + + SQLSMALLINT nValueLen = 0; + N3SQLGetInfo(m_aConnectionHandle,SQL_GETDATA_EXTENSIONS,&nValueLen,sizeof nValueLen,&nValueLen); + SQLINTEGER nCurType = 0; + N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nCurType,SQL_IS_UINTEGER,0); + + allocBuffer((SQL_GD_ANY_ORDER & nValueLen) != SQL_GD_ANY_ORDER && nCurType != SQL_CURSOR_FORWARD_ONLY); + osl_decrementInterlockedCount( &m_refCount ); +} +// ------------------------------------------------------------------------- +OResultSet::OResultSet(SQLHANDLE _pStatementHandle ) : OResultSet_BASE(m_aMutex) + ,OPropertySetHelper(OResultSet_BASE::rBHelper) + ,m_aStatement(NULL) + ,m_aStatementHandle(_pStatementHandle) + ,m_aConnectionHandle(NULL) + ,m_nRowPos(0) + ,m_bLastRecord(sal_False) + ,m_bEOF(sal_False) + ,m_bFreeHandle(sal_False) + ,m_xMetaData(NULL) + ,m_bInserting(sal_False) + ,m_nLastColumnPos(0) +{ + osl_incrementInterlockedCount( &m_refCount ); + m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value + osl_decrementInterlockedCount( &m_refCount ); + // allocBuffer(); +} + +// ------------------------------------------------------------------------- +OResultSet::~OResultSet() +{ + delete m_pRowStatusArray; + if(m_aBindVector.size()) + releaseBuffer(); +} +// ------------------------------------------------------------------------- +void OResultSet::disposing(void) +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + if(m_bFreeHandle) + { + N3SQLFreeStmt(m_aStatementHandle,SQL_CLOSE); + N3SQLFreeHandle(SQL_HANDLE_STMT,m_aStatementHandle); + m_aStatementHandle = NULL; + } + m_aStatement = NULL; + m_xMetaData = NULL; +} +// ------------------------------------------------------------------------- +void OResultSet::allocBuffer(sal_Bool _bAllocRow) +{ + m_bFetchData = !_bAllocRow; + m_aBindVector.push_back(NULL); // the first is reserved for the bookmark + Reference< XResultSetMetaData > xMeta = getMetaData(); + sal_Int32 nLen = xMeta->getColumnCount(); + for(sal_Int32 i = 1;i<=nLen;++i) + { + switch (xMeta->getColumnType(i)) + { + case DataType::CHAR: + case DataType::VARCHAR: + m_aBindVector.push_back(new ::rtl::OString()); + break; + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::BIGINT: + m_aBindVector.push_back(new ::rtl::OString()); + break; + case DataType::DOUBLE: + m_aBindVector.push_back(new double(0.0)); + break; + case DataType::LONGVARCHAR: + m_aBindVector.push_back(new char[2]); // dient nur zum auffinden + break; + case DataType::LONGVARBINARY: + m_aBindVector.push_back(new char[2]); // dient nur zum auffinden + break; + case DataType::DATE: + m_aBindVector.push_back(new DATE_STRUCT); + break; + case DataType::TIME: + m_aBindVector.push_back(new TIME_STRUCT); + break; + case DataType::TIMESTAMP: + m_aBindVector.push_back(new TIMESTAMP_STRUCT); + break; + case DataType::BIT: + m_aBindVector.push_back(new sal_Int8(0)); + break; + case DataType::TINYINT: + case DataType::SMALLINT: + m_aBindVector.push_back(new sal_Int16(0)); + break; + case DataType::INTEGER: + m_aBindVector.push_back(new sal_Int32(0)); + break; + case DataType::REAL: + m_aBindVector.push_back(new float(0)); + break; + case DataType::BINARY: + case DataType::VARBINARY: + m_aBindVector.push_back(new sal_Int8[xMeta->getPrecision(i)]); + break; + } + } + m_aLengthVector.resize(nLen + 1); +// if(_bAllocRow) +// m_aRow.resize(nLen + 1); +} +// ------------------------------------------------------------------------- +void OResultSet::releaseBuffer() +{ + Reference< XResultSetMetaData > xMeta = getMetaData(); + sal_Int32 nLen = xMeta->getColumnCount(); + for(sal_Int32 i = 0;i<nLen;++i) + { + switch (xMeta->getColumnType(i+1)) + { + case DataType::CHAR: + case DataType::VARCHAR: + delete (::rtl::OString*) m_aBindVector[i]; + break; + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::BIGINT: + delete (::rtl::OString*) m_aBindVector[i]; + break; + case DataType::DOUBLE: + m_aBindVector.push_back(new double(0.0)); + break; + case DataType::LONGVARCHAR: + delete (char*) m_aBindVector[i]; + break; + case DataType::LONGVARBINARY: + delete (char*) m_aBindVector[i]; + break; + case DataType::DATE: + delete (DATE_STRUCT*) m_aBindVector[i]; + break; + case DataType::TIME: + delete (TIME_STRUCT*) m_aBindVector[i]; + break; + case DataType::TIMESTAMP: + delete (TIMESTAMP_STRUCT*) m_aBindVector[i]; + break; + case DataType::BIT: + delete (sal_Int8*) m_aBindVector[i]; + break; + case DataType::TINYINT: + case DataType::SMALLINT: + delete (sal_Int16*) m_aBindVector[i]; + break; + case DataType::INTEGER: + delete (sal_Int32*) m_aBindVector[i]; + break; + case DataType::REAL: + delete (float*) m_aBindVector[i]; + break; + case DataType::BINARY: + case DataType::VARBINARY: + delete (sal_Int8*) m_aBindVector[i]; + break; + } + } + m_aLengthVector.clear(); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OPropertySetHelper::queryInterface(rType); + if(!aRet.hasValue()) + aRet = OResultSet_BASE::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- + Sequence< Type > SAL_CALL OResultSet::getTypes( ) throw( RuntimeException) +{ + OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), + ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), + ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes()); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + Reference< XResultSetMetaData > xMeta = getMetaData(); + sal_Int32 nLen = xMeta->getColumnCount(); + sal_Int32 i = 1; + for(;i<=nLen;++i) + if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) : columnName.equalsIgnoreCase(xMeta->getColumnName(i))) + break; + return i; +} +// ------------------------------------------------------------------------- +Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + // TODO use getBytes instead of + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + // TODO use getBytes instead of + return NULL; +} + +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + +// if(m_bFetchData) +// { +// if(columnIndex > m_nLastColumnPos) +// fillRow(columnIndex); +// return any2bool(m_aRow[columnIndex]); +// } + + + return getValue(m_aStatementHandle,columnIndex,SQL_C_BIT,m_bWasNull,**this,sal_Int8(0)); +} +// ------------------------------------------------------------------------- + +sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +// if(!m_bFetchData) +// { +// if(columnIndex > m_nLastColumnPos) +// fillRow(columnIndex); +// return getINT16(m_aRow[columnIndex]); +// } + + + return getValue(m_aStatementHandle,columnIndex,SQL_C_CHAR,m_bWasNull,**this,sal_Int8(0)); +} +// ------------------------------------------------------------------------- + +Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +// if(!m_bFetchData) +// { +// if(columnIndex > m_nLastColumnPos) +// fillRow(columnIndex); +// return *(Sequence< sal_Int8 >*)m_aRow[columnIndex].getValue(); // no assignment because this is very expensive +// } + return OTools::getBytesValue(m_aStatementHandle,columnIndex,getMetaData()->getColumnType(columnIndex),m_bWasNull,**this); +} +// ------------------------------------------------------------------------- + +Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +// if(!m_bFetchData) +// { +// if(columnIndex > m_nLastColumnPos) +// fillRow(columnIndex); +// Date aRet; +// m_aRow[columnIndex] >>= aRet; +// return aRet; +// } + + DATE_STRUCT aDate; + aDate.day = 0; + aDate.month = 0; + aDate.year = 0; + aDate = getValue(m_aStatementHandle,columnIndex,SQL_C_DATE,m_bWasNull,**this,aDate); + return Date(aDate.day,aDate.month,aDate.year); +} +// ------------------------------------------------------------------------- + +double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +// if(!m_bFetchData) +// { +// if(columnIndex > m_nLastColumnPos) +// fillRow(columnIndex); +// return connectivity::getDouble(m_aRow[columnIndex]); +// } + return getValue(m_aStatementHandle,columnIndex,SQL_C_DOUBLE,m_bWasNull,**this,double(0.0)); +} +// ------------------------------------------------------------------------- + +float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +// if(!m_bFetchData) +// { +// if(columnIndex > m_nLastColumnPos) +// fillRow(columnIndex); +// float nRet = 0.0; +// m_aRow[columnIndex] >>= nRet; +// return nRet; +// } + return getValue(m_aStatementHandle,columnIndex,SQL_C_FLOAT,m_bWasNull,**this,float(0)); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +// if(!m_bFetchData) +// { +// if(columnIndex > m_nLastColumnPos) +// fillRow(columnIndex); +// return getINT32(m_aRow[columnIndex]); +// } + return getValue(m_aStatementHandle,columnIndex,SQL_C_LONG,m_bWasNull,**this,sal_Int32(0)); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 nValue = 0; + N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_NUMBER,&nValue,SQL_IS_UINTEGER,0); + return nValue; +} +// ------------------------------------------------------------------------- + +sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + return sal_Int64(); +} +// ------------------------------------------------------------------------- + +Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_xMetaData.is()) + m_xMetaData = new OResultSetMetaData(m_aStatementHandle); + return m_xMetaData; +} +// ------------------------------------------------------------------------- +Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + return NULL; +} + +// ------------------------------------------------------------------------- + +Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + return NULL; +} +// ------------------------------------------------------------------------- + +Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + return NULL; +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + return Any(); +} +// ------------------------------------------------------------------------- + +sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +// if(!m_bFetchData) +// { +// if(columnIndex > m_nLastColumnPos) +// fillRow(columnIndex); +// return getINT16(m_aRow[columnIndex]); +// } + return getValue(m_aStatementHandle,columnIndex,SQL_C_SHORT,m_bWasNull,**this,sal_Int16(0)); +} +// ------------------------------------------------------------------------- + + +::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +// if(!m_bFetchData) +// { +// if(columnIndex > m_nLastColumnPos) +// fillRow(columnIndex); +// ::rtl::OUString aRet; +// m_aRow[columnIndex] >>= aRet; +// return aRet; +// } + return OTools::getStringValue(m_aStatementHandle,columnIndex,getMetaData()->getColumnType(columnIndex),m_bWasNull,**this); +} +// ------------------------------------------------------------------------- + + +Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +// if(!m_bFetchData) +// { +// if(columnIndex > m_nLastColumnPos) +// fillRow(columnIndex); +// Time aRet; +// m_aRow[columnIndex] >>= aRet; +// return aRet; +// } + TIME_STRUCT aTime={0,0,0}; + aTime = getValue(m_aStatementHandle,columnIndex,SQL_C_TIME,m_bWasNull,**this,aTime); + return Time(0,aTime.second,aTime.minute,aTime.hour); +} +// ------------------------------------------------------------------------- + + +DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +// if(!m_bFetchData) +// { +// if(columnIndex > m_nLastColumnPos) +// fillRow(columnIndex); +// DateTime aRet; +// m_aRow[columnIndex] >>= aRet; +// return aRet; +// } + TIMESTAMP_STRUCT aTime={0,0,0,0,0,0,0}; + aTime = getValue(m_aStatementHandle,columnIndex,SQL_C_TIMESTAMP,m_bWasNull,**this,aTime); + return DateTime(aTime.fraction*1000,aTime.second,aTime.minute,aTime.hour,aTime.day,aTime.month,aTime.year); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_nCurrentFetchState == SQL_NO_DATA; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_nRowPos == 1; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_bEOF && m_nCurrentFetchState != SQL_NO_DATA; +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(first()) + previous(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(last()) + next(); + m_bEOF = sal_True; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + } + dispose(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_FIRST,0); + OTools::ThrowException(m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); + sal_Bool bRet; + if(bRet = (m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO)) + m_nRowPos = 1; + return bRet; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_LAST,0); + OTools::ThrowException(m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); + // here I know definitely that I stand on the last record + return m_bLastRecord = (m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_ABSOLUTE,row); + OTools::ThrowException(m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); + sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO; + if(bRet) + m_nRowPos = row; + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,row); + OTools::ThrowException(m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); + sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO; + if(bRet) + m_nRowPos += row; + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0); + OTools::ThrowException(m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); + sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO; + if(bRet) + --m_nRowPos; + return bRet; +} +// ------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_aStatement.get(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_pRowStatusArray[0] == SQL_ROW_DELETED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException) +{ ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_pRowStatusArray[0] == SQL_ROW_ADDED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_pRowStatusArray[0] == SQL_ROW_UPDATED; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return m_nRowPos == 0; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + // m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_NEXT,0); + m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle); + OTools::ThrowException(m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); + return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_bFetchData) + return !m_aRow[m_nLastColumnPos].hasValue(); + + return m_bWasNull; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::cancel( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OTools::ThrowException(N3SQLCancel(m_aStatementHandle),m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- +Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException) +{ + return Any(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + SQLRETURN nRet; + if(pODBC3SQLBulkOperations) + nRet = N3SQLBulkOperations(m_aStatementHandle, SQL_ADD); + else + { + if(isBeforeFirst()) + next(); // must be done + nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_ADD,SQL_LOCK_NO_CHANGE); + } + OTools::ThrowException(nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); + nRet = N3SQLFreeStmt(m_aStatementHandle,SQL_UNBIND); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + SQLRETURN nRet; + nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + if( nRet == SQL_NEED_DATA) + { + void * pData = NULL; + nRet = N3SQLParamData(m_aStatementHandle,&pData); + do + { + if (nRet != SQL_SUCCESS && nRet != SQL_SUCCESS_WITH_INFO && nRet != SQL_NEED_DATA) + break; + + ::std::vector<void*>::const_iterator aFound = ::std::find(m_aBindVector.begin(),m_aBindVector.end(),pData); + sal_Int32 nPos = m_aBindVector.size() - (m_aBindVector.end() - aFound); + + // TODO transfer long data + // N3SQLPutData(m_aStatementHandle,,); + nRet = N3SQLParamData(m_aStatementHandle,&pData); + } + while (nRet == SQL_NEED_DATA); + + } + OTools::ThrowException(nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); + // now unbind all columns so we can fetch all columns again with SQLGetData + nRet = N3SQLFreeStmt(m_aStatementHandle,SQL_UNBIND); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::deleteRow( ) throw(SQLException, RuntimeException) +{ + SQLRETURN nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_DELETE,SQL_LOCK_NO_CHANGE); + OTools::ThrowException(nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + // first unbound all columns + N3SQLFreeStmt(m_aStatementHandle,SQL_UNBIND); + // SQLRETURN nRet = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)1,SQL_IS_INTEGER); + m_bInserting = sal_True; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + bindValue(m_aStatementHandle,columnIndex,SQL_CHAR,0,0,(sal_Int8*)NULL,NULL,&m_aLengthVector[columnIndex],**this); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + void* pData = m_aBindVector[columnIndex]; + bindValue<sal_Bool>(m_aStatementHandle,columnIndex,SQL_BIT,0,0,&x,pData,&m_aLengthVector[columnIndex],**this); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + void* pData = m_aBindVector[columnIndex]; + bindValue(m_aStatementHandle,columnIndex,SQL_CHAR,0,0,&x,pData,&m_aLengthVector[columnIndex],**this); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + void* pData = m_aBindVector[columnIndex]; + bindValue(m_aStatementHandle,columnIndex,SQL_TINYINT,0,0,&x,pData,&m_aLengthVector[columnIndex],**this); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + void* pData = m_aBindVector[columnIndex]; + bindValue(m_aStatementHandle,columnIndex,SQL_INTEGER,0,0,&x,pData,&m_aLengthVector[columnIndex],**this); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + throw RuntimeException(); +} +// ----------------------------------------------------------------------- +void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + void* pData = m_aBindVector[columnIndex]; + bindValue(m_aStatementHandle,columnIndex,SQL_REAL,0,0,&x,pData,&m_aLengthVector[columnIndex],**this); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + void* pData = m_aBindVector[columnIndex]; + bindValue(m_aStatementHandle,columnIndex,SQL_DOUBLE,0,0,&x,pData,&m_aLengthVector[columnIndex],**this); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + void* pData = m_aBindVector[columnIndex]; + bindValue(m_aStatementHandle,columnIndex,SQL_VARCHAR,0,0,&x,pData,&m_aLengthVector[columnIndex],**this); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + void* pData = m_aBindVector[columnIndex]; + bindValue(m_aStatementHandle,columnIndex,SQL_BINARY,0,0,&x,pData,&m_aLengthVector[columnIndex],**this); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const Date& x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + void* pData = m_aBindVector[columnIndex]; + DATE_STRUCT aVal = OTools::DateToOdbcDate(x); + bindValue(m_aStatementHandle,columnIndex,SQL_DATE,0,0,&aVal,pData,&m_aLengthVector[columnIndex],**this); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const Time& x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + void* pData = m_aBindVector[columnIndex]; + TIME_STRUCT aVal = OTools::TimeToOdbcTime(x); + bindValue(m_aStatementHandle,columnIndex,SQL_TIME,0,0,&aVal,pData,&m_aLengthVector[columnIndex],**this); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const DateTime& x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + void* pData = m_aBindVector[columnIndex]; + TIMESTAMP_STRUCT aVal = OTools::DateTimeToTimestamp(x); + bindValue(m_aStatementHandle,columnIndex,SQL_TIMESTAMP,0,0,&aVal,pData,&m_aLengthVector[columnIndex],**this); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + SQLRETURN nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_REFRESH,SQL_LOCK_NO_CHANGE); + // m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0); + OTools::ThrowException(nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); +// switch(x.getValueTypeClass()) +// { +// case TypeClass_VOID: +// args[0].l = NULL; +// break; +// +// case TypeClass_BOOLEAN: +// { +// sal_Bool f; +// x >>= f; +// updateBoolean(columnIndex,f); +// } +// break; +// case TypeClass_BYTE: +// { +// sal_Int8 f; +// x >>= f; +// updateByte(columnIndex,f); +// } +// break; +// case TypeClass_SHORT: +// case TypeClass_UNSIGNED_SHORT: +// { +// sal_Int16 f; +// x >>= f; +// updateShort(columnIndex,f); +// } +// break; +// case TypeClass_LONG: +// case TypeClass_UNSIGNED_LONG: +// { +// sal_Int32 f; +// x >>= f; +// updateInt(columnIndex,f); +// } +// break; +// case TypeClass_HYPER: +// case TypeClass_UNSIGNED_HYPER: +// { +// sal_Int64 f; +// x >>= f; +// updateLong(columnIndex,f); +// } +// break; +// case TypeClass_FLOAT: +// { +// float f; +// x >>= f; +// updateFloat(columnIndex,f); +// } +// break; +// case TypeClass_DOUBLE: +// updateDouble(columnIndex,::utl::getDouble(x)); +// break; +// case TypeClass_CHAR: +// case TypeClass_STRING: +// updateString(columnIndex,::utl::getString(x)); +// break; +// case TypeClass_ENUM: +// default: +// OSL_ENSHURE(0,"UNKOWN TYPE for OResultSet::updateObject"); +// } +// return; +// // Parameter konvertieren +// // temporaere Variable initialisieren +// char * cSignature = "(ILjava/lang/Object;)V"; +// char * cMethodName = "updateObject"; +// // Java-Call absetzen +// } +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 scale ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + columnIndex = mapColumn(columnIndex); + OSL_ENSHURE(0,"OResultSet::updateNumericObject: NYI"); +// SDBThreadAttach t; +// if( t.pEnv ) +// { +// jvalue args[1]; +// // Parameter konvertieren +// args[0].l = +// // temporaere Variable initialisieren +// char * cSignature = "(I;Ljava/lang/Object;I)V"; +// char * cMethodName = "updateObject"; +// // Java-Call absetzen +// jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature ); +// if( mID ){ +// t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l,scale); + // ThrowSQLException(t.pEnv,*this); +// t.pEnv->DeleteLocalRef((jobject)args[0].l); +// } +// } +} +// ------------------------------------------------------------------------- +// XRowLocate +Any SAL_CALL OResultSet::getBookmark( ) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_uInt32 nValue = SQL_UB_OFF; + N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&nValue,SQL_IS_UINTEGER,NULL); + if(nValue == SQL_UB_OFF) + throw SQLException(); + + + return makeAny(OTools::getBytesValue(m_aStatementHandle,0,SQL_BINARY,m_bWasNull,**this)); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + Sequence<sal_Int8> aBookmark; + bookmark >>= aBookmark; + SQLRETURN nReturn = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_FETCH_BOOKMARK_PTR,aBookmark.getArray(),SQL_IS_POINTER); + + m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,0); + OTools::ThrowException(m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); + return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + Sequence<sal_Int8> aBookmark; + bookmark >>= aBookmark; + SQLRETURN nReturn = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_FETCH_BOOKMARK_PTR,aBookmark.getArray(),SQL_IS_POINTER); + + m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,rows); + OTools::ThrowException(m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this); + return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSet::compareBookmarks( const Any& first, const Any& second ) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return (first == second) ? CompareBookmark::EQUAL : CompareBookmark::NOT_EQUAL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException) +{ + throw SQLException(); +} +// ------------------------------------------------------------------------- +// XDeleteRows +Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& rows ) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OResultSet_BASE::rBHelper.bDisposed) + throw DisposedException(); + + SQLRETURN nReturn; + + const Any* pBegin = rows.getConstArray(); + const Any* pEnd = pBegin + rows.getLength(); + + typedef sal_Int8* sal_INT8; + sal_Int8** pArray = new sal_INT8[rows.getLength()]; + for(sal_Int32 i=0;pBegin != pEnd;++i,++pBegin) + { + pArray[i] = ((Sequence<sal_Int8>*)pBegin->getValue())->getArray(); + } + + sal_Int32* pStatusArray = new sal_Int32[rows.getLength()]; + + + nReturn = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR ,(SQLPOINTER)pStatusArray,SQL_IS_POINTER); + nReturn = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)rows.getLength(),SQL_IS_INTEGER); + sal_Int32 nLen = rows.getLength(); + nReturn = N3SQLBindCol(m_aStatementHandle,0,SQL_C_VARBOOKMARK,pArray,rows.getLength(),&nLen); + nReturn = N3SQLBulkOperations(m_aStatementHandle,SQL_DELETE_BY_BOOKMARK); + + delete [] pArray; + + Sequence< sal_Int32 > aRet(rows.getLength()); + for(sal_Int32 j=0;j<rows.getLength();++j) + { + aRet.getArray()[j] = pStatusArray[j] == SQL_ROW_SUCCESS; + } + delete pStatusArray; + delete pArray; + return aRet; +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getResultSetConcurrency() const throw( SQLException, RuntimeException) +{ + sal_uInt32 nValue; + N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CONCURRENCY,&nValue,SQL_IS_UINTEGER,0); + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getResultSetType() const throw( SQLException, RuntimeException) +{ + sal_uInt32 nValue; + N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_SENSITIVITY,&nValue,SQL_IS_UINTEGER,0); + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getFetchDirection() const throw( SQLException, RuntimeException) +{ + sal_uInt32 nValue; + N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nValue,SQL_IS_UINTEGER,0); + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getFetchSize() const throw( SQLException, RuntimeException) +{ + sal_uInt32 nValue; + N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,&nValue,SQL_IS_UINTEGER,0); + return nValue; +} +//------------------------------------------------------------------------------ +::rtl::OUString OResultSet::getCursorName() const throw( SQLException, RuntimeException) +{ + SQLCHAR pName[258]; + SQLSMALLINT nRealLen = 0; + N3SQLGetCursorName(m_aStatementHandle,(SQLCHAR*)pName,256,&nRealLen); + return ::rtl::OUString::createFromAscii((const char*)pName); +} +// ------------------------------------------------------------------------- +sal_Bool OResultSet::isBookmarkable() const throw( SQLException, RuntimeException) +{ + if(!m_aConnectionHandle) + return sal_False; + + sal_uInt32 nValue; + N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nValue,SQL_IS_UINTEGER,0); + + sal_Int32 nAttr = 0; + switch(nValue) + { + case SQL_CURSOR_FORWARD_ONLY: + return sal_False; + break; + case SQL_CURSOR_STATIC: + OTools::GetInfo(m_aConnectionHandle,SQL_STATIC_CURSOR_ATTRIBUTES1,nAttr,*(Reference< XInterface >*)this); + break; + case SQL_CURSOR_KEYSET_DRIVEN: + OTools::GetInfo(m_aConnectionHandle,SQL_KEYSET_CURSOR_ATTRIBUTES1,nAttr,*(Reference< XInterface >*)this); + break; + case SQL_CURSOR_DYNAMIC: + OTools::GetInfo(m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nAttr,*(Reference< XInterface >*)this); + break; + } + sal_uInt32 nUseBookmark = SQL_UB_OFF; + N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&nUseBookmark,SQL_IS_UINTEGER,NULL); + + return (nUseBookmark != SQL_UB_OFF) && (nAttr & SQL_CA1_BOOKMARK) == SQL_CA1_BOOKMARK; +} +//------------------------------------------------------------------------------ +void OResultSet::setFetchDirection(sal_Int32 _par0) throw( SQLException, RuntimeException) +{ + N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)_par0,SQL_IS_UINTEGER); +} +//------------------------------------------------------------------------------ +void OResultSet::setFetchSize(sal_Int32 _par0) throw( SQLException, RuntimeException) +{ + N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER); + delete m_pRowStatusArray; + m_pRowStatusArray = new SQLUSMALLINT[_par0]; + N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER); +} +// ------------------------------------------------------------------------- +IPropertyArrayHelper* OResultSet::createArrayHelper( ) const +{ + Sequence< Property > aProps(6); + Property* pProperties = aProps.getArray(); + sal_Int32 nPos = 0; + DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY); + DECL_PROP0(FETCHDIRECTION, sal_Int32); + DECL_PROP0(FETCHSIZE, sal_Int32); + DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY); + DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY); + DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY); + + return new OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +IPropertyArrayHelper & OResultSet::getInfoHelper() +{ + return *const_cast<OResultSet*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +sal_Bool OResultSet::convertFastPropertyValue( + Any & rConvertedValue, + Any & rOldValue, + sal_Int32 nHandle, + const Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException) +{ + switch(nHandle) + { + case PROPERTY_ID_ISBOOKMARKABLE: + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + throw ::com::sun::star::lang::IllegalArgumentException(); + break; + case PROPERTY_ID_FETCHDIRECTION: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); + case PROPERTY_ID_FETCHSIZE: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); + default: + ; + } + return sal_False; +} +// ------------------------------------------------------------------------- +void OResultSet::setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const Any& rValue + ) + throw (Exception) +{ + switch(nHandle) + { + case PROPERTY_ID_ISBOOKMARKABLE: + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + throw Exception(); + break; + case PROPERTY_ID_FETCHDIRECTION: + setFetchDirection(getINT32(rValue)); + break; + case PROPERTY_ID_FETCHSIZE: + setFetchSize(getINT32(rValue)); + break; + default: + ; + } +} +// ------------------------------------------------------------------------- +void OResultSet::getFastPropertyValue( + Any& rValue, + sal_Int32 nHandle + ) const +{ + switch(nHandle) + { + case PROPERTY_ID_ISBOOKMARKABLE: + rValue = bool2any(isBookmarkable()); + break; + case PROPERTY_ID_CURSORNAME: + rValue <<= getCursorName(); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + rValue <<= getResultSetConcurrency(); + break; + case PROPERTY_ID_RESULTSETTYPE: + rValue <<= getResultSetType(); + break; + case PROPERTY_ID_FETCHDIRECTION: + rValue <<= getFetchDirection(); + break; + case PROPERTY_ID_FETCHSIZE: + rValue <<= getFetchSize(); + break; + } +} +// ------------------------------------------------------------------------- +void OResultSet::openTypeInfo() throw(SQLException, RuntimeException) +{ + m_bFreeHandle = sal_True; + OTools::ThrowException(N3SQLGetTypeInfo(m_aStatementHandle, SQL_ALL_TYPES),m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +//----------------------------------------------------------------------------- +void OResultSet::openTables(const Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern, + const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException) +{ + m_bFreeHandle = sal_True; + ::rtl::OString aPKQ,aPKO,aPKN,aCOL; + const ::rtl::OUString *pSchemaPat = NULL; + + if(schemaPattern.toChar() != '%') + pSchemaPat = &schemaPattern; + else + pSchemaPat = NULL; + + const char *pPKQ = catalog.hasValue() ? (aPKQ = ::rtl::OUStringToOString(connectivity::getString(catalog), + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKO = pSchemaPat ? (aPKO = ::rtl::OUStringToOString(schemaPattern, + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKN = aPKN = ::rtl::OUStringToOString(tableNamePattern, + osl_getThreadTextEncoding() + ).getStr(); + + + const char *pCOL = NULL; + const ::rtl::OUString* pBegin = types.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + types.getLength(); + for(;pBegin != pEnd;++pBegin) + { + aCOL += ::rtl::OUStringToOString(*pBegin, + osl_getThreadTextEncoding() + ); + aCOL += ","; + } + if(aCOL.getLength()) + pCOL = aCOL.getStr(); + + SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle, + (SDB_ODBC_CHAR *) pPKQ, catalog.hasValue() ? SQL_NTS : 0, + (SDB_ODBC_CHAR *) pPKO, SQL_NTS , + (SDB_ODBC_CHAR *) pPKN, SQL_NTS, + (SDB_ODBC_CHAR *) pCOL, pCOL ? SQL_NTS : 0); + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); + +} +//----------------------------------------------------------------------------- +void OResultSet::openTablesTypes( ) throw(SQLException, RuntimeException) +{ + m_bFreeHandle = sal_True; + SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle, + 0,0, + 0,0, + 0,0, + (SDB_ODBC_CHAR *) SQL_ALL_TABLE_TYPES,SQL_NTS); + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); + + m_aColMapping.clear(); + m_aColMapping.push_back(-1); + m_aColMapping.push_back(4); + m_xMetaData = new OResultSetMetaData(m_aStatementHandle,m_aColMapping); +} +// ------------------------------------------------------------------------- +void OResultSet::openCatalogs() throw(SQLException, RuntimeException) +{ + m_bFreeHandle = sal_True; + SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle, + (SDB_ODBC_CHAR *) SQL_ALL_CATALOGS,SQL_NTS, + 0,0, + 0,0, + (SDB_ODBC_CHAR *) "",SQL_NTS); + + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); + + m_aColMapping.clear(); + m_aColMapping.push_back(-1); + m_aColMapping.push_back(1); + m_xMetaData = new OResultSetMetaData(m_aStatementHandle,m_aColMapping); +} +// ------------------------------------------------------------------------- +void OResultSet::openSchemas() throw(SQLException, RuntimeException) +{ + m_bFreeHandle = sal_True; + SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle, + 0,0, + (SDB_ODBC_CHAR *) SQL_ALL_SCHEMAS,SQL_NTS, + 0,0, + (SDB_ODBC_CHAR *) "",SQL_NTS); + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); + + m_aColMapping.clear(); + m_aColMapping.push_back(-1); + m_aColMapping.push_back(2); + m_xMetaData = new OResultSetMetaData(m_aStatementHandle,m_aColMapping); +} +// ------------------------------------------------------------------------- +void OResultSet::openColumnPrivileges( const Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) + throw(SQLException, RuntimeException) +{ + const ::rtl::OUString *pSchemaPat = NULL; + + if(schema.toChar() != '%') + pSchemaPat = &schema; + else + pSchemaPat = NULL; + + m_bFreeHandle = sal_True; + ::rtl::OString aPKQ,aPKO,aPKN,aCOL; + + const char *pPKQ = catalog.hasValue() ? (aPKQ = ::rtl::OUStringToOString(connectivity::getString(catalog), + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKO = pSchemaPat ? (aPKO = ::rtl::OUStringToOString(schema, + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKN = aPKN = ::rtl::OUStringToOString(table, + osl_getThreadTextEncoding() + ).getStr(), + *pCOL = aCOL = ::rtl::OUStringToOString(columnNamePattern, + osl_getThreadTextEncoding() + ).getStr(); + + + SQLRETURN nRetcode = N3SQLColumnPrivileges(m_aStatementHandle, + (SDB_ODBC_CHAR *) pPKQ, catalog.hasValue() ? SQL_NTS : 0, + (SDB_ODBC_CHAR *) pPKO, SQL_NTS , + (SDB_ODBC_CHAR *) pPKN, SQL_NTS, + (SDB_ODBC_CHAR *) pCOL, SQL_NTS); + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); + + +} +// ------------------------------------------------------------------------- +void OResultSet::openColumns( const Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) + throw(SQLException, RuntimeException) +{ + const ::rtl::OUString *pSchemaPat = NULL; + + if(schemaPattern.toChar() != '%') + pSchemaPat = &schemaPattern; + else + pSchemaPat = NULL; + + m_bFreeHandle = sal_True; + ::rtl::OString aPKQ,aPKO,aPKN,aCOL; + + const char *pPKQ = catalog.hasValue() ? (aPKQ = ::rtl::OUStringToOString(connectivity::getString(catalog), + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKO = pSchemaPat ? (aPKO = ::rtl::OUStringToOString(schemaPattern, + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKN = aPKN = ::rtl::OUStringToOString(tableNamePattern, + osl_getThreadTextEncoding() + ).getStr(), + *pCOL = aCOL = ::rtl::OUStringToOString(columnNamePattern, + osl_getThreadTextEncoding() + ).getStr(); + + + SQLRETURN nRetcode = N3SQLColumns(m_aStatementHandle, + (SDB_ODBC_CHAR *) pPKQ, catalog.hasValue() ? SQL_NTS : 0, + (SDB_ODBC_CHAR *) pPKO, SQL_NTS , + (SDB_ODBC_CHAR *) pPKN, SQL_NTS, + (SDB_ODBC_CHAR *) pCOL, SQL_NTS); + + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +// ------------------------------------------------------------------------- +void OResultSet::openProcedureColumns( const Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern,const ::rtl::OUString& columnNamePattern ) + throw(SQLException, RuntimeException) +{ + const ::rtl::OUString *pSchemaPat = NULL; + + if(schemaPattern.toChar() != '%') + pSchemaPat = &schemaPattern; + else + pSchemaPat = NULL; + + m_bFreeHandle = sal_True; + ::rtl::OString aPKQ,aPKO,aPKN,aCOL; + + const char *pPKQ = catalog.hasValue() ? (aPKQ = ::rtl::OUStringToOString(connectivity::getString(catalog), + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKO = pSchemaPat ? (aPKO = ::rtl::OUStringToOString(schemaPattern, + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKN = aPKN = ::rtl::OUStringToOString(procedureNamePattern, + osl_getThreadTextEncoding() + ).getStr(), + *pCOL = aCOL = ::rtl::OUStringToOString(columnNamePattern, + osl_getThreadTextEncoding() + ).getStr(); + + + SQLRETURN nRetcode = N3SQLProcedureColumns(m_aStatementHandle, + (SDB_ODBC_CHAR *) pPKQ, catalog.hasValue() ? SQL_NTS : 0, + (SDB_ODBC_CHAR *) pPKO, SQL_NTS , + (SDB_ODBC_CHAR *) pPKN, SQL_NTS, + (SDB_ODBC_CHAR *) pCOL, SQL_NTS); + + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +// ------------------------------------------------------------------------- +void OResultSet::openProcedures(const Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern) + throw(SQLException, RuntimeException) +{ + const ::rtl::OUString *pSchemaPat = NULL; + + if(schemaPattern.toChar() != '%') + pSchemaPat = &schemaPattern; + else + pSchemaPat = NULL; + + m_bFreeHandle = sal_True; + ::rtl::OString aPKQ,aPKO,aPKN,aCOL; + + const char *pPKQ = catalog.hasValue() ? (aPKQ = ::rtl::OUStringToOString(connectivity::getString(catalog), + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKO = pSchemaPat ? (aPKO = ::rtl::OUStringToOString(schemaPattern, + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKN = aPKN = ::rtl::OUStringToOString(procedureNamePattern, + osl_getThreadTextEncoding() + ).getStr(); + + + SQLRETURN nRetcode = N3SQLProcedures(m_aStatementHandle, + (SDB_ODBC_CHAR *) pPKQ, catalog.hasValue() ? SQL_NTS : 0, + (SDB_ODBC_CHAR *) pPKO, SQL_NTS , + (SDB_ODBC_CHAR *) pPKN, SQL_NTS); + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +// ------------------------------------------------------------------------- +void OResultSet::openSpecialColumns(sal_Bool _bRowVer,const Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table,sal_Int32 scope, sal_Bool nullable ) + throw(SQLException, RuntimeException) +{ + const ::rtl::OUString *pSchemaPat = NULL; + + if(schema.toChar() != '%') + pSchemaPat = &schema; + else + pSchemaPat = NULL; + + m_bFreeHandle = sal_True; + ::rtl::OString aPKQ,aPKO,aPKN,aCOL; + + const char *pPKQ = catalog.hasValue() ? (aPKQ = ::rtl::OUStringToOString(connectivity::getString(catalog), + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKO = pSchemaPat ? (aPKO = ::rtl::OUStringToOString(schema, + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKN = aPKN = ::rtl::OUStringToOString(table, + osl_getThreadTextEncoding() + ).getStr(); + + + SQLRETURN nRetcode = N3SQLSpecialColumns(m_aStatementHandle,_bRowVer ? SQL_ROWVER : SQL_BEST_ROWID, + (SDB_ODBC_CHAR *) pPKQ, catalog.hasValue() ? SQL_NTS : 0, + (SDB_ODBC_CHAR *) pPKO, SQL_NTS , + (SDB_ODBC_CHAR *) pPKN, SQL_NTS, + scope, + nullable ? SQL_NULLABLE : SQL_NO_NULLS); + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +// ------------------------------------------------------------------------- +void OResultSet::openVersionColumns(const Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table) throw(SQLException, RuntimeException) +{ + openSpecialColumns(sal_True,catalog,schema,table,SQL_SCOPE_TRANSACTION,sal_False); +} +// ------------------------------------------------------------------------- +void OResultSet::openBestRowIdentifier( const Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table,sal_Int32 scope,sal_Bool nullable ) throw(SQLException, RuntimeException) +{ + openSpecialColumns(sal_False,catalog,schema,table,scope,nullable); +} +// ------------------------------------------------------------------------- +void OResultSet::openForeignKeys( const Any& catalog, const ::rtl::OUString* schema, + const ::rtl::OUString* table, + const Any& catalog2, const ::rtl::OUString* schema2, + const ::rtl::OUString* table2) throw(SQLException, RuntimeException) +{ + m_bFreeHandle = sal_True; + + ::rtl::OString aPKQ,aPKO,aPKN, aFKQ, aFKO, aFKN; + + const char *pPKQ = catalog.hasValue() ? (aPKQ = ::rtl::OUStringToOString(connectivity::getString(catalog), + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKO = schema ? (aPKO = ::rtl::OUStringToOString(*schema, + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKN = table ? (aPKN = ::rtl::OUStringToOString(*table, + osl_getThreadTextEncoding() + )).getStr(): NULL, + *pFKQ = catalog2.hasValue() ? (aFKQ = ::rtl::OUStringToOString(connectivity::getString(catalog), + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pFKO = schema2 ? (aFKO = ::rtl::OUStringToOString(*schema2, + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pFKN = table2 ? (aFKN = ::rtl::OUStringToOString(*table2, + osl_getThreadTextEncoding() + )).getStr() : NULL; + + + SQLRETURN nRetcode = N3SQLForeignKeys(m_aStatementHandle, + (SDB_ODBC_CHAR *) pPKQ, catalog.hasValue() ? SQL_NTS : 0, + (SDB_ODBC_CHAR *) pPKO, SQL_NTS , + (SDB_ODBC_CHAR *) pPKN, pPKN ? SQL_NTS : 0, + (SDB_ODBC_CHAR *) pFKQ, catalog2.hasValue() ? SQL_NTS : 0, + (SDB_ODBC_CHAR *) pFKO, SQL_NTS , + (SDB_ODBC_CHAR *) pFKN, SQL_NTS + ); + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +// ------------------------------------------------------------------------- +void OResultSet::openImportedKeys(const Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table) throw(SQLException, RuntimeException) +{ + openForeignKeys(catalog,!schema.compareToAscii("%") ? &schema : NULL,&table,Any(),NULL,NULL); +} +// ------------------------------------------------------------------------- +void OResultSet::openExportedKeys(const Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table) throw(SQLException, RuntimeException) +{ + openForeignKeys(Any(),NULL,NULL,catalog,!schema.compareToAscii("%") ? &schema : NULL,&table); +} +// ------------------------------------------------------------------------- +void OResultSet::openPrimaryKeys(const Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table) throw(SQLException, RuntimeException) +{ + const ::rtl::OUString *pSchemaPat = NULL; + + if(schema.toChar() != '%') + pSchemaPat = &schema; + else + pSchemaPat = NULL; + + m_bFreeHandle = sal_True; + ::rtl::OString aPKQ,aPKO,aPKN,aCOL; + + const char *pPKQ = catalog.hasValue() ? (aPKQ = ::rtl::OUStringToOString(connectivity::getString(catalog), + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKO = pSchemaPat ? (aPKO = ::rtl::OUStringToOString(schema, + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKN = (aPKN = ::rtl::OUStringToOString(table, + osl_getThreadTextEncoding() + )).getStr(); + + + SQLRETURN nRetcode = N3SQLPrimaryKeys(m_aStatementHandle, + (SDB_ODBC_CHAR *) pPKQ, catalog.hasValue() ? SQL_NTS : 0, + (SDB_ODBC_CHAR *) pPKO, SQL_NTS , + (SDB_ODBC_CHAR *) pPKN, SQL_NTS); + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +// ------------------------------------------------------------------------- +void OResultSet::openTablePrivileges(const Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern) throw(SQLException, RuntimeException) +{ + const ::rtl::OUString *pSchemaPat = NULL; + + if(schemaPattern.toChar() != '%') + pSchemaPat = &schemaPattern; + else + pSchemaPat = NULL; + + m_bFreeHandle = sal_True; + ::rtl::OString aPKQ,aPKO,aPKN; + + const char *pPKQ = catalog.hasValue() ? (aPKQ = ::rtl::OUStringToOString(connectivity::getString(catalog), + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKO = pSchemaPat ? (aPKO = ::rtl::OUStringToOString(schemaPattern, + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKN = (aPKN = ::rtl::OUStringToOString(tableNamePattern, + osl_getThreadTextEncoding() + )).getStr(); + + + SQLRETURN nRetcode = N3SQLTablePrivileges(m_aStatementHandle, + (SDB_ODBC_CHAR *) pPKQ, catalog.hasValue() ? SQL_NTS : 0, + (SDB_ODBC_CHAR *) pPKO, SQL_NTS , + (SDB_ODBC_CHAR *) pPKN, SQL_NTS); + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +// ------------------------------------------------------------------------- +void OResultSet::openIndexInfo( const Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table,sal_Bool unique,sal_Bool approximate ) + throw(SQLException, RuntimeException) +{ + const ::rtl::OUString *pSchemaPat = NULL; + + if(schema.toChar() != '%') + pSchemaPat = &schema; + else + pSchemaPat = NULL; + + m_bFreeHandle = sal_True; + ::rtl::OString aPKQ,aPKO,aPKN; + + const char *pPKQ = catalog.hasValue() ? (aPKQ = ::rtl::OUStringToOString(connectivity::getString(catalog), + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKO = pSchemaPat ? (aPKO = ::rtl::OUStringToOString(schema, + osl_getThreadTextEncoding() + )).getStr() : NULL, + *pPKN = (aPKN = ::rtl::OUStringToOString(table, + osl_getThreadTextEncoding() + )).getStr(); + + + SQLRETURN nRetcode = N3SQLStatistics(m_aStatementHandle, + (SDB_ODBC_CHAR *) pPKQ, catalog.hasValue() ? SQL_NTS : 0, + (SDB_ODBC_CHAR *) pPKO, SQL_NTS , + (SDB_ODBC_CHAR *) pPKN, SQL_NTS, + unique, + approximate); + OTools::ThrowException(nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +// ------------------------------------------------------------------------- +void OResultSet::fillRow(sal_Int32 _nToColumn) +{ + m_bFetchData = sal_True; + Reference< XResultSetMetaData > xMeta = getMetaData(); + for(sal_Int32 i=m_nLastColumnPos+1;i <= _nToColumn; ++i) + { + switch (xMeta->getColumnType(i)) + { + case DataType::CHAR: + case DataType::VARCHAR: + m_aRow[i] <<= getString(i); + break; + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::BIGINT: + m_aRow[i] <<= getString(i); + break; + case DataType::DOUBLE: + m_aRow[i] <<= getDouble(i); + break; + case DataType::LONGVARCHAR: + m_aRow[i] <<= getString(i); + break; + case DataType::LONGVARBINARY: + m_aRow[i] <<= getBytes(i); + break; + case DataType::DATE: + m_aRow[i] <<= getDate(i); + break; + case DataType::TIME: + m_aRow[i] <<= getTime(i); + break; + case DataType::TIMESTAMP: + m_aRow[i] <<= getTimestamp(i); + break; + case DataType::BIT: + m_aRow[i] = bool2any(getBoolean(i)); + break; + case DataType::TINYINT: + m_aRow[i] <<= getByte(i); + break; + case DataType::SMALLINT: + m_aRow[i] <<= getShort(i); + break; + case DataType::INTEGER: + m_aRow[i] <<= getInt(i); + break; + case DataType::REAL: + m_aRow[i] <<= getFloat(i); + break; + case DataType::BINARY: + case DataType::VARBINARY: + m_aRow[i] <<= getBytes(i); + break; + } + } + m_nLastColumnPos = _nToColumn; + m_bFetchData = sal_False; +} + + diff --git a/connectivity/source/drivers/odbc/OResultSetMetaData.cxx b/connectivity/source/drivers/odbc/OResultSetMetaData.cxx new file mode 100644 index 000000000000..ae35669da768 --- /dev/null +++ b/connectivity/source/drivers/odbc/OResultSetMetaData.cxx @@ -0,0 +1,254 @@ +/************************************************************************* + * + * $RCSfile: OResultSetMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_ODBC_ORESULTSETMETADATA_HXX_ +#include "odbc/OResultSetMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_OTOOLS_HXX_ +#include "odbc/OTools.hxx" +#endif + +using namespace connectivity::odbc; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::sdbc; + +// ------------------------------------------------------------------------- +OResultSetMetaData::~OResultSetMetaData() +{ +} +// ------------------------------------------------------------------------- +::rtl::OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident) throw(SQLException, RuntimeException) +{ + sal_Int32 column = _column; + if(_column < m_vMapping.size()) // use mapping + column = m_vMapping[_column]; + + sal_Int32 BUFFER_LEN = 128; + char *pName = new char[BUFFER_LEN]; + SQLSMALLINT nRealLen=0; + OTools::ThrowException(N3SQLColAttribute(m_aStatementHandle, + column, + ident, + (SQLPOINTER)pName, + BUFFER_LEN, + &nRealLen, + NULL + ),m_aStatementHandle,SQL_HANDLE_STMT,*this); + if(nRealLen > BUFFER_LEN) + { + delete pName; + pName = new char[nRealLen]; + OTools::ThrowException(N3SQLColAttribute(m_aStatementHandle, + column, + ident, + (SQLPOINTER)pName, + nRealLen, + &nRealLen, + NULL + ),m_aStatementHandle,SQL_HANDLE_STMT,*this); + } + + return ::rtl::OUString::createFromAscii(pName); +} +// ------------------------------------------------------------------------- +sal_Int32 OResultSetMetaData::getNumColAttrib(sal_Int32 _column,sal_Int32 ident) throw(SQLException, RuntimeException) +{ + sal_Int32 column = _column; + if(_column < m_vMapping.size()) // use mapping + column = m_vMapping[_column]; + + sal_Int32 nValue=0; + sal_Int16 nLen = sizeof(nValue); + OTools::ThrowException(N3SQLColAttribute(m_aStatementHandle, + column, + ident, + NULL, + NULL, + NULL, + &nValue),m_aStatementHandle,SQL_HANDLE_STMT,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_DISPLAY_SIZE); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return OTools::MapOdbcType2Jdbc(getNumColAttrib(column,SQL_DESC_TYPE)); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException) +{ + if(m_nColCount != -1) + return m_nColCount; + sal_Int16 nNumResultCols=0; + OTools::ThrowException(N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this); + return m_nColCount = nNumResultCols; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_CASE_SENSITIVE) == SQL_TRUE; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_SCHEMA_NAME); +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_NAME); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_TABLE_NAME); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_CATALOG_NAME); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_TYPE_NAME +); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_LABEL); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_FIXED_PREC_SCALE) == SQL_TRUE; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_AUTO_UNIQUE_VALUE) == SQL_TRUE; +} +// ------------------------------------------------------------------------- + + +sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_UNSIGNED) == SQL_FALSE; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_PRECISION); +} +sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_SCALE); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_NULLABLE); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_SEARCHABLE) != SQL_PRED_NONE; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_READONLY; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_WRITE; +; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_WRITE; +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/odbc/OStatement.cxx b/connectivity/source/drivers/odbc/OStatement.cxx new file mode 100644 index 000000000000..3fa896cdfece --- /dev/null +++ b/connectivity/source/drivers/odbc/OStatement.cxx @@ -0,0 +1,1004 @@ +/************************************************************************* + * + * $RCSfile: OStatement.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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 _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _CONNECTIVITY_ODBC_OSTATEMENT_HXX_ +#include "odbc/OStatement.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OCONNECTION_HXX_ +#include "odbc/OConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_ORESULTSET_HXX_ +#include "odbc/OResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _UTL_PROPERTY_HXX_ +#include <unotools/property.hxx> +#endif +#ifndef _CONNECTIVITY_OTOOLS_HXX_ +#include "odbc/OTools.hxx" +#endif +#ifndef _UTL_UNO3_HXX_ +#include <unotools/uno3.hxx> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif + +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif + +#define THROW_SQL(x) \ + OTools::ThrowException(x,m_aStatementHandle,SQL_HANDLE_STMT,*this) + +#ifdef DEBUG +#define DEBUG_THROW \ + try \ + { \ + THROW_SQL(nRetCode); \ + } \ + catch(...) \ + { \ + } +#endif + +using namespace connectivity::odbc; +//------------------------------------------------------------------------------ +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::container; +using namespace com::sun::star::io; +using namespace com::sun::star::util; +//------------------------------------------------------------------------------ +OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE(m_aMutex), + OPropertySetHelper(OStatement_BASE::rBHelper), + rBHelper(OStatement_BASE::rBHelper), + m_pConnection(_pConnection), + m_pRowStatusArray(0) +{ + m_pConnection->acquire(); + N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&m_aStatementHandle); +} +//------------------------------------------------------------------------------ +void OStatement_Base::disposeResultSet() +{ + // free the cursor if alive + Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + m_xResultSet = Reference< XResultSet>(); +} +//------------------------------------------------------------------------------ +void OStatement_BASE2::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + disposeResultSet(); + + if (N3SQLFreeStmt(m_aStatementHandle,SQL_RESET_PARAMS) || + N3SQLFreeStmt(m_aStatementHandle,SQL_UNBIND) || + N3SQLFreeStmt(m_aStatementHandle,SQL_CLOSE)) + OTools::ThrowException(N3SQLFreeStmt(m_aStatementHandle,SQL_DROP),m_aStatementHandle,SQL_HANDLE_STMT,*this); + + if (m_pConnection) + m_pConnection->release(); + + dispose_ChildImpl(); + OStatement_Base::disposing(); +} +//----------------------------------------------------------------------------- +void SAL_CALL OStatement_BASE2::release() throw(RuntimeException) +{ + relase_ChildImpl(); +} +//----------------------------------------------------------------------------- +Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OStatement_BASE::queryInterface(rType); + if(!aRet.hasValue()) + aRet = OPropertySetHelper::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ), + ::getCppuType( (const Reference< XFastPropertySet > *)0 ), + ::getCppuType( (const Reference< XPropertySet > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes()); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException) +{ + OTools::ThrowException(N3SQLCancel(m_aStatementHandle),m_aStatementHandle,SQL_HANDLE_STMT,*this); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + } + dispose(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement::clearBatch( ) throw(SQLException, RuntimeException) +{ + +} +// ------------------------------------------------------------------------- + +void OStatement_Base::reset() throw (SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + clearWarnings (); + + if (m_xResultSet.get().is()) + { + clearMyResultSet(); + THROW_SQL(N3SQLFreeStmt(m_aStatementHandle, SQL_CLOSE)); + } +} +//-------------------------------------------------------------------- +// clearMyResultSet +// If a ResultSet was created for this Statement, close it +//-------------------------------------------------------------------- + +void OStatement_Base::clearMyResultSet () throw (SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + Reference<XCloseable> xCloseable; + if(::utl::query_interface(m_xResultSet.get(),xCloseable)) + xCloseable->close(); + m_xResultSet = Reference< XResultSet>(); +} +//-------------------------------------------------------------------- +sal_Int32 OStatement_Base::getRowCount () throw( SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 numRows = 0; + + try { + THROW_SQL(N3SQLRowCount(m_aStatementHandle,&numRows)); + } + catch (...) + { + } + return numRows; +} +//-------------------------------------------------------------------- +// lockIfNecessary +// If the given SQL statement contains a 'FOR UPDATE' clause, change +// the concurrency to lock so that the row can then be updated. Returns +// true if the concurrency has been changed +//-------------------------------------------------------------------- + +sal_Bool OStatement_Base::lockIfNecessary (const ::rtl::OUString& sql) throw( SQLException) +{ + sal_Bool rc = sal_False; + + // First, convert the statement to upper case + + ::rtl::OUString sqlStatement = sql.toUpperCase (); + + // Now, look for the FOR UPDATE keywords. If there is any extra white + // space between the FOR and UPDATE, this will fail. + + sal_Int32 index = sqlStatement.indexOf(::rtl::OUString::createFromAscii(" FOR UPDATE")); + + // We found it. Change our concurrency level to ensure that the + // row can be updated. + + if (index > 0) + { + try + { + SQLINTEGER nLock = SQL_CONCUR_LOCK; + THROW_SQL(N3SQLSetStmtAttr(m_aStatementHandle, SQL_CONCURRENCY,(SQLPOINTER)nLock,SQL_IS_UINTEGER)); + } + catch (SQLWarning& warn) + { + // Catch any warnings and place on the warning stack + setWarning (warn); + } + rc = sal_True; + } + + return rc; +} +//-------------------------------------------------------------------- +// setWarning +// Sets the warning +//-------------------------------------------------------------------- + +void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_aLastWarning = ex; +} + +//-------------------------------------------------------------------- +// getColumnCount +// Return the number of columns in the ResultSet +//-------------------------------------------------------------------- + +sal_Int32 OStatement_Base::getColumnCount () throw( SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int16 numCols = 0; + + try { + THROW_SQL(N3SQLNumResultCols(m_aStatementHandle,&numCols)); + } + catch (...) + { + } + return numCols; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ::rtl::OString aSql(::rtl::OUStringToOString(sql, + osl_getThreadTextEncoding() + )); + + sal_Bool hasResultSet = sal_False; + SQLWarning aWarning; + + // Reset the statement handle and warning + + reset(); + + // Check for a 'FOR UPDATE' statement. If present, change + // the concurrency to lock + + lockIfNecessary (sql); + + // Call SQLExecDirect + + try { + THROW_SQL(N3SQLExecDirect(m_aStatementHandle, (SDB_ODBC_CHAR*)aSql.getStr(),aSql.getLength())); + } + catch (SQLWarning& ex) { + + // Save pointer to warning and save with ResultSet + // object once it is created. + + aWarning = ex; + } + + // Now determine if there is a result set associated with + // the SQL statement that was executed. Get the column + // count, and if it is not zero, there is a result set. + + if (getColumnCount () > 0) + { + hasResultSet = sal_True; + } + + return hasResultSet; +} +//-------------------------------------------------------------------- +// getResultSet +// getResultSet returns the current result as a ResultSet. It +// returns NULL if the current result is not a ResultSet. +//-------------------------------------------------------------------- +Reference< XResultSet > OStatement_Base::getResultSet (sal_Bool checkCount) throw( SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if (m_xResultSet.get().is()) // if resultset already retrieved, + { + // throw exception to avoid sequence error + throw SQLException(::rtl::OUString::createFromAscii("Invalid state for getResultSet"),*this, + ::rtl::OUString(),0,Any()); + } + + OResultSet* pRs = NULL; + sal_Int32 numCols = 1; + + // If we already know we have result columns, checkCount + // is false. This is an optimization to prevent unneeded + // calls to getColumnCount + + if (checkCount) + numCols = getColumnCount (); + + // Only return a result set if there are result columns + + if (numCols > 0) + { + pRs = new OResultSet(m_aStatementHandle,this); + + // Save a copy of our last result set + // Changed to save copy at getResultSet. + //m_xResultSet = rs; + } + else + clearMyResultSet (); + + return pRs; +} +//-------------------------------------------------------------------- +// getStmtOption +// Invoke SQLGetStmtOption with the given option. +//-------------------------------------------------------------------- + +sal_Int32 OStatement_Base::getStmtOption (short fOption) const throw( SQLException) +{ + sal_Int32 result = 0; + + // Reset last warning message + + // clearWarnings(); + + try { + N3SQLGetStmtAttr(m_aStatementHandle, fOption,&result,SQL_IS_INTEGER,NULL); + } + catch (...) + { + } + return result; +} +// ------------------------------------------------------------------------- + +Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + Reference< XResultSet > xRS = NULL; + + // Execute the statement. If execute returns true, a result + // set exists. + + if (execute (sql)) + { + xRS = getResultSet (sal_False); + } + else + { + // No ResultSet was produced. Raise an exception + throw SQLException(::rtl::OUString::createFromAscii("No ResultSet was produced"),*this, + ::rtl::OUString(),0,Any()); + } + return xRS; +} +// ------------------------------------------------------------------------- + +Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException) +{ + return (Reference< XConnection >)m_pConnection; +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this)); + if(!aRet.hasValue()) + aRet = OStatement_Base::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement::addBatch( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_aBatchList.push_back(sql); +} +// ------------------------------------------------------------------------- +Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ::rtl::OString aBatchSql; + sal_Int32 nLen = 0; + for(::std::list< ::rtl::OUString>::const_iterator i=m_aBatchList.begin();i != m_aBatchList.end();++i,++nLen) + { + aBatchSql += ::rtl::OUStringToOString(*i, + osl_getThreadTextEncoding() + ); + aBatchSql += ";"; + } + + THROW_SQL(N3SQLExecDirect(m_aStatementHandle, (SDB_ODBC_CHAR*)aBatchSql.getStr(),aBatchSql.getLength())); + + Sequence< sal_Int32 > aRet(nLen); + sal_Int32* pArray = aRet.getArray(); + for(sal_Int32 j=0;j<nLen;++j) + { + SQLRETURN nError = N3SQLMoreResults(m_aStatementHandle); + if(nError == SQL_SUCCESS) + { + N3SQLRowCount(m_aStatementHandle,&pArray[j]); + } + } + return aRet; +} +// ------------------------------------------------------------------------- + + +sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 numRows = -1; + + // Execute the statement. If execute returns false, a + // row count exists. + + if (!execute (sql)) { + numRows = getUpdateCount(); + } + else { + + // No update count was produced (a ResultSet was). Raise + // an exception + + throw new SQLException (::rtl::OUString::createFromAscii("No row count was produced"),*this, + ::rtl::OUString(),0,Any()); + } + return numRows; + +} +// ------------------------------------------------------------------------- + +Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_xResultSet = getResultSet(sal_True); + return m_xResultSet; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OStatement_Base::getUpdateCount( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_Int32 rowCount = -1; + + // Only return a row count for SQL statements that did not + // return a result set. + + if (getColumnCount () == 0) + rowCount = getRowCount (); + + return rowCount; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OStatement_Base::getMoreResults( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OResultSet* pRS = NULL; + SQLWarning warning; + sal_Bool hasResultSet = sal_False; + + // clear previous warnings + + clearWarnings (); + + // Call SQLMoreResults + + try { + hasResultSet = N3SQLMoreResults(m_aStatementHandle) == SQL_SUCCESS; + } + catch (SQLWarning &ex) { + + // Save pointer to warning and save with ResultSet + // object once it is created. + + warning = ex; + } + + // There are more results (it may not be a result set, though) + + if (hasResultSet) + { + + // Now determine if there is a result set associated + // with the SQL statement that was executed. Get the + // column count, and if it is zero, there is not a + // result set. + + if (getColumnCount () == 0) + hasResultSet = sal_False; + } + + // Set the warning for the statement, if one was generated + + setWarning (warning); + + // Return the result set indicator + + return hasResultSet; +} +// ------------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return makeAny(m_aLastWarning); +} +// ------------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + m_aLastWarning = SQLWarning(); +} +// ------------------------------------------------------------------------- +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getQueryTimeOut() const throw(SQLException, RuntimeException) +{ + return getStmtOption(SQL_ATTR_QUERY_TIMEOUT); +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getMaxRows() const throw(SQLException, RuntimeException) +{ + return getStmtOption(SQL_ATTR_MAX_ROWS); +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getResultSetConcurrency() const throw(SQLException, RuntimeException) +{ + sal_uInt32 nValue; + SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CONCURRENCY,&nValue,SQL_IS_UINTEGER,0); + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getResultSetType() const throw(SQLException, RuntimeException) +{ + sal_uInt32 nValue=0; + SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_SENSITIVITY,&nValue,SQL_IS_UINTEGER,0); + nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nValue,SQL_IS_UINTEGER,0); + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getFetchDirection() const throw(SQLException, RuntimeException) +{ + sal_uInt32 nValue; + SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nValue,SQL_IS_UINTEGER,0); + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getFetchSize() const throw(SQLException, RuntimeException) +{ + sal_uInt32 nValue; + SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,&nValue,SQL_IS_UINTEGER,0); + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getMaxFieldSize() const throw(SQLException, RuntimeException) +{ + return getStmtOption(SQL_ATTR_MAX_LENGTH); +} +//------------------------------------------------------------------------------ +::rtl::OUString OStatement_Base::getCursorName() const throw(SQLException, RuntimeException) +{ + SQLCHAR pName[258]; + SQLSMALLINT nRealLen = 0; + SQLRETURN nRetCode = N3SQLGetCursorName(m_aStatementHandle,(SQLCHAR*)pName,256,&nRealLen); + return ::rtl::OUString::createFromAscii((const char*)pName); +} +//------------------------------------------------------------------------------ +void OStatement_Base::setQueryTimeOut(sal_Int32 seconds) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_QUERY_TIMEOUT,(SQLPOINTER)seconds,SQL_IS_UINTEGER); +#ifdef DEBUG + DEBUG_THROW +#endif +} +//------------------------------------------------------------------------------ +void OStatement_Base::setMaxRows(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_MAX_ROWS, (SQLPOINTER)_par0,SQL_IS_UINTEGER); +#ifdef DEBUG + DEBUG_THROW +#endif + +} +//------------------------------------------------------------------------------ +void OStatement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + SQLINTEGER nSet; + if(_par0 == ResultSetConcurrency::READ_ONLY) + nSet = SQL_CONCUR_READ_ONLY; + else + nSet = SQL_CONCUR_VALUES; + + THROW_SQL(N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_CONCURRENCY,(SQLPOINTER)nSet,SQL_IS_UINTEGER)); + +} +//------------------------------------------------------------------------------ +void OStatement_Base::setResultSetType(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_ROW_BIND_TYPE,(SQLPOINTER)SQL_BIND_BY_COLUMN,SQL_IS_UINTEGER); + + SQLUINTEGER nSet; + switch(_par0) + { + case ResultSetType::FORWARD_ONLY: + nSet = SQL_UNSPECIFIED; + break; + case ResultSetType::SCROLL_INSENSITIVE: + nSet = SQL_INSENSITIVE; + THROW_SQL(N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)SQL_CURSOR_KEYSET_DRIVEN,SQL_IS_UINTEGER)); + break; + case ResultSetType::SCROLL_SENSITIVE: + nSet = SQL_CURSOR_DYNAMIC; + if(N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)nSet,SQL_IS_UINTEGER) != SQL_SUCCESS) + { + nSet = SQL_CURSOR_KEYSET_DRIVEN; + THROW_SQL(N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)nSet,SQL_IS_UINTEGER)); + } + nSet = SQL_SENSITIVE; + break; + } + + + if(nRetCode = N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_CURSOR_SENSITIVITY,(SQLPOINTER)nSet,SQL_IS_UINTEGER) != SQL_SUCCESS) + { + } +} +//------------------------------------------------------------------------------ +void OStatement_Base::setFetchDirection(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)_par0,SQL_IS_UINTEGER); +} +//------------------------------------------------------------------------------ +void OStatement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER); + +#ifdef DEBUG + DEBUG_THROW +#endif + + delete m_pRowStatusArray; + m_pRowStatusArray = new SQLUSMALLINT[_par0]; + nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER); +#ifdef DEBUG + DEBUG_THROW +#endif + +} +//------------------------------------------------------------------------------ +void OStatement_Base::setMaxFieldSize(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + THROW_SQL(N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_MAX_LENGTH,(SQLPOINTER)_par0,SQL_IS_UINTEGER)); +} +//------------------------------------------------------------------------------ +void OStatement_Base::setCursorName(const ::rtl::OUString &_par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + ::rtl::OString aName(::rtl::OUStringToOString(_par0, + osl_getThreadTextEncoding() + )); + THROW_SQL(N3SQLSetCursorName(m_aStatementHandle,(SDB_ODBC_CHAR*)aName.getStr(),aName.getLength())); +} +// ------------------------------------------------------------------------- +sal_Bool OStatement_Base::isUsingBookmarks() const throw(SQLException, RuntimeException) +{ + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_uInt32 nValue = SQL_UB_OFF; + SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&nValue,SQL_IS_UINTEGER,NULL); + // THROW_SQL(nRet); + return nValue != SQL_UB_OFF; +} +// ------------------------------------------------------------------------- +void OStatement_Base::setUsingBookmarks(sal_Bool _bUseBookmark) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OStatement_BASE::rBHelper.bDisposed) + throw DisposedException(); + + sal_uInt32 nValue = _bUseBookmark ? SQL_UB_VARIABLE : SQL_UB_OFF; + SQLRETURN nRet = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,(SQLPOINTER)nValue,SQL_IS_UINTEGER); + THROW_SQL(nRet); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const +{ + Sequence< Property > aProps(10); + Property* pProperties = aProps.getArray(); + sal_Int32 nPos = 0; + DECL_PROP0(CURSORNAME, ::rtl::OUString); + DECL_BOOL_PROP0(ESCAPEPROCESSING); + DECL_PROP0(FETCHDIRECTION,sal_Int32); + DECL_PROP0(FETCHSIZE, sal_Int32); + DECL_PROP0(MAXFIELDSIZE,sal_Int32); + DECL_PROP0(MAXROWS, sal_Int32); + DECL_PROP0(QUERYTIMEOUT,sal_Int32); + DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32); + DECL_PROP0(RESULTSETTYPE,sal_Int32); + DECL_BOOL_PROP0(USEBOOKMARKS); + + return new ::cppu::OPropertyArrayHelper(aProps); +} + +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper() +{ + return *const_cast<OStatement_Base*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +sal_Bool OStatement_Base::convertFastPropertyValue( + Any & rConvertedValue, + Any & rOldValue, + sal_Int32 nHandle, + const Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException) +{ + switch(nHandle) + { + case PROPERTY_ID_QUERYTIMEOUT: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut()); + case PROPERTY_ID_MAXFIELDSIZE: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize()); + case PROPERTY_ID_MAXROWS: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxRows()); + case PROPERTY_ID_CURSORNAME: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName()); + case PROPERTY_ID_RESULTSETCONCURRENCY: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency()); + case PROPERTY_ID_RESULTSETTYPE: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType()); + case PROPERTY_ID_FETCHDIRECTION: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); + case PROPERTY_ID_FETCHSIZE: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); + case PROPERTY_ID_ESCAPEPROCESSING: + // return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink); + break; + case PROPERTY_ID_USEBOOKMARKS: + return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, isUsingBookmarks()); + + default: + ; + } + return sal_False; +} +// ------------------------------------------------------------------------- +void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception) +{ + switch(nHandle) + { + case PROPERTY_ID_QUERYTIMEOUT: + setQueryTimeOut(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_MAXFIELDSIZE: + setMaxFieldSize(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_MAXROWS: + setMaxRows(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_CURSORNAME: + setCursorName(connectivity::getString(rValue)); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + setResultSetConcurrency(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_RESULTSETTYPE: + setResultSetType(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_FETCHDIRECTION: + setFetchDirection(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_FETCHSIZE: + setFetchSize(connectivity::getINT32(rValue)); + break; + case PROPERTY_ID_ESCAPEPROCESSING: + // return ::utl::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink); + break; + case PROPERTY_ID_USEBOOKMARKS: + setUsingBookmarks(connectivity::getBOOL(rValue)); + break; + default: + ; + } +} +// ------------------------------------------------------------------------- +void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + switch(nHandle) + { + case PROPERTY_ID_QUERYTIMEOUT: + rValue <<= getQueryTimeOut(); + break; + case PROPERTY_ID_MAXFIELDSIZE: + rValue <<= getMaxFieldSize(); + break; + case PROPERTY_ID_MAXROWS: + rValue <<= getMaxRows(); + break; + case PROPERTY_ID_CURSORNAME: + rValue <<= getCursorName(); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + rValue <<= getResultSetConcurrency(); + break; + case PROPERTY_ID_RESULTSETTYPE: + rValue <<= getResultSetType(); + break; + case PROPERTY_ID_FETCHDIRECTION: + rValue <<= getFetchDirection(); + break; + case PROPERTY_ID_FETCHSIZE: + rValue <<= getFetchSize(); + break; + case PROPERTY_ID_ESCAPEPROCESSING: + break; + case PROPERTY_ID_USEBOOKMARKS: + rValue <<= cppu::bool2any(isUsingBookmarks()); + break; + default: + ; + } +} +// ------------------------------------------------------------------------- +IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement"); + diff --git a/connectivity/source/drivers/odbc/OTools.cxx b/connectivity/source/drivers/odbc/OTools.cxx new file mode 100644 index 000000000000..23d3589ac0f3 --- /dev/null +++ b/connectivity/source/drivers/odbc/OTools.cxx @@ -0,0 +1,545 @@ +/************************************************************************* + * + * $RCSfile: OTools.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_OTOOLS_HXX_ +#include "odbc/OTools.hxx" +#endif + +#define __STL_IMPORT_VENDOR_CSTD +#include <cstring> +#ifndef _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_ +#include "odbc/OFunctions.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +using namespace connectivity::odbc; +using namespace com::sun::star::uno; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::util; +#ifndef min +#define min(x,y) (x) < ( y) ? (x) : (y) +#endif +// ------------------------------------------------------------------------- +void OTools::ThrowException(SQLRETURN _rRetCode,SQLHANDLE _pContext,SQLSMALLINT _nHandleType,const Reference< XInterface >& _xInterface,sal_Bool _bNoFound) throw(SQLException, RuntimeException) +{ + switch(_rRetCode) + { + case SQL_NEED_DATA: + case SQL_STILL_EXECUTING: + case SQL_SUCCESS: + + case SQL_SUCCESS_WITH_INFO: + return; + case SQL_NO_DATA_FOUND: + if(_bNoFound) + return; // no need to throw a exception + case SQL_ERROR: break; + + + case SQL_INVALID_HANDLE: OSL_ENSHURE(0,"SdbODBC3_SetStatus: SQL_INVALID_HANDLE"); + throw RuntimeException(); + break; + } + + + // Zusaetliche Informationen zum letzten ODBC-Funktionsaufruf vorhanden. + // SQLError liefert diese Informationen. + + SDB_ODBC_CHAR szSqlState[5]; + SDWORD pfNativeError; + SDB_ODBC_CHAR szErrorMessage[SQL_MAX_MESSAGE_LENGTH]; + SWORD pcbErrorMsg; + + // Informationen zur letzten Operation: + // wenn hstmt != SQL_NULL_HSTMT ist (Benutzung von SetStatus in SdbCursor, SdbTable, ...), + // dann wird der Status des letzten Statements erfragt, sonst der Status des letzten + // Statements zu dieser Verbindung [was in unserem Fall wahrscheinlich gleichbedeutend ist, + // aber das Reference Manual drueckt sich da nicht so klar aus ...]. + // Entsprechend bei hdbc. + SQLRETURN n = N3SQLGetDiagRec(_nHandleType,_pContext,1, + szSqlState, + &pfNativeError, + szErrorMessage,sizeof szErrorMessage - 1,&pcbErrorMsg); + OSL_ENSHURE(n != SQL_INVALID_HANDLE,"SdbODBC3_SetStatus: SQLError returned SQL_INVALID_HANDLE"); + OSL_ENSHURE(n == SQL_SUCCESS || n == SQL_SUCCESS_WITH_INFO || n == SQL_NO_DATA_FOUND || n == SQL_ERROR,"SdbODBC3_SetStatus: SQLError failed"); + + // Zum Return Code von SQLError siehe ODBC 2.0 Programmer's Reference Seite 287ff + throw SQLException( ::rtl::OUString((char *)szErrorMessage,pcbErrorMsg,RTL_TEXTENCODING_MS_1252), + _xInterface, + ::rtl::OUString((char *)szSqlState,5,RTL_TEXTENCODING_MS_1252), + pfNativeError, + Any() + ); + +} +// ------------------------------------------------------------------------- +Sequence<sal_Int8> OTools::getBytesValue(SQLHANDLE _aStatementHandle,sal_Int32 columnIndex,SWORD _fSqlType,sal_Bool &_bWasNull, + const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException) +{ + char aCharArray[2048]; + // Erstmal versuchen, die Daten mit dem kleinen Puffer + // abzuholen: + SQLINTEGER nMaxLen = sizeof aCharArray - 1; + // GETDATA(SQL_C_CHAR,aCharArray,nMaxLen); + SQLINTEGER pcbValue = 0; + OTools::ThrowException(N3SQLGetData(_aStatementHandle, + (SQLUSMALLINT)columnIndex, + SQL_C_BINARY, + &aCharArray, + (SQLINTEGER)nMaxLen, + &pcbValue), + _aStatementHandle,SQL_HANDLE_STMT,_xInterface); + + _bWasNull = pcbValue == SQL_NULL_DATA; + if(_bWasNull) + return Sequence<sal_Int8>(); + + SQLINTEGER nBytes = pcbValue != SQL_NO_TOTAL ? min(pcbValue, nMaxLen) : nMaxLen; + Sequence<sal_Int8> aData((sal_Int8*)aCharArray, nBytes); + + + // Es handelt sich um Binaerdaten, um einen String, der fuer + // StarView zu lang ist oder der Treiber kann die Laenge der + // Daten nicht im voraus bestimmen - also als MemoryStream + // speichern. + while ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen) + { + // Bei Strings wird der Puffer nie ganz ausgenutzt + // (das letzte Byte ist immer ein NULL-Byte, das + // aber bei pcbValue nicht mitgezaehlt wird) + if (pcbValue != SQL_NO_TOTAL && (pcbValue - nMaxLen) < nMaxLen) + nBytes = pcbValue - nMaxLen; + else + nBytes = nMaxLen; + + // Solange eine "truncation"-Warnung vorliegt, weiter Daten abholen + // GETDATA(SQL_C_CHAR,aCharArray, nLen + 1); + OTools::ThrowException(N3SQLGetData(_aStatementHandle, + (SQLUSMALLINT)columnIndex, + SQL_C_BINARY, + &aCharArray, + (SQLINTEGER)nBytes, + &pcbValue), + _aStatementHandle,SQL_HANDLE_STMT,_xInterface); + sal_Int32 nLen = aData.getLength(); + aData.realloc(nLen + nBytes); + ::std::memcpy(aData.getArray() + nLen, aCharArray, nBytes); + } + return aData; +} +// ------------------------------------------------------------------------- +::rtl::OUString OTools::getStringValue(SQLHANDLE _aStatementHandle,sal_Int32 columnIndex,SWORD _fSqlType,sal_Bool &_bWasNull, + const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aData; + switch(_fSqlType) + { + case SQL_WVARCHAR: + case SQL_WCHAR: + case SQL_WLONGVARCHAR: + { + sal_Unicode waCharArray[2048]; + // read the unicode data + sal_Int32 nMaxLen = sizeof(waCharArray) - sizeof(sal_Unicode); + // GETDATA(SQL_C_WCHAR, waCharArray, nMaxLen + sizeof(sal_Unicode)); + + SQLINTEGER pcbValue=0; + OTools::ThrowException(N3SQLGetData(_aStatementHandle, + (SQLUSMALLINT)columnIndex, + SQL_C_WCHAR, + &waCharArray, + (SQLINTEGER)nMaxLen*sizeof(sal_Unicode), + &pcbValue), + _aStatementHandle,SQL_HANDLE_STMT,_xInterface); + _bWasNull = pcbValue == SQL_NULL_DATA; + if(_bWasNull) + return ::rtl::OUString(); + // Bei Fehler bricht der GETDATA-Makro mit return ab, + // bei NULL mit break! + SQLINTEGER nLen = pcbValue != SQL_NO_TOTAL ? min(pcbValue, nMaxLen) : nMaxLen; + waCharArray[nLen] = 0; + aData = ::rtl::OUString(waCharArray); + + // Es handelt sich um Binaerdaten, um einen String, der fuer + // StarView zu lang ist oder der Treiber kann die Laenge der + // Daten nicht im voraus bestimmen - also als MemoryStream + // speichern. + while ((pcbValue == SQL_NO_TOTAL ) || pcbValue > nMaxLen) + { + // Bei Strings wird der Puffer nie ganz ausgenutzt + // (das letzte Byte ist immer ein NULL-Byte, das + // aber bei pcbValue nicht mitgezaehlt wird) + if (pcbValue != SQL_NO_TOTAL && (pcbValue - nMaxLen) < nMaxLen) + nLen = pcbValue - nMaxLen; + else + nLen = nMaxLen; + + // Solange eine "truncation"-Warnung vorliegt, weiter Daten abholen + // GETDATA(SQL_C_CHAR,waCharArray, nLen + 1); + OTools::ThrowException(N3SQLGetData(_aStatementHandle, + (SQLUSMALLINT)columnIndex, + SQL_C_WCHAR, + &waCharArray, + (SQLINTEGER)nLen+1, + &pcbValue), + _aStatementHandle,SQL_HANDLE_STMT,_xInterface); + waCharArray[nLen] = 0; + + aData += ::rtl::OUString(waCharArray); + } + } + break; + default: + { + char aCharArray[2048]; + // Erstmal versuchen, die Daten mit dem kleinen Puffer + // abzuholen: + SDWORD nMaxLen = sizeof aCharArray - 1; + // GETDATA(SQL_C_CHAR,aCharArray,nMaxLen); + SQLINTEGER pcbValue = 0; + OTools::ThrowException(N3SQLGetData(_aStatementHandle, + (SQLUSMALLINT)columnIndex, + SQL_C_CHAR, + &aCharArray, + (SQLINTEGER)nMaxLen, + &pcbValue), + _aStatementHandle,SQL_HANDLE_STMT,_xInterface); + _bWasNull = pcbValue == SQL_NULL_DATA; + if(_bWasNull) + return ::rtl::OUString(); + + SQLINTEGER nLen = pcbValue != SQL_NO_TOTAL ? min(pcbValue, nMaxLen) : nMaxLen; + aCharArray[nLen] = 0; + aData = ::rtl::OUString((const sal_Char*)aCharArray,nLen, osl_getThreadTextEncoding()); + + // Es handelt sich um Binaerdaten, um einen String, der fuer + // StarView zu lang ist oder der Treiber kann die Laenge der + // Daten nicht im voraus bestimmen - also als MemoryStream + // speichern. + while ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen) + { + // Bei Strings wird der Puffer nie ganz ausgenutzt + // (das letzte Byte ist immer ein NULL-Byte, das + // aber bei pcbValue nicht mitgezaehlt wird) + if (pcbValue != SQL_NO_TOTAL && (pcbValue - nMaxLen) < nMaxLen) + nLen = pcbValue - nMaxLen; + else + nLen = nMaxLen; + + // Solange eine "truncation"-Warnung vorliegt, weiter Daten abholen + // GETDATA(SQL_C_CHAR,aCharArray, nLen + 1); + OTools::ThrowException(N3SQLGetData(_aStatementHandle, + (SQLUSMALLINT)columnIndex, + SQL_C_CHAR, + &aCharArray, + (SQLINTEGER)nLen +1, + &pcbValue), + _aStatementHandle,SQL_HANDLE_STMT,_xInterface); + aCharArray[nLen] = 0; + + aData += ::rtl::OUString((const sal_Char*)aCharArray,nLen,osl_getThreadTextEncoding()); + } + + // delete all blanks + // aData.EraseTrailingChars(); + } + } + + return aData; +} +// ------------------------------------------------------------------------- +void OTools::GetInfo(SQLHANDLE _aConnectionHandle,SQLUSMALLINT _nInfo,::rtl::OUString &_rValue,const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException) +{ + char aValue[512]; + SQLSMALLINT nValueLen; + OTools::ThrowException( + N3SQLGetInfo(_aConnectionHandle,_nInfo,aValue,sizeof aValue,&nValueLen), + _aConnectionHandle,SQL_HANDLE_DBC,_xInterface); + + _rValue = ::rtl::OUString(aValue,nValueLen,RTL_TEXTENCODING_MS_1252); +} +// ------------------------------------------------------------------------- +void OTools::GetInfo(SQLHANDLE _aConnectionHandle,SQLUSMALLINT _nInfo,sal_Int32 &_rValue,const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException) +{ + SQLSMALLINT nValueLen; + _rValue = 0; // in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION) + OTools::ThrowException( + N3SQLGetInfo(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen), + _aConnectionHandle,SQL_HANDLE_DBC,_xInterface); +} +// ------------------------------------------------------------------------- +void OTools::GetInfo(SQLHANDLE _aConnectionHandle,SQLUSMALLINT _nInfo,sal_Bool &_rValue,const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException) +{ + SQLSMALLINT nValueLen; + OTools::ThrowException( + N3SQLGetInfo(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen), + _aConnectionHandle,SQL_HANDLE_DBC,_xInterface); +} +// ------------------------------------------------------------------------- +sal_Int32 OTools::MapOdbcType2Jdbc(sal_Int32 _nType) +{ + sal_Int32 nValue; + switch(_nType) + { + case SQL_BIT: + nValue = DataType::BIT; + break; + case SQL_TINYINT: + nValue = DataType::TINYINT; + break; + case SQL_SMALLINT: + nValue = DataType::SMALLINT; + break; + case SQL_INTEGER: + nValue = DataType::INTEGER; + break; + case SQL_BIGINT: + nValue = DataType::BIGINT; + break; + case SQL_FLOAT: + nValue = DataType::FLOAT; + break; + case SQL_REAL: + nValue = DataType::REAL; + break; + case SQL_DOUBLE: + nValue = DataType::DOUBLE; + break; + case SQL_NUMERIC: + nValue = DataType::NUMERIC; + break; + case SQL_DECIMAL: + nValue = DataType::DECIMAL; + break; + case SQL_WCHAR: + case SQL_CHAR: + nValue = DataType::CHAR; + break; + case SQL_WVARCHAR: + case SQL_VARCHAR: + nValue = DataType::VARCHAR; + break; + case SQL_WLONGVARCHAR: + case SQL_LONGVARCHAR: + nValue = DataType::LONGVARCHAR; + break; + case SQL_TYPE_DATE: + case SQL_DATE: + nValue = DataType::DATE; + break; + case SQL_TYPE_TIME: + case SQL_TIME: + nValue = DataType::TIME; + break; + case SQL_TYPE_TIMESTAMP: + case SQL_TIMESTAMP: + nValue = DataType::TIMESTAMP; + break; + case SQL_BINARY: + nValue = DataType::BINARY; + break; + case SQL_VARBINARY: + nValue = DataType::VARBINARY; + break; + case SQL_LONGVARBINARY: + nValue = DataType::LONGVARBINARY; + break; + } + return nValue; +} +//-------------------------------------------------------------------- +// jdbcTypeToOdbc +// Convert the JDBC SQL type to the correct ODBC type +//-------------------------------------------------------------------- +sal_Int32 OTools::jdbcTypeToOdbc(sal_Int32 jdbcType) +{ + // For the most part, JDBC types match ODBC types. We'll + // just convert the ones that we know are different + + sal_Int32 odbcType = jdbcType; + + switch (jdbcType) + { + case DataType::DATE: + odbcType = SQL_DATE; + break; + case DataType::TIME: + odbcType = SQL_TIME; + break; + case DataType::TIMESTAMP: + odbcType = SQL_TIMESTAMP; + break; + } + + return odbcType; +} +//----------------------------------------------------------------------------- +void OTools::getBindTypes(sal_Bool _bUseWChar,sal_Bool _bUseOldTimeDate, + sal_Int32 jdbcType,SQLSMALLINT& fCType,SQLSMALLINT& fSqlType, + SQLUINTEGER& nColumnSize,SQLSMALLINT& nDecimalDigits) +{ + switch(jdbcTypeToOdbc(jdbcType)) + { + case SQL_CHAR: if(_bUseWChar) + { + fCType = SQL_C_WCHAR; + fSqlType = SQL_WCHAR; + } + else + { + fCType = SQL_C_CHAR; + fSqlType = SQL_CHAR; + } + break; + case SQL_VARCHAR: if(_bUseWChar) + { + fCType = SQL_C_WCHAR; + fSqlType = SQL_WVARCHAR; + } + else + { + fCType = SQL_C_CHAR; + fSqlType = SQL_VARCHAR; + } + break; + case SQL_LONGVARCHAR: if(_bUseWChar) + { + fCType = SQL_C_WCHAR; + fSqlType = SQL_WLONGVARCHAR; + } + else + { + fCType = SQL_C_CHAR; + fSqlType = SQL_LONGVARCHAR; + } + break; + case SQL_DECIMAL: fCType = _bUseWChar ? SQL_C_WCHAR : SQL_C_CHAR; + fSqlType = SQL_DECIMAL; break; + case SQL_NUMERIC: fCType = _bUseWChar ? SQL_C_WCHAR : SQL_C_CHAR; + fSqlType = SQL_NUMERIC; break; + case SQL_BIT: fCType = SQL_C_TINYINT; + fSqlType = SQL_INTEGER; break; + case SQL_TINYINT: fCType = SQL_C_SHORT; + fSqlType = SQL_TINYINT; break; + case SQL_SMALLINT: fCType = SQL_C_SHORT; + fSqlType = SQL_SMALLINT; break; + case SQL_INTEGER: fCType = SQL_C_LONG; + fSqlType = SQL_INTEGER; break; + case SQL_BIGINT: fCType = _bUseWChar ? SQL_C_WCHAR : SQL_C_CHAR; + fSqlType = SQL_BIGINT; break; + case SQL_REAL: fCType = SQL_C_FLOAT; + fSqlType = SQL_REAL; break; + case SQL_DOUBLE: fCType = SQL_C_DOUBLE; + fSqlType = SQL_DOUBLE; break; + case SQL_BINARY: fCType = SQL_C_BINARY; + fSqlType = SQL_BINARY; break; + case SQL_VARBINARY: + fCType = SQL_C_BINARY; + fSqlType = SQL_VARBINARY; break; + case SQL_LONGVARBINARY: fCType = SQL_C_BINARY; + fSqlType = SQL_LONGVARBINARY; break; + case SQL_DATE: + if(_bUseOldTimeDate) + { + fCType = SQL_C_DATE; + fSqlType = SQL_DATE; + } + else + { + fCType = SQL_C_TYPE_DATE; + fSqlType = SQL_TYPE_DATE; + } + break; + case SQL_TIME: + if(_bUseOldTimeDate) + { + fCType = SQL_C_TIME; + fSqlType = SQL_TIME; + } + else + { + fCType = SQL_C_TYPE_TIME; + fSqlType = SQL_TYPE_TIME; + } + break; + case SQL_TIMESTAMP: + if(_bUseOldTimeDate) + { + fCType = SQL_C_TIMESTAMP; + fSqlType = SQL_TIMESTAMP; + } + else + { + fCType = SQL_C_TYPE_TIMESTAMP; + fSqlType = SQL_TYPE_TIMESTAMP; + } + break; + default: fCType = SQL_C_BINARY; + fSqlType = SQL_LONGVARBINARY; break; + } +} + + diff --git a/connectivity/source/drivers/odbc/makefile.mk b/connectivity/source/drivers/odbc/makefile.mk new file mode 100644 index 000000000000..dd1cef6b9938 --- /dev/null +++ b/connectivity/source/drivers/odbc/makefile.mk @@ -0,0 +1,177 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=..$/.. +PRJNAME=connectivity +TARGET=odbc + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/version.mk + +# --- Types ------------------------------------- + + +UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb + +UNOUCROUT=$(OUT)$/inc +INCPRE+=$(UNOUCROUT) + +# --- Types ------------------------------------- + +UNOTYPES+= \ + com.sun.star.util.XCancellable \ + com.sun.star.util.XNumberFormatter \ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XWeak \ + com.sun.star.uno.XAggregation \ + com.sun.star.beans.XPropertyState \ + com.sun.star.beans.XPropertySet \ + com.sun.star.beans.PropertyValue \ + com.sun.star.beans.XMultiPropertySet \ + com.sun.star.beans.XFastPropertySet \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.EventObject \ + com.sun.star.lang.XComponent \ + com.sun.star.lang.IllegalArgumentException \ + com.sun.star.lang.DisposedException \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.java.XJavaThreadRegister_11 \ + com.sun.star.java.XJavaVM \ + com.sun.star.sdbc.XConnection \ + com.sun.star.sdbc.XStatement \ + com.sun.star.sdbc.XResultSet \ + com.sun.star.sdbc.XResultSetMetaDataSupplier \ + com.sun.star.sdbc.XColumnLocate \ + com.sun.star.sdbc.XResultSetUpdate \ + com.sun.star.sdbc.XWarningsSupplier \ + com.sun.star.sdbc.XRowUpdate \ + com.sun.star.sdbc.XMultipleResults \ + com.sun.star.sdbc.XBatchExecution \ + com.sun.star.sdbc.XPreparedBatchExecution \ + com.sun.star.sdbc.XParameters \ + com.sun.star.sdbc.XOutParameters \ + com.sun.star.sdbc.DriverPropertyInfo \ + com.sun.star.sdbc.XDriver \ + com.sun.star.sdbc.XRow \ + com.sun.star.sdbc.SQLWarning \ + com.sun.star.sdbc.ColumnSearch \ + com.sun.star.sdbc.DataType \ + com.sun.star.sdbc.ResultSetConcurrency \ + com.sun.star.sdbc.ResultSetType \ + com.sun.star.sdbc.ColumnValue \ + com.sun.star.sdb.XColumnUpdate \ + com.sun.star.sdb.XColumn \ + com.sun.star.lang.XServiceInfo \ + + +# --- Files ------------------------------------- + +SLOFILES=\ + $(SLO)$/OPreparedStatement.obj \ + $(SLO)$/OStatement.obj \ + $(SLO)$/OResultSetMetaData.obj \ + $(SLO)$/OResultSet.obj \ + $(SLO)$/OTools.obj \ + $(SLO)$/ODatabaseMetaData.obj \ + $(SLO)$/ODriver.obj \ + $(SLO)$/OFunctions.obj \ + $(SLO)$/oservices.obj \ + $(SLO)$/OConnection.obj + +# --- Library ----------------------------------- + +SHL1TARGET= $(ODBC_TARGET)$(ODBC_MAJOR) +SHL1OBJS=$(SLOFILES) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(OSLLIB) \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(ODBC_TARGET) +SHL1LIBS= $(SLB)$/commontools.lib \ + $(SLB)$/resource.lib + +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + + diff --git a/connectivity/source/drivers/odbc/odbc.map b/connectivity/source/drivers/odbc/odbc.map new file mode 100644 index 000000000000..becb2594a6a3 --- /dev/null +++ b/connectivity/source/drivers/odbc/odbc.map @@ -0,0 +1,8 @@ +ODBC_2_0 { + global: + component_getImplementationEnvironment + component_writeInfo + component_getFactory + local: + *; +}; diff --git a/connectivity/source/drivers/odbc/odbc.xml b/connectivity/source/drivers/odbc/odbc.xml new file mode 100644 index 000000000000..253bccb84c4c --- /dev/null +++ b/connectivity/source/drivers/odbc/odbc.xml @@ -0,0 +1,70 @@ +<?xml version='1.0' encoding="UTF-8"?> +<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//W3C//DTD HTML 3.2//EN" "componentdependencies.dtd"> +<COMPONENTDESCRIPTION> + +<Name> com.sun.star.sdbc.ODBCDriver </Name> + +<Description> + This is the implementation of the sdbc-odbc bridge. +</Description> + +<ModuleName> odbc </ModuleName> + +<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName> + +<SupportedService> com.sun.star.sdbc.Driver </SupportedService> + +<ServiceDependency> ... </ServiceDependency> + +<ProjectBuildDependency> cppuhelper </ProjectBuildDependency> +<ProjectBuildDependency> cppu </ProjectBuildDependency> +<ProjectBuildDependency> sal </ProjectBuildDependency> +<ProjectBuildDependency> vos </ProjectBuildDependency> + +<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency> +<RuntimeModuleDependency> cppu1 </RuntimeModuleDependency> +<RuntimeModuleDependency> sal1 </RuntimeModuleDependency> +<RuntimeModuleDependency> vos </RuntimeModuleDependency> + +<Language> c++ </Language> + +<Status StatusValue="final"/> + +<Type> com.sun.star.util.XCancellable </Type> +<Type> com.sun.star.util.XNumberFormatter </Type> +<Type> com.sun.star.uno.TypeClass </Type> +<Type> com.sun.star.uno.XWeak </Type> +<Type> com.sun.star.uno.XAggregation </Type> +<Type> com.sun.star.beans.XPropertyState </Type> +<Type> com.sun.star.beans.XPropertySet </Type> +<Type> com.sun.star.beans.PropertyValue </Type> +<Type> com.sun.star.beans.XMultiPropertySet </Type> +<Type> com.sun.star.beans.XFastPropertySet </Type> +<Type> com.sun.star.lang.XTypeProvider </Type> +<Type> com.sun.star.lang.EventObject </Type> +<Type> com.sun.star.lang.XComponent </Type> +<Type> com.sun.star.lang.IllegalArgumentException </Type> +<Type> com.sun.star.lang.XMultiServiceFactory </Type> +<Type> com.sun.star.java.XJavaThreadRegister_11 </Type> +<Type> com.sun.star.java.XJavaVM </Type> +<Type> com.sun.star.sdbc.XConnection </Type> +<Type> com.sun.star.sdbc.XStatement </Type> +<Type> com.sun.star.sdbc.XResultSet </Type> +<Type> com.sun.star.sdbc.XResultSetMetaDataSupplier</Type> +<Type> com.sun.star.sdbc.XColumnLocate </Type> +<Type> com.sun.star.sdbc.XResultSetUpdate </Type> +<Type> com.sun.star.sdbc.XWarningsSupplier </Type> +<Type> com.sun.star.sdbc.XRowUpdate </Type> +<Type> com.sun.star.sdbc.XMultipleResults </Type> +<Type> com.sun.star.sdbc.XBatchExecution </Type> +<Type> com.sun.star.sdbc.XPreparedBatchExecution </Type> +<Type> com.sun.star.sdbc.XParameters </Type> +<Type> com.sun.star.sdbc.XOutParameters </Type> +<Type> com.sun.star.sdbc.DriverPropertyInfo </Type> +<Type> com.sun.star.sdbc.XRow </Type> +<Type> com.sun.star.sdb.XColumnUpdate </Type> +<Type> com.sun.star.sdb.XColumn </Type> + +</COMPONENTDESCRIPTION> + + diff --git a/connectivity/source/drivers/odbc/oservices.cxx b/connectivity/source/drivers/odbc/oservices.cxx new file mode 100644 index 000000000000..7e6bf4bc118a --- /dev/null +++ b/connectivity/source/drivers/odbc/oservices.cxx @@ -0,0 +1,212 @@ +/************************************************************************* + * + * $RCSfile: oservices.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:23 $ + * + * 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_ODBC_ODRIVER_HXX_ +#include "odbc/ODriver.hxx" +#endif +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +using namespace connectivity::odbc; +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::registry::XRegistryKey; +using ::com::sun::star::lang::XSingleServiceFactory; +using ::com::sun::star::lang::XMultiServiceFactory; + +typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) + ( + const Reference< XMultiServiceFactory > & rServiceManager, + const OUString & rComponentName, + ::cppu::ComponentInstantiation pCreateFunction, + const Sequence< OUString > & rServiceNames + ); + +//*************************************************************************************** +// +// Die vorgeschriebene C-Api muss erfuellt werden! +// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen. +// + +//--------------------------------------------------------------------------------------- +void REGISTER_PROVIDER( + const OUString& aServiceImplName, + const Sequence< OUString>& Services, + const Reference< ::com::sun::star::registry::XRegistryKey > & xKey) +{ + OUString aMainKeyName; + aMainKeyName = OUString::createFromAscii("/"); + aMainKeyName += aServiceImplName; + aMainKeyName += OUString::createFromAscii("/UNO/SERVICES"); + + Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) ); + OSL_ENSHURE(xNewKey.is(), "ODBC::component_writeInfo : could not create a registry key !"); + + for (sal_uInt32 i=0; i<Services.getLength(); ++i) + xNewKey->createKey(Services[i]); +} + + +//--------------------------------------------------------------------------------------- +struct ProviderRequest +{ + Reference< XSingleServiceFactory > xRet; + Reference< XMultiServiceFactory > const xServiceManager; + OUString const sImplementationName; + + ProviderRequest( + void* pServiceManager, + sal_Char const* pImplementationName + ) + : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) + , sImplementationName(OUString::createFromAscii(pImplementationName)) + { + } + + inline + sal_Bool CREATE_PROVIDER( + const OUString& Implname, + const Sequence< OUString > & Services, + ::cppu::ComponentInstantiation Factory, + createFactoryFunc creator + ) + { + if (!xRet.is() && (Implname == sImplementationName)) + try + { + xRet = creator( xServiceManager, sImplementationName,Factory, Services); + } + catch(...) + { + } + return xRet.is(); + } + + void* getProvider() const { return xRet.get(); } +}; + +//--------------------------------------------------------------------------------------- + +extern "C" void SAL_CALL component_getImplementationEnvironment( + const sal_Char **ppEnvTypeName, + uno_Environment **ppEnv + ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//--------------------------------------------------------------------------------------- +extern "C" sal_Bool SAL_CALL component_writeInfo( + void* pServiceManager, + void* pRegistryKey + ) +{ + if (pRegistryKey) + try + { + Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey)); + + REGISTER_PROVIDER( + ODBCDriver::getImplementationName_Static(), + ODBCDriver::getSupportedServiceNames_Static(), xKey); + + return sal_True; + } + catch (::com::sun::star::registry::InvalidRegistryException& ) + { + OSL_ENSHURE(sal_False, "ODBC::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !"); + } + + return sal_False; +} + +//--------------------------------------------------------------------------------------- +extern "C" void* SAL_CALL component_getFactory( + const sal_Char* pImplementationName, + void* pServiceManager, + void* pRegistryKey) +{ + void* pRet = 0; + if (pServiceManager) + { + ProviderRequest aReq(pServiceManager,pImplementationName); + + aReq.CREATE_PROVIDER( + ODBCDriver::getImplementationName_Static(), + ODBCDriver::getSupportedServiceNames_Static(), + ODBCDriver_CreateInstance, ::cppu::createSingleFactory) + ; + + if(aReq.xRet.is()) + aReq.xRet->acquire(); + + pRet = aReq.getProvider(); + } + + return pRet; +}; + + diff --git a/connectivity/source/inc/OColumn.hxx b/connectivity/source/inc/OColumn.hxx new file mode 100644 index 000000000000..a03c8debc371 --- /dev/null +++ b/connectivity/source/inc/OColumn.hxx @@ -0,0 +1,174 @@ +/************************************************************************* + * + * $RCSfile: OColumn.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_COLUMN_HXX_ +#define _CONNECTIVITY_COLUMN_HXX_ + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +namespace connectivity +{ + class OColumn + { + ::rtl::OUString m_CatalogName; + ::rtl::OUString m_SchemaName; + ::rtl::OUString m_TableName; + ::rtl::OUString m_ColumnName; + ::rtl::OUString m_ColumnLabel; + ::rtl::OUString m_ColumnTypeName; + ::rtl::OUString m_ColumnServiceName; + + sal_Int32 m_Nullable; + sal_Int32 m_ColumnDisplaySize; + sal_Int32 m_Precision; + sal_Int32 m_Scale; + sal_Int32 m_ColumnType; + + sal_Bool m_AutoIncrement; + sal_Bool m_CaseSensitive; + sal_Bool m_Searchable; + sal_Bool m_Currency; + sal_Bool m_Signed; + sal_Bool m_ReadOnly; + sal_Bool m_Writable; + sal_Bool m_DefinitelyWritable; + + public: + OColumn() {} + OColumn(const ::rtl::OUString &_aTableName, + const ::rtl::OUString &_aColumnName, + + sal_Int32 _aNullable=0, + sal_Int32 _aColumnDisplaySize=0, + sal_Int32 _aPrecision=0, + sal_Int32 _aScale=0, + sal_Int32 _aColumnType=0, + + sal_Bool _aAutoIncrement=sal_False, + sal_Bool _aCaseSensitive=sal_False, + sal_Bool _aSearchable=sal_True, + sal_Bool _aCurrency=sal_False, + sal_Bool _aSigned=sal_False, + sal_Bool _aReadOnly=sal_True, + sal_Bool _aWritable=sal_False, + sal_Bool _aDefinitelyWritable=sal_False, + + const ::rtl::OUString &_aColumnLabel = ::rtl::OUString(), + const ::rtl::OUString &_aColumnTypeName = ::rtl::OUString(), + const ::rtl::OUString &_aColumnServiceName = ::rtl::OUString()) + : m_TableName(_aTableName), + m_ColumnName(_aColumnName), + m_ColumnLabel(_aColumnLabel), + m_ColumnTypeName(_aColumnTypeName), + m_ColumnServiceName(_aColumnServiceName), + + m_Nullable(_aNullable), + m_ColumnDisplaySize(_aColumnDisplaySize), + m_Precision(_aPrecision), + m_Scale(_aScale), + m_ColumnType(_aColumnType), + + m_AutoIncrement(_aAutoIncrement), + m_CaseSensitive(_aCaseSensitive), + m_Searchable(_aSearchable), + m_Currency(_aCurrency), + m_Signed(_aSigned), + m_ReadOnly(_aReadOnly), + m_Writable(_aWritable), + m_DefinitelyWritable(_aDefinitelyWritable) + { + if(!m_ColumnLabel.getLength()) + m_ColumnLabel = _aColumnName; + } + + sal_Bool isAutoIncrement() const { return m_AutoIncrement; } + sal_Bool isCaseSensitive() const { return m_CaseSensitive; } + sal_Bool isSearchable() const { return m_Searchable; } + sal_Bool isCurrency() const { return m_Currency; } + sal_Bool isSigned() const { return m_Signed; } + sal_Bool isReadOnly() const { return m_ReadOnly; } + sal_Bool isWritable() const { return m_Writable; } + sal_Bool isDefinitelyWritable() const { return m_DefinitelyWritable; } + + sal_Int32 isNullable() const { return m_Nullable; } + sal_Int32 getColumnDisplaySize() const { return m_ColumnDisplaySize; } + sal_Int32 getPrecision() const { return m_Precision; } + sal_Int32 getScale() const { return m_Scale; } + sal_Int32 getColumnType() const { return m_ColumnType; } + + const ::rtl::OUString& getColumnLabel() const { return m_ColumnLabel; } + const ::rtl::OUString& getColumnName() const { return m_ColumnName; } + const ::rtl::OUString& getSchemaName() const { return m_SchemaName; } + const ::rtl::OUString& getTableName() const { return m_TableName; } + const ::rtl::OUString& getCatalogName() const { return m_CatalogName; } + const ::rtl::OUString& getColumnTypeName() const { return m_ColumnTypeName; } + const ::rtl::OUString& getColumnServiceName() const { return m_ColumnServiceName; } + + }; +} + +#endif //_CONNECTIVITY_COLUMN_HXX_ + diff --git a/connectivity/source/inc/OSubComponent.hxx b/connectivity/source/inc/OSubComponent.hxx new file mode 100644 index 000000000000..da7f1f48bada --- /dev/null +++ b/connectivity/source/inc/OSubComponent.hxx @@ -0,0 +1,135 @@ +/************************************************************************* + * + * $RCSfile: OSubComponent.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_OSUBCOMPONENT_HXX_ +#define _CONNECTIVITY_OSUBCOMPONENT_HXX_ + +#ifndef _CPPUHELPER_WEAK_HXX_ +#include <cppuhelper/Weak.hxx> +#endif + +namespace connectivity +{ + + //************************************************************ + // OSubComponent + //************************************************************ + template <class T > class OSubComponent + { + protected: + // the parent must support the tunnel implementation + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent; + T* m_pChildImpl; + + public: + OSubComponent(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParent) : m_xParent(_xParent) + { + m_pChildImpl = (T*)this; + } + + + protected: + void dispose_ChildImpl() + { + ::osl::MutexGuard aGuard( m_pChildImpl->rBHelper.rMutex ); + m_xParent = NULL; + } + void relase_ChildImpl() + { + if (osl_decrementInterlockedCount( &m_pChildImpl->m_refCount ) == 0) + { + if (! m_pChildImpl->rBHelper.bDisposed) + { + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xHoldAlive( *m_pChildImpl ); + + // remember the parent + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xParent; + { + ::osl::MutexGuard aGuard( m_pChildImpl->rBHelper.rMutex ); + xParent = m_xParent; + m_xParent = NULL; + } + + // First dispose + m_pChildImpl->dispose(); + + // only the alive ref holds the object + OSL_ASSERT( m_pChildImpl->m_refCount == 1 ); + + // release the parent in the ~ + if (xParent.is()) + { + ::osl::MutexGuard aGuard( m_pChildImpl->rBHelper.rMutex ); + m_xParent = xParent; + } + + // destroy the object if xHoldAlive decrement the refcount to 0 + return; + } + } + // restore the reference count + osl_incrementInterlockedCount( &m_pChildImpl->m_refCount ); + // as we cover the job of the componenthelper we use the ... + // ((::cppu::OWeakObject*)m_pChildImpl)->release(); + } + }; +} +#endif // _CONNECTIVITY_OSUBCOMPONENT_HXX_ + diff --git a/connectivity/source/inc/OTypeInfo.hxx b/connectivity/source/inc/OTypeInfo.hxx new file mode 100644 index 000000000000..31812128ad6a --- /dev/null +++ b/connectivity/source/inc/OTypeInfo.hxx @@ -0,0 +1,119 @@ +/************************************************************************* + * + * $RCSfile: OTypeInfo.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_OTYPEINFO_HXX_ +#define _CONNECTIVITY_OTYPEINFO_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_COLUMNSEARCH_HPP_ +#include <com/sun/star/sdbc/ColumnSearch.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif + +namespace connectivity +{ + namespace starsdbc2 = ::com::sun::star::sdbc; + + struct OTypeInfo + { + ::rtl::OUString aTypeName; // Name des Types in der Datenbank + ::rtl::OUString aLiteralPrefix; // Prefix zum Quoten + ::rtl::OUString aLiteralSuffix; // Suffix zum Quoten + ::rtl::OUString aCreateParams; // Parameter zum Erstellen + ::rtl::OUString aLocalTypeName; + + sal_Int32 nPrecision; // Laenge des Types + + sal_Int16 nMaximumScale; // Nachkommastellen + sal_Int16 nMinimumScale; // Min Nachkommastellen + + sal_Int16 nType; // Datenbanktyp + sal_Int16 nSearchType; // kann nach dem Typen gesucht werden + sal_Int16 nNumPrecRadix; // indicating the radix, which is usually 2 or 10 + + sal_Bool bCurrency : 1, // Waehrung + bAutoIncrement : 1, // Ist es ein automatisch incrementierendes Feld + bNullable : 1, // Kann das Feld NULL annehmen + bCaseSensitive : 1, // Ist der Type Casesensitive + bUnsigned : 1, // Ist der Type Unsigned + bEmpty_1 : 1, // for later use + bEmpty_2 : 1; + + OTypeInfo() + :bCurrency(sal_False) + ,bAutoIncrement(sal_False) + ,bNullable(sal_True) + ,bCaseSensitive(sal_False) + ,bUnsigned(sal_False) + ,nMaximumScale(0) + ,nMinimumScale(0) + ,nType(starsdbc2::DataType::OTHER) + ,nPrecision(0) + ,nSearchType(starsdbc2::ColumnSearch::FULL) + {} + sal_Bool operator == (const OTypeInfo& lh) const { return lh.nType == nType; } + sal_Bool operator != (const OTypeInfo& lh) const { return lh.nType != nType; } + }; +} +#endif // _CONNECTIVITY_OTYPEINFO_HXX_ + + diff --git a/connectivity/source/inc/adabas/BCatalog.hxx b/connectivity/source/inc/adabas/BCatalog.hxx new file mode 100644 index 000000000000..9d2fb25f1831 --- /dev/null +++ b/connectivity/source/inc/adabas/BCatalog.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * $RCSfile: BCatalog.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_CATALOG_HXX_ +#define _CONNECTIVITY_ADABAS_CATALOG_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_CATALOG_HXX_ +#include "connectivity/sdbcx/VCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_OFUNCTIONDEFS_HXX_ +#include "odbc/OFunctiondefs.hxx" +#endif + +namespace connectivity +{ + namespace adabas + { + class OAdabasConnection; + class OAdabasCatalog : public connectivity::sdbcx::OCatalog + { + OAdabasConnection* m_pConnection; + SQLHANDLE m_aConnectionHdl; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + + public: + virtual void refreshTables(); + virtual void refreshViews() ; + virtual void refreshGroups(); + virtual void refreshUsers() ; + + public: + OAdabasCatalog(SQLHANDLE _aConnectionHdl,OAdabasConnection* _pCon); + + OAdabasConnection* getConnection() { return m_pConnection; } + }; + } +} +#endif // _CONNECTIVITY_ADABAS_CATALOG_HXX_ + diff --git a/connectivity/source/inc/adabas/BColumn.hxx b/connectivity/source/inc/adabas/BColumn.hxx new file mode 100644 index 000000000000..530fb4414531 --- /dev/null +++ b/connectivity/source/inc/adabas/BColumn.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * $RCSfile: BColumn.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_COLUMN_HXX_ +#define _CONNECTIVITY_ADABAS_COLUMN_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif + +namespace connectivity +{ + namespace adabas + { + class OAdabasColumn : public sdbcx::OColumn + { + public: + OAdabasColumn(); + OAdabasColumn(const ::rtl::OUString& _Name, + const ::rtl::OUString& _TypeName, + const ::rtl::OUString& _DefaultValue, + sal_Int32 _IsNullable, + sal_Int32 _Precision, + sal_Int32 _Scale, + sal_Int32 _Type, + sal_Bool _IsAutoIncrement); + + }; + } +} +#endif // _CONNECTIVITY_ADABAS_COLUMN_HXX_ + diff --git a/connectivity/source/inc/adabas/BColumns.hxx b/connectivity/source/inc/adabas/BColumns.hxx new file mode 100644 index 000000000000..dc847c57d716 --- /dev/null +++ b/connectivity/source/inc/adabas/BColumns.hxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * $RCSfile: BColumns.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_COLUMNS_HXX_ +#define _CONNECTIVITY_ADABAS_COLUMNS_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_ +#include "connectivity/sdbcx/IRefreshable.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif + +namespace connectivity +{ + namespace adabas + { + class OColumns : public sdbcx::OCollection + { + protected: + OAdabasTable* m_pTable; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + OColumns( OAdabasTable* _pTable, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector + ) : sdbcx::OCollection(*_pTable,sal_True,_rMutex,_rVector) + ,m_pTable(_pTable) + {} + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ADABAS_COLUMNS_HXX_ + diff --git a/connectivity/source/inc/adabas/BConnection.hxx b/connectivity/source/inc/adabas/BConnection.hxx new file mode 100644 index 000000000000..621ae1151ffd --- /dev/null +++ b/connectivity/source/inc/adabas/BConnection.hxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * $RCSfile: BConnection.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_BCONNECTION_HXX_ +#define _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ + +#ifndef _CPPUHELPER_COMPBASE2_HXX_ +#include <cppuhelper/compbase2.hxx> +#endif +#ifndef _CONNECTIVITY_ODBC_OCONNECTION_HXX_ +#include "odbc/OConnection.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _CPPUHELPER_WEAKREF_HXX_ +#include <cppuhelper/weakref.hxx> +#endif + +namespace connectivity +{ + namespace odbc + { + class ODBCDriver; + } + namespace adabas + { + typedef connectivity::odbc::OConnection OConnection_BASE2; + + // we must use the name "OAdabasConnection" because of a compiler bug + + class OAdabasConnection : public OConnection_BASE2 + { + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; + + sal_Bool isStarted(); + + protected: + virtual SQLRETURN OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, const ::rtl::OUString& _uid,const ::rtl::OUString& _pwd); + public: + virtual SQLRETURN Construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException); + + OAdabasConnection(const SQLHANDLE _pDriverHandle,connectivity::odbc::ODBCDriver* _pDriver); + + // OComponentHelper; + virtual void SAL_CALL disposing(); + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog(); + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ + diff --git a/connectivity/source/inc/adabas/BDatabaseMetaData.hxx b/connectivity/source/inc/adabas/BDatabaseMetaData.hxx new file mode 100644 index 000000000000..7b2714b8c721 --- /dev/null +++ b/connectivity/source/inc/adabas/BDatabaseMetaData.hxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * $RCSfile: BDatabaseMetaData.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ODBC_ODATABASEMETADATA_HXX_ +#include "odbc/ODatabaseMetaData.hxx" +#endif + +namespace connectivity +{ + namespace odbc + { + class OConnection; + } + namespace adabas + { + typedef odbc::ODatabaseMetaData OAdabasDatabaseMetaData_BASE; + + class OAdabasDatabaseMetaData : public OAdabasDatabaseMetaData_BASE + { + public: + OAdabasDatabaseMetaData(const SQLHANDLE _pHandle,odbc::OConnection* _pCon) + : ODatabaseMetaData(_pHandle,_pCon) + { + } + + virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} + diff --git a/connectivity/source/inc/adabas/BDriver.hxx b/connectivity/source/inc/adabas/BDriver.hxx new file mode 100644 index 000000000000..74ce2ed48bfb --- /dev/null +++ b/connectivity/source/inc/adabas/BDriver.hxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * $RCSfile: BDriver.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_BDRIVER_HXX_ +#define _CONNECTIVITY_ADABAS_BDRIVER_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_ +#include <com/sun/star/sdbc/XDriver.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _CONNECTIVITY_OFUNCTIONDEFS_HXX_ +#include "odbc/OFunctiondefs.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_ODRIVER_HXX_ +#include "odbc/ODriver.hxx" +#endif + +namespace connectivity +{ + namespace adabas + { + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ); + + typedef odbc::ODBCDriver ODriver_BASE; + + class ODriver : public ODriver_BASE, + public ::com::sun::star::sdbcx::XDataDefinitionSupplier + { + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; + protected: + virtual SQLHANDLE EnvironmentHandle(::rtl::OUString &_rPath); + public: + + DECLARE_CTY_DEFAULTS(ODriver_BASE); + DECLARE_SERVICE_INFO(); + + ODriver(); + ~ODriver(){} + + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + + // XDriver + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); + + // XDataDefinitionSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } + +} +#endif //_CONNECTIVITY_ADABAS_BDRIVER_HXX_ + + diff --git a/connectivity/source/inc/adabas/BGroup.hxx b/connectivity/source/inc/adabas/BGroup.hxx new file mode 100644 index 000000000000..66e4b511363c --- /dev/null +++ b/connectivity/source/inc/adabas/BGroup.hxx @@ -0,0 +1,86 @@ +/************************************************************************* + * + * $RCSfile: BGroup.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_GROUP_HXX_ +#define _CONNECTIVITY_ADABAS_GROUP_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_GROUP_HXX_ +#include "connectivity/sdbcx/VGroup.hxx" +#endif + +namespace connectivity +{ + namespace adabas + { + class OAdabasConnection; + class OAdabasGroup : public sdbcx::OGroup + { + OAdabasConnection* m_pConnection; + public: + virtual void refreshUsers(); + public: + OAdabasGroup( OAdabasConnection* _pConnection); + OAdabasGroup( OAdabasConnection* _pConnection,const ::rtl::OUString& _Name); + }; + } +} +#endif // _CONNECTIVITY_ADABAS_GROUP_HXX_ + diff --git a/connectivity/source/inc/adabas/BGroups.hxx b/connectivity/source/inc/adabas/BGroups.hxx new file mode 100644 index 000000000000..917cdcff9756 --- /dev/null +++ b/connectivity/source/inc/adabas/BGroups.hxx @@ -0,0 +1,106 @@ +/************************************************************************* + * + * $RCSfile: BGroups.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_GROUPS_HXX_ +#define _CONNECTIVITY_ADABAS_GROUPS_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +namespace connectivity +{ + namespace sdbcx + { + class IRefreshableGroups; + } + namespace adabas + { + class OAdabasConnection; + class OGroups : public sdbcx::OCollection + { + protected: + OAdabasConnection* m_pConnection; + connectivity::sdbcx::IRefreshableGroups* m_pParent; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + OGroups(::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector, + OAdabasConnection* _pConnection, + connectivity::sdbcx::IRefreshableGroups* _pParent) : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector) + ,m_pConnection(_pConnection) + ,m_pParent(_pParent) + {} + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // _CONNECTIVITY_ADABAS_GROUPS_HXX_ + diff --git a/connectivity/source/inc/adabas/BIndex.hxx b/connectivity/source/inc/adabas/BIndex.hxx new file mode 100644 index 000000000000..229d32cf9931 --- /dev/null +++ b/connectivity/source/inc/adabas/BIndex.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * $RCSfile: BIndex.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_INDEX_HXX_ +#define _CONNECTIVITY_ADABAS_INDEX_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_INDEX_HXX_ +#include "connectivity/sdbcx/VIndex.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif + +namespace connectivity +{ + namespace adabas + { + class OAdabasTable; + class OAdabasIndex : public sdbcx::OIndex + { + OAdabasTable* m_pTable; + public: + virtual void refreshColumns(); + public: + OAdabasIndex( OAdabasTable* _pTable); + OAdabasIndex( OAdabasTable* _pTable, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Catalog, + sal_Bool _isUnique, + sal_Bool _isPrimaryKeyIndex, + sal_Bool _isClustered + ); + OAdabasTable* getTable() const { return m_pTable; } + }; + } +} +#endif // _CONNECTIVITY_ADABAS_INDEX_HXX_ + diff --git a/connectivity/source/inc/adabas/BIndexColumn.hxx b/connectivity/source/inc/adabas/BIndexColumn.hxx new file mode 100644 index 000000000000..9385c00f0318 --- /dev/null +++ b/connectivity/source/inc/adabas/BIndexColumn.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * $RCSfile: BIndexColumn.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_INDEXCOLUMN_HXX_ +#define _CONNECTIVITY_ADABAS_INDEXCOLUMN_HXX_ + +#ifndef _CONNECTIVITY_ADABAS_COLUMN_HXX_ +#include "adabas/BColumn.hxx" +#endif + +namespace connectivity +{ + namespace adabas + { + class OIndexColumn : public OAdabasColumn + { + protected: + sal_Bool m_IsAscending; + public: + OIndexColumn(); + OIndexColumn( sal_Bool _IsAscending, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _TypeName, + const ::rtl::OUString& _DefaultValue, + sal_Int32 _IsNullable, + sal_Int32 _Precision, + sal_Int32 _Scale, + sal_Int32 _Type, + sal_Bool _IsAutoIncrement); + + virtual void construct(); + }; + } +} +#endif // _CONNECTIVITY_ADABAS_INDEXCOLUMN_HXX_ + diff --git a/connectivity/source/inc/adabas/BIndexColumns.hxx b/connectivity/source/inc/adabas/BIndexColumns.hxx new file mode 100644 index 000000000000..93632d29f7bc --- /dev/null +++ b/connectivity/source/inc/adabas/BIndexColumns.hxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * $RCSfile: BIndexColumns.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_INDEXCOLUMNS_HXX_ +#define _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_INDEX_HXX_ +#include "adabas/BIndex.hxx" +#endif + +namespace connectivity +{ + namespace adabas + { + class OIndexColumns : public sdbcx::OCollection + { + OAdabasIndex* m_pIndex; + protected: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException) + { + m_pIndex->refreshColumns(); + } + public: + OIndexColumns( OAdabasIndex* _pIndex, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector) + : sdbcx::OCollection(*_pIndex,sal_True,_rMutex,_rVector) + ,m_pIndex(_pIndex) + { + } + }; + } +} +#endif // _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_ + diff --git a/connectivity/source/inc/adabas/BIndexes.hxx b/connectivity/source/inc/adabas/BIndexes.hxx new file mode 100644 index 000000000000..210260c2c0c2 --- /dev/null +++ b/connectivity/source/inc/adabas/BIndexes.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * $RCSfile: BIndexes.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_INDEXES_HXX_ +#define _CONNECTIVITY_ADABAS_INDEXES_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +namespace connectivity +{ + namespace adabas + { + class OIndexes : public sdbcx::OCollection + { + OAdabasTable* m_pTable; + protected: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + OIndexes(OAdabasTable* _pTable, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector + ) : sdbcx::OCollection(*_pTable,sal_True,_rMutex,_rVector) + ,m_pTable(_pTable) + {} + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // _CONNECTIVITY_ADABAS_INDEXES_HXX_ + diff --git a/connectivity/source/inc/adabas/BKeys.hxx b/connectivity/source/inc/adabas/BKeys.hxx new file mode 100644 index 000000000000..b4112dfc3742 --- /dev/null +++ b/connectivity/source/inc/adabas/BKeys.hxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * $RCSfile: BKeys.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_KEYS_HXX_ +#define _CONNECTIVITY_ADABAS_KEYS_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +namespace connectivity +{ + namespace adabas + { + class OKeys : public sdbcx::OCollection + { + OAdabasTable* m_pTable; + protected: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + OKeys(OAdabasTable* _pTable, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector + ) : sdbcx::OCollection(*_pTable,sal_True,_rMutex,_rVector) + ,m_pTable(_pTable) + {} + //XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // _CONNECTIVITY_ADABAS_KEYS_HXX_ + diff --git a/connectivity/source/inc/adabas/BTable.hxx b/connectivity/source/inc/adabas/BTable.hxx new file mode 100644 index 000000000000..5a7e6e246203 --- /dev/null +++ b/connectivity/source/inc/adabas/BTable.hxx @@ -0,0 +1,135 @@ +/************************************************************************* + * + * $RCSfile: BTable.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_TABLE_HXX_ +#define _CONNECTIVITY_ADABAS_TABLE_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_TABLE_HXX_ +#include "connectivity/sdbcx/VTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif + +namespace connectivity +{ + namespace adabas + { + typedef connectivity::sdbcx::OTable OTable_TYPEDEF; + + ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp); + + class OAdabasTable : public OTable_TYPEDEF, + public ::com::sun::star::lang::XUnoTunnel + { + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + OAdabasConnection* m_pConnection; + + void refreshPrimaryKeys(std::vector< ::rtl::OUString>& _rKeys); + void refreshForgeinKeys(std::vector< ::rtl::OUString>& _rKeys); + + public: + virtual void refreshColumns(); + virtual void refreshKeys(); + virtual void refreshIndexes(); + + public: + DECLARE_CTY_DEFAULTS( OTable_TYPEDEF); + OAdabasTable( OAdabasConnection* _pConnection); + OAdabasTable( OAdabasConnection* _pConnection, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description = ::rtl::OUString(), + const ::rtl::OUString& _SchemaName = ::rtl::OUString(), + const ::rtl::OUString& _CatalogName = ::rtl::OUString() + ); + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + OAdabasConnection* getConnection() { return m_pConnection;} + + const ::rtl::OUString& getName() const { return m_Name; } + const ::rtl::OUString& getSchema() const { return m_SchemaName; } + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + // XRename + virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + + // XAlterTable + virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& colName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + // + sal_Bool create() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ADABAS_TABLE_HXX_ + diff --git a/connectivity/source/inc/adabas/BTables.hxx b/connectivity/source/inc/adabas/BTables.hxx new file mode 100644 index 000000000000..b81d1016b118 --- /dev/null +++ b/connectivity/source/inc/adabas/BTables.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * $RCSfile: BTables.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_TABLES_HXX_ +#define _CONNECTIVITY_ADABAS_TABLES_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +namespace connectivity +{ + namespace adabas + { + class OTables : public sdbcx::OCollection + { + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + // OCatalog* m_pParent; + protected: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + void setComments(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + public: + OTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector) : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector) + ,m_xMetaData(_rMetaData) + // ,m_pParent(_pParent) + {} + + // only the name is identical to ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ADABAS_TABLES_HXX_ + diff --git a/connectivity/source/inc/adabas/BUser.hxx b/connectivity/source/inc/adabas/BUser.hxx new file mode 100644 index 000000000000..2fbba63872cb --- /dev/null +++ b/connectivity/source/inc/adabas/BUser.hxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * $RCSfile: BUser.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_USER_HXX_ +#define _CONNECTIVITY_ADABAS_USER_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_USER_HXX_ +#include "connectivity/sdbcx/VUser.hxx" +#endif + +namespace connectivity +{ + namespace adabas + { + class OAdabasConnection; + typedef connectivity::sdbcx::OUser OUser_TYPEDEF; + + class OAdabasUser : public OUser_TYPEDEF + { + OAdabasConnection* m_pConnection; + public: + virtual void refreshGroups(); + public: + OAdabasUser( OAdabasConnection* _pConnection); + OAdabasUser( OAdabasConnection* _pConnection,const ::rtl::OUString& _Name); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + }; + + class OUserExtend; + typedef ::utl::OPropertyArrayUsageHelper<OUserExtend> OUserExtend_PROP; + + class OUserExtend : public OAdabasUser, + public OUserExtend_PROP + { + protected: + ::rtl::OUString m_Password; + DECLARE_CTY_PROPERTY(OAdabasUser,OUserExtend) + public: + OUserExtend(OAdabasConnection* _pConnection); + OUserExtend(OAdabasConnection* _pConnection,const ::rtl::OUString& _Name); + + virtual void construct(); + }; + } +} +#endif // _CONNECTIVITY_ADABAS_USER_HXX_ + diff --git a/connectivity/source/inc/adabas/BUsers.hxx b/connectivity/source/inc/adabas/BUsers.hxx new file mode 100644 index 000000000000..cbe7037235b7 --- /dev/null +++ b/connectivity/source/inc/adabas/BUsers.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * $RCSfile: BUsers.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_USERS_HXX_ +#define _CONNECTIVITY_ADABAS_USERS_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +namespace connectivity +{ + namespace sdbcx + { + class IRefreshableUsers; + } + namespace adabas + { + class OAdabasConnection; + class OUsers : public sdbcx::OCollection + { + OAdabasConnection* m_pConnection; + connectivity::sdbcx::IRefreshableUsers* m_pParent; + public: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + public: + OUsers( ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector, + OAdabasConnection* _pConnection, + connectivity::sdbcx::IRefreshableUsers* _pParent) : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector) + ,m_pConnection(_pConnection) + ,m_pParent(_pParent) + {} + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // _CONNECTIVITY_ADABAS_USERS_HXX_ + diff --git a/connectivity/source/inc/ado/ACallableStatement.hxx b/connectivity/source/inc/ado/ACallableStatement.hxx new file mode 100644 index 000000000000..7009ba80a151 --- /dev/null +++ b/connectivity/source/inc/ado/ACallableStatement.hxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * $RCSfile: ACallableStatement.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ACALLABLESTATEMENT_HXX_ +#define _CONNECTIVITY_ADO_ACALLABLESTATEMENT_HXX_ + +#ifndef _CONNECTIVITY_ADO_APREPAREDSTATEMENT_HXX_ +#include "ado/APreparedStatement.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XOUTPARAMETERS_HPP_ +#include <com/sun/star/sdbc/XOutParameters.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +namespace connectivity +{ + namespace ado + { + //************************************************************** + //************ Class: java.sql.CallableStatement + //************************************************************** + + class OCallableStatement : public OPreparedStatement, + public ::com::sun::star::sdbc::XRow, + public ::com::sun::star::sdbc::XOutParameters + { + OLEVariant m_aValue; + public: + DECLARE_CTY_DEFAULTS(OPreparedStatement); + DECLARE_SERVICE_INFO(); + virtual ~OCallableStatement() {} ; + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OCallableStatement( OConnection* _pConnection,const ::std::vector<OTypeInfo>& _TypeInfo,const ::rtl::OUString& sql ); + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + + // XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XOutParameters + virtual void SAL_CALL registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_OCallableStatement_HXX_ + + diff --git a/connectivity/source/inc/ado/ACatalog.hxx b/connectivity/source/inc/ado/ACatalog.hxx new file mode 100644 index 000000000000..dbc99f046c0d --- /dev/null +++ b/connectivity/source/inc/ado/ACatalog.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * $RCSfile: ACatalog.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_CATALOG_HXX_ +#define _CONNECTIVITY_ADO_CATALOG_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_CATALOG_HXX_ +#include "connectivity/sdbcx/VCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + class OConnection; + + class OCatalog : public connectivity::sdbcx::OCatalog + { + WpADOCatalog m_aCatalog; + OConnection* m_pConnection; + + public: + virtual void refreshTables(); + virtual void refreshViews() ; + virtual void refreshGroups(); + virtual void refreshUsers() ; + + public: + OCatalog(_ADOCatalog* _pCatalog,OConnection* _pCon); + + OConnection* getConnection() { return m_pConnection; } + }; + } +} +#endif // _CONNECTIVITY_ADO_CATALOG_HXX_ + diff --git a/connectivity/source/inc/ado/ACollection.hxx b/connectivity/source/inc/ado/ACollection.hxx new file mode 100644 index 000000000000..13d5c91de160 --- /dev/null +++ b/connectivity/source/inc/ado/ACollection.hxx @@ -0,0 +1,274 @@ +/************************************************************************* + * + * $RCSfile: ACollection.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_COLLECTION_HXX_ +#define _CONNECTIVITY_ADO_COLLECTION_HXX_ + +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include <cppuhelper/implbase3.hxx> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AOLEVARIANT_HXX_ +#include "ado/Aolevariant.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +namespace connectivity +{ + namespace ado + { + namespace starcontainer = ::com::sun::star::container; + namespace starlang = ::com::sun::star::lang; + namespace staruno = ::com::sun::star::uno; + namespace starbeans = ::com::sun::star::beans; + + typedef ::cppu::WeakImplHelper3< starcontainer::XNameAccess, + starcontainer::XIndexAccess, + starlang::XServiceInfo> OCollectionBase; + + //************************************************************ + // OCollection + //************************************************************ + template <class T,class SimT,class OCl> class OCollection : public OCollectionBase + { + protected: + vector<OCl*> m_aElements; + ::cppu::OWeakObject& m_rParent; + ::osl::Mutex& m_rMutex; // mutex of the parent + T* m_pCollection; + + + public: + OCollection(::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,T* _pCollection) + : m_rParent(_rParent) + ,m_rMutex(_rMutex) + ,m_pCollection(_pCollection) + { + m_pCollection->AddRef(); + } + + ~OCollection() + { + m_pCollection->Release(); + } + + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (staruno::RuntimeException) + { + return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ACollection"); + } + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& _rServiceName ) throw(staruno::RuntimeException) + { + staruno::Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) + if (pSupported->equals(_rServiceName)) + return sal_True; + + return sal_False; + } + virtual staruno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(staruno::RuntimeException) + { + staruno::Sequence< ::rtl::OUString > aSupported(1); + aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Container"); + return aSupported; + } + + // dispatch the refcounting to the parent + virtual void SAL_CALL acquire() throw(staruno::RuntimeException) + { + m_rParent.acquire(); + } + virtual void SAL_CALL release() throw(staruno::RuntimeException) + { + m_rParent.release(); + } + + // ::com::sun::star::container::XElementAccess + virtual staruno::Type SAL_CALL getElementType( ) throw(staruno::RuntimeException) + { + return::getCppuType(static_cast< staruno::Reference< starbeans::XPropertySet>*>(NULL)); + } + + virtual sal_Bool SAL_CALL hasElements( ) throw(staruno::RuntimeException) + { + ::osl::MutexGuard aGuard(m_rMutex); + return getCount() > 0; + } + + // starcontainer::XIndexAccess + virtual sal_Int32 SAL_CALL getCount( ) throw(staruno::RuntimeException) + { + ::osl::MutexGuard aGuard(m_rMutex); + sal_Int32 nCnt = 0; + m_pCollection->get_Count(&nCnt); + return nCnt; + } + + virtual staruno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(starlang::IndexOutOfBoundsException, starlang::WrappedTargetException, staruno::RuntimeException) + { + ::osl::MutexGuard aGuard(m_rMutex); + if (Index < 0 || Index >= getCount()) + throw starlang::IndexOutOfBoundsException(); + SimT* pCol = NULL; + m_pCollection->get_Item(OLEVariant(Index),&pCol); + if(!pCol) + throw starlang::IndexOutOfBoundsException(); + + OCl* pIndex = new OCl(pCol); + + m_aElements.push_back(pIndex); + + return staruno::makeAny( staruno::Reference< starbeans::XPropertySet >(pIndex)); + } + + + // starcontainer::XNameAccess + virtual staruno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(starcontainer::NoSuchElementException, starlang::WrappedTargetException, staruno::RuntimeException) + { + ::osl::MutexGuard aGuard(m_rMutex); + + SimT* pCol = NULL; + m_pCollection->get_Item(OLEVariant(aName),&pCol); + if(!pCol) + throw starlang::IndexOutOfBoundsException(); + + OCl* pIndex = new OCl(pCol); + + m_aElements.push_back(pIndex); + + return staruno::makeAny( staruno::Reference< starbeans::XPropertySet >(pIndex)); + } + virtual staruno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(staruno::RuntimeException) + { + ::osl::MutexGuard aGuard(m_rMutex); + sal_Int32 nLen = getCount(); + staruno::Sequence< ::rtl::OUString > aNameList(nLen); + + ::rtl::OUString* pStringArray = aNameList.getArray(); + OLEVariant aVar; + for (sal_Int32 i=0;i<nLen;++i) + { + aVar.setInt32(i); + SimT* pIdx = NULL; + m_pCollection->get_Item(aVar,&pIdx); + pIdx->AddRef(); + BSTR aBSTR; + pIdx->get_Name(&aBSTR); + (*pStringArray) = (sal_Unicode*)aBSTR; + SysFreeString(aBSTR); + pIdx->Release(); + ++pStringArray; + } + return aNameList; + } + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(staruno::RuntimeException) + { + ::osl::MutexGuard aGuard(m_rMutex); + SimT* pCol = NULL; + m_pCollection->get_Item(OLEVariant(aName),&pCol); + return pCol != NULL; + } + + void SAL_CALL disposing() + { + ::osl::MutexGuard aGuard(m_rMutex); + for (::std::vector<OCl*>::const_iterator i = m_aElements.begin(); i != m_aElements.end(); ++i) + { + (*i)->disposing(); + (*i)->release(); + } + m_aElements.clear(); + } + + }; + + class OIndex; + class OKey; + class OColumn; + class OTable; + class OView; + class OGroup; + class OUser; + + typedef OCollection< ADOIndexes,ADOIndex,OIndex> OIndexes; + typedef OCollection< ADOKeys,ADOKey,OKey> OKeys; + typedef OCollection< ADOColumns,ADOColumn,OColumn> OColumns; + typedef OCollection< ADOTables,ADOTable,OTable> OTables; + typedef OCollection< ADOViews,ADOView,OView> OViews; + typedef OCollection< ADOGroups,ADOGroup,OGroup> OGroups; + typedef OCollection< ADOUsers,ADOUser,OUser> OUsers; + + } +} +#endif // _CONNECTIVITY_ADO_COLLECTION_HXX_ + + + diff --git a/connectivity/source/inc/ado/AColumn.hxx b/connectivity/source/inc/ado/AColumn.hxx new file mode 100644 index 000000000000..cff2e1e6fb82 --- /dev/null +++ b/connectivity/source/inc/ado/AColumn.hxx @@ -0,0 +1,124 @@ +/************************************************************************* + * + * $RCSfile: AColumn.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_COLUMN_HXX_ +#define _CONNECTIVITY_ADO_COLUMN_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif + +namespace connectivity +{ + namespace ado + { + typedef sdbcx::OColumn OColumn_ADO; + class OAdoColumn : public OColumn_ADO, + public ::com::sun::star::lang::XUnoTunnel + { + WpADOColumn m_aColumn; + protected: + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle + ) const; + public: + DECLARE_CTY_DEFAULTS( OColumn_ADO); + + OAdoColumn(sal_Bool _bCase,_ADOColumn* _pColumn = NULL); + OAdoColumn(const ::rtl::OUString& _Name, + const ::rtl::OUString& _TypeName, + const ::rtl::OUString& _DefaultValue, + sal_Int32 _IsNullable, + sal_Int32 _Precision, + sal_Int32 _Scale, + sal_Int32 _Type, + sal_Bool _IsAutoIncrement, + sal_Bool _IsCurrency, + sal_Bool _bCase); + + // virtual void construct(); + + // XInterface + ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + WpADOColumn getColumnImpl() const { return m_aColumn;} + }; + } +} +#endif // _CONNECTIVITY_ADO_COLUMN_HXX_ + diff --git a/connectivity/source/inc/ado/AColumns.hxx b/connectivity/source/inc/ado/AColumns.hxx new file mode 100644 index 000000000000..0be84e819525 --- /dev/null +++ b/connectivity/source/inc/ado/AColumns.hxx @@ -0,0 +1,117 @@ +/************************************************************************* + * + * $RCSfile: AColumns.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_COLUMNS_HXX_ +#define _CONNECTIVITY_ADO_COLUMNS_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_ +#include "connectivity/sdbcx/IRefreshable.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + + class OColumns : public sdbcx::OCollection + { + protected: + ADOColumns* m_pCollection; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + OColumns( ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector, + ADOColumns* _pCollection,sal_Bool _bCase) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector) + ,m_pCollection(_pCollection) + { + if(m_pCollection) + m_pCollection->AddRef(); + } + + ~OColumns() + { + if(m_pCollection) + m_pCollection->Release(); + } + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ADO_COLUMNS_HXX_ + diff --git a/connectivity/source/inc/ado/AConnection.hxx b/connectivity/source/inc/ado/AConnection.hxx new file mode 100644 index 000000000000..b3f2b7f4162b --- /dev/null +++ b/connectivity/source/inc/ado/AConnection.hxx @@ -0,0 +1,183 @@ +/************************************************************************* + * + * $RCSfile: AConnection.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ACONNECTION_HXX_ +#define _CONNECTIVITY_ADO_ACONNECTION_HXX_ + +#ifndef _CPPUHELPER_COMPBASE3_HXX_ +#include <cppuhelper/compbase3.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ +#include <com/sun/star/sdbc/SQLWarning.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif +#ifndef _CONNECTIVITY_OSUBCOMPONENT_HXX_ +#include "OSubComponent.hxx" +#endif +#ifndef _MAP_ +#include <map> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CONNECTIVITY_OTYPEINFO_HXX_ +#include "OTypeInfo.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +namespace connectivity +{ + namespace ado + { + typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XConnection, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::lang::XServiceInfo> OConnection_BASE; + class WpADOConnection; + class ODriver; + + class OConnection : public OConnection_BASE, + public connectivity::OSubComponent<OConnection> + { + friend class connectivity::OSubComponent<OConnection>; + ::osl::Mutex m_aMutex; + + protected: + //==================================================================== + // Data attributes + //==================================================================== + ::std::vector<connectivity::OTypeInfo> m_aTypeInfo; // vector containing an entry + // for each row returned by + // DatabaseMetaData.getTypeInfo. + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + + connectivity::OWeakRefArray m_aStatements; // vector containing a list + // of all the Statement objects + // for this Connection + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; + ODriver* m_pDriver; + private: + WpADOConnection* m_pAdoConnection; + sal_Bool m_bClosed; + sal_Bool m_bAutocommit; + + protected: + void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException); + public: + + OConnection(const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info, + ODriver* _pDriver) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // OConnection(const SQLHANDLE _pConnectionHandle); + ~OConnection(); + void construct(const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info); + + DECLARE_SERVICE_INFO(); + + void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); + + // XConnection + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // + WpADOConnection* getConnection() { return m_pAdoConnection; } + void setCatalog(const ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>& _xCat) { m_xCatalog = _xCat; } + }; + } +} +#endif // _CONNECTIVITY_ADO_ACONNECTION_HXX_ + diff --git a/connectivity/source/inc/ado/ADatabaseMetaData.hxx b/connectivity/source/inc/ado/ADatabaseMetaData.hxx new file mode 100644 index 000000000000..8e2f03978c9e --- /dev/null +++ b/connectivity/source/inc/ado/ADatabaseMetaData.hxx @@ -0,0 +1,266 @@ +/************************************************************************* + * + * $RCSfile: ADatabaseMetaData.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ +#define _CONNECTIVITY_ADO_ADATABASEMETADATA_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _CONNECTIVITY_ADO_ACONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + class WpADOConnection; + //************************************************************** + //************ Class: java.sql.DatabaseMetaDataDate + //************************************************************** + + class ODatabaseMetaData : public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XDatabaseMetaData> + { + typedef struct _LiteralInfo + { + ::rtl::OUString pwszLiteralValue; + sal_uInt32 cchMaxLen; + sal_Bool fSupported; + } LiteralInfo; + + ::std::map<sal_uInt32,LiteralInfo> m_aLiteralInfo; + WpADOConnection* m_pADOConnection; + OConnection* m_pConnection; + + void fillLiterals() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // 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); + + // get info out of propertyst + ::rtl::OUString getStringProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getInt32Property(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Bool getBoolProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + public: + + ODatabaseMetaData(OConnection* _pCon); + + // XDatabaseMetaData + virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getUserName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCatalogAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogSeparator( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxStatements( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ADO_ADATABASEMETADATA_HXX_ + diff --git a/connectivity/source/inc/ado/ADatabaseMetaDataResultSet.hxx b/connectivity/source/inc/ado/ADatabaseMetaDataResultSet.hxx new file mode 100644 index 000000000000..9c4523490c0c --- /dev/null +++ b/connectivity/source/inc/ado/ADatabaseMetaDataResultSet.hxx @@ -0,0 +1,284 @@ +/************************************************************************* + * + * $RCSfile: ADatabaseMetaDataResultSet.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ADATABASEMETADATARESULTSET_HXX_ +#define _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSET_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_ +#include <com/sun/star/sdbc/XCloseable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_ +#include <com/sun/star/sdbc/XColumnLocate.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ +#include <com/sun/star/util/XCancellable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_ +#include <com/sun/star/sdbc/XRowUpdate.hpp> +#endif +#ifndef _CPPUHELPER_COMPBASE7_HXX_ +#include <cppuhelper/compbase7.hxx> +#endif +#ifndef _UNOTOOLS_PROPERTY_ARRAY_HELPER_HXX_ +#include <unotools/proparrhlp.hxx> +#endif +#ifndef _CONNECTIVITY_ADO_ASTATEMENT_HXX_ +#include "ado/AStatement.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + class ODatabaseMetaDataResultSetMetaData; + /* + ** java_sql_ResultSet + */ + typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::sdbc::XResultSet, + ::com::sun::star::sdbc::XRow, + ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + ::com::sun::star::util::XCancellable, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::sdbc::XCloseable, + ::com::sun::star::sdbc::XColumnLocate> ODatabaseMetaDataResultSet_BASE; + + class ODatabaseMetaDataResultSet : public OBaseMutex, + public ODatabaseMetaDataResultSet_BASE, + public ::cppu::OPropertySetHelper, + public ::utl::OPropertyArrayUsageHelper<ODatabaseMetaDataResultSet> + { + ::std::vector<void*> m_aBindVector; + ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime + + ::std::map<sal_Int32, ::std::map<sal_Int32,sal_Int32> > m_aValueRange; + ::std::map<sal_Int32, ::std::map<sal_Int32,sal_Int32> >::iterator m_aValueRangeIter; + + ::std::map<sal_Int32, ::std::map< ::rtl::OUString,sal_Int32> > m_aStrValueRange; + ::std::map<sal_Int32, ::std::map< ::rtl::OUString,sal_Int32> >::iterator m_aStrValueRangeIter; + + ::std::map<sal_Int32, ::std::map< sal_Int32,::rtl::OUString> > m_aIntValueRange; + ::std::map<sal_Int32, ::std::map< sal_Int32,::rtl::OUString> >::iterator m_aIntValueRangeIter; + + ADORecordset* m_pRecordSet; + ::com::sun::star::uno::WeakReferenceHelper m_aStatement; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; + OLEVariant m_aValue; + sal_Int32 m_nRowPos; + sal_Bool m_bWasNull; + sal_Bool m_bEOF; + sal_Bool m_bOnFirstAfterOpen; + + sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + + inline sal_Int32 mapColumn (sal_Int32 column); + + protected: + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + virtual sal_Bool SAL_CALL convertFastPropertyValue( + ::com::sun::star::uno::Any & rConvertedValue, + ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle + ) const; + public: + DECLARE_CTY_DEFAULTS(ODatabaseMetaDataResultSet_BASE); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + ODatabaseMetaDataResultSet( ADORecordset* _pRecordSet); + ~ODatabaseMetaDataResultSet(); + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) + { + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); + } + // XResultSet + virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XColumnLocate + virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + const ::std::vector<sal_Int32>& getColumnMapping() { return m_aColMapping; } + + void setCatalogsMap(); + void setSchemasMap(); + void setColumnPrivilegesMap(); + void setColumnsMap(); + void setTablesMap(); + void setProcedureColumnsMap(); + void setProceduresMap(); + void setExportedKeysMap(); + void setImportedKeysMap(); + void setPrimaryKeysMap(); + void setIndexInfoMap(); + void setTablePrivilegesMap(); + void setCrossReferenceMap(); + void setTypeInfoMap(); + }; + // ------------------------------------------------------------------------- + inline sal_Int32 ODatabaseMetaDataResultSet::mapColumn (sal_Int32 column) + { + sal_Int32 map = column; + + if (m_aColMapping.size()) + { + // Validate column number + map = m_aColMapping[column]; + } + + return map; + } + } + +} +#endif // _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSET_HXX_ + diff --git a/connectivity/source/inc/ado/ADatabaseMetaDataResultSetMetaData.hxx b/connectivity/source/inc/ado/ADatabaseMetaDataResultSetMetaData.hxx new file mode 100644 index 000000000000..628ddbff1e29 --- /dev/null +++ b/connectivity/source/inc/ado/ADatabaseMetaDataResultSetMetaData.hxx @@ -0,0 +1,159 @@ +/************************************************************************* + * + * $RCSfile: ADatabaseMetaDataResultSetMetaData.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ADATABASEMETADATARESULTSETMETADATA_HXX_ +#define _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSETMETADATA_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _VECTOR_ +#include <vector> +#endif + +#ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_ +#include "ado/Awrapado.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSET_HXX_ +#include "ado/ADatabaseMetaDataResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_COLUMN_HXX_ +#include "OColumn.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + //************************************************************** + //************ Class: ResultSetMetaData + //************************************************************** + typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> ODatabaseMetaResultSetMetaData_BASE; + + class ODatabaseMetaDataResultSetMetaData : public ODatabaseMetaResultSetMetaData_BASE + { + friend class ODatabaseMetaDataResultSet; + + const ::std::vector<sal_Int32> &m_vMapping; // when not every column is needed + ::std::map<sal_Int32,connectivity::OColumn> m_mColumns; + ::std::map<sal_Int32,connectivity::OColumn>::const_iterator m_mColumnsIter; + + ADORecordset* m_pRecordSet; + sal_Int32 m_nColCount; + + sal_Int32 MapADOType2Jdbc(DataTypeEnum eType); + protected: + void setColumnPrivilegesMap(); + void setColumnsMap(); + void setTablesMap(); + void setProcedureColumnsMap(); + void setPrimaryKeysMap(); + void setIndexInfoMap(); + void setTablePrivilegesMap(); + void setCrossReferenceMap(); + void setTypeInfoMap(); + void setProceduresMap(); + public: + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + ODatabaseMetaDataResultSetMetaData( ADORecordset* _pRecordSet ,ODatabaseMetaDataResultSet* _pRes) + : m_pRecordSet(_pRecordSet),m_vMapping(_pRes->getColumnMapping()), + m_nColCount(m_vMapping.size()-1) + { + if(m_pRecordSet) + m_pRecordSet->AddRef(); + } +// ODatabaseMetaDataResultSetMetaData( ADORecordset* _pRecordSet,::std::vector<sal_Int32> _vMapping) +// : m_pRecordSet(_pRecordSet),m_vMapping(_vMapping){m_pRecordSet->AddRef();} + ~ODatabaseMetaDataResultSetMetaData(); + + /// Avoid ambigous cast error from the compiler. + inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw() + { return this; } + + virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ADO_ADATABASEMETARESULTSETMETADATA_HXX_ + diff --git a/connectivity/source/inc/ado/ADriver.hxx b/connectivity/source/inc/ado/ADriver.hxx new file mode 100644 index 000000000000..4b6470b6a8be --- /dev/null +++ b/connectivity/source/inc/ado/ADriver.hxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * $RCSfile: ADriver.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADRIVER_HXX_ +#define _CONNECTIVITY_ADO_ADRIVER_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_ +#include <com/sun/star/sdbc/XDriver.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _CPPUHELPER_COMPBASE3_HXX_ +#include <cppuhelper/compbase3.hxx> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ); + + typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver, + ::com::sun::star::sdbcx::XDataDefinitionSupplier, + ::com::sun::star::lang::XServiceInfo + > ODriver_BASE; + class ODriver : public ODriver_BASE + { + ::osl::Mutex m_aMutex; + + connectivity::OWeakRefArray m_xConnections; // vector containing a list + // of all the Connection objects + // for this Driver + + + public: + ODriver(); + ~ODriver(); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // XDriver + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); + + // XDataDefinitionSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } + +} +#endif //_CONNECTIVITY_ADO_ADRIVER_HXX_ + + diff --git a/connectivity/source/inc/ado/AGroup.hxx b/connectivity/source/inc/ado/AGroup.hxx new file mode 100644 index 000000000000..4d2355a879b3 --- /dev/null +++ b/connectivity/source/inc/ado/AGroup.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * $RCSfile: AGroup.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_GROUP_HXX_ +#define _CONNECTIVITY_ADABAS_GROUP_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_GROUP_HXX_ +#include "connectivity/sdbcx/VGroup.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif + +namespace connectivity +{ + namespace ado + { + typedef sdbcx::OGroup OGroup_ADO; + + class OAdoGroup : public OGroup_ADO + , public ::com::sun::star::lang::XUnoTunnel + { + WpADOGroup m_aGroup; + + sal_Int32 MapRight(RightsEnum _eNum); + RightsEnum Map2Right(sal_Int32 _eNum); + ObjectTypeEnum MapObjectType(sal_Int32 _ObjType); + protected: + virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue,sal_Int32 nHandle) const; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue)throw (::com::sun::star::uno::Exception); + + public: + virtual void refreshUsers(); + public: + DECLARE_CTY_DEFAULTS( OGroup_ADO); + + OAdoGroup(sal_Bool _bCase, ADOGroup* _pGroup=NULL); + OAdoGroup(sal_Bool _bCase, const ::rtl::OUString& _Name); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + // XAuthorizable + virtual sal_Int32 SAL_CALL getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + WpADOGroup getImpl() const { return m_aGroup; } + }; + } +} +#endif // _CONNECTIVITY_ADABAS_GROUP_HXX_ + diff --git a/connectivity/source/inc/ado/AGroups.hxx b/connectivity/source/inc/ado/AGroups.hxx new file mode 100644 index 000000000000..60ce4da82caa --- /dev/null +++ b/connectivity/source/inc/ado/AGroups.hxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * $RCSfile: AGroups.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_GROUPS_HXX_ +#define _CONNECTIVITY_ADO_GROUPS_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif + +namespace connectivity +{ + namespace sdbcx + { + class IRefreshableGroups; + } + namespace ado + { + class OAdabasConnection; + class OGroups : public sdbcx::OCollection + { + ADOGroups* m_pCollection; + protected: + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + OGroups(::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector, + ADOGroups* _pCollection,sal_Bool _bCase) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector) + ,m_pCollection(_pCollection) + { + if(m_pCollection) + m_pCollection->AddRef(); + } + + ~OGroups() + { + if(m_pCollection) + m_pCollection->Release(); + } + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // _CONNECTIVITY_ADO_GROUPS_HXX_ + diff --git a/connectivity/source/inc/ado/AIndex.hxx b/connectivity/source/inc/ado/AIndex.hxx new file mode 100644 index 000000000000..6096bfc50adf --- /dev/null +++ b/connectivity/source/inc/ado/AIndex.hxx @@ -0,0 +1,118 @@ +/************************************************************************* + * + * $RCSfile: AIndex.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_INDEX_HXX_ +#define _CONNECTIVITY_ADO_INDEX_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_INDEX_HXX_ +#include "connectivity/sdbcx/VIndex.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif + +namespace connectivity +{ + namespace ado + { + typedef sdbcx::OIndex OIndex_ADO; + + class OAdoIndex : public OIndex_ADO + ,public ::com::sun::star::lang::XUnoTunnel + { + WpADOIndex m_aIndex; + protected: + virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue,sal_Int32 nHandle) const; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue)throw (::com::sun::star::uno::Exception); + public: + virtual void refreshColumns(); + public: + DECLARE_CTY_DEFAULTS( OIndex_ADO); + + OAdoIndex(sal_Bool _bCase, ADOIndex* _pIndex=NULL); + OAdoIndex( const ::rtl::OUString& _Name, + const ::rtl::OUString& _Catalog, + sal_Bool _isUnique, + sal_Bool _isPrimaryKeyIndex, + sal_Bool _isClustered, + sal_Bool _bCase + ); + + // XInterface + ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + WpADOIndex getImpl() const { return m_aIndex;} + }; + } +} +#endif // _CONNECTIVITY_ADO_INDEX_HXX_ + diff --git a/connectivity/source/inc/ado/AIndexColumn.hxx b/connectivity/source/inc/ado/AIndexColumn.hxx new file mode 100644 index 000000000000..0defab959696 --- /dev/null +++ b/connectivity/source/inc/ado/AIndexColumn.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * $RCSfile: AIndexColumn.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ADABAS_INDEXCOLUMN_HXX_ +#define _CONNECTIVITY_ADABAS_INDEXCOLUMN_HXX_ + +#ifndef _CONNECTIVITY_ADO_COLUMN_HXX_ +#include "ado/AColumn.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + class OIndexColumn : public OAdoColumn + { + protected: + sal_Bool m_IsAscending; + public: + OIndexColumn(); + OIndexColumn( sal_Bool _IsAscending, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _TypeName, + const ::rtl::OUString& _DefaultValue, + sal_Int32 _IsNullable, + sal_Int32 _Precision, + sal_Int32 _Scale, + sal_Int32 _Type, + sal_Bool _IsAutoIncrement); + + virtual void construct(); + }; + } +} +#endif // _CONNECTIVITY_ADABAS_INDEXCOLUMN_HXX_ + diff --git a/connectivity/source/inc/ado/AIndexColumns.hxx b/connectivity/source/inc/ado/AIndexColumns.hxx new file mode 100644 index 000000000000..09d2e95e99b9 --- /dev/null +++ b/connectivity/source/inc/ado/AIndexColumns.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * $RCSfile: AIndexColumns.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ADABAS_INDEXCOLUMNS_HXX_ +#define _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_ + +#ifndef _CONNECTIVITY_ADABAS_COLUMNS_HXX_ +#include "adabas/BColumns.hxx" +#endif + +namespace connectivity +{ + namespace adabas + { + class OIndexColumns : public OColumns + { + protected: + virtual ::com::sun::star::uno::Reference< starcontainer::XNamed > createObject(const ::rtl::OUString& _rName); + virtual ::com::sun::star::uno::Reference< starbeans::XPropertySet > createEmptyObject(); + public: + OIndexColumns( ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector, + OTable* _pTable, + connectivity::sdbcx::IRefreshableColumns* _pParent) + : OColumns(_rParent,_rMutex,_rVector,_pTable,_pParent) + { + } + }; + } +} +#endif // _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_ + diff --git a/connectivity/source/inc/ado/AIndexes.hxx b/connectivity/source/inc/ado/AIndexes.hxx new file mode 100644 index 000000000000..68dac8792a6f --- /dev/null +++ b/connectivity/source/inc/ado/AIndexes.hxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * $RCSfile: AIndexes.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_INDEXES_HXX_ +#define _CONNECTIVITY_ADO_INDEXES_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + class OIndexes : public sdbcx::OCollection + { + ADOIndexes* m_pCollection; + protected: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + OIndexes(::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector, + ADOIndexes* _pCollection,sal_Bool _bCase) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector) + ,m_pCollection(_pCollection) + { + if(m_pCollection) + m_pCollection->AddRef(); + } + + ~OIndexes() + { + if(m_pCollection) + m_pCollection->Release(); + } + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // _CONNECTIVITY_ADO_INDEXES_HXX_ + diff --git a/connectivity/source/inc/ado/AKey.hxx b/connectivity/source/inc/ado/AKey.hxx new file mode 100644 index 000000000000..44317bec3adb --- /dev/null +++ b/connectivity/source/inc/ado/AKey.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * $RCSfile: AKey.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_KEY_HXX_ +#define _CONNECTIVITY_ADO_KEY_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_KEY_HXX_ +#include "connectivity/sdbcx/VKey.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif + +namespace connectivity +{ + namespace ado + { + typedef sdbcx::OKey OKey_ADO; + + class OAdoKey : public OKey_ADO + ,public ::com::sun::star::lang::XUnoTunnel + { + WpADOKey m_aKey; + protected: + virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue,sal_Int32 nHandle) const; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue)throw (::com::sun::star::uno::Exception); + public: + virtual void refreshColumns(); + public: + DECLARE_CTY_DEFAULTS( OKey_ADO); + + OAdoKey(sal_Bool _bCase, ADOKey* _pKey=NULL); + OAdoKey( const ::rtl::OUString& _Name, + const ::rtl::OUString& _ReferencedTable, + sal_Int32 _Type, + sal_Int32 _UpdateRule, + sal_Int32 _DeleteRule, + sal_Bool _bCase + ); + + // XInterface + ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + WpADOKey getImpl() const { return m_aKey;} + RuleEnum Map2Rule(const sal_Int32& _eNum) const; + sal_Int32 MapRule(const RuleEnum& _eNum) const; + }; + } +} +#endif // _CONNECTIVITY_ADO_KEY_HXX_ + diff --git a/connectivity/source/inc/ado/AKeyColumn.hxx b/connectivity/source/inc/ado/AKeyColumn.hxx new file mode 100644 index 000000000000..f883d1035116 --- /dev/null +++ b/connectivity/source/inc/ado/AKeyColumn.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * $RCSfile: AKeyColumn.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ADABAS_KEYCOLUMN_HXX_ +#define _CONNECTIVITY_ADABAS_KEYCOLUMN_HXX_ + +#ifndef _CONNECTIVITY_ADO_COLUMN_HXX_ +#include "ado/AColumn.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + class OKeyColumn : public OAdoColumn + { + protected: + ::rtl::OUString m_ReferencedColumn; + public: + OKeyColumn(); + OKeyColumn( const ::rtl::OUString& _ReferencedColumn, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _TypeName, + const ::rtl::OUString& _DefaultValue, + sal_Int32 _IsNullable, + sal_Int32 _Precision, + sal_Int32 _Scale, + sal_Int32 _Type, + sal_Bool _IsAutoIncrement); + + virtual void construct(); + }; + } +} +#endif // _CONNECTIVITY_ADABAS_KEYCOLUMN_HXX_ + diff --git a/connectivity/source/inc/ado/AKeyColumns.hxx b/connectivity/source/inc/ado/AKeyColumns.hxx new file mode 100644 index 000000000000..85b322c28c12 --- /dev/null +++ b/connectivity/source/inc/ado/AKeyColumns.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * $RCSfile: AKeyColumns.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_ADABAS_KEYCOLUMNS_HXX_ +#define _CONNECTIVITY_ADABAS_KEYCOLUMNS_HXX_ + +#ifndef _CONNECTIVITY_ADABAS_COLUMNS_HXX_ +#include "adabas/BColumns.hxx" +#endif + +namespace connectivity +{ + namespace adabas + { + class OKeyColumns : public OColumns + { + protected: + virtual ::com::sun::star::uno::Reference< starcontainer::XNamed > createObject(const ::rtl::OUString& _rName); + virtual ::com::sun::star::uno::Reference< starbeans::XPropertySet > createEmptyObject(); + public: + OKeyColumns( ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector, + OTable* _pTable, + connectivity::sdbcx::IRefreshableColumns* _pParent) + : OColumns(_rParent,_rMutex,_rVector,_pTable,_pParent) + { + } + }; + } +} +#endif // _CONNECTIVITY_ADABAS_KEYCOLUMNS_HXX_ + diff --git a/connectivity/source/inc/ado/AKeys.hxx b/connectivity/source/inc/ado/AKeys.hxx new file mode 100644 index 000000000000..d3e945bedd06 --- /dev/null +++ b/connectivity/source/inc/ado/AKeys.hxx @@ -0,0 +1,111 @@ +/************************************************************************* + * + * $RCSfile: AKeys.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_KEYS_HXX_ +#define _CONNECTIVITY_ADO_KEYS_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + class OKeys : public sdbcx::OCollection + { + ADOKeys* m_pCollection; + + protected: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + OKeys(::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector, + ADOKeys* _pCollection,sal_Bool _bCase) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector) + ,m_pCollection(_pCollection) + { + if(m_pCollection) + m_pCollection->AddRef(); + } + + ~OKeys() + { + if(m_pCollection) + m_pCollection->Release(); + } + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // _CONNECTIVITY_ADO_KEYS_HXX_ + diff --git a/connectivity/source/inc/ado/APreparedStatement.hxx b/connectivity/source/inc/ado/APreparedStatement.hxx new file mode 100644 index 000000000000..94794aefc06e --- /dev/null +++ b/connectivity/source/inc/ado/APreparedStatement.hxx @@ -0,0 +1,169 @@ +/************************************************************************* + * + * $RCSfile: APreparedStatement.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_APREPAREDSTATEMENT_HXX_ +#define _CONNECTIVITY_ADO_APREPAREDSTATEMENT_HXX_ + + +#ifndef _CONNECTIVITY_ADO_ASTATEMENT_HXX_ +#include "ado/AStatement.hxx" +#endif + +#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_ +#include <com/sun/star/sdbc/XPreparedStatement.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_ +#include <com/sun/star/sdbc/XParameters.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +// #include <com/sun/star/sdbc/XClearParameters.hpp> +#ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HPP_ +#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ +#include <com/sun/star/io/XInputStream.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +namespace connectivity +{ + namespace ado + { + + class OPreparedStatement : public OStatement_Base, + public ::com::sun::star::sdbc::XPreparedStatement, + public ::com::sun::star::sdbc::XParameters, + public ::com::sun::star::sdbc::XPreparedBatchExecution, + public ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + public ::com::sun::star::lang::XServiceInfo + + { + void setParameter(sal_Int32 parameterIndex, const DataTypeEnum& _eType,const sal_Int32& _nSize,const OLEVariant& _Val) + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + protected: + //==================================================================== + // Data attributes + //==================================================================== + + int numParams; // Number of parameter markers + // for the prepared statement + + ::std::vector<OTypeInfo> m_aTypeInfo; + ADOParameters* m_pParameters; + + public: + DECLARE_CTY_DEFAULTS(OStatement_Base); + DECLARE_SERVICE_INFO(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OPreparedStatement( OConnection* _pConnection,const ::std::vector<OTypeInfo>& _TypeInfo,const ::rtl::OUString& sql); + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XPreparedStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XParameters + virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XPreparedBatchExecution + virtual void SAL_CALL addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // OComponentHelper + virtual void SAL_CALL disposing(void); + }; + } +} +#endif // _CONNECTIVITY_ADO_APREPAREDSTATEMENT_HXX_ + diff --git a/connectivity/source/inc/ado/AResultSet.hxx b/connectivity/source/inc/ado/AResultSet.hxx new file mode 100644 index 000000000000..6999759b1a06 --- /dev/null +++ b/connectivity/source/inc/ado/AResultSet.hxx @@ -0,0 +1,296 @@ +/************************************************************************* + * + * $RCSfile: AResultSet.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ARESULTSET_HXX_ +#define _CONNECTIVITY_ADO_ARESULTSET_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_ +#include <com/sun/star/sdbc/XCloseable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_ +#include <com/sun/star/sdbc/XColumnLocate.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ +#include <com/sun/star/util/XCancellable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_ +#include <com/sun/star/sdbcx/XRowLocate.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDELETEROWS_HPP_ +#include <com/sun/star/sdbcx/XDeleteRows.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_ +#include <com/sun/star/sdbc/XRowUpdate.hpp> +#endif +#ifndef _CPPUHELPER_COMPBASE12_HXX_ +#include <cppuhelper/compbase12.hxx> +#endif +#ifndef _UNOTOOLS_PROPERTY_ARRAY_HELPER_HXX_ +#include <unotools/proparrhlp.hxx> +#endif +#ifndef _CONNECTIVITY_ADO_ASTATEMENT_HXX_ +#include "ado/AStatement.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +namespace connectivity +{ + namespace ado + { + class OResultSetMetaData; + /* + ** java_sql_ResultSet + */ + typedef ::cppu::WeakComponentImplHelper12< ::com::sun::star::sdbc::XResultSet, + ::com::sun::star::sdbc::XRow, + ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + ::com::sun::star::util::XCancellable, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::sdbc::XResultSetUpdate, + ::com::sun::star::sdbc::XRowUpdate, + ::com::sun::star::sdbc::XCloseable, + ::com::sun::star::sdbc::XColumnLocate, + ::com::sun::star::sdbcx::XRowLocate, + ::com::sun::star::sdbcx::XDeleteRows, + ::com::sun::star::lang::XServiceInfo> OResultSet_BASE; + + class OResultSet : public OBaseMutex, + public OResultSet_BASE, + public ::cppu::OPropertySetHelper, + public ::utl::OPropertyArrayUsageHelper<OResultSet> + { + + ADORecordset* m_pRecordSet; + OStatement_Base* m_pStmt; + ::com::sun::star::uno::WeakReferenceHelper m_aStatement; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; + ::std::vector<OLEVariant> m_aBookmarks; + OLEVariant m_aValue; + sal_Int32 m_nRowPos; + sal_Bool m_bWasNull; + sal_Bool m_bEOF; + sal_Bool m_bOnFirstAfterOpen; + + sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + protected: + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + virtual sal_Bool SAL_CALL convertFastPropertyValue( + ::com::sun::star::uno::Any & rConvertedValue, + ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle + ) const; + public: + DECLARE_CTY_DEFAULTS(OResultSet_BASE); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OResultSet( ADORecordset* _pRecordSet,OStatement_Base* pStmt); + OResultSet( ADORecordset* _pRecordSet); + ~OResultSet(); + + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) + { + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); + } + // XResultSet + virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetUpdate + virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRowUpdate + virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XColumnLocate + virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRowLocate + virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XDeleteRows + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + }; + } + +} +#endif // _CONNECTIVITY_ADO_ARESULTSET_HXX_ + + diff --git a/connectivity/source/inc/ado/AResultSetMetaData.hxx b/connectivity/source/inc/ado/AResultSetMetaData.hxx new file mode 100644 index 000000000000..cdd1d9d00be4 --- /dev/null +++ b/connectivity/source/inc/ado/AResultSetMetaData.hxx @@ -0,0 +1,140 @@ +/************************************************************************* + * + * $RCSfile: AResultSetMetaData.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ARESULTSETMETADATA_HXX_ +#define _CONNECTIVITY_ADO_ARESULTSETMETADATA_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _VECTOR_ +#include <vector> +#endif + +#ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_ +#include "ado/Awrapado.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ARESULTSET_HXX_ +#include "ado/AResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_COLUMN_HXX_ +#include "OColumn.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + + //************************************************************** + //************ Class: ResultSetMetaData + //************************************************************** + typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE; + + class OResultSetMetaData : public OResultSetMetaData_BASE + { + friend class OResultSet; + + ADORecordset* m_pRecordSet; + sal_Int32 m_nColCount; + + sal_Int32 MapADOType2Jdbc(DataTypeEnum eType); + public: + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OResultSetMetaData( ADORecordset* _pRecordSet) + : m_pRecordSet(_pRecordSet), + m_nColCount(-1){m_pRecordSet->AddRef();} + ~OResultSetMetaData(); +#if SUPD < 570 + /// Avoid ambigous cast error from the compiler. + inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw() + { return this; } +#endif + + virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ADO_ARESULTSETMETADATA_HXX_ + diff --git a/connectivity/source/inc/ado/AStatement.hxx b/connectivity/source/inc/ado/AStatement.hxx new file mode 100644 index 000000000000..9e1843acc491 --- /dev/null +++ b/connectivity/source/inc/ado/AStatement.hxx @@ -0,0 +1,262 @@ +/************************************************************************* + * + * $RCSfile: AStatement.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ASTATEMENT_HXX_ +#define _CONNECTIVITY_ADO_ASTATEMENT_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_ +#include <com/sun/star/sdbc/XStatement.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XMULTIPLERESULTS_HPP_ +#include <com/sun/star/sdbc/XMultipleResults.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XBATCHEXECUTION_HPP_ +#include <com/sun/star/sdbc/XBatchExecution.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_ +#include <com/sun/star/sdbc/XCloseable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ +#include <com/sun/star/sdbc/SQLWarning.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ +#include <com/sun/star/util/XCancellable.hpp> +#endif +#ifndef _CPPUHELPER_COMPBASE5_HXX_ +#include <cppuhelper/compbase5.hxx> +#endif +#ifndef _UNOTOOLS_PROPERTY_ARRAY_HELPER_HXX_ +#include <unotools/proparrhlp.hxx> +#endif +#ifndef _UTL_UNO3_HXX_ +#include <unotools/uno3.hxx> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ACONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif +#ifndef _LIST_ +#include <list> +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_ +#include "ado/Awrapado.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +namespace connectivity +{ + namespace ado + { + typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::util::XCancellable, + ::com::sun::star::sdbc::XCloseable, + ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE; + + //************************************************************** + //************ Class: java.sql.Statement + //************************************************************** + class OStatement_Base : public OBaseMutex, + public OStatement_BASE, + public ::cppu::OPropertySetHelper, + public ::utl::OPropertyArrayUsageHelper<OStatement_Base>, + public connectivity::OSubComponent< OStatement_Base> + + { + friend class connectivity::OSubComponent< OStatement_Base>; + friend class OResultSet; + + ::com::sun::star::sdbc::SQLWarning m_aLastWarning; + + protected: + ::std::list< ::rtl::OUString> m_aBatchList; + + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created + // for this Statement + + OConnection* m_pConnection;// The owning Connection object + WpADOCommand m_Command; + WpADORecordset m_RecordSet; + OLEVariant m_RecordsAffected; + OLEVariant m_Parameters; + ::std::vector<connectivity::OTypeInfo> m_aTypeInfo; // Hashtable containing an entry + // for each row returned by + // DatabaseMetaData.getTypeInfo. + sal_Int32 m_nMaxRows; + sal_Int32 m_nFetchSize; + LockTypeEnum m_eLockType; + CursorTypeEnum m_eCursorType; + + using OStatement_BASE::rBHelper; + private: + + sal_Int32 getQueryTimeOut() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getMaxFieldSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getMaxRows() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + void setQueryTimeOut(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setMaxFieldSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setMaxRows(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setResultSetConcurrency(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setResultSetType(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setCursorName(const ::rtl::OUString &_par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + protected: + + void reset () throw( ::com::sun::star::sdbc::SQLException); + void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException); + void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException); + sal_Int32 getColumnCount () throw( ::com::sun::star::sdbc::SQLException); + sal_Int32 getRowCount () throw( ::com::sun::star::sdbc::SQLException); + sal_Int32 getPrecision ( sal_Int32 sqlType); + + void disposeResultSet(); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + virtual sal_Bool SAL_CALL convertFastPropertyValue( + ::com::sun::star::uno::Any & rConvertedValue, + ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle + ) const; + public: + DECLARE_CTY_ACQUIRE(OStatement_BASE); + OStatement_Base(OConnection* _pConnection ); + + using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) + { + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); + } + // XStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XMultipleResults + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + + class OStatement : public OStatement_Base, + public ::com::sun::star::sdbc::XBatchExecution, + public ::com::sun::star::lang::XServiceInfo + { + public: + DECLARE_CTY_DEFAULTS(OStatement_Base); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OStatement( OConnection* _pConnection) : OStatement_Base( _pConnection){}; + ~OStatement(); + + DECLARE_SERVICE_INFO(); + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + // XBatchExecution + virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ADO_ASTATEMENT_HXX_ + diff --git a/connectivity/source/inc/ado/ATable.hxx b/connectivity/source/inc/ado/ATable.hxx new file mode 100644 index 000000000000..97083aaeb5c8 --- /dev/null +++ b/connectivity/source/inc/ado/ATable.hxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * $RCSfile: ATable.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_TABLE_HXX_ +#define _CONNECTIVITY_ADO_TABLE_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_TABLE_HXX_ +#include "connectivity/sdbcx/VTable.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + typedef connectivity::sdbcx::OTable OTable_TYPEDEF; + + class OAdoTable : public OTable_TYPEDEF, + public ::com::sun::star::lang::XUnoTunnel + { + WpADOTable m_aTable; + + protected: + virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue,sal_Int32 nHandle) const; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue)throw (::com::sun::star::uno::Exception); + + public: + virtual void refreshColumns(); + virtual void refreshKeys(); + virtual void refreshIndexes(); + + public: + DECLARE_CTY_DEFAULTS( OTable_TYPEDEF); + OAdoTable(sal_Bool _bCase, _ADOTable* _pTable=NULL); + OAdoTable(sal_Bool _bCase, const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description = ::rtl::OUString(), + const ::rtl::OUString& _SchemaName = ::rtl::OUString(), + const ::rtl::OUString& _CatalogName = ::rtl::OUString()); + + // XINterface + ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + const ::rtl::OUString& getName() const { return m_Name; } + const ::rtl::OUString& getSchema() const { return m_SchemaName; } + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + // XRename + virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + + // XAlterTable + virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& colName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + // + sal_Bool create() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + WpADOTable getImpl() const { return m_aTable;} + }; + } +} +#endif // _CONNECTIVITY_ADO_TABLE_HXX_ + diff --git a/connectivity/source/inc/ado/ATables.hxx b/connectivity/source/inc/ado/ATables.hxx new file mode 100644 index 000000000000..c98831cf8a6e --- /dev/null +++ b/connectivity/source/inc/ado/ATables.hxx @@ -0,0 +1,108 @@ +/************************************************************************* + * + * $RCSfile: ATables.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_TABLES_HXX_ +#define _CONNECTIVITY_ADO_TABLES_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + class OTables : public sdbcx::OCollection + { + ADOTables* m_pCollection; + protected: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + void setComments(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + public: + OTables(::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector, + ADOTables* _pCollection,sal_Bool _bCase) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector) + ,m_pCollection(_pCollection) + { + if(m_pCollection) + m_pCollection->AddRef(); + } + + ~OTables() + { + if(m_pCollection) + m_pCollection->Release(); + } + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ADO_TABLES_HXX_ + diff --git a/connectivity/source/inc/ado/AUser.hxx b/connectivity/source/inc/ado/AUser.hxx new file mode 100644 index 000000000000..a7100a26639a --- /dev/null +++ b/connectivity/source/inc/ado/AUser.hxx @@ -0,0 +1,134 @@ +/************************************************************************* + * + * $RCSfile: AUser.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_USER_HXX_ +#define _CONNECTIVITY_ADO_USER_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_USER_HXX_ +#include "connectivity/sdbcx/VUser.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif + +namespace connectivity +{ + namespace ado + { + typedef connectivity::sdbcx::OUser OUser_TYPEDEF; + + class OAdoUser : public OUser_TYPEDEF + , public ::com::sun::star::lang::XUnoTunnel + { + protected: + WpADOUser m_aUser; + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle + ) const; + public: + virtual void refreshGroups(); + public: + DECLARE_CTY_DEFAULTS( OUser_TYPEDEF); + OAdoUser(sal_Bool _bCase, ADOUser* _pUser=NULL); + OAdoUser(sal_Bool _bCase, const ::rtl::OUString& _Name); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + WpADOUser getImpl() const { return m_aUser;} + }; + + class OUserExtend; + typedef ::utl::OPropertyArrayUsageHelper<OUserExtend> OUserExtend_PROP; + + class OUserExtend : public OAdoUser, + public OUserExtend_PROP + { + protected: + ::rtl::OUString m_Password; + DECLARE_CTY_PROPERTY(OAdoUser,OUserExtend) + + public: + OUserExtend(sal_Bool _bCase,ADOUser* _pUser=NULL); + OUserExtend(sal_Bool _bCase,const ::rtl::OUString& _Name); + + virtual void construct(); + ::rtl::OUString getPassword() const { return m_Password;} + }; + } +} +#endif // _CONNECTIVITY_ADO_USER_HXX_ + diff --git a/connectivity/source/inc/ado/AUsers.hxx b/connectivity/source/inc/ado/AUsers.hxx new file mode 100644 index 000000000000..d25a7f5c0e69 --- /dev/null +++ b/connectivity/source/inc/ado/AUsers.hxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * $RCSfile: AUsers.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_USERS_HXX_ +#define _CONNECTIVITY_ADO_USERS_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif + +namespace connectivity +{ + namespace sdbcx + { + class IRefreshableUsers; + } + namespace ado + { + + class OUsers : public sdbcx::OCollection + { + ADOUsers* m_pCollection; + public: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + public: + OUsers( ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector, + ADOUsers* _pCollection,sal_Bool _bCase) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector) + ,m_pCollection(_pCollection) + { + if(m_pCollection) + m_pCollection->AddRef(); + } + + ~OUsers() + { + if(m_pCollection) + m_pCollection->Release(); + } + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // _CONNECTIVITY_ADO_USERS_HXX_ + diff --git a/connectivity/source/inc/ado/AView.hxx b/connectivity/source/inc/ado/AView.hxx new file mode 100644 index 000000000000..acb55bf9fb31 --- /dev/null +++ b/connectivity/source/inc/ado/AView.hxx @@ -0,0 +1,122 @@ +/************************************************************************* + * + * $RCSfile: AView.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_VIEW_HXX_ +#define _CONNECTIVITY_ADO_VIEW_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_VIEW_HXX_ +#include "connectivity/sdbcx/VView.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + + typedef sdbcx::OView OView_ADO; + + class OAdoView : public OView_ADO + ,public ::com::sun::star::lang::XUnoTunnel + { + WpADOView m_aView; + + protected: + // OPropertySetHelper + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle + ) const; + public: + DECLARE_CTY_DEFAULTS( OView_ADO); + + OAdoView(sal_Bool _bCase, ADOView* _pView=NULL); + OAdoView(sal_Bool _bCase, const ::rtl::OUString& _rName, + sal_Int32 _nCheckOption = 0, + const ::rtl::OUString& _rCommand = ::rtl::OUString(), + const ::rtl::OUString& _rSchemaName = ::rtl::OUString(), + const ::rtl::OUString& _rCatalogName = ::rtl::OUString()); + + // XInterface + ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + WpADOView getImpl() const { return m_aView;} + }; + } +} + +#endif // _CONNECTIVITY_ADO_VIEW_HXX_ + diff --git a/connectivity/source/inc/ado/AViews.hxx b/connectivity/source/inc/ado/AViews.hxx new file mode 100644 index 000000000000..dfc254e0e8b4 --- /dev/null +++ b/connectivity/source/inc/ado/AViews.hxx @@ -0,0 +1,110 @@ +/************************************************************************* + * + * $RCSfile: AViews.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_VIEWS_HXX_ +#define _CONNECTIVITY_ADO_VIEWS_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + + class OViews : public sdbcx::OCollection + { + ADOViews* m_pCollection; + protected: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + void setComments(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + public: + OViews(::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector, + ADOViews* _pCollection,sal_Bool _bCase) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector) + ,m_pCollection(_pCollection) + { + if(m_pCollection) + m_pCollection->AddRef(); + } + + ~OViews() + { + if(m_pCollection) + m_pCollection->Release(); + } + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ADO_VIEWS_HXX_ + diff --git a/connectivity/source/inc/ado/Aolevariant.hxx b/connectivity/source/inc/ado/Aolevariant.hxx new file mode 100644 index 000000000000..fe76c63af935 --- /dev/null +++ b/connectivity/source/inc/ado/Aolevariant.hxx @@ -0,0 +1,373 @@ +/************************************************************************* + * + * $RCSfile: Aolevariant.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_AOLEVARIANT_HXX_ +#define _CONNECTIVITY_ADO_AOLEVARIANT_HXX_ + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _OSL_TYPES_H_ +#include <osl/types.h> +#endif +#ifndef _CONNECTIVITY_DATECONVERSION_HXX_ +#include "DateConversion.hxx" +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif + +namespace connectivity +{ + namespace ado + { + + class OLEVariant : public ::tagVARIANT + { + public: + OLEVariant() { VariantInit(this);} + OLEVariant(const VARIANT& varSrc) + { + ::VariantInit(this); + ::VariantCopy(this, const_cast<VARIANT*>(&varSrc)); + } + OLEVariant(const OLEVariant& varSrc) { VariantInit(this); + VariantCopy(this, const_cast<VARIANT*>(static_cast<const VARIANT*>(&varSrc)));} + OLEVariant(sal_Int32 n) { VariantInit(this); vt = VT_I4; lVal = n;} + OLEVariant(const rtl::OUString& us) { VariantInit(this); vt = VT_BSTR; bstrVal = SysAllocString(us);} + ~OLEVariant() { VariantClear(this); } // clears all the memory that was allocated before + + OLEVariant(const ::com::sun::star::util::Date& x ) + { + VariantInit(this); vt = VT_R8; + dblVal = DateConversion::toDouble(x); + } + OLEVariant(const ::com::sun::star::util::Time& x ) + { + VariantInit(this); vt = VT_R8; + dblVal = DateConversion::toDouble(x); + } + OLEVariant(const ::com::sun::star::util::DateTime& x ) + { + VariantInit(this); vt = VT_R8; + dblVal = DateConversion::toDouble(x); + } + OLEVariant(IDispatch* pDispInterface) + { VariantInit(this); vt = VT_DISPATCH; pdispVal = pDispInterface;} + + OLEVariant(const ::com::sun::star::uno::Sequence< sal_Int8 >& x) + { + VariantInit(this); vt = VT_ARRAY|VT_UI1; + parray = SafeArrayCreateVector(VT_UI1, 0, x.getLength()); + const sal_Int8* pBegin = x.getConstArray(); + const sal_Int8* pEnd = pBegin + x.getLength(); + for(sal_Int32 i=0;pBegin != pEnd;++i,++pBegin) + SafeArrayPutElement(parray,&i,&pBegin); + + } + + OLEVariant& operator=(const OLEVariant& varSrc) + { + VariantCopy(this, const_cast<VARIANT*>(static_cast<const VARIANT*>(&varSrc))); + return *this; + } + // Assign a const VARIANT& (::VariantCopy handles everything) + // + inline OLEVariant& operator=(const tagVARIANT& varSrc) + { + ::VariantCopy(this, const_cast<VARIANT*>(&varSrc)); + + return *this; + } + + // Assign a const VARIANT* (::VariantCopy handles everything) + // + inline OLEVariant& operator=(const VARIANT* pSrc) + { + ::VariantCopy(this, const_cast<VARIANT*>(pSrc)); + + return *this; + } + + void setByte(sal_uInt8 n) { VariantClear(this); vt = VT_UI1; bVal = n;} + void setInt16(sal_Int16 n) { VariantClear(this); vt = VT_I2; iVal = n;} + void setInt32(sal_Int32 n) { VariantClear(this); vt = VT_I4; lVal = n;} + void setFloat(float f) { VariantClear(this); vt = VT_R4; fltVal = f;} + void setDouble(double d) { VariantClear(this); vt = VT_R8; dblVal = d;} + void setDate(DATE d) { VariantClear(this); vt = VT_DATE; date = d;} + void setChar(unsigned char a) { VariantClear(this); vt = VT_UI1; bVal = a;} + void setCurrency(double aCur) { VariantClear(this); vt = VT_CY; set(aCur*10000);} + void setBool(sal_Bool b) { VariantClear(this); vt = VT_BOOL; boolVal = b ? -1:0;} + void setString(const rtl::OUString& us){ VariantClear(this); vt = VT_BSTR; bstrVal = SysAllocString(us);} + void setNoArg() { VariantClear(this); vt = VT_ERROR; scode = DISP_E_PARAMNOTFOUND;} + + void setIDispatch(IDispatch* pDispInterface) + { VariantClear(this); vt = VT_DISPATCH; pdispVal = pDispInterface;} + + void setNull() { VariantClear(this); vt = VT_NULL;} + void setEmpty() { VariantClear(this); vt = VT_EMPTY;} + + void setUI1SAFEARRAYPtr(SAFEARRAY* pSafeAr) + { VariantClear(this); vt = VT_ARRAY|VT_UI1; parray = pSafeAr; } + + inline void setArray(SAFEARRAY* pSafeArray, VARTYPE vtType) + { VariantClear(this); vt = VT_ARRAY|vtType; parray = pSafeArray; } + + sal_Bool isNull() const { return (vt == VT_NULL); } + sal_Bool isEmpty() const { return (vt == VT_EMPTY); } + + VARTYPE getType() const { return vt; } + + operator rtl::OUString() + { + if(vt == VT_NULL) + return rtl::OUString(); + if (vt != VT_BSTR) VariantChangeType(this, this, NULL, VT_BSTR); + return rtl::OUString((sal_Unicode*)bstrVal); + } + + rtl::OUString getString() + { + return (rtl::OUString)*this; + } + operator sal_Bool() { return getBool(); } + operator sal_Int32() { return getInt32(); } + operator sal_Int16() { return getInt16(); } + operator sal_Int8() { return getInt8(); } + operator float() { return getFloat(); } + operator double() { return getDouble(); } + operator ::com::sun::star::util::Date() + { + return connectivity::DateConversion::toDate(date,::com::sun::star::util::Date(30,12,1899)); + } + operator ::com::sun::star::util::Time() + { + return connectivity::DateConversion::toTime(date); + } + operator ::com::sun::star::util::DateTime() + { + return connectivity::DateConversion::toDateTime(date,::com::sun::star::util::Date(30,12,1899)); + } + + sal_Bool getBool() + { + if (vt != VT_BOOL) VariantChangeType(this, this, NULL, VT_BOOL); + return boolVal ? sal_True : sal_False; + }; + + IUnknown* getIUnknown() + { + if (vt != VT_UNKNOWN) VariantChangeType(this, this, NULL, VT_UNKNOWN); + return (IUnknown*) punkVal; + + } + + IDispatch* getIDispatch() + { + if (vt != VT_DISPATCH) VariantChangeType(this,this, NULL, VT_DISPATCH); + return (IDispatch*) pdispVal; + + } + + + sal_uInt8 getByte() + { + if (vt != VT_UI1) VariantChangeType(this, this, NULL, VT_UI1); + return (sal_uInt8) bVal; + } + + sal_Int16 getInt16() + { + if (vt != VT_I2) VariantChangeType(this, this, NULL, VT_I2); + return (sal_Int16) iVal; + } + + sal_Int8 getInt8() + { + if (vt != VT_UI1) VariantChangeType(this, this, NULL, VT_UI1); + return (sal_Int8) iVal; + } + + sal_Int32 getInt32() + { + if (vt != VT_I4) VariantChangeType(this, this, NULL, VT_I4); + return (sal_Int32) lVal; + } + + sal_Int32 getUInt32() + { + if (vt != VT_UI4) VariantChangeType(this, this, NULL, VT_UI4); + return (sal_uInt32) lVal; + } + + float getFloat() + { + if (vt != VT_R4) VariantChangeType(this, this, NULL, VT_R4); + return (float) fltVal; + } + + double getDouble() + { + if (vt != VT_R8) VariantChangeType(this, this, NULL, VT_R8); + return (double) dblVal; + } + + double getDate() + { + if (vt != VT_DATE) VariantChangeType(this, this, NULL, VT_DATE); + return (double) date; + } + + double getCurrency() + { + if (vt != VT_CY) VariantChangeType(this, this, NULL, VT_CY); + double toRet = ((double)cyVal.Hi*(double)4294967296.0 + (double)cyVal.Lo) / 10000; + return toRet; + } + + SAFEARRAY* getUI1SAFEARRAYPtr() + { + if (vt != (VT_ARRAY|VT_UI1)) + VariantChangeType(this,this, NULL, VT_ARRAY|VT_UI1); + return (parray); + } + + // static methods + + // ACHTUNG! Der zurueckgegebene UnicodeString mu vom + // Rufer mit delete[] freigegeben werden!!!! + inline static OLECHAR* UniCodeFromC(const char* pText) + { + + int nLength = strlen(pText)+1; + OLECHAR* aReturnString = new OLECHAR[nLength]; + + MultiByteToWideChar(CP_ACP, //ANSI Code Page + MB_PRECOMPOSED, + pText, + nLength, + (OLECHAR*) aReturnString, + nLength); + + return aReturnString; + + } + + // Der zurueckgegebene BSTR muss noch mit + // SysFreeString() wieder freigegeben werden! + // inline static BSTR BSTRFromC(const char* pText) + // { + // OLECHAR* pUniString = UniCodeFromC(pText); + // BSTR aBSTR = SysAllocString(pUniString); + // delete[] pUniString; + // return aBSTR; + // } + + inline static VARIANT_BOOL VariantBool(sal_Bool bEinBoolean) + { + return (VARIANT_BOOL) (bEinBoolean? -1:0); + } + + // static String StringFromBSTR(BSTR& aBSTR) + // { + // sal_uInt16 nLength = SysStringLen(aBSTR); + // String sRetString; + // char* pBuf = sRetString.AllocStrBuf(nLength); + // + // WideCharToMultiByte(CP_ACP, //ANSI Code Page + // WC_COMPOSITECHECK, + // aBSTR, + // nLength, + // pBuf, + // nLength, + // NULL, NULL); + // + // return sRetString; + // } + private: + void CHS() + { + cyVal.Lo ^= (sal_uInt32)-1; + cyVal.Hi ^= -1; + cyVal.Lo++; + if( !cyVal.Lo ) + cyVal.Hi++; + } + + void set(double n) + { + if( n >= 0 ) + { + cyVal.Hi = (sal_Int32)(n / (double)4294967296.0); + cyVal.Lo = (sal_uInt32)(n - ((double)cyVal.Hi * (double)4294967296.0)); + } + else { + cyVal.Hi = (sal_Int32)(-n / (double)4294967296.0); + cyVal.Lo = (sal_uInt32)(-n - ((double)cyVal.Hi * (double)4294967296.0)); + CHS(); + } + } + + }; + } +} +#endif // _CONNECTIVITY_ADO_AOLEVARIANT_HXX_ + diff --git a/connectivity/source/inc/ado/Aolewrap.hxx b/connectivity/source/inc/ado/Aolewrap.hxx new file mode 100644 index 000000000000..cd95ebf75e3c --- /dev/null +++ b/connectivity/source/inc/ado/Aolewrap.hxx @@ -0,0 +1,254 @@ +/************************************************************************* + * + * $RCSfile: Aolewrap.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_AOLEWRAP_HXX_ +#define _CONNECTIVITY_ADO_AOLEWRAP_HXX_ + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +namespace connectivity +{ + namespace ado + { + ////////////////////////////////////////////////////////////////////////// + // + // Template-Klasse WpOLEBase<class T> + // ================================== + // + // Objekte dieser Klasse hlt einen Zeiger auf ein Interface vom Typ T. + // Es gibt Konstruktoren und Zuweisungsoperator die sicherstellen, dass + // AddRef() und Release() entsprechend den COM-Konventionen gerufen werden. + // Ein Objekt kann auch keinen Zeiger halten (Nullzeiger), dann ergibt + // der Aufruf von IsValid() FALSE. + // + // Um effizientes pass-by-value machen zu koennen, ist diese (ebenso wie die + // abgeleiteten Klassen) eine ganz schmale Wrapper-Klasse unter Vermeidung + // virtueller Methoden und mit Inlining. + + //------------------------------------------------------------------------ + template<class T> class WpOLEBase + { + + protected: + T* pInterface; + + public: + + WpOLEBase(); + WpOLEBase(T* pInt); + + + //inline + WpOLEBase<T>& operator=(const WpOLEBase<T>& rhs) + { + if (rhs.pInterface != pInterface) + { + if (pInterface) pInterface->Release(); + pInterface = rhs.pInterface; + if (pInterface) pInterface->AddRef(); + } + return *this; + }; + + WpOLEBase<T>& operator=(T* rhs) + { + if (pInterface != rhs) + { + if (pInterface) pInterface->Release(); + pInterface = rhs; + if (pInterface) pInterface->AddRef(); + } + return *this; + } + + WpOLEBase(const WpOLEBase<T>& aWrapper) + { + operator=(aWrapper); + } + + virtual ~WpOLEBase() + { + if (pInterface) + { + pInterface->Release(); + pInterface = NULL; + } + } + + inline void clear() + { + if (pInterface) + { + pInterface->Release(); + pInterface = NULL; + } + } + + + inline sal_Bool IsValid() const {return pInterface != NULL;}; + operator IDispatch*() { return pInterface; } + operator T*() { return pInterface; } + }; + + + template<class T> WpOLEBase<T>::WpOLEBase<T>() + { + pInterface = NULL; + }; + + + template<class T> WpOLEBase<T>::WpOLEBase<T>(T* pInt) + { + pInterface = pInt; + }; + // kein AddRef(), da + // der nach Konvention von der erz. Methode + // schon durchgefhrt wurde. + + + + + + ////////////////////////////////////////////////////////////////////////// + // + // Template-Klasse WpOLECollection<class Ts, class T, class WrapT> + // =============================================================== + // + // Diese Klasse, welche sich von WpOLEBase<Ts> ableitet, abstrahiert die + // den DAO-Collections gemeinsamen Eigenschaften: + // + // Sie werden ber ein Interface Ts (etwa: DAOFields) angesprochen + // und koennen ueber get_Item (hier:GetItem) Items des Typs T (genauer: + // mit Interface T, etwa DAOField) herausgeben. + // + // Diese Wrapperklasse gibt aber nicht ein Interface T heraus, + // sondern ein Objekt der Klasse WrapT. Dieses mu eine Konstruktion + // durch T zulassen, vorzugsweise ist es von WpOLEBase<T> abgeleitet. + // + + //------------------------------------------------------------------------ + template<class Ts, class T, class WrapT> class WpOLECollection: public WpOLEBase<Ts> + { + public: + // Konstruktoren, operator= + // diese rufen nur die Oberklasse + WpOLECollection(Ts* pInt):WpOLEBase<Ts>(pInt){} + WpOLECollection(const WpOLECollection& rhs){operator=(rhs);} + inline WpOLECollection& operator=(const WpOLECollection& rhs) + {WpOLEBase<Ts>::operator=(rhs); return *this;}; + + ////////////////////////////////////////////////////////////////////// + + inline void Refresh(){pInterface->Refresh();}; + + inline sal_Int32 GetItemCount() const + { + sal_Int32 nCount = 0; + pInterface->get_Count(&nCount); + return nCount; + }; + + inline WrapT GetItem(sal_Int32 index) const + { + OSL_ENSHURE(index >= 0 && index<GetItemCount(),"Wrong index for field!"); + T* pT; + if (FAILED(pInterface->get_Item(OLEVariant(index), &pT))) return WrapT(NULL); + return WrapT(pT); + }; + + inline WrapT GetItem(const ::rtl::OUString& sStr) const + { + T* pT; + if (FAILED(pInterface->get_Item(OLEVariant(sStr), &pT))) return WrapT(NULL); + return WrapT(pT); + } + }; + + template<class Ts, class T, class WrapT> class WpOLEAppendCollection: + public WpOLECollection<Ts,T,WrapT> + { + + public: + // Konstruktoren, operator= + // diese rufen nur die Oberklasse + WpOLEAppendCollection(Ts* pInt):WpOLECollection<Ts,T,WrapT>(pInt){} + WpOLEAppendCollection(const WpOLEAppendCollection& rhs){operator=(rhs);} + inline WpOLEAppendCollection& operator=(const WpOLEAppendCollection& rhs) + {WpOLEBase<Ts>::operator=(rhs); return *this;}; + ////////////////////////////////////////////////////////////////////// + + inline sal_Bool Append(WrapT aWrapT) + { + return SUCCEEDED(pInterface->Append(aWrapT.pInterface)); + }; + + inline sal_Bool Delete(const ::rtl::OUString& sName) + { + return SUCCEEDED(pInterface->Delete(OLEVariant(sName))); + }; + + + }; + } +} +#endif // _CONNECTIVITY_ADO_AOLEWRAP_HXX_ + diff --git a/connectivity/source/inc/ado/Awrapado.hxx b/connectivity/source/inc/ado/Awrapado.hxx new file mode 100644 index 000000000000..84e60c600a33 --- /dev/null +++ b/connectivity/source/inc/ado/Awrapado.hxx @@ -0,0 +1,1021 @@ +/************************************************************************* + * + * $RCSfile: Awrapado.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_AWRAPADO_HXX_ +#define _CONNECTIVITY_ADO_AWRAPADO_HXX_ + +#include <tools/prewin.h> +// Includes fuer ADO +#include <oledb.h> +//#include <objbase.h> +//#include <initguid.h> +//#include <mapinls.h> +#include <ocidl.h> + +#ifndef _ADOINT_H_ +#include <adoint.h> +#endif + +#include <tools/postwin.h> + +#ifndef _CONNECTIVITY_ADO_ADOIMP_HXX_ +#include "ado/adoimp.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AOLEWRAP_HXX_ +#include "ado/Aolewrap.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AOLEVARIANT_HXX_ +#include "ado/Aolevariant.hxx" +#endif + +namespace connectivity +{ + namespace ado + { + class WpADOConnection; + class WpADOCommand; + class WpADORecordset; + class WpADOField; + class WpADOParameter; + class WpADOError; + class WpADOProperty; + + typedef WpOLEAppendCollection<ADOFields, ADOField, WpADOField> WpADOFields; + + //------------------------------------------------------------------------ + class WpADOConnection : public WpOLEBase<ADOConnection> + { + friend class WpADOCommand; + public: + + WpADOConnection(ADOConnection* pInt) : WpOLEBase<ADOConnection>(pInt){} + + WpADOConnection(const WpADOConnection& rhs){operator=(rhs);} + + inline WpADOConnection& operator=(const WpADOConnection& rhs) + {WpOLEBase<ADOConnection>::operator=(rhs); return *this;} + + ////////////////////////////////////////////////////////////////////// + + inline ADOProperties* get_Properties() const + { + ADOProperties* pProps=NULL; + pInterface->get_Properties(&pProps); + return pProps; + } + + inline rtl::OUString GetConnectionString() const + { + BSTR aBSTR; pInterface->get_ConnectionString(&aBSTR); + rtl::OUString sRetStr((sal_Unicode*)aBSTR); + SysFreeString(aBSTR); + return sRetStr; + } + + inline sal_Bool PutConnectionString(const ::rtl::OUString &aCon) const + { + return SUCCEEDED(pInterface->put_ConnectionString(SysAllocString(aCon.getStr()))); + } + + inline sal_Int32 GetCommandTimeout() const + { + sal_Int32 nRet; + pInterface->get_CommandTimeout(&nRet); + return nRet; + } + + inline void PutCommandTimeout(sal_Int32 nRet) + { + pInterface->put_CommandTimeout(nRet); + } + + inline sal_Int32 GetConnectionTimeout() const + { + sal_Int32 nRet; + pInterface->get_ConnectionTimeout(&nRet); + return nRet; + } + + inline void PutConnectionTimeout(sal_Int32 nRet) + { + pInterface->put_ConnectionTimeout(nRet); + } + + inline sal_Bool Close( ) + { + return (SUCCEEDED(pInterface->Close())); + } + + inline sal_Bool Execute(const ::rtl::OUString& _CommandText,OLEVariant& RecordsAffected,long Options, WpADORecordset** ppiRset) + { + return SUCCEEDED(pInterface->Execute(SysAllocString(_CommandText.getStr()),&RecordsAffected,Options,(_ADORecordset**)ppiRset)); + } + + inline sal_Bool BeginTrans() + { + sal_Int32 nIso; + return SUCCEEDED(pInterface->BeginTrans(&nIso)); + } + + inline sal_Bool CommitTrans( ) + { + return SUCCEEDED(pInterface->CommitTrans()); + } + + inline sal_Bool RollbackTrans( ) + { + return SUCCEEDED(pInterface->RollbackTrans()); + } + + inline sal_Bool Open(const ::rtl::OUString& ConnectionString, const ::rtl::OUString& UserID,const ::rtl::OUString& Password,long Options) + { + return SUCCEEDED(pInterface->Open(SysAllocString(ConnectionString.getStr()),SysAllocString(UserID.getStr()),SysAllocString(Password.getStr()),Options)); + } + + inline sal_Bool GetErrors(ADOErrors** pErrors) + { + return SUCCEEDED(pInterface->get_Errors(pErrors)); + } + + inline ::rtl::OUString GetDefaultDatabase() const + { + BSTR aBSTR; pInterface->get_DefaultDatabase(&aBSTR); + ::rtl::OUString sRetStr(aBSTR); + SysFreeString(aBSTR); return sRetStr; + } + + inline sal_Bool PutDefaultDatabase(const ::rtl::OUString& bstr) + { + return SUCCEEDED(pInterface->put_DefaultDatabase(SysAllocString(bstr.getStr()))); + } + + inline IsolationLevelEnum get_IsolationLevel() const + { + IsolationLevelEnum eNum; + pInterface->get_IsolationLevel(&eNum); + return eNum; + } + + inline sal_Bool put_IsolationLevel(const IsolationLevelEnum& eNum) + { + return SUCCEEDED(pInterface->put_IsolationLevel(eNum)); + } + + inline sal_Int32 get_Attributes() const + { + sal_Int32 nRet; + pInterface->get_Attributes(&nRet); + return nRet; + } + + inline sal_Bool put_Attributes(sal_Int32 nRet) + { + return SUCCEEDED(pInterface->put_Attributes(nRet)); + } + + inline CursorLocationEnum get_CursorLocation() const + { + CursorLocationEnum eNum; + pInterface->get_CursorLocation(&eNum); + return eNum; + } + + inline sal_Bool put_CursorLocation(const CursorLocationEnum &eNum) + { + return SUCCEEDED(pInterface->put_CursorLocation(eNum)); + } + + inline ConnectModeEnum get_Mode() const + { + ConnectModeEnum eNum; + pInterface->get_Mode(&eNum); + return eNum; + } + + inline sal_Bool put_Mode(const ConnectModeEnum &eNum) + { + + return SUCCEEDED(pInterface->put_Mode(eNum)); + } + + inline ::rtl::OUString get_Provider() const + { + BSTR aBSTR; pInterface->get_Provider(&aBSTR); + ::rtl::OUString sRetStr(aBSTR); + SysFreeString(aBSTR); return sRetStr; + } + + inline sal_Bool put_Provider(const ::rtl::OUString& bstr) + { + return SUCCEEDED(pInterface->put_Provider(SysAllocString(bstr.getStr()))); + } + + inline sal_Int32 get_State() const + { + sal_Int32 nRet; + pInterface->get_State(&nRet); + return nRet; + } + + inline sal_Bool OpenSchema(SchemaEnum eNum,OLEVariant& Restrictions,OLEVariant& SchemaID,ADORecordset**pprset) + { + return SUCCEEDED(pInterface->OpenSchema(eNum,Restrictions,SchemaID,pprset)); + } + + inline ::rtl::OUString get_Version() const + { + BSTR aBSTR; + pInterface->get_Version(&aBSTR); + ::rtl::OUString sRetStr(aBSTR); + SysFreeString(aBSTR); return sRetStr; + } + }; + + //------------------------------------------------------------------------ + class WpADOCommand : public WpOLEBase<ADOCommand> + { + public: + WpADOCommand(){} + // Konstruktoren, operator= + // diese rufen nur die Oberklasse + WpADOCommand(ADOCommand* pInt) : WpOLEBase<ADOCommand>(pInt){} + + WpADOCommand(const WpADOCommand& rhs){operator=(rhs);} + + inline WpADOCommand& operator=(const WpADOCommand& rhs) + { + WpOLEBase<ADOCommand>::operator=(rhs); return *this;} + + ////////////////////////////////////////////////////////////////////// + + sal_Bool putref_ActiveConnection( WpADOConnection *pCon) + { + return SUCCEEDED(pInterface->putref_ActiveConnection(pCon->pInterface)); + } + + void put_ActiveConnection(/* [in] */ const OLEVariant& vConn) + { + pInterface->put_ActiveConnection(vConn); + } + + inline void Create() + { + IClassFactory2* pIUnknown = NULL; + IUnknown *pOuter = NULL; + HRESULT hr; + hr = CoGetClassObject( ADOS::CLSID_ADOCOMMAND_21, + CLSCTX_INPROC_SERVER, + NULL, + IID_IClassFactory2, + (void**)&pIUnknown ); + + if( !FAILED( hr ) ) + { + pIUnknown->AddRef(); + ADOCommand* pCommand; + + hr = pIUnknown->CreateInstanceLic( pOuter, + NULL, + ADOS::IID_ADOCOMMAND_21, + ADOS::GetKeyStr(), + (void**) &pCommand); + + if( !FAILED( hr ) ) + { + pInterface = pCommand; + pInterface->AddRef(); + } + pIUnknown->Release(); + } + } + + inline sal_Int32 get_State() const + { + sal_Int32 nRet; + pInterface->get_State(&nRet); + return nRet; + } + + inline ::rtl::OUString get_CommandText() const + { + BSTR aBSTR; pInterface->get_CommandText(&aBSTR); + ::rtl::OUString sRetStr(aBSTR); + SysFreeString(aBSTR); return sRetStr; + } + + inline sal_Bool put_CommandText(const ::rtl::OUString &aCon) + { + BSTR bstr = SysAllocString(aCon.getStr()); + sal_Bool bErg = SUCCEEDED(pInterface->put_CommandText(bstr)); + SysFreeString(bstr); + return bErg; + } + + inline sal_Int32 get_CommandTimeout() const + { + sal_Int32 nRet; + pInterface->get_CommandTimeout(&nRet); + return nRet; + } + + inline void put_CommandTimeout(sal_Int32 nRet) + { + pInterface->put_CommandTimeout(nRet); + } + + inline sal_Bool get_Prepared() const + { + VARIANT_BOOL bPrepared; + pInterface->get_Prepared(&bPrepared); + return bPrepared == VARIANT_TRUE; + } + + inline sal_Bool put_Prepared(VARIANT_BOOL bPrepared) const + { + return SUCCEEDED(pInterface->put_Prepared(bPrepared)); + } + + inline sal_Bool Execute(OLEVariant& RecordsAffected,OLEVariant& Parameters,long Options, ADORecordset** ppiRset) + { + return SUCCEEDED(pInterface->Execute(&RecordsAffected,&Parameters,Options,ppiRset)); + } + + inline ADOParameter* CreateParameter(const ::rtl::OUString &bstr,DataTypeEnum Type,ParameterDirectionEnum Direction,long nSize,const OLEVariant &Value) + { + ADOParameter* pPara = NULL; + if(SUCCEEDED(pInterface->CreateParameter(bstr.getLength() ? SysAllocString(bstr.getStr()) : NULL,Type,Direction,nSize,Value,&pPara))) + return pPara; + return NULL; + } + + inline ADOParameters* get_Parameters() const + { + ADOParameters* pPara; + pInterface->get_Parameters(&pPara); + return pPara; + } + + inline sal_Bool put_CommandType( /* [in] */ CommandTypeEnum lCmdType) + { + return SUCCEEDED(pInterface->put_CommandType(lCmdType)); + } + + inline CommandTypeEnum get_CommandType( ) const + { + CommandTypeEnum eNum; + pInterface->get_CommandType(&eNum); + return eNum; + } + + // gibt den Namen des Feldes zur"ueck + inline ::rtl::OUString GetName() const + { + BSTR aBSTR; pInterface->get_Name(&aBSTR); + ::rtl::OUString sRetStr(aBSTR); + SysFreeString(aBSTR); return sRetStr; + } + + inline sal_Bool put_Name(const ::rtl::OUString& _Name) + { + return SUCCEEDED(pInterface->put_Name(SysAllocString(_Name.getStr()))); + } + inline sal_Bool Cancel() + { + return SUCCEEDED(pInterface->Cancel()); + } + }; + //------------------------------------------------------------------------ + class WpADOError:public WpOLEBase<ADOError> + { + public: + + // Konstruktoren, operator= + // diese rufen nur die Oberklasse + + WpADOError(ADOError* pInt):WpOLEBase<ADOError>(pInt){} + + WpADOError(const WpADOError& rhs){operator=(rhs);} + + inline WpADOError& operator=(const WpADOError& rhs) + {WpOLEBase<ADOError>::operator=(rhs); return *this;} + + ////////////////////////////////////////////////////////////////////// + + inline ::rtl::OUString GetDescription() const + { + BSTR aBSTR; pInterface->get_Description(&aBSTR); + ::rtl::OUString sRetStr(aBSTR); + SysFreeString(aBSTR); return sRetStr; + } + + inline ::rtl::OUString GetSource() const {BSTR aBSTR; pInterface->get_Source(&aBSTR); + ::rtl::OUString sRetStr(aBSTR); + SysFreeString(aBSTR); return sRetStr;} + + inline sal_Int32 GetNumber() const {sal_Int32 nErrNr; pInterface->get_Number(&nErrNr); + return nErrNr;} + + inline ::rtl::OUString GetSQLState() const + { + BSTR aBSTR; pInterface->get_SQLState(&aBSTR); + ::rtl::OUString sRetStr(aBSTR); + SysFreeString(aBSTR); return sRetStr; + } + + inline sal_Int32 GetNativeError() const + { + sal_Int32 nErrNr; pInterface->get_NativeError(&nErrNr); + return nErrNr; + } + }; + + + + //------------------------------------------------------------------------ + class WpADOField : public WpOLEBase<ADOField> + { + // friend class WpADOFields; + public: + + // Konstruktoren, operator= + // diese rufen nur die Oberklasse + WpADOField(ADOField* pInt=NULL):WpOLEBase<ADOField>(pInt){} + WpADOField(const WpADOField& rhs){operator=(rhs);} + + inline WpADOField& operator=(const WpADOField& rhs) + {WpOLEBase<ADOField>::operator=(rhs); return *this;} + ////////////////////////////////////////////////////////////////////// + + inline ADOProperties* get_Properties() + { + ADOProperties* pProps = NULL; + pInterface->get_Properties(&pProps); + return pProps; + } + + inline sal_Int32 GetActualSize() const + { + sal_Int32 nActualSize; pInterface->get_ActualSize(&nActualSize); + return nActualSize; + } + + inline sal_Int32 GetAttributes() const + { + sal_Int32 eADOSFieldAttributes; pInterface->get_Attributes(&eADOSFieldAttributes); + return eADOSFieldAttributes; + } + + inline sal_Int32 GetStatus() const + { + sal_Int32 eADOSFieldAttributes=0; + // pInterface->get_Status(&eADOSFieldAttributes); + return eADOSFieldAttributes; + } + + inline sal_Int32 GetDefinedSize() const + { + sal_Int32 nDefinedSize; + pInterface->get_DefinedSize(&nDefinedSize); + return nDefinedSize; + } + + // gibt den Namen des Feldes zur"ueck + inline ::rtl::OUString GetName() const + { + BSTR aBSTR; pInterface->get_Name(&aBSTR); + ::rtl::OUString sRetStr(aBSTR); + SysFreeString(aBSTR); return sRetStr; + } + + inline DataTypeEnum GetADOType() const + { + DataTypeEnum eType; pInterface->get_Type(&eType); + return eType; + } + + inline void get_Value(OLEVariant& aValVar) const + { + aValVar.setEmpty(); + pInterface->get_Value(&aValVar); + } + + inline OLEVariant get_Value() const + { + OLEVariant aValVar; + pInterface->get_Value(&aValVar); + return aValVar; + } + + inline sal_Bool PutValue(const OLEVariant& aVariant) + { + return (SUCCEEDED(pInterface->put_Value(aVariant))); + } + + inline sal_Int32 GetPrecision() const + { + sal_uInt8 eType; pInterface->get_Precision(&eType); + return eType; + } + + inline sal_Int32 GetNumericScale() const + { + sal_uInt8 eType; pInterface->get_NumericScale(&eType); + return eType; + } + + inline sal_Bool AppendChunk(const OLEVariant& _Variant) + { + return (SUCCEEDED(pInterface->AppendChunk(_Variant))); + } + + inline OLEVariant GetChunk(long Length) const + { + OLEVariant aValVar; + pInterface->GetChunk(Length,&aValVar); + return aValVar; + } + + inline void GetChunk(long Length,OLEVariant &aValVar) const + { + pInterface->GetChunk(Length,&aValVar); + } + + inline OLEVariant GetOriginalValue() const + { + OLEVariant aValVar; + pInterface->get_OriginalValue(&aValVar); + return aValVar; + } + + inline void GetOriginalValue(OLEVariant &aValVar) const + { + pInterface->get_OriginalValue(&aValVar); + } + + inline OLEVariant GetUnderlyingValue() const + { + OLEVariant aValVar; + pInterface->get_UnderlyingValue(&aValVar); + return aValVar; + } + + inline void GetUnderlyingValue(OLEVariant &aValVar) const + { + pInterface->get_UnderlyingValue(&aValVar); + } + + inline sal_Bool PutPrecision(sal_Int8 _prec) + { + return (SUCCEEDED(pInterface->put_Precision(_prec))); + } + + inline sal_Bool PutNumericScale(sal_Int8 _prec) + { + return (SUCCEEDED(pInterface->put_NumericScale(_prec))); + } + + inline void PutADOType(DataTypeEnum eType) + { + pInterface->put_Type(eType); + } + + inline sal_Bool PutDefinedSize(sal_Int32 _nDefSize) + { + return (SUCCEEDED(pInterface->put_DefinedSize(_nDefSize))); + } + + inline sal_Bool PutAttributes(sal_Int32 _nDefSize) + { + return (SUCCEEDED(pInterface->put_Attributes(_nDefSize))); + } + }; + + + + //------------------------------------------------------------------------ + class WpADOProperty: public WpOLEBase<ADOProperty> + { + friend class WpADOProperties; + + public: + // Konstruktoren, operator= + // diese rufen nur die Oberklasse + WpADOProperty(ADOProperty* pInt):WpOLEBase<ADOProperty>(pInt){} + WpADOProperty(const WpADOProperty& rhs){operator=(rhs);} + inline WpADOProperty& operator=(const WpADOProperty& rhs) + {WpOLEBase<ADOProperty>::operator=(rhs); return *this;} + ////////////////////////////////////////////////////////////////////// + + inline OLEVariant GetValue() const + { + OLEVariant aValVar; + pInterface->get_Value(&aValVar); + return aValVar; + } + + inline void GetValue(OLEVariant &aValVar) const + { + pInterface->get_Value(&aValVar); + } + + inline sal_Bool PutValue(const OLEVariant &aValVar) + { + return (SUCCEEDED(pInterface->put_Value(aValVar))); + } + + inline ::rtl::OUString GetName() const + { + BSTR aBSTR; pInterface->get_Name(&aBSTR); + ::rtl::OUString sRetStr(aBSTR); + SysFreeString(aBSTR); return sRetStr; + } + + inline DataTypeEnum GetADOType() const + { + DataTypeEnum eType; pInterface->get_Type(&eType); + return eType; + } + + inline sal_Int32 GetAttributes() const + { + sal_Int32 eADOSFieldAttributes; pInterface->get_Attributes(&eADOSFieldAttributes); + return eADOSFieldAttributes; + } + + inline sal_Bool PutAttributes(sal_Int32 _nDefSize) + { + return (SUCCEEDED(pInterface->put_Attributes(_nDefSize))); + } + }; + + + class WpADORecordset:public WpOLEBase<ADORecordset> + { + + public: + // Konstruktoren, operator= + // diese rufen nur die Oberklasse + WpADORecordset(ADORecordset* pInt=NULL):WpOLEBase<ADORecordset>(pInt){} + WpADORecordset(const WpADORecordset& rhs){operator=(rhs);} + inline WpADORecordset& operator=(const WpADORecordset& rhs) + { + WpOLEBase<ADORecordset>::operator=(rhs); + return *this; + } + ~WpADORecordset() + { + // if(pInterface && get_State() == adStateOpen) + // Close(); + } + ////////////////////////////////////////////////////////////////////// + inline void Create() + { + IClassFactory2* pIUnknown = NULL; + IUnknown *pOuter = NULL; + HRESULT hr; + hr = CoGetClassObject( ADOS::CLSID_ADORECORDSET_21, + CLSCTX_INPROC_SERVER, + NULL, + IID_IClassFactory2, + (void**)&pIUnknown ); + + if( !FAILED( hr ) ) + { + pIUnknown->AddRef(); + + ADORecordset *pRec = NULL; + hr = pIUnknown->CreateInstanceLic( pOuter, + NULL, + ADOS::IID_ADORECORDSET_21, + ADOS::GetKeyStr(), + (void**) &pRec); + + if( !FAILED( hr ) ) + { + pInterface = pRec; + pInterface->AddRef(); + } + pIUnknown->Release(); + } + } + + inline sal_Bool Open( + /* [optional][in] */ VARIANT Source, + /* [optional][in] */ VARIANT ActiveConnection, + /* [defaultvalue][in] */ CursorTypeEnum CursorType, + /* [defaultvalue][in] */ LockTypeEnum LockType, + /* [defaultvalue][in] */ sal_Int32 Options) + { + return (SUCCEEDED(pInterface->Open(Source,ActiveConnection,CursorType,LockType,Options))); + } + + + inline LockTypeEnum GetLockType() + { + LockTypeEnum eType; + pInterface->get_LockType(&eType); + return eType; + } + + inline void Close() + { + pInterface->Close(); + } + + inline sal_Bool Cancel() const + { + return (SUCCEEDED(pInterface->Cancel())); + } + + inline sal_Int32 get_State( ) + { + sal_Int32 nState = 0; + pInterface->get_State(&nState); + return nState; + } + + inline sal_Bool Supports( /* [in] */ CursorOptionEnum CursorOptions) + { + VARIANT_BOOL bSupports; + pInterface->Supports(CursorOptions,&bSupports); + return (sal_Bool) bSupports; + } + + PositionEnum get_AbsolutePosition() + { + PositionEnum aTemp; + pInterface->get_AbsolutePosition(&aTemp); + return aTemp; + } + + inline void GetDataSource(IUnknown** pIUnknown) const + { + pInterface->get_DataSource(pIUnknown); + } + + inline void PutRefDataSource(IUnknown* pIUnknown) + { + pInterface->putref_DataSource(pIUnknown); + } + + inline void GetBookmark(VARIANT& var) + { + pInterface->get_Bookmark(&var); + } + + inline OLEVariant GetBookmark() + { + OLEVariant var; + pInterface->get_Bookmark(&var); + return var; + } + + CompareEnum CompareBookmarks(const OLEVariant& left,const OLEVariant& right) + { + CompareEnum eNum; + pInterface->CompareBookmarks(left,right,&eNum); + return eNum; + } + + inline sal_Bool SetBookmark(const OLEVariant &pSafeAr) + { + return SUCCEEDED(pInterface->put_Bookmark(pSafeAr)); + } + + + inline ADOFields* GetFields() const + { + ADOFields* pFields; + pInterface->get_Fields(&pFields); + return pFields; + } + + + inline sal_Bool Move(sal_Int32 nRows, VARIANT aBmk) {return SUCCEEDED(pInterface->Move(nRows, aBmk));} + inline sal_Bool MoveNext() {return SUCCEEDED(pInterface->MoveNext());} + inline sal_Bool MovePrevious() {return SUCCEEDED(pInterface->MovePrevious());} + inline sal_Bool MoveFirst() {return SUCCEEDED(pInterface->MoveFirst());} + inline sal_Bool MoveLast() {return SUCCEEDED(pInterface->MoveLast());} + + inline sal_Bool IsAtBOF() const + { + VARIANT_BOOL bIsAtBOF; + pInterface->get_BOF(&bIsAtBOF); + return (sal_Bool) bIsAtBOF; + } + + inline sal_Bool IsAtEOF() const + { + VARIANT_BOOL bIsAtEOF; + pInterface->get_EOF(&bIsAtEOF); + return (sal_Bool) bIsAtEOF; + } + + inline sal_Bool Delete(AffectEnum eNum) + { + return SUCCEEDED(pInterface->Delete(eNum)); + } + + inline sal_Bool AddNew(const OLEVariant &FieldList,const OLEVariant &Values) + { + return SUCCEEDED(pInterface->AddNew(FieldList,Values)); + } + + inline sal_Bool Update(const OLEVariant &FieldList,const OLEVariant &Values) + { + return SUCCEEDED(pInterface->Update(FieldList,Values)); + } + + inline sal_Bool CancelUpdate() + { + return SUCCEEDED(pInterface->CancelUpdate()); + } + + inline ADOProperties* get_Properties() const + { + ADOProperties* pProps=NULL; + pInterface->get_Properties(&pProps); + return pProps; + } + + inline sal_Bool NextRecordset(OLEVariant& RecordsAffected,ADORecordset** ppiRset) + { + return SUCCEEDED(pInterface->NextRecordset(&RecordsAffected,ppiRset)); + } + + inline sal_Bool get_RecordCount(sal_Int32 &_nRet) const + { + return SUCCEEDED(pInterface->get_RecordCount(&_nRet)); + } + + inline sal_Bool get_MaxRecords(sal_Int32 &_nRet) const + { + return SUCCEEDED(pInterface->get_MaxRecords(&_nRet)); + } + + inline sal_Bool put_MaxRecords(sal_Int32 _nRet) + { + return SUCCEEDED(pInterface->put_MaxRecords(_nRet)); + } + + inline sal_Bool get_CursorType(CursorTypeEnum &_nRet) const + { + return SUCCEEDED(pInterface->get_CursorType(&_nRet)); + } + + inline sal_Bool put_CursorType(CursorTypeEnum _nRet) + { + return SUCCEEDED(pInterface->put_CursorType(_nRet)); + } + + inline sal_Bool get_LockType(LockTypeEnum &_nRet) const + { + return SUCCEEDED(pInterface->get_LockType(&_nRet)); + } + + inline sal_Bool put_LockType(LockTypeEnum _nRet) + { + return SUCCEEDED(pInterface->put_LockType(_nRet)); + } + + inline sal_Bool get_CacheSize(sal_Int32 &_nRet) const + { + return SUCCEEDED(pInterface->get_CacheSize(&_nRet)); + } + + inline sal_Bool put_CacheSize(sal_Int32 _nRet) + { + return SUCCEEDED(pInterface->put_CacheSize(_nRet)); + } + + inline sal_Bool UpdateBatch(AffectEnum AffectRecords) + { + return SUCCEEDED(pInterface->UpdateBatch(AffectRecords)); + } + }; + + //------------------------------------------------------------------------ + class WpADOParameter:public WpOLEBase<ADOParameter> + { + public: + // Konstruktoren, operator= + // diese rufen nur die Oberklasse + WpADOParameter(ADOParameter* pInt):WpOLEBase<ADOParameter>(pInt){} + WpADOParameter(const WpADOParameter& rhs):WpOLEBase<ADOParameter>(rhs){} + inline WpADOParameter& operator=(const WpADOParameter& rhs) + {WpOLEBase<ADOParameter>::operator=(rhs); return *this;} + ////////////////////////////////////////////////////////////////////// + + inline ::rtl::OUString GetName() const {BSTR aBSTR; pInterface->get_Name(&aBSTR); + ::rtl::OUString sRetStr(aBSTR); + SysFreeString(aBSTR); return sRetStr;} + + inline DataTypeEnum GetADOType() const + { + DataTypeEnum eType; pInterface->get_Type(&eType); + return eType; + } + + inline sal_Int32 GetAttributes() const + { + sal_Int32 eADOSFieldAttributes; pInterface->get_Attributes(&eADOSFieldAttributes); + return eADOSFieldAttributes; + } + + inline sal_Int32 GetPrecision() const + { + sal_uInt8 eType; pInterface->get_Precision(&eType); + return eType; + } + + inline sal_Int32 GetNumericScale() const + { + sal_uInt8 eType; pInterface->get_NumericScale(&eType); + return eType; + } + + inline ParameterDirectionEnum get_Direction() const + { + ParameterDirectionEnum alParmDirection; + pInterface->get_Direction(&alParmDirection); + return alParmDirection; + } + + inline void GetValue(OLEVariant& aValVar) const + { + pInterface->get_Value(&aValVar); + } + + inline OLEVariant GetValue() const + { + OLEVariant aValVar; + pInterface->get_Value(&aValVar); + return aValVar; + } + + inline sal_Bool PutValue(const OLEVariant& aVariant) + { + return (SUCCEEDED(pInterface->put_Value(aVariant))); + } + }; + } +} +#endif //_CONNECTIVITY_ADO_AWRAPADO_HXX_ + diff --git a/connectivity/source/inc/ado/Awrapadox.hxx b/connectivity/source/inc/ado/Awrapadox.hxx new file mode 100644 index 000000000000..2257cf7835af --- /dev/null +++ b/connectivity/source/inc/ado/Awrapadox.hxx @@ -0,0 +1,634 @@ +/************************************************************************* + * + * $RCSfile: Awrapadox.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_AWRAPADOX_HXX_ +#define _CONNECTIVITY_ADO_AWRAPADOX_HXX_ + +// Includes fuer ADO +#include <tools/prewin.h> +//#include <oledb.h> +//#include <objbase.h> +//#include <initguid.h> +//#include <mapinls.h> +//#include <ocidl.h> + +#ifndef __User_FWD_DEFINED__ +#define __User_FWD_DEFINED__ +typedef struct _ADOUser User; +#endif /* __User_FWD_DEFINED__ */ + +#ifndef __Group_FWD_DEFINED__ +#define __Group_FWD_DEFINED__ +typedef struct _ADOGroup Group; +#endif /* __Group_FWD_DEFINED__ */ + +#ifndef __Column_FWD_DEFINED__ +#define __Column_FWD_DEFINED__ +typedef struct _ADOColumn Column; +#endif /* __Column_FWD_DEFINED__ */ + +#ifndef __Index_FWD_DEFINED__ +#define __Index_FWD_DEFINED__ +typedef struct _ADOIndex Index; +#endif /* __cplusplus */ + +#ifndef __Key_FWD_DEFINED__ +#define __Key_FWD_DEFINED__ +typedef struct _ADOKey Key; +#endif /* __Key_FWD_DEFINED__ */ + +#ifndef __Table_FWD_DEFINED__ +#define __Table_FWD_DEFINED__ +typedef struct _ADOTable Table; +#endif /* __Table_FWD_DEFINED__ */ + +#ifndef _ADOINT_H_ +#include <adoint.h> +#endif + +#ifndef _ADOCTINT_H_ +#include <ado/adoctint.h> +#endif +#include <tools/postwin.h> + +#ifndef _CONNECTIVITY_ADO_AOLEWRAP_HXX_ +#include "ado/Aolewrap.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AOLEVARIANT_HXX_ +#include "ado/Aolevariant.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_ADOIMP_HXX_ +#include "ado/adoimp.hxx" +#endif +namespace connectivity +{ + namespace ado + { + class WpADOColumn : public WpOLEBase<_ADOColumn> + { + public: + WpADOColumn(_ADOColumn* pInt=NULL) : WpOLEBase<_ADOColumn>(pInt){} + + void Create(); + + inline WpADOColumn& operator=(const WpADOColumn& rhs) + {WpOLEBase<_ADOColumn>::operator=(rhs); return *this;} + + ::rtl::OUString get_Name() const + { + BSTR aBSTR; + pInterface->get_Name(&aBSTR); + rtl::OUString sRetStr((sal_Unicode*)aBSTR); + SysFreeString(aBSTR); + return sRetStr; + } + + void put_Name(const ::rtl::OUString& _rName) + { + pInterface->put_Name(SysAllocString(_rName.getStr())); + } + + DataTypeEnum get_Type() const + { + DataTypeEnum eNum; + pInterface->get_Type(&eNum); + return eNum; + } + + void put_Type(const DataTypeEnum& _eNum) + { + pInterface->put_Type(_eNum); + } + + sal_Int32 get_Precision() const + { + sal_Int32 nPrec=0; + pInterface->get_Precision(&nPrec); + return nPrec; + } + + void put_Precision(sal_Int32 _nPre) + { + pInterface->put_Precision(_nPre); + } + + sal_Int32 get_NumericScale() const + { + sal_uInt8 nPrec=0; + pInterface->get_NumericScale(&nPrec); + return nPrec; + } + + void put_NumericScale(sal_Int32 _nScale) + { + pInterface->put_NumericScale(_nScale); + } + + SortOrderEnum get_SortOrder() const + { + SortOrderEnum nPrec; + pInterface->get_SortOrder(&nPrec); + return nPrec; + } + + void put_SortOrder(SortOrderEnum _nScale) + { + pInterface->put_SortOrder(_nScale); + } + + ColumnAttributesEnum get_Attributes() const + { + ColumnAttributesEnum eNum; + pInterface->get_Attributes(&eNum); + return eNum; + } + + void put_Attributes(const ColumnAttributesEnum& _eNum) + { + pInterface->put_Attributes(_eNum); + } + + ADOProperties* get_Properties() const + { + ADOProperties* pProps = NULL; + pInterface->get_Properties(&pProps); + return pProps; + } + }; + + class WpADOKey : public WpOLEBase<ADOKey> + { + public: + WpADOKey(ADOKey* pInt=NULL) : WpOLEBase<ADOKey>(pInt){} + + inline WpADOKey& operator=(const WpADOKey& rhs) + {WpOLEBase<ADOKey>::operator=(rhs); return *this;} + + void Create(); + + ::rtl::OUString get_Name() const + { + BSTR aBSTR; + pInterface->get_Name(&aBSTR); + rtl::OUString sRetStr((sal_Unicode*)aBSTR); + SysFreeString(aBSTR); + return sRetStr; + } + + void put_Name(const ::rtl::OUString& _rName) + { + pInterface->put_Name(SysAllocString(_rName.getStr())); + } + + KeyTypeEnum get_Type() const + { + KeyTypeEnum eNum; + pInterface->get_Type(&eNum); + return eNum; + } + + void put_Type(const KeyTypeEnum& _eNum) + { + pInterface->put_Type(_eNum); + } + + ::rtl::OUString get_RelatedTable() const + { + BSTR aBSTR; + pInterface->get_RelatedTable(&aBSTR); + rtl::OUString sRetStr((sal_Unicode*)aBSTR); + SysFreeString(aBSTR); + return sRetStr; + } + + void put_RelatedTable(const ::rtl::OUString& _rName) + { + pInterface->put_RelatedTable(SysAllocString(_rName.getStr())); + } + + RuleEnum get_DeleteRule() const + { + RuleEnum eNum; + pInterface->get_DeleteRule(&eNum); + return eNum; + } + + void put_DeleteRule(const RuleEnum& _eNum) + { + pInterface->put_DeleteRule(_eNum); + } + + RuleEnum get_UpdateRule() const + { + RuleEnum eNum; + pInterface->get_UpdateRule(&eNum); + return eNum; + } + + void put_UpdateRule(const RuleEnum& _eNum) + { + pInterface->put_UpdateRule(_eNum); + } + + ADOColumns* get_Columns() const + { + ADOColumns* pCols = NULL; + pInterface->get_Columns(&pCols); + return pCols; + } + }; + + class WpADOIndex : public WpOLEBase<_ADOIndex> + { + public: + WpADOIndex(_ADOIndex* pInt=NULL) : WpOLEBase<_ADOIndex>(pInt){} + + inline WpADOIndex& operator=(const WpADOIndex& rhs) + {WpOLEBase<_ADOIndex>::operator=(rhs); return *this;} + + void Create(); + + ::rtl::OUString get_Name() const + { + BSTR aBSTR; + pInterface->get_Name(&aBSTR); + rtl::OUString sRetStr((sal_Unicode*)aBSTR); + SysFreeString(aBSTR); + return sRetStr; + } + + void put_Name(const ::rtl::OUString& _rName) + { + pInterface->put_Name(SysAllocString(_rName.getStr())); + } + + sal_Bool get_Clustered() const + { + VARIANT_BOOL eNum; + pInterface->get_Clustered(&eNum); + return eNum == VARIANT_TRUE; + } + + void put_Clustered(sal_Bool _b) + { + pInterface->put_Clustered(_b ? VARIANT_TRUE : VARIANT_FALSE); + } + + sal_Bool get_Unique() const + { + VARIANT_BOOL eNum; + pInterface->get_Unique(&eNum); + return eNum == VARIANT_TRUE; + } + + void put_Unique(sal_Bool _b) + { + pInterface->put_Unique(_b ? VARIANT_TRUE : VARIANT_FALSE); + } + + sal_Bool get_PrimaryKey() const + { + VARIANT_BOOL eNum; + pInterface->get_PrimaryKey(&eNum); + return eNum == VARIANT_TRUE; + } + + void put_PrimaryKey(sal_Bool _b) + { + pInterface->put_PrimaryKey(_b ? VARIANT_TRUE : VARIANT_FALSE); + } + + ADOColumns* get_Columns() const + { + ADOColumns* pCols = NULL; + pInterface->get_Columns(&pCols); + return pCols; + } + }; + + class WpADOCatalog : public WpOLEBase<_ADOCatalog> + { + public: + WpADOCatalog(_ADOCatalog* pInt = NULL) : WpOLEBase<_ADOCatalog>(pInt){} + + inline WpADOCatalog& operator=(const WpADOCatalog& rhs) + {WpOLEBase<_ADOCatalog>::operator=(rhs); return *this;} + + ::rtl::OUString GetObjectOwner(const ::rtl::OUString& _rName, ObjectTypeEnum _eNum); + + void putref_ActiveConnection(IDispatch* pCon) + { + pInterface->putref_ActiveConnection(pCon); + } + + ADOTables* get_Tables() + { + ADOTables* pRet = NULL; + pInterface->get_Tables(&pRet); + return pRet; + } + + ADOViews* get_Views() + { + ADOViews* pRet = NULL; + pInterface->get_Views(&pRet); + return pRet; + } + + ADOGroups* get_Groups() + { + ADOGroups* pRet = NULL; + pInterface->get_Groups(&pRet); + return pRet; + } + + ADOUsers* get_Users() + { + ADOUsers* pRet = NULL; + pInterface->get_Users(&pRet); + return pRet; + } + + ADOProcedures* get_Procedures() + { + ADOProcedures* pRet = NULL; + pInterface->get_Procedures(&pRet); + return pRet; + } + + void Create(); + }; + + class WpADOTable : public WpOLEBase<_ADOTable> + { + public: + WpADOTable(_ADOTable* pInt=NULL) : WpOLEBase<_ADOTable>(pInt){} + + inline WpADOTable& operator=(const WpADOTable& rhs) + {WpOLEBase<_ADOTable>::operator=(rhs); return *this;} + + void Create(); + + ::rtl::OUString get_Name() const + { + BSTR aBSTR; + pInterface->get_Name(&aBSTR); + rtl::OUString sRetStr((sal_Unicode*)aBSTR); + SysFreeString(aBSTR); + return sRetStr; + } + + void put_Name(const ::rtl::OUString& _rName) + { + pInterface->put_Name(SysAllocString(_rName.getStr())); + } + + ::rtl::OUString get_Type() const + { + BSTR aBSTR; + pInterface->get_Type(&aBSTR); + rtl::OUString sRetStr((sal_Unicode*)aBSTR); + SysFreeString(aBSTR); + return sRetStr; + } + + ADOColumns* get_Columns() const + { + ADOColumns* pCols = NULL; + pInterface->get_Columns(&pCols); + return pCols; + } + + ADOIndexes* get_Indexes() const + { + ADOIndexes* pCols = NULL; + pInterface->get_Indexes(&pCols); + return pCols; + } + + ADOKeys* get_Keys() const + { + ADOKeys* pCols = NULL; + pInterface->get_Keys(&pCols); + return pCols; + } + + WpADOCatalog get_ParentCatalog() const + { + ADOCatalog* pCat = NULL; + pInterface->get_ParentCatalog(&pCat); + return WpADOCatalog(pCat); + } + + ADOProperties* get_Properties() const + { + ADOProperties* pProps = NULL; + pInterface->get_Properties(&pProps); + return pProps; + } + }; + + class WpADOView : public WpOLEBase<ADOView> + { + public: + WpADOView(ADOView* pInt=NULL) : WpOLEBase<ADOView>(pInt){} + + inline WpADOView& operator=(const WpADOView& rhs) + {WpOLEBase<ADOView>::operator=(rhs); return *this;} + + void Create(); + + ::rtl::OUString get_Name() const + { + BSTR aBSTR; + pInterface->get_Name(&aBSTR); + rtl::OUString sRetStr((sal_Unicode*)aBSTR); + SysFreeString(aBSTR); + return sRetStr; + } + + void get_Command(OLEVariant& _rVar) const + { + pInterface->get_Command(&_rVar); + } + + void put_Command(OLEVariant& _rVar) + { + pInterface->put_Command(_rVar); + } + }; + + class WpADOGroup : public WpOLEBase<_ADOGroup> + { + public: + WpADOGroup(_ADOGroup* pInt=NULL) : WpOLEBase<_ADOGroup>(pInt){} + + inline WpADOGroup& operator=(const WpADOGroup& rhs) + {WpOLEBase<_ADOGroup>::operator=(rhs); return *this;} + + void Create(); + + ::rtl::OUString get_Name() const + { + BSTR aBSTR; + pInterface->get_Name(&aBSTR); + rtl::OUString sRetStr((sal_Unicode*)aBSTR); + SysFreeString(aBSTR); + return sRetStr; + } + + void put_Name(const ::rtl::OUString& _rName) + { + pInterface->put_Name(SysAllocString(_rName.getStr())); + } + + RightsEnum GetPermissions( + /* [in] */ const OLEVariant& Name, + /* [in] */ ObjectTypeEnum ObjectType) + { + RightsEnum Rights; + OLEVariant ObjectTypeId; + ObjectTypeId.setNoArg(); + pInterface->GetPermissions(Name,ObjectType,ObjectTypeId,&Rights); + return Rights; + } + + sal_Bool SetPermissions( + /* [in] */ const OLEVariant& Name, + /* [in] */ ObjectTypeEnum ObjectType, + /* [in] */ ActionEnum Action, + /* [in] */ RightsEnum Rights) + { + OLEVariant ObjectTypeId; + ObjectTypeId.setNoArg(); + return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId)); + } + + ADOUsers* get_Users( ) + { + ADOUsers* pRet = NULL; + pInterface->get_Users( &pRet); + return pRet; + } + }; + + class WpADOUser : public WpOLEBase<_ADOUser> + { + public: + WpADOUser(_ADOUser* pInt=NULL) : WpOLEBase<_ADOUser>(pInt){} + + inline WpADOUser& operator=(const WpADOUser& rhs) + {WpOLEBase<_ADOUser>::operator=(rhs); return *this;} + + void Create(); + + ::rtl::OUString get_Name() const + { + BSTR aBSTR; + pInterface->get_Name(&aBSTR); + rtl::OUString sRetStr((sal_Unicode*)aBSTR); + SysFreeString(aBSTR); + return sRetStr; + } + + void put_Name(const ::rtl::OUString& _rName) + { + pInterface->put_Name(SysAllocString(_rName.getStr())); + } + + sal_Bool ChangePassword(const ::rtl::OUString& _rPwd,const ::rtl::OUString& _rNewPwd) + { + return SUCCEEDED(pInterface->ChangePassword(SysAllocString(_rPwd.getStr()),SysAllocString(_rNewPwd.getStr()))); + } + + ADOGroups* get_Groups() + { + ADOGroups* pRet = NULL; + pInterface->get_Groups(&pRet); + return pRet; + } + + RightsEnum GetPermissions( + /* [in] */ const OLEVariant& Name, + /* [in] */ ObjectTypeEnum ObjectType) + { + RightsEnum Rights; + OLEVariant ObjectTypeId; + ObjectTypeId.setNoArg(); + pInterface->GetPermissions(Name,ObjectType,ObjectTypeId,&Rights); + return Rights; + } + + sal_Bool SetPermissions( + /* [in] */ const OLEVariant& Name, + /* [in] */ ObjectTypeEnum ObjectType, + /* [in] */ ActionEnum Action, + /* [in] */ RightsEnum Rights) + { + OLEVariant ObjectTypeId; + ObjectTypeId.setNoArg(); + return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId)); + } + }; + } +} +#endif // _CONNECTIVITY_ADO_AWRAPADOX_HXX_ + diff --git a/connectivity/source/inc/ado/adoimp.hxx b/connectivity/source/inc/ado/adoimp.hxx new file mode 100644 index 000000000000..bc05046dce9a --- /dev/null +++ b/connectivity/source/inc/ado/adoimp.hxx @@ -0,0 +1,146 @@ +/************************************************************************* + * + * $RCSfile: adoimp.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ADOIMP_HXX_ +#define _CONNECTIVITY_ADO_ADOIMP_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_ +#include <com/sun/star/sdbc/SQLException.hpp> +#endif + +struct ADOConnection; +enum DataTypeEnum; +namespace connectivity +{ + namespace ado + { + + class ADOS + { + public: + // Auch hier: BSTR mit SysFreeString() freigeben! + inline static BSTR GetKeyStr() + { + return (BSTR)::rtl::OUString::createFromAscii("gxwaezucfyqpwjgqbcmtsncuhwsnyhiohwxz").getStr(); + } + + static const CLSID CLSID_ADOCATALOG_25; + static const IID IID_ADOCATALOG_25; + + static const CLSID CLSID_ADOCONNECTION_21; + static const IID IID_ADOCONNECTION_21; + + static const CLSID CLSID_ADOCOMMAND_21; + static const IID IID_ADOCOMMAND_21; + + static const CLSID CLSID_ADORECORDSET_21; + static const IID IID_ADORECORDSET_21; + + static const CLSID CLSID_ADOINDEX_25; + static const IID IID_ADOINDEX_25; + + static const CLSID CLSID_ADOCOLUMN_25; + static const IID IID_ADOCOLUMN_25; + + static const CLSID CLSID_ADOKEY_25; + static const IID IID_ADOKEY_25; + + static const CLSID CLSID_ADOTABLE_25; + static const IID IID_ADOTABLE_25; + + static const CLSID CLSID_ADOGROUP_25; + static const IID IID_ADOGROUP_25; + + static const CLSID CLSID_ADOUSER_25; + static const IID IID_ADOUSER_25; + + static const CLSID CLSID_ADOVIEW_25; + static const IID IID_ADOVIEW_25; + + 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); + }; + + + } +} + +#define ADO_PROP(ItemName) \ + WpADOProperty aProp(aProps.GetItem(ItemName)); \ + OLEVariant aVar; \ + if(aProp.IsValid()) \ + aVar = aProp.GetValue(); \ + else \ + ADOS::ThrowException(*m_pADOConnection,*this); + + +#define ADO_GETFIELD(Name) \ + ADOFields* pFields = NULL; \ + m_pRecordSet->get_Fields(&pFields); \ + WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(pFields); \ + WpADOField aField(aFields.GetItem(Name-1)); \ + if(!aField.IsValid()) \ + throw ::com::sun::star::sdbc::SQLException(STAT_INVALID_INDEX,*this,::rtl::OUString::createFromAscii("07009"),0,::com::sun::star::uno::Any()); + + +#endif //_CONNECTIVITY_ADO_ADOIMP_HXX_ + + diff --git a/connectivity/source/inc/dbase/DCatalog.hxx b/connectivity/source/inc/dbase/DCatalog.hxx new file mode 100644 index 000000000000..03fbce362706 --- /dev/null +++ b/connectivity/source/inc/dbase/DCatalog.hxx @@ -0,0 +1,85 @@ +/************************************************************************* + * + * $RCSfile: DCatalog.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_CATALOG_HXX_ +#define _CONNECTIVITY_DBASE_CATALOG_HXX_ + +#ifndef _CONNECTIVITY_FILE_CATALOG_HXX_ +#include "file/FCatalog.hxx" +#endif + +namespace connectivity +{ + namespace dbase + { + class ODbaseConnection; + class ODbaseCatalog : public file::OFileCatalog + { + public: + virtual void refreshTables(); + + public: + ODbaseCatalog(ODbaseConnection* _pCon); + }; + } +} +#endif // _CONNECTIVITY_DBASE_CATALOG_HXX_ + diff --git a/connectivity/source/inc/dbase/DColumns.hxx b/connectivity/source/inc/dbase/DColumns.hxx new file mode 100644 index 000000000000..0f5005a8689d --- /dev/null +++ b/connectivity/source/inc/dbase/DColumns.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * $RCSfile: DColumns.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_COLUMNS_HXX_ +#define _CONNECTIVITY_DBASE_COLUMNS_HXX_ + +#ifndef _CONNECTIVITY_FILE_COLUMNS_HXX_ +#include "file/FColumns.hxx" +#endif + +namespace connectivity +{ + namespace dbase + { + class ODbaseColumns : public file::OColumns + { + protected: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + ODbaseColumns(file::OFileTable* _pTable, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector + ) : file::OColumns(_pTable,_rMutex,_rVector) + {} + + }; + } +} +#endif // _CONNECTIVITY_DBASE_COLUMNS_HXX_ + diff --git a/connectivity/source/inc/dbase/DConnection.hxx b/connectivity/source/inc/dbase/DConnection.hxx new file mode 100644 index 000000000000..0b40007042d9 --- /dev/null +++ b/connectivity/source/inc/dbase/DConnection.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * $RCSfile: DConnection.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_DCONNECTION_HXX_ +#define _CONNECTIVITY_DBASE_DCONNECTION_HXX_ + +#ifndef _CONNECTIVITY_FILE_OCONNECTION_HXX_ +#include "file/FConnection.hxx" +#endif + +namespace connectivity +{ + namespace dbase + { + class ODriver; + class ODbaseConnection : public file::OConnection + { + public: + ODbaseConnection(ODriver* _pDriver); + virtual ~ODbaseConnection(); + + // XServiceInfo + DECLARE_SERVICE_INFO(); + + // XConnection + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog(); + }; + } +} +#endif // _CONNECTIVITY_DBASE_DCONNECTION_HXX_ + diff --git a/connectivity/source/inc/dbase/DDatabaseMetaData.hxx b/connectivity/source/inc/dbase/DDatabaseMetaData.hxx new file mode 100644 index 000000000000..5efc9595537e --- /dev/null +++ b/connectivity/source/inc/dbase/DDatabaseMetaData.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * $RCSfile: DDatabaseMetaData.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ODATABASEMETADATA_HXX_ +#define _CONNECTIVITY_DBASE_ODATABASEMETADATA_HXX_ + +#ifndef _CONNECTIVITY_FILE_ODATABASEMETADATA_HXX_ +#include "file/FDatabaseMetaData.hxx" +#endif + +namespace connectivity +{ + namespace dbase + { + //************************************************************** + //************ Class: java.sql.DatabaseMetaDataDate + //************************************************************** + + class ODbaseDatabaseMetaData : public file::ODatabaseMetaData + { + public: + + ODbaseDatabaseMetaData(file::OConnection* _pCon); + ~ODbaseDatabaseMetaData(); + + // virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_DBASE_ODATABASEMETADATA_HXX_ + diff --git a/connectivity/source/inc/dbase/DDatabaseMetaDataResultSet.hxx b/connectivity/source/inc/dbase/DDatabaseMetaDataResultSet.hxx new file mode 100644 index 000000000000..b071370f0b69 --- /dev/null +++ b/connectivity/source/inc/dbase/DDatabaseMetaDataResultSet.hxx @@ -0,0 +1,253 @@ +/************************************************************************* + * + * $RCSfile: DDatabaseMetaDataResultSet.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ADATABASEMETADATARESULTSET_HXX_ +#define _CONNECTIVITY_FILE_ADATABASEMETADATARESULTSET_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_ +#include <com/sun/star/sdbc/XCloseable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_ +#include <com/sun/star/sdbc/XColumnLocate.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ +#include <com/sun/star/util/XCancellable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_ +#include <com/sun/star/sdbc/XRowUpdate.hpp> +#endif +#ifndef _CPPUHELPER_COMPBASE7_HXX_ +#include <cppuhelper/compbase7.hxx> +#endif +#ifndef _UNOTOOLS_PROPERTY_ARRAY_HELPER_HXX_ +#include <unotools/proparrhlp.hxx> +#endif +#ifndef _CONNECTIVITY_FILE_ASTATEMENT_HXX_ +#include "file/FStatement.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CONNECTIVITY_SIMPLEPROPERTYCONTAINER_HXX_ +#include "connectivity/simplepropertycontainer.hxx" +#endif + +namespace connectivity +{ + namespace file + { + namespace ::com::sun::star::sdbc = ::com::sun::star::sdbc; + namespace ::com::sun::star::beans = ::com::sun::star::beans; + namespace ::com::sun::star::util = ::com::sun::star::util; + + class ODatabaseMetaDataResultSetMetaData; + /* + ** java_sql_ResultSet + */ + typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::sdbc::XResultSet, + ::com::sun::star::sdbc::XRow, + ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + ::com::sun::star::util::XCancellable, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::sdbc::XCloseable, + ::com::sun::star::sdbc::XColumnLocate> ODatabaseMetaDataResultSet_BASE; + + DECLARE_STL_VECTOR(::com::sun::star::uno::Any,ORow); + DECLARE_STL_VECTOR(ORow, ORows); + + class ODatabaseMetaDataResultSet : public OBaseMutex, + public ODatabaseMetaDataResultSet_BASE, + public connectivity::OSimplePropertyContainer, + public ::utl::OPropertyArrayUsageHelper<ODatabaseMetaDataResultSet> + { + + + ORows m_aRows; + ORowsIterator m_aRowsIter; + ::com::sun::star::uno::WeakReferenceHelper m_aStatement; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; + sal_Int32 m_nRowPos; + sal_Int32 m_nColPos; + + sal_Int32 m_nFetchSize; + sal_Int32 m_nResultSetType; + sal_Int32 m_nFetchDirection; + sal_Int32 m_nResultSetConcurrency; + + sal_Bool m_bWasNull; + sal_Bool m_bBOF; + + void construct(); + + protected: + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + public: + DECLARE_CTY_DEFAULTS(ODatabaseMetaDataResultSet_BASE); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + ODatabaseMetaDataResultSet( ); + ~ODatabaseMetaDataResultSet(); + + void setRows(const ORows& _rRows) { m_aRows = _rRows; } + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) + { + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); + } + // XResultSet + virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XColumnLocate + virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + void setCatalogsMap(); + void setSchemasMap(); + void setColumnPrivilegesMap(); + void setColumnsMap(); + void setTablesMap(); + void setTableTypes(); + void setProcedureColumnsMap(); + void setProceduresMap(); + void setExportedKeysMap(); + void setImportedKeysMap(); + void setPrimaryKeysMap(); + void setIndexInfoMap(); + void setTablePrivilegesMap(); + void setCrossReferenceMap(); + void setTypeInfoMap(); + }; + } + +} +#endif // _CONNECTIVITY_FILE_ADATABASEMETADATARESULTSET_HXX_ + diff --git a/connectivity/source/inc/dbase/DDatabaseMetaDataResultSetMetaData.hxx b/connectivity/source/inc/dbase/DDatabaseMetaDataResultSetMetaData.hxx new file mode 100644 index 000000000000..c63c46a3bc68 --- /dev/null +++ b/connectivity/source/inc/dbase/DDatabaseMetaDataResultSetMetaData.hxx @@ -0,0 +1,150 @@ +/************************************************************************* + * + * $RCSfile: DDatabaseMetaDataResultSetMetaData.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ADATABASEMETADATARESULTSETMETADATA_HXX_ +#define _CONNECTIVITY_FILE_ADATABASEMETADATARESULTSETMETADATA_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _VECTOR_ +#include <vector> +#endif +#ifndef _CONNECTIVITY_FILE_ADATABASEMETADATARESULTSET_HXX_ +#include "file/FDatabaseMetaDataResultSet.hxx" +#endif +#ifndef _CONNECTIVITY_COLUMN_HXX_ +#include "OColumn.hxx" +#endif + +namespace connectivity +{ + namespace file + { + //************************************************************** + //************ Class: ResultSetMetaData + //************************************************************** + typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> ODatabaseMetaResultSetMetaData_BASE; + + class ODatabaseMetaDataResultSetMetaData : public ODatabaseMetaResultSetMetaData_BASE + { + friend class ODatabaseMetaDataResultSet; + + ::std::vector<sal_Int32> m_vMapping; // when not every column is needed + ::std::map<sal_Int32,connectivity::OColumn> m_mColumns; + ::std::map<sal_Int32,connectivity::OColumn>::const_iterator m_mColumnsIter; + + sal_Int32 m_nColCount; + + protected: + void setColumnPrivilegesMap(); + void setColumnsMap(); + void setTablesMap(); + void setProcedureColumnsMap(); + void setPrimaryKeysMap(); + void setIndexInfoMap(); + void setTablePrivilegesMap(); + void setCrossReferenceMap(); + void setTypeInfoMap(); + void setProceduresMap(); + void setTableTypes(); + public: + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + ODatabaseMetaDataResultSetMetaData( ODatabaseMetaDataResultSet* _pRes) + : m_nColCount(0) + { + } + ~ODatabaseMetaDataResultSetMetaData(); + + /// Avoid ambigous cast error from the compiler. + inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw() + { return this; } + + virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_FILE_ADATABASEMETARESULTSETMETADATA_HXX_ + + diff --git a/connectivity/source/inc/dbase/DDriver.hxx b/connectivity/source/inc/dbase/DDriver.hxx new file mode 100644 index 000000000000..0f84642999e1 --- /dev/null +++ b/connectivity/source/inc/dbase/DDriver.hxx @@ -0,0 +1,100 @@ +/************************************************************************* + * + * $RCSfile: DDriver.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_DDRIVER_HXX_ +#define _CONNECTIVITY_DBASE_DDRIVER_HXX_ + +#ifndef _CPPUHELPER_COMPBASE2_HXX_ +#include <cppuhelper/compbase2.hxx> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_ODRIVER_HXX_ +#include "file/FDriver.hxx" +#endif + +namespace connectivity +{ + namespace dbase + { + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ); + + class ODriver : public file::OFileDriver + { + public: + ODriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) : file::OFileDriver(_rxFactory){} + + // XInterface + static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException); + // static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException); + + ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + // XDriver + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } + +} +#endif //_CONNECTIVITY_DBASE_DDRIVER_HXX_ + diff --git a/connectivity/source/inc/dbase/DIndex.hxx b/connectivity/source/inc/dbase/DIndex.hxx new file mode 100644 index 000000000000..9ef8deb91c74 --- /dev/null +++ b/connectivity/source/inc/dbase/DIndex.hxx @@ -0,0 +1,201 @@ +/************************************************************************* + * + * $RCSfile: DIndex.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_INDEX_HXX_ +#define _CONNECTIVITY_DBASE_INDEX_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_INDEX_HXX_ +#include "connectivity/sdbcx/VIndex.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif +#ifndef _CONNECTIVITY_DBASE_TABLE_HXX_ +#include "dbase/DTable.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_INDEXNODE_HXX_ +#include "dbase/dindexnode.hxx" +#endif + +#define dBASE_III_GROUP "dBase III" + +namespace connectivity +{ + namespace dbase + { + class OIndexIterator; + class ONDXKey; + + typedef sdbcx::OIndex ODbaseIndex_BASE; + typedef file::OBoolOperator OBoolOperator_BASE; + typedef file::OOperand OOperand_BASE; + + class ODbaseIndex : public ODbaseIndex_BASE, + public com::sun::star::lang::XUnoTunnel + { + friend SvStream& operator << (SvStream &rStream, ODbaseIndex&); + friend SvStream& operator >> (SvStream &rStream, ODbaseIndex&); + + friend class ONDXNode; + friend class ONDXPage; + friend class ONDXPagePtr; + friend class OIndexIterator; + + public: + //================================================================== + // Kopfsatz-Struktur, verbleibt im Speicher + //================================================================== + struct NDXHeader + { + sal_uInt32 db_rootpage; /* Position der Rootpage */ + sal_uInt32 db_pagecount; /* Anzahl Pages */ + sal_uInt8 db_frei[4]; /* reserviert */ + sal_uInt16 db_keylen; /* Laenge des Schluessels */ + sal_uInt16 db_maxkeys; /* Max. # keys pro Seite */ + sal_uInt16 db_keytype; /* Art des Schluessels + (0-Text) + (1-Numerisch) */ + sal_uInt16 db_keyrec; /* Laenge eines IndexSatzes + SatzNr + keylen */ + sal_uInt8 db_frei1[3]; /* reserviert */ + sal_uInt8 db_unique; /* eindeutig */ + char db_name[488]; /* index_name (Feldname) */ + }; + + private: + SvFileStream m_aFileStream; // Stream zum Lesen/Schreiben des Index + NDXHeader m_aHeader; + ONDXPageList m_aCollector; // Pool von nicht mehr bentigten Seiten + ONDXPagePtr m_aRoot, // Wurzel des b+ Baums + m_aCurLeaf; // aktuelles Blatt + USHORT m_nCurNode; // Position des aktuellen Knoten + + sal_uInt32 m_nPageCount, + m_nRootPage; + + ODbaseTable* m_pTable; + BOOL m_bUseCollector : 1; // Verwenden des GarbageCollectors + sal_Bool m_bUnique; + + sal_Bool openIndexFile(); + INetURLObject getEntry(); + public: + DECLARE_CTY_DEFAULTS( ODbaseIndex_BASE); + + ODbaseIndex(ODbaseTable* _pTable); + ODbaseIndex(ODbaseTable* _pTable,const NDXHeader& _aHeader,const ::rtl::OUString& _Name); + + virtual void refreshColumns(); + + //XInterface + virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type & rType ) throw(com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(com::sun::star::uno::RuntimeException); + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(com::sun::star::uno::RuntimeException); + static com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + const ODbaseTable* getTable() const { return m_pTable; } + const NDXHeader& getHeader() const { return m_aHeader; } + virtual OIndexIterator* createIterator(OBoolOperator_BASE* pOp, + const OOperand_BASE* pOperand = NULL); + + void SetRootPos(sal_uInt32 nPos) {m_nRootPage = nPos;} + void SetPageCount(sal_uInt32 nCount) {m_nPageCount = nCount;} + + sal_uInt32 GetRootPos() {return m_nRootPage;} + sal_uInt32 GetPageCount() {return m_nPageCount;} + + BOOL IsText() const {return m_aHeader.db_keytype == 0;} + USHORT GetMaxNodes() const {return m_aHeader.db_maxkeys;} + + virtual BOOL Insert(sal_uInt32 nRec, const OFileValue_BASE& rValue); + virtual BOOL Update(sal_uInt32 nRec, const OFileValue_BASE&, const OFileValue_BASE&); + virtual BOOL Delete(sal_uInt32 nRec, const OFileValue_BASE& rValue); + virtual BOOL Find(sal_uInt32 nRec, const OFileValue_BASE& rValue); + + void createINFEntry(); + BOOL CreateImpl(); + BOOL DropImpl(); + + DECLARE_SERVICE_INFO(); + protected: + + ONDXPage* CreatePage(sal_uInt32 nPagePos, ONDXPage* pParent = NULL, BOOL bLoad = FALSE); + void Collect(ONDXPage*); + ONDXPagePtr getRoot(); + + sal_Bool isUnique() const { return m_bUnique; } + BOOL UseCollector() const {return m_bUseCollector;} + // Tree operationen + void Insert(ONDXPagePtr aCurPage, ONDXNode& rNode); + void Release(BOOL bSave = TRUE); + BOOL ConvertToKey(ONDXKey* rKey, sal_uInt32 nRec, const OFileValue_BASE& rValue); + }; + + SvStream& operator << (SvStream &rStream, ODbaseIndex&); + SvStream& operator >> (SvStream &rStream, ODbaseIndex&); + } +} + +#endif // _CONNECTIVITY_DBASE_INDEX_HXX_ + + diff --git a/connectivity/source/inc/dbase/DIndexColumns.hxx b/connectivity/source/inc/dbase/DIndexColumns.hxx new file mode 100644 index 000000000000..faa46465c0cc --- /dev/null +++ b/connectivity/source/inc/dbase/DIndexColumns.hxx @@ -0,0 +1,99 @@ +/************************************************************************* + * + * $RCSfile: DIndexColumns.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_INDEXCOLUMNS_HXX_ +#define _CONNECTIVITY_DBASE_INDEXCOLUMNS_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_INDEX_HXX_ +#include "dbase/DIndex.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_TABLE_HXX_ +#include "dbase/DTable.hxx" +#endif + +namespace connectivity +{ + namespace dbase + { + class ODbaseIndexColumns : public sdbcx::OCollection + { + ODbaseIndex* m_pIndex; + protected: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + ODbaseIndexColumns( ODbaseIndex* _pIndex, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector) + : sdbcx::OCollection(*_pIndex,_pIndex->getTable()->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(),_rMutex,_rVector) + , m_pIndex(_pIndex) + {} + + }; + } +} +#endif // _CONNECTIVITY_DBASE_INDEXCOLUMNS_HXX_ + + diff --git a/connectivity/source/inc/dbase/DIndexIter.hxx b/connectivity/source/inc/dbase/DIndexIter.hxx new file mode 100644 index 000000000000..1403777b722e --- /dev/null +++ b/connectivity/source/inc/dbase/DIndexIter.hxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * $RCSfile: DIndexIter.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_INDEXITER_HXX_ +#define _CONNECTIVITY_DBASE_INDEXITER_HXX_ + +#ifndef _CONNECTIVITY_FILE_FCODE_HXX_ +#include "file/fcode.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_INDEX_HXX_ +#include "dbase/DIndex.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_INDEXNODE_HXX_ +#include "dbase/dindexnode.hxx" +#endif + +namespace connectivity +{ + namespace dbase + { + //================================================================== + // IndexIterator + //================================================================== + class OIndexIterator + { + protected: + file::OBoolOperator* m_pOperator; + const file::OOperand* m_pOperand; + ODbaseIndex* m_pIndex; + ONDXPagePtr m_aRoot, + m_aCurLeaf; + USHORT m_nCurNode; + + protected: + ULONG Find(BOOL bFirst); + ULONG GetCompare(BOOL bFirst); + ULONG GetLike(BOOL bFirst); + ULONG GetNull(BOOL bFirst); + ULONG GetNotNull(BOOL bFirst); + + ONDXKey* GetFirstKey(ONDXPage* pPage, + const file::OOperand& rKey); + ONDXKey* GetNextKey(); + ODbaseIndex* GetIndex() const {return m_pIndex;} + + + public: + OIndexIterator(ODbaseIndex* pInd, + file::OBoolOperator* pOp, + const file::OOperand* pOper) + :m_pOperator(pOp) + ,m_pOperand(pOper) + ,m_pIndex(pInd) + ,m_nCurNode(NODE_NOTFOUND) + { + pInd->acquire(); + } + + virtual ~OIndexIterator(); + ULONG First(); + ULONG Next(); + + }; + } +} +#endif // _CONNECTIVITY_DBASE_INDEXITER_HXX_ + diff --git a/connectivity/source/inc/dbase/DIndexPage.hxx b/connectivity/source/inc/dbase/DIndexPage.hxx new file mode 100644 index 000000000000..cd39e3c7e66f --- /dev/null +++ b/connectivity/source/inc/dbase/DIndexPage.hxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * $RCSfile: DIndexPage.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_INDEXPAGE_HXX_ +#define _CONNECTIVITY_DBASE_INDEXPAGE_HXX_ + +//#ifndef _REF_HXX +//#include <tools/ref.hxx> +//#endif +#ifndef _VOS_REF_HXX_ +#include <vos/ref.hxx> +#endif +#ifndef _STREAM_HXX +#include <tools/stream.hxx> +#endif +#ifndef _VECTOR_ +#include <vector> +#endif +//#ifndef _CONNECTIVITY_FILE_FCODE_HXX_ +//#include "file/fcode.hxx" +//#endif +//#ifndef _CONNECTIVITY_DBASE_INDEXNODE_HXX_ +//#include "dbase/dindexnode.hxx" +//#endif + +#if 0 +namespace connectivity +{ + namespace dbase + { + //================================================================== + // Index Seitenverweis + //================================================================== + // SV_DECL_REF(ONDXPage); // Basisklasse da weitere Informationen gehalten werden muessen + + class ONDXPage; + typedef vos::ORef<ONDXPage> ONDXPagePtr_BASE; + + class ONDXPagePtr : public ONDXPagePtr_BASE //ONDXPageRef + { + friend SvStream& operator << (SvStream &rStream, const ONDXPagePtr&); + friend SvStream& operator >> (SvStream &rStream, ONDXPagePtr&); + + UINT32 nPagePos; // Position in der Indexdatei + + public: + ONDXPagePtr(UINT32 nPos = 0):nPagePos(nPos){} + ONDXPagePtr(const ONDXPagePtr& rRef); + ONDXPagePtr(ONDXPage* pRefPage); + + ONDXPagePtr& operator=(const ONDXPagePtr& rRef); + ONDXPagePtr& operator=(ONDXPage* pPageRef); + + UINT32 GetPagePos() const {return nPagePos;} + BOOL HasPage() const {return nPagePos != 0;} + sal_Bool Is() const { return isValid(); } + void Clear() + { + unbind(); + } + }; + + SvStream& operator << (SvStream &rStream, const ONDXPagePtr&); + SvStream& operator >> (SvStream &rStream, ONDXPagePtr&); + } +} +#endif +#endif // _CONNECTIVITY_DBASE_INDEXPAGE_HXX_ + diff --git a/connectivity/source/inc/dbase/DIndexes.hxx b/connectivity/source/inc/dbase/DIndexes.hxx new file mode 100644 index 000000000000..708e8ab47e00 --- /dev/null +++ b/connectivity/source/inc/dbase/DIndexes.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * $RCSfile: DIndexes.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_INDEXES_HXX_ +#define _CONNECTIVITY_DBASE_INDEXES_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_TABLE_HXX_ +#include "dbase/DTable.hxx" +#endif + +namespace connectivity +{ + namespace dbase + { + class ODbaseTable; + + typedef sdbcx::OCollection ODbaseIndexes_BASE; + + class ODbaseIndexes : public ODbaseIndexes_BASE + { + ODbaseTable* m_pTable; + protected: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + ODbaseIndexes(ODbaseTable* _pTable, ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector) : ODbaseIndexes_BASE(*_pTable,_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(),_rMutex,_rVector) + , m_pTable(_pTable) + {} + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + }; + } +} +#endif // _CONNECTIVITY_DBASE_INDEXES_HXX_ + diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx new file mode 100644 index 000000000000..32cd7cd969ae --- /dev/null +++ b/connectivity/source/inc/dbase/DTable.hxx @@ -0,0 +1,191 @@ +/************************************************************************* + * + * $RCSfile: DTable.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:25 $ + * + * 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_ +#define _CONNECTIVITY_DBASE_TABLE_HXX_ + +#ifndef _CONNECTIVITY_FILE_TABLE_HXX_ +#include "file/FTable.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _FSYS_HXX //autogen +#include <tools/fsys.hxx> +#endif + + +namespace connectivity +{ + namespace dbase + { + typedef file::OFileTable ODbaseTable_BASE; + class ODbaseConnection; + + typedef ::std::map< ::rtl::OUString, + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed>, utl::UStringMixLess > OContainer; + + class ODbaseTable : public ODbaseTable_BASE + { + // der Typ einer dBase datei wird mit dem ersten Byte bestimmt + public: + enum DBFType { dBaseIII = 0x03, + dBaseIV = 0x04, + dBaseV = 0x05, + dBaseFS = 0x43, + dBaseFSMemo = 0xB3, + dBaseIIIMemo = 0x83, + dBaseIVMemo = 0x8B, + dBaseIVMemoSQL = 0x8E, + FoxProMemo = 0xF5 + }; + enum DBFMemoType { MemodBaseIII = 0, + MemodBaseIV, + MemoFoxPro + }; + + private: + struct DBFHeader { /* Kopfsatz-Struktur */ + DBFType db_typ; /* Dateityp */ + BYTE db_aedat[3]; /* Datum der letzen Aenderung */ + /* JJ MM TT */ + ULONG db_anz; /* Anzahl der Saetze */ + USHORT db_kopf; /* laenge Kopfsatz-Struktur */ + USHORT db_slng; /* laenge der Daten-Saetze */ + BYTE db_frei[20]; /* reserviert */ + }; + struct DBFColumn { /* Feldbezeichner */ + BYTE db_fnm[11]; /* Feldname */ + BYTE db_typ; /* Feldtyp */ + ULONG db_adr; /* Feldadresse */ + BYTE db_flng; /* Feldlaenge */ + BYTE db_dez; /* Dezimalstellen fuer N */ + BYTE db_frei2[14]; /* reserviert */ + }; + struct DBFMemoHeader + { + DBFMemoType db_typ; /* Dateityp */ + UINT32 db_next; /* nchster freier Block */ + USHORT db_size; /* Blockgre: dBase 3 fest */ + }; + + DBFHeader m_aHeader; + DBFMemoHeader m_aMemoHeader; + SvFileStream m_aMemoStream; + + void readHeader(); + void fillColumns(); + BOOL CreateFile(const DirEntry& aFile, BOOL& bCreateMemo); + BOOL CreateMemoFile(const DirEntry& aFile); + BOOL HasMemoFields() const { return m_aHeader.db_typ > dBaseIV;} + BOOL ReadMemoHeader(); + BOOL ReadMemo(ULONG nBlockNo, file::OFileValue& aVariable); + + BOOL WriteMemo(file::OFileValue& aVariable, ULONG& rBlockNr); + BOOL WriteBuffer(); + BOOL UpdateBuffer(file::OValueVector& rRow, file::OValueRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols); + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet> isUniqueByColumnName(const ::rtl::OUString& _rColName); + void AllocBuffer(); + + void FileClose(); + public: + virtual void refreshColumns(); + virtual void refreshIndexes(); + + public: + // DECLARE_CTY_DEFAULTS( ODbaseTable_BASE); + ODbaseTable( ODbaseConnection* _pConnection); + ODbaseTable( ODbaseConnection* _pConnection, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description = ::rtl::OUString(), + const ::rtl::OUString& _SchemaName = ::rtl::OUString(), + const ::rtl::OUString& _CatalogName = ::rtl::OUString() + ); + + virtual sal_Int32 getCurrentLastPos() const {return m_aHeader.db_anz;} + virtual sal_Bool seekRow(FilePosition eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos); + virtual sal_Bool fetchRow(file::OValueRow _rRow,const OSQLColumns& _rCols, sal_Bool bRetrieveData); + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL disposing(void); + + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + BOOL DropImpl(); + BOOL CreateImpl(); + DirEntry getEntry(); + + virtual BOOL InsertRow(file::ORefAssignValues& rRow, BOOL bFlush,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols); + virtual BOOL DeleteRow(const OSQLColumns& _rCols); + virtual BOOL UpdateRow(file::OValueVector& rRow, file::OValueRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols); + }; + } +} +#endif // _CONNECTIVITY_DBASE_TABLE_HXX_ + diff --git a/connectivity/source/inc/dbase/DTables.hxx b/connectivity/source/inc/dbase/DTables.hxx new file mode 100644 index 000000000000..ec191e8ba091 --- /dev/null +++ b/connectivity/source/inc/dbase/DTables.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * $RCSfile: DTables.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_TABLES_HXX_ +#define _CONNECTIVITY_DBASE_TABLES_HXX_ + +#ifndef _CONNECTIVITY_FILE_TABLES_HXX_ +#include "file/FTables.hxx" +#endif + +namespace connectivity +{ + namespace dbase + { + // namespace ::com::sun::star::sdbcx = ::com::sun::star::sdbcx; + typedef file::OTables ODbaseTables_BASE; + + class ODbaseTables : public ODbaseTables_BASE + { + protected: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + ODbaseTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector) : ODbaseTables_BASE(_rMetaData,_rParent,_rMutex,_rVector) + {} + + // XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_DBASE_TABLES_HXX_ + diff --git a/connectivity/source/inc/dbase/dindexnode.hxx b/connectivity/source/inc/dbase/dindexnode.hxx new file mode 100644 index 000000000000..8f93ea1bce28 --- /dev/null +++ b/connectivity/source/inc/dbase/dindexnode.hxx @@ -0,0 +1,410 @@ +/************************************************************************* + * + * $RCSfile: dindexnode.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_INDEXNODE_HXX_ +#define _CONNECTIVITY_DBASE_INDEXNODE_HXX_ + +#ifndef _CONNECTIVITY_FILE_FCODE_HXX_ +#include "file/fcode.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_TABLE_HXX_ +#include "file/FTable.hxx" +#endif +#ifndef _CONNECTIVITY_DBASE_INDEXPAGE_HXX_ +#include "dbase/DIndexPage.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_VALUE_HXX_ +#include "file/FValue.hxx" +#endif + +namespace connectivity +{ + namespace dbase + { + + class ONDXNode; + class ODbaseIndex; + typedef file::OFileValue OFileValue_BASE; + //================================================================== + // Index Key + //================================================================== + typedef file::OOperand ONDXKey_BASE; + class ONDXKey : public ONDXKey_BASE + { + friend class ONDXNode; + UINT32 nRecord; /* Satzzeiger */ + OFileValue_BASE xValue; /* Schluesselwert */ + + public: + ONDXKey():nRecord(0){} + inline ONDXKey(const OFileValue_BASE& rVal, sal_Int32 eType, UINT32 nRec) + : ONDXKey_BASE(eType) + , nRecord(nRec) + , xValue(rVal) + {} + ONDXKey(const rtl::OUString& aStr, UINT32 nRec = 0) + : ONDXKey_BASE(::com::sun::star::sdbc::DataType::VARCHAR) + ,nRecord(nRec) + { + if (aStr.len()) + xValue = aStr; + } + ONDXKey(double aVal, UINT32 nRec = 0) + : ONDXKey_BASE(::com::sun::star::sdbc::DataType::DOUBLE) + ,nRecord(nRec) + ,xValue(aVal) + { + } + ONDXKey(UINT32 nRec) + : nRecord(nRec){} + inline ONDXKey(const ONDXKey& rKey); + + inline ONDXKey& operator= (const ONDXKey& rKey); + virtual void setValue(const ::com::sun::star::uno::Any& _rVal) + { + xValue = _rVal; + } + + virtual ::com::sun::star::uno::Any getValue() const + { + return xValue; + } + + UINT32 GetRecord() const {return nRecord;} + void ResetRecord() {nRecord = 0;} + + BOOL operator == (const ONDXKey& rKey) const; + BOOL operator != (const ONDXKey& rKey) const; + BOOL operator < (const ONDXKey& rKey) const; + BOOL operator <= (const ONDXKey& rKey) const; + BOOL operator > (const ONDXKey& rKey) const; + BOOL operator >= (const ONDXKey& rKey) const; + + BOOL Load (SvFileStream& rStream, BOOL bText); + BOOL Write(SvFileStream& rStream, BOOL bText); + + static BOOL IsText(sal_Int32 eType); + + private: + StringCompare Compare(const ONDXKey& rKey) const; + }; + + #define NODE_NOTFOUND 0xFFFF + + class ONDXPagePtr; + //================================================================== + // Index Seite + //================================================================== + class ONDXPage //: public SvRefBase + { + friend class ODbaseIndex; + + friend SvStream& operator << (SvStream &rStream, const ONDXPage&); + friend SvStream& operator >> (SvStream &rStream, ONDXPage&); + + UINT32 nPagePos; // Position in der Indexdatei + BOOL bModified : 1; + USHORT nCount; + + ONDXPagePtr *aParent, // VaterSeite + *aChild; // Zeiger auf rechte ChildPage + ODbaseIndex& rIndex; + ONDXNode* ppNodes; // array von Knoten + + oslInterlockedCount m_refCount; + + public: + void acquire() + { + osl_incrementInterlockedCount( &m_refCount ); + } + void release(); + + // Knoten Operationen + USHORT Count() const {return nCount;} + + BOOL Insert(ONDXNode& rNode, ULONG nRowsLeft = 0); + BOOL Insert(USHORT nIndex, ONDXNode& rNode); + BOOL Append(ONDXNode& rNode); + BOOL Delete(USHORT); + void Remove(USHORT); + void Release(BOOL bSave = TRUE); + void ReleaseFull(BOOL bSave = TRUE); + + // Aufteilen und Zerlegen + ONDXNode Split(ONDXPage& rPage); + void Merge(USHORT nParentNodePos, ONDXPagePtr xPage); + + // Zugriffsoperationen + ONDXNode& operator[] (USHORT nPos); + const ONDXNode& operator[] (USHORT nPos) const; + + BOOL IsRoot() const; + BOOL IsLeaf() const; + BOOL IsModified() const; + BOOL HasParent(); + BOOL HasChild() const; + + BOOL IsFull() const; + + UINT32 GetPagePos() const {return nPagePos;} + ONDXPagePtr& GetChild(ODbaseIndex* pIndex = 0); + + // Parent braucht nicht nachgeladen zu werden + ONDXPagePtr GetParent(); + ODbaseIndex& GetIndex() {return rIndex;} + const ODbaseIndex& GetIndex() const {return rIndex;} + + // Setzen des Childs, ueber Referenz, um die PagePos zu erhalten + void SetChild(ONDXPagePtr aCh); + void SetParent(ONDXPagePtr aPa); + + USHORT Search(const ONDXKey& rSearch); + USHORT Search(const ONDXPage* pPage); + void SearchAndReplace(const ONDXKey& rSearch, ONDXKey& rReplace); + + protected: + ONDXPage(ODbaseIndex& rIndex, ULONG nPos, ONDXPage* = NULL); + ~ONDXPage(); + + virtual void QueryDelete(); + + void SetModified(BOOL bMod) {bModified = bMod;} + void SetPagePos(UINT32 nPage) {nPagePos = nPage;} + + BOOL Find(const ONDXKey&); // rek. Abstieg + USHORT FindPos(const ONDXKey& rKey) const; + + #ifdef DEBUG + void PrintPage(); + #endif + }; + + //================================================================== + // Index Seitenverweis + //================================================================== + // SV_DECL_REF(ONDXPage); // Basisklasse da weitere Informationen gehalten werden muessen + typedef vos::ORef<ONDXPage> ONDXPagePtr_BASE; + + class ONDXPagePtr : public ONDXPagePtr_BASE //ONDXPageRef + { + friend SvStream& operator << (SvStream &rStream, const ONDXPagePtr&); + friend SvStream& operator >> (SvStream &rStream, ONDXPagePtr&); + + UINT32 nPagePos; // Position in der Indexdatei + + public: + ONDXPagePtr(UINT32 nPos = 0):nPagePos(nPos){} + ONDXPagePtr(const ONDXPagePtr& rRef); + ONDXPagePtr(ONDXPage* pRefPage); + + ONDXPagePtr& operator=(const ONDXPagePtr& rRef); + ONDXPagePtr& operator=(ONDXPage* pPageRef); + + UINT32 GetPagePos() const {return nPagePos;} + BOOL HasPage() const {return nPagePos != 0;} + sal_Bool Is() const { return isValid(); } + void Clear() + { + unbind(); + } + }; + + SvStream& operator << (SvStream &rStream, const ONDXPagePtr&); + SvStream& operator >> (SvStream &rStream, ONDXPagePtr&); + + inline BOOL ONDXPage::IsRoot() const {return !aParent->Is();} + inline BOOL ONDXPage::IsLeaf() const {return !aChild->HasPage();} + inline BOOL ONDXPage::IsModified() const {return bModified;} + inline BOOL ONDXPage::HasParent() {return aParent->Is();} + inline BOOL ONDXPage::HasChild() const {return aChild->HasPage();} + inline ONDXPagePtr ONDXPage::GetParent() {return *aParent;} + + inline void ONDXPage::SetParent(ONDXPagePtr aPa = ONDXPagePtr()) + { *aParent = aPa;} + + inline void ONDXPage::SetChild(ONDXPagePtr aCh = ONDXPagePtr()) + { + *aChild = aCh; + if (aChild->Is()) + (*aChild)->SetParent(this); + } + SvStream& operator >> (SvStream &rStream, ONDXPage& rPage); + SvStream& operator << (SvStream &rStream, const ONDXPage& rPage); + + + typedef ::std::vector<ONDXPage*> ONDXPageList; + + //================================================================== + // Index Knoten + //================================================================== + class ONDXNode + { + friend class ONDXPage; + ONDXPagePtr aChild; /* naechster Seitenverweis */ + ONDXKey aKey; + + public: + ONDXNode(){} + ONDXNode(const ONDXKey& rKey, + ONDXPagePtr aPagePtr = ONDXPagePtr()) + :aKey(rKey), aChild(aPagePtr) {} + + // verweist der Knoten auf eine Seite + BOOL HasChild() const {return aChild.HasPage();} + // Ist ein Index angegeben, kann gegebenfalls die Seite nachgeladen werden + ONDXPagePtr& GetChild(ODbaseIndex* pIndex = NULL, ONDXPage* = NULL); + + const ONDXKey& GetKey() const {return aKey;} + ONDXKey& GetKey() {return aKey;} + + // Setzen des Childs, ueber Referenz, um die PagePos zu erhalten + void SetChild(ONDXPagePtr aCh = ONDXPagePtr(), ONDXPage* = NULL); + void SetKey(ONDXKey& rKey) {aKey = rKey;} + + void Write(SvStream &rStream, const ONDXPage& rPage) const; + void Read(SvStream &rStream, ODbaseIndex&); + }; + //================================================================== + // inline implementation + //================================================================== +// inline ONDXKey::ONDXKey(const OFileValue_BASE& rVal, sal_Int32 eType, UINT32 nRec) +// : ONDXKey_BASE(eType) +// , nRecord(nRec),xValue(rVal) +// { +// } + + +// inline ONDXKey::ONDXKey(const rtl::OUString& aStr, UINT32 nRec) +// : ONDXKey_BASE(::com::sun::star::sdbc::DataType::VARCHAR) +// ,nRecord(nRec) +// { +// if (aStr.len()) +// xValue = aStr; +// } + +// inline ONDXKey::ONDXKey(double aVal, UINT32 nRec) +// : ONDXKey_BASE(::com::sun::star::sdbc::DataType::DOUBLE) +// ,nRecord(nRec) +// ,xValue(aVal) +// { +// } + +// inline ONDXKey::ONDXKey(UINT32 nRec) +// :nRecord(nRec) +// { +// } + + inline ONDXKey::ONDXKey(const ONDXKey& rKey) + : ONDXKey_BASE(rKey.getDBType()) + ,nRecord(rKey.nRecord),xValue(rKey.xValue) + { + } + + inline ONDXKey& ONDXKey::operator=(const ONDXKey& rKey) + { + xValue = rKey.xValue; + nRecord = rKey.nRecord; + m_eDBType = rKey.getDBType(); + return *this; + } + + inline BOOL ONDXKey::operator == (const ONDXKey& rKey) const + { + return Compare(rKey) == COMPARE_EQUAL; + } + inline BOOL ONDXKey::operator != (const ONDXKey& rKey) const + { + return !operator== (rKey); + } + inline BOOL ONDXKey::operator < (const ONDXKey& rKey) const + { + return Compare(rKey) == COMPARE_LESS; + } + inline BOOL ONDXKey::operator > (const ONDXKey& rKey) const + { + return Compare(rKey) == COMPARE_GREATER; + } + inline BOOL ONDXKey::operator <= (const ONDXKey& rKey) const + { + return !operator > (rKey); + } + inline BOOL ONDXKey::operator >= (const ONDXKey& rKey) const + { + return !operator< (rKey); + } + + inline void ONDXNode::SetChild(ONDXPagePtr aCh, ONDXPage* pParent) + { + aChild = aCh; + if (aChild.Is()) + aChild->SetParent(pParent); + } + + } + +} + + + + +#endif // _CONNECTIVITY_DBASE_INDEXNODE_HXX_ + + diff --git a/connectivity/source/inc/file/FCatalog.hxx b/connectivity/source/inc/file/FCatalog.hxx new file mode 100644 index 000000000000..259ea76cf139 --- /dev/null +++ b/connectivity/source/inc/file/FCatalog.hxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * $RCSfile: FCatalog.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_ +#define _CONNECTIVITY_FILE_CATALOG_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_CATALOG_HXX_ +#include "connectivity/sdbcx/VCatalog.hxx" +#endif + +namespace connectivity +{ + namespace file + { + class OConnection; + class OFileCatalog : public connectivity::sdbcx::OCatalog + { + protected: + OConnection* m_pConnection; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + + public: + virtual void refreshTables(); + virtual void refreshViews(){} + virtual void refreshGroups(){} + virtual void refreshUsers(){} + + public: + OFileCatalog(OConnection* _pCon); + + OConnection* getConnection() { return m_pConnection; } + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + }; + } +} +#endif // _CONNECTIVITY_FILE_CATALOG_HXX_ + diff --git a/connectivity/source/inc/file/FColumns.hxx b/connectivity/source/inc/file/FColumns.hxx new file mode 100644 index 000000000000..445482790c37 --- /dev/null +++ b/connectivity/source/inc/file/FColumns.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * $RCSfile: FColumns.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_COLUMNS_HXX_ +#define _CONNECTIVITY_FILE_COLUMNS_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_ +#include "connectivity/sdbcx/IRefreshable.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_TABLE_HXX_ +#include "file/FTable.hxx" +#endif + +namespace connectivity +{ + namespace file + { + class OColumns : public sdbcx::OCollection + { + protected: + OFileTable* m_pTable; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + OColumns( OFileTable* _pTable, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector + ) : sdbcx::OCollection(*_pTable,_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(),_rMutex,_rVector) + ,m_pTable(_pTable) + {} + + }; + } +} +#endif // _CONNECTIVITY_FILE_COLUMNS_HXX_ + diff --git a/connectivity/source/inc/file/FConnection.hxx b/connectivity/source/inc/file/FConnection.hxx new file mode 100644 index 000000000000..dc9821ff2c33 --- /dev/null +++ b/connectivity/source/inc/file/FConnection.hxx @@ -0,0 +1,213 @@ +/************************************************************************* + * + * $RCSfile: FConnection.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_OCONNECTION_HXX_ +#define _CONNECTIVITY_FILE_OCONNECTION_HXX_ + +#ifndef _CPPUHELPER_COMPBASE3_HXX_ +#include <cppuhelper/compbase3.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_ +#include <com/sun/star/ucb/XContent.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ +#include <com/sun/star/sdbc/SQLWarning.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _CONNECTIVITY_OSUBCOMPONENT_HXX_ +#include "OSubComponent.hxx" +#endif +#ifndef _MAP_ +#include <map> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CONNECTIVITY_OTYPEINFO_HXX_ +#include "OTypeInfo.hxx" +#endif +#ifndef _STRING_HXX +#include <tools/string.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _CONNECTIVITY_SQLPARSE_HXX +#include "connectivity/sqlparse.hxx" +#endif +#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_ +#include "connectivity/sqliterator.hxx" +#endif +// namespace ucb { class Content } } + +namespace connectivity +{ + namespace file + { + + class OStatement_Base; + class ODatabaseMetaData; + class OFileDriver; + + typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XConnection, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::lang::XServiceInfo + > OConnection_BASE; + + class OConnection : public OConnection_BASE, + public connectivity::OSubComponent<OConnection> + { + friend class connectivity::OSubComponent<OConnection>; + + protected: + ::osl::Mutex m_aMutex; + //==================================================================== + // Data attributes + //==================================================================== + ::std::vector<connectivity::OTypeInfo> m_aTypeInfo; // vector containing an entry + // for each row returned by + // DatabaseMetaData.getTypeInfo. + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; + + connectivity::OWeakRefArray m_aStatements; // vector containing a list + // of all the Statement objects + // for this Connection + + ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by + // an operation + String m_aURL; // URL of connection + // String m_aDirectoryName; + String m_aFilenameExtension; + OFileDriver* m_pDriver; // Pointer to the owning + // driver object + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xDir; + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent> m_xContent; + + sal_Bool m_bClosed; + sal_Bool m_bAutoCommit; + sal_Bool m_bReadOnly; + + + public: + + OConnection(OFileDriver* _pDriver); + virtual ~OConnection(); + + void construct(const ::rtl::OUString& _rUrl,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo ) throw( ::com::sun::star::sdbc::SQLException); + + void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + DECLARE_SERVICE_INFO(); + + // XConnection + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // no interface methods + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > getDir() const { return m_xDir; } + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent> getContent() const { return m_xContent; } + // create a catalog or return the catalog already created + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog(); + String getExtension() const { return m_aFilenameExtension;} + }; + } +} +#endif // _CONNECTIVITY_FILE_OCONNECTION_HXX_ + diff --git a/connectivity/source/inc/file/FDatabaseMetaData.hxx b/connectivity/source/inc/file/FDatabaseMetaData.hxx new file mode 100644 index 000000000000..3b69630f5bfc --- /dev/null +++ b/connectivity/source/inc/file/FDatabaseMetaData.hxx @@ -0,0 +1,245 @@ +/************************************************************************* + * + * $RCSfile: FDatabaseMetaData.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_ODATABASEMETADATA_HXX_ +#define _CONNECTIVITY_FILE_ODATABASEMETADATA_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _CONNECTIVITY_FILE_OCONNECTION_HXX_ +#include "file/FConnection.hxx" +#endif +namespace connectivity +{ + namespace file + { + //************************************************************** + //************ Class: java.sql.DatabaseMetaDataDate + //************************************************************** + + class ODatabaseMetaData : public OBaseMutex, + public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XDatabaseMetaData > + { + protected: + OConnection* m_pConnection; + public: + + ODatabaseMetaData(OConnection* _pCon); + ~ODatabaseMetaData(); + // XDatabaseMetaData + virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getUserName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCatalogAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogSeparator( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxStatements( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_FILE_ODATABASEMETADATA_HXX_ + diff --git a/connectivity/source/inc/file/FDriver.hxx b/connectivity/source/inc/file/FDriver.hxx new file mode 100644 index 000000000000..5edbb9fe379a --- /dev/null +++ b/connectivity/source/inc/file/FDriver.hxx @@ -0,0 +1,133 @@ +/************************************************************************* + * + * $RCSfile: FDriver.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_ODRIVER_HXX_ +#define _CONNECTIVITY_FILE_ODRIVER_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_ +#include <com/sun/star/sdbc/XDriver.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> +#endif +#ifndef _CPPUHELPER_COMPBASE2_HXX_ +#include <cppuhelper/compbase2.hxx> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif + +namespace connectivity +{ + namespace file + { + typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XDriver, ::com::sun::star::lang::XServiceInfo > ODriver_BASE; + + class OFileDriver : public ODriver_BASE, + public ::com::sun::star::sdbcx::XDataDefinitionSupplier + { + protected: + ::osl::Mutex m_aMutex; + + connectivity::OWeakRefArray m_xConnections; // vector containing a list + // of all the Connection objects + // for this Driver + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; + public: + + DECLARE_CTY_DEFAULTS(ODriver_BASE); + + OFileDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // XDriver + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); + + // XDataDefinitionSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getFactory() { return m_xFactory; } + }; + } + +} +#endif //_CONNECTIVITY_FILE_ODRIVER_HXX_ + + diff --git a/connectivity/source/inc/file/FPreparedStatement.hxx b/connectivity/source/inc/file/FPreparedStatement.hxx new file mode 100644 index 000000000000..3c89cd193fbf --- /dev/null +++ b/connectivity/source/inc/file/FPreparedStatement.hxx @@ -0,0 +1,163 @@ +/************************************************************************* + * + * $RCSfile: FPreparedStatement.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_OPREPAREDSTATEMENT_HXX_ +#define _CONNECTIVITY_FILE_OPREPAREDSTATEMENT_HXX_ + + +#ifndef _CONNECTIVITY_FILE_OSTATEMENT_HXX_ +#include "file/FStatement.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_ +#include <com/sun/star/sdbc/XPreparedStatement.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_ +#include <com/sun/star/sdbc/XParameters.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +// #include <com/sun/star/sdbc/XClearParameters.hpp> +#ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HPP_ +#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ +#include <com/sun/star/io/XInputStream.hpp> +#endif +#ifndef _CONNECTIVITY_FILE_FRESULTSET_HXX_ +#include "file/FResultSet.hxx" +#endif + +namespace connectivity +{ + namespace file + { + + class OPreparedStatement : public OStatement_BASE2, + public ::com::sun::star::sdbc::XPreparedStatement, + public ::com::sun::star::sdbc::XParameters, + public ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + public ::com::sun::star::lang::XServiceInfo + + { + protected: + //==================================================================== + // Data attributes + //==================================================================== + + ::rtl::OUString m_aSql; + OValueRow m_aRow; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xRS; // only to enshure that the result isn't deleted + OResultSet* m_pResultSet; + + public: + DECLARE_CTY_DEFAULTS(OStatement_BASE2); + DECLARE_SERVICE_INFO(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OPreparedStatement( OConnection* _pConnection,const ::std::vector<connectivity::OTypeInfo>& _TypeInfo); + + void construct(const ::rtl::OUString& sql) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + //XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XPreparedStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XParameters + virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_FILE_OPREPAREDSTATEMENT_HXX_ + + diff --git a/connectivity/source/inc/file/FResultSet.hxx b/connectivity/source/inc/file/FResultSet.hxx new file mode 100644 index 000000000000..32f1e0e32351 --- /dev/null +++ b/connectivity/source/inc/file/FResultSet.hxx @@ -0,0 +1,458 @@ +/************************************************************************* + * + * $RCSfile: FResultSet.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_FRESULTSET_HXX_ +#define _CONNECTIVITY_FILE_FRESULTSET_HXX_ + +#ifndef _COM_SUN_STAR_SQLC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XCLOSEABLE_HPP_ +#include <com/sun/star/sdbc/XCloseable.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XCOLUMNLOCATE_HPP_ +#include <com/sun/star/sdbc/XColumnLocate.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ +#include <com/sun/star/util/XCancellable.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XRESULTSETUPDATE_HPP_ +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XROWUPDATE_HPP_ +#include <com/sun/star/sdbc/XRowUpdate.hpp> +#endif +#ifndef _CPPUHELPER_COMPBASE11_HXX_ +#include <cppuhelper/compbase11.hxx> +#endif +#ifndef _UNOTOOLS_PROPERTY_ARRAY_HELPER_HXX_ +#include <unotools/proparrhlp.hxx> +#endif +#ifndef _CONNECTIVITY_FILE_OSTATEMENT_HXX_ +#include "file/FStatement.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CONNECTIVITY_SIMPLEPROPERTYCONTAINER_HXX_ +#include "connectivity/simplepropertycontainer.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_FANALYZER_HXX_ +#include "file/fanalyzer.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_TABLE_HXX_ +#include "file/FTable.hxx" +#endif + +namespace connectivity +{ + namespace file + { + class OKeySet : public ::std::vector<sal_Int32> + { + sal_Bool m_bFrozen; + public: + OKeySet(): ::std::vector<sal_Int32>(),m_bFrozen(sal_False){} + OKeySet(size_type _nSize) : ::std::vector<sal_Int32>(_nSize),m_bFrozen(sal_False){} + + sal_Bool isFrozen() const { return m_bFrozen; } + void setFrozen(sal_Bool _bFrozen=sal_True) { m_bFrozen = _bFrozen; } + }; + + typedef union + { + double aDouble; + rtl::OUString* pString; + } OFILEKey; + +#define SQL_ORDERBYKEYS 10 +#define SQL_COLUMN_NOTFOUND STRING_NOTFOUND + + class OFILEKeyValue + { + private: + INT32 nValue; + OFILEKey pKey[SQL_ORDERBYKEYS]; + + public: + OFILEKeyValue() { } + OFILEKeyValue(INT32 nVal) : nValue(nVal) {} + ~OFILEKeyValue(){} + + void SetKey(UINT16 i, double d) { pKey[i].aDouble = d; } + void SetKey(UINT16 i, const rtl::OUString& rString) { pKey[i].pString = new rtl::OUString(rString); } + void SetValue(INT32 nVal) { nValue = nVal; } + + rtl::OUString* GetKeyString(UINT16 i) const { return pKey[i].pString; } + double GetKeyDouble(UINT16 i) const { return pKey[i].aDouble; } + + inline INT32 GetValue() const {return nValue;} + }; + + typedef OFILEKeyValue * OFILEKeyValuePtr; + + typedef enum + { + SQL_ORDERBYKEY_NONE, // Nicht sortieren + SQL_ORDERBYKEY_DOUBLE, // Numerischer Key + SQL_ORDERBYKEY_STRING // String Key + } OKeyType; + + class OFILESortIndex + { + private: + INT32 nMaxCount; // Maximal moegliche Anzahl Key/Value-Paare im Index (und damit Array-Groesse) + INT32 nCount; // Anzahl Key/Value-Paare im Index (und damit naechste freie Position) + + OFILEKeyValuePtr * ppKeyValueArray; + // Zeiger auf Array der Groesse [nMaxCount] + + BOOL bFrozen; + CharSet eCharSet; + + public: // nur fuer OFILECompare: + static OFILESortIndex *pCurrentIndex; // Waehrend der Ausfuehrung von qsort ist hier der Zeiger + static CharSet eCurrentCharSet; + // auf den gerade zur Sortierung verwendeten Index hinterlegt + // (wird von der Vergleichsfunktion OFILEKeyCompare verwendet). + OKeyType eKeyType[SQL_ORDERBYKEYS]; + BOOL bAscending[SQL_ORDERBYKEYS]; + + + public: + + OFILESortIndex(const OKeyType eKeyType[], // Art des Schluessels: numerisch/String/nicht sortieren (Genau 3 Eintraege!) + const BOOL bAscending[], // TRUE = Aufsteigend sortieren (Genau 3 Eintraege!) + INT32 nMaxNumberOfRows, + CharSet eSet); + + ~OFILESortIndex(); + + + BOOL AddKeyValue(OFILEKeyValue * pKeyValue); + // TRUE, wenn erfolgreich hinzugefuegt, FALSE bei Ueberschreitung + // der Index-Kapazitaet. + // pKeyValue wird beim Zerstoeren des Index automatisch freigegeben. + + void Freeze(); // "Einfrieren" des Index: + // Vor "Freeze" duerfen Count() und Get() nicht gerufen werden, + // nach "Freeze" darf dafuer Add() nicht mehr gerufen werden. + + OKeySet* CreateKeySet(); + + + + BOOL IsFrozen() { return bFrozen; } // TRUE nach Aufruf von Freeze() + + INT32 Count() const { return nCount; } // Anzahl Key/Value-Paare im Index + INT32 GetValue(INT32 nPos) const; // Value an Position nPos (1..n) [sortierter Zugriff]. + }; + + static int +#if defined(WIN) || defined(WNT) +__cdecl +#endif +#if defined(ICC) && defined(OS2) +_Optlink +#endif +OFILEKeyCompare(const void * elem1, const void * elem2); + + /* + ** java_sql_ResultSet + */ + typedef ::cppu::WeakComponentImplHelper11< ::com::sun::star::sdbc::XResultSet, + ::com::sun::star::sdbc::XRow, + ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + ::com::sun::star::util::XCancellable, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::sdbc::XResultSetUpdate, + ::com::sun::star::sdbc::XRowUpdate, + ::com::sun::star::sdbc::XCloseable, + ::com::sun::star::sdbc::XColumnLocate, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::lang::XUnoTunnel> OResultSet_BASE; + + class OResultSet : public OBaseMutex, + public OResultSet_BASE, + public connectivity::OSimplePropertyContainer, + public ::utl::OPropertyArrayUsageHelper<OResultSet> + { + + ::std::vector<void*> m_aBindVector; + ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime + + OValueRow m_aRow; + OValueRow m_aEvaluateRow; // contains all values of a row + OValueRow m_aParameterRow; + ORefAssignValues m_aAssignValues; // needed for insert,update and parameters + // to compare with the restrictions + ::std::vector<sal_Int32>* m_pEvaluationKeySet; + ::std::vector<sal_Int32>::iterator m_aEvaluateIter; + + OKeySet* m_pFileSet; + OKeySet::iterator m_aFileSetIter; + + UINT16 nOrderbyColumnNumber[SQL_ORDERBYKEYS]; + BOOL bOrderbyAscending[SQL_ORDERBYKEYS]; + + OFILESortIndex* m_pSortIndex; + ::vos::ORef<connectivity::OSQLColumns> m_xColumns; // this are the select columns + ::vos::ORef<connectivity::OSQLColumns> m_xParamColumns; + OFileTable* m_pTable; + connectivity::OSQLParseNode* m_pParseTree; + + OFILEAnalyzer m_aSQLAnalyzer; + connectivity::OSQLParseTreeIterator& m_aSQLIterator; + + sal_Int32 m_nFetchSize; + sal_Int32 m_nResultSetType; + sal_Int32 m_nFetchDirection; + sal_Int32 m_nResultSetConcurrency; + + ::com::sun::star::uno::WeakReferenceHelper m_aStatement; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xDBMetaData; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColNames; // table columns + + ::rtl::OUString m_aTableRange; + sal_Int32 m_nRowPos; + sal_Int32 m_nFilePos; + sal_Int32 m_nLastVisitedPos; + sal_Int32 m_nRowCountResult; + sal_Bool m_bWasNull; + sal_Bool m_bBOF; // before first record + sal_Bool m_bEOF; // after last record + sal_Bool m_bLastRecord; + sal_Bool m_bFileSetFrozen; + + void construct(); + sal_Bool evaluate(); + BOOL Move(OFileTable::FilePosition eCursorPosition, INT32 nOffset, BOOL bRetrieveData); + BOOL ExecuteRow(OFileTable::FilePosition eFirstCursorPosition, + INT32 nOffset = 1, + BOOL bRebind = TRUE, + BOOL bEvaluate = TRUE, + BOOL bRetrieveData = TRUE); + + OFILEKeyValue* GetOrderbyKeyValue(OValueRow _rRow); + BOOL IsSorted() const {return nOrderbyColumnNumber[0] != SQL_COLUMN_NOTFOUND;} + void anylizeSQL(); + void setOrderbyColumn(UINT16 nOrderbyColumnNo, + connectivity::OSQLParseNode* pColumnRef, + connectivity::OSQLParseNode* pAscendingDescending); + void SetAssignValue(const String& aColumnName, + const String& aValue, + BOOL bSetNull = FALSE, + UINT32 nParameter=SQL_NO_PARAMETER); + void ParseAssignValues( const ::std::vector< String>& aColumnNameList, + connectivity::OSQLParseNode* pRow_Value_Constructor_Elem,xub_StrLen nIndex); + UINT32 AddParameter(connectivity::OSQLParseNode * pParameter, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet>& _xCol); + void GetAssignValues(); + + void scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes); + protected: + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + public: + DECLARE_CTY_DEFAULTS(OResultSet_BASE); + DECLARE_SERVICE_INFO(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator); + ~OResultSet(); + + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *() + { + return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(OResultSet_BASE*)this); + } + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) + { + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); + } + // XResultSet + virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetUpdate + virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRowUpdate + virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XColumnLocate + virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + // special methods + inline sal_Int32 mapColumn(sal_Int32 column); + BOOL OpenImpl(); + + sal_Int32 getRowCountResult() const { return m_nRowCountResult; } + void setParameterRow(const OValueRow& _rParaRow) { m_aParameterRow = _rParaRow; } + void describeParameter(); + }; + // ------------------------------------------------------------------------- + inline sal_Int32 OResultSet::mapColumn (sal_Int32 column) + { + return column; +// sal_Int32 map = column; +// +// if (m_aColMapping.size()) +// { +// // Validate column number +// OSL_ENSHURE(column>0,"OResultSet::mapColumn column <= 0"); +// map = m_aColMapping[column]; +// } +// +// return map; + } + } +} +#endif // _CONNECTIVITY_FILE_ORESULTSET_HXX_ + + diff --git a/connectivity/source/inc/file/FResultSetMetaData.hxx b/connectivity/source/inc/file/FResultSetMetaData.hxx new file mode 100644 index 000000000000..6aaf565012ff --- /dev/null +++ b/connectivity/source/inc/file/FResultSetMetaData.hxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * $RCSfile: FResultSetMetaData.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_ORESULTSETMETADATA_HXX_ +#define _CONNECTIVITY_FILE_ORESULTSETMETADATA_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif + +namespace connectivity +{ + namespace file + { + + //************************************************************** + //************ Class: ResultSetMetaData + //************************************************************** + typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE; + + class OResultSetMetaData : public OResultSetMetaData_BASE + { + ::rtl::OUString m_aTableName; + const connectivity::OSQLColumns& m_rColumns; + + public: + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OResultSetMetaData(const OSQLColumns& _rColumns,const ::rtl::OUString& _aTableName) + : m_rColumns(_rColumns) + , m_aTableName(_aTableName) + {} + ~OResultSetMetaData(); + + /// Avoid ambigous cast error from the compiler. + inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw() + { return this; } + + virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_FILE_ORESULTSETMETADATA_HXX_ + diff --git a/connectivity/source/inc/file/FStatement.hxx b/connectivity/source/inc/file/FStatement.hxx new file mode 100644 index 000000000000..b4bbfb1ed193 --- /dev/null +++ b/connectivity/source/inc/file/FStatement.hxx @@ -0,0 +1,233 @@ +/************************************************************************* + * + * $RCSfile: FStatement.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_OSTATEMENT_HXX_ +#define _CONNECTIVITY_FILE_OSTATEMENT_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_ +#include <com/sun/star/sdbc/XStatement.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XMULTIPLERESULTS_HPP_ +#include <com/sun/star/sdbc/XMultipleResults.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XBATCHEXECUTION_HPP_ +#include <com/sun/star/sdbc/XBatchExecution.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_ +#include <com/sun/star/sdbc/XCloseable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ +#include <com/sun/star/sdbc/SQLWarning.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ +#include <com/sun/star/util/XCancellable.hpp> +#endif +#ifndef _UNOTOOLS_PROPERTY_ARRAY_HELPER_HXX_ +#include <unotools/proparrhlp.hxx> +#endif +#ifndef _CPPUHELPER_COMPBASE4_HXX_ +#include <cppuhelper/compbase4.hxx> +#endif +#ifndef _UTL_UNO3_HXX_ +#include <unotools/uno3.hxx> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_OCONNECTION_HXX_ +#include "file/FConnection.hxx" +#endif +#ifndef _LIST_ +#include <list> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _CONNECTIVITY_SIMPLEPROPERTYCONTAINER_HXX_ +#include "connectivity/simplepropertycontainer.hxx" +#endif +#ifndef _CONNECTIVITY_FILE_FANALYZER_HXX_ +#include "file/fanalyzer.hxx" +#endif + +namespace connectivity +{ + namespace file + { + typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbc::XStatement, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::util::XCancellable, + ::com::sun::star::sdbc::XCloseable> OStatement_BASE; + + //************************************************************** + //************ Class: java.sql.Statement + //************************************************************** + class OStatement_Base : public OBaseMutex, + public OStatement_BASE, + public connectivity::OSimplePropertyContainer, + public ::utl::OPropertyArrayUsageHelper<OStatement_Base> + + { + ::com::sun::star::sdbc::SQLWarning m_aLastWarning; + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created + // for this Statement + protected: + + connectivity::OSQLParser m_aParser; + connectivity::OSQLParseTreeIterator m_aSQLIterator; + + + OConnection* m_pConnection;// The owning Connection object + connectivity::OSQLParseNode* m_pParseTree; + + ::rtl::OUString m_aCursorName; + sal_Int32 m_nMaxFieldSize; + sal_Int32 m_nMaxRows; + sal_Int32 m_nQueryTimeOut; + sal_Int32 m_nFetchSize; + sal_Int32 m_nResultSetType; + sal_Int32 m_nFetchDirection; + sal_Int32 m_nResultSetConcurrency; + sal_Bool m_bEscapeProcessing; + protected: + + void reset () throw( ::com::sun::star::sdbc::SQLException); + void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException); + void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException); + sal_Int32 getPrecision ( sal_Int32 sqlType); + + void disposeResultSet(); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + public: + connectivity::OSQLParseNode* getParseTree() const { return m_pParseTree;} + + ::cppu::OBroadcastHelper& rBHelper; + DECLARE_CTY_ACQUIRE(OStatement_BASE); + OStatement_Base(OConnection* _pConnection ); + + using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; + // OComponentHelper + virtual void SAL_CALL disposing(void){OStatement_BASE::disposing();} + // XInterface + // virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException) = 0; + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) + { + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); + } + // XStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + + class OStatement_BASE2 : public OStatement_Base, + public connectivity::OSubComponent< OStatement_BASE2> + + { + friend class connectivity::OSubComponent< OStatement_BASE2>; + public: + OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ), + connectivity::OSubComponent< OStatement_BASE2>((::cppu::OWeakObject*)_pConnection){} + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); + }; + + class OStatement : public OStatement_BASE2, + public ::com::sun::star::lang::XServiceInfo + { + public: + DECLARE_CTY_DEFAULTS(OStatement_BASE2); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){} + DECLARE_SERVICE_INFO(); + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) + { + return OStatement_BASE2::queryInterface( rType); + } + }; + } +} +#endif // _CONNECTIVITY_FILE_OSTATEMENT_HXX_ + diff --git a/connectivity/source/inc/file/FTable.hxx b/connectivity/source/inc/file/FTable.hxx new file mode 100644 index 000000000000..aed252f10909 --- /dev/null +++ b/connectivity/source/inc/file/FTable.hxx @@ -0,0 +1,163 @@ +/************************************************************************* + * + * $RCSfile: FTable.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_TABLE_HXX_ +#define _CONNECTIVITY_FILE_TABLE_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_TABLE_HXX_ +#include "connectivity/sdbcx/VTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif +#ifndef _CONNECTIVITY_FILE_BCONNECTION_HXX_ +#include "file/FConnection.hxx" +#endif +#ifndef _STREAM_HXX +#include <tools/stream.hxx> +#endif +#ifndef _CONNECTIVITY_FILE_VALUE_HXX_ +#include "file/FValue.hxx" +#endif + +namespace connectivity +{ + namespace file + { + typedef connectivity::sdbcx::OTable OTable_TYPEDEF; + + class OFileTable : public OTable_TYPEDEF, + public ::com::sun::star::lang::XUnoTunnel + { + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + OConnection* m_pConnection; + SvFileStream m_aFileStream; + ::vos::ORef<OSQLColumns> m_aColumns; + sal_uInt8* m_pBuffer; + sal_uInt16 m_nBufferSize; // Groesse des ReadBuffer, wenn pBuffer != NULL + sal_Int32 m_nFilePos; // aktuelle FilePosition + + public: + virtual void refreshColumns(); + virtual void refreshKeys(); + virtual void refreshIndexes(); + + enum FilePosition + { + FILE_NEXT = 0, + FILE_PRIOR, + FILE_FIRST, + FILE_LAST, + FILE_RELATIVE, + FILE_ABSOLUTE, + FILE_BOOKMARK + }; + + public: + DECLARE_CTY_DEFAULTS( OTable_TYPEDEF); + OFileTable( OConnection* _pConnection); + OFileTable( OConnection* _pConnection, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description = ::rtl::OUString(), + const ::rtl::OUString& _SchemaName = ::rtl::OUString(), + const ::rtl::OUString& _CatalogName = ::rtl::OUString() + ); + + //XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + + OConnection* getConnection() const { return m_pConnection;} + virtual sal_Int32 getCurrentLastPos() const {return 0;} + + virtual sal_Bool seekRow(FilePosition eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) = 0; + virtual sal_Bool fetchRow(OValueRow _rRow,const OSQLColumns& _rCols, sal_Bool bRetrieveData) = 0; + + ::vos::ORef<OSQLColumns> getTableColumns() const {return m_aColumns;} + virtual BOOL InsertRow(ORefAssignValues& rRow, BOOL bFlush,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols) + { + return sal_False; + } + virtual BOOL DeleteRow(const OSQLColumns& _rCols) + { + return sal_False; + } + virtual BOOL UpdateRow(OValueVector& rRow, file::OValueRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols) + { + return sal_False; + } + + const ::rtl::OUString& getName() const { return m_Name; } + const ::rtl::OUString& getSchema() const { return m_SchemaName; } + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + }; + } +} +#endif // _CONNECTIVITY_FILE_TABLE_HXX_ + diff --git a/connectivity/source/inc/file/FTables.hxx b/connectivity/source/inc/file/FTables.hxx new file mode 100644 index 000000000000..cde2c2710c88 --- /dev/null +++ b/connectivity/source/inc/file/FTables.hxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * $RCSfile: FTables.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_TABLES_HXX_ +#define _CONNECTIVITY_FILE_TABLES_HXX_ + +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +namespace connectivity +{ + namespace file + { + class OTables : public sdbcx::OCollection + { + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); + public: + OTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector) : sdbcx::OCollection(_rParent,_rMetaData->storesMixedCaseQuotedIdentifiers(),_rMutex,_rVector) + ,m_xMetaData(_rMetaData) + // ,m_pParent(_pParent) + {} + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + + // only the name is identical to ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + }; + } +} +#endif // _CONNECTIVITY_FILE_TABLES_HXX_ + diff --git a/connectivity/source/inc/file/fanalyzer.hxx b/connectivity/source/inc/file/fanalyzer.hxx new file mode 100644 index 000000000000..43229b4e8793 --- /dev/null +++ b/connectivity/source/inc/file/fanalyzer.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * $RCSfile: fanalyzer.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_FANALYZER_HXX_ +#define _CONNECTIVITY_FILE_FANALYZER_HXX_ + +#ifndef _CONNECTIVITY_FILE_FCOMP_HXX_ +#include "file/fcomp.hxx" +#endif + +namespace connectivity +{ + namespace file + { + class OSQLAnalyzer + { + OPredicateCompiler m_aCompiler; + OPredicateInterpreter m_aInterpreter; + + // OCursor& m_rCursor; + + public: + OSQLAnalyzer(); + + void describeParam(::vos::ORef<OSQLColumns> rParameterColumns); // genauere Beschreibung der Parameter + ::std::vector<sal_Int32>* bindResultRow(OValueRow _pRow); // Anbinden einer Ergebniszeile an die Restrictions + void bindParameterRow(OValueRow _pRow); // Anbinden einer Parameterzeile an die Restrictions + + void start(OSQLParseNode* pSQLParseNode); + void clean(); + BOOL hasRestriction() const {return m_aCompiler.hasCode();} + BOOL evaluateRestriction() {return m_aInterpreter.start();} + void setOrigColumns(const OFileColumns& rCols) { m_aCompiler.setOrigColumns(rCols); } + void setParameterColumns(::vos::ORef< connectivity::OSQLColumns > _rParaCols) { m_aCompiler.setParameterColumns(_rParaCols); } + virtual OOperandAttr* createOperandAttr(sal_Int32 _nPos,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet>& _xCol) { return new OOperandAttr(_nPos,_xCol); } + }; + + class OFILEAnalyzer : public OSQLAnalyzer + { + public: + OFILEAnalyzer() : OSQLAnalyzer(){} + virtual OOperandAttr* createOperandAttr(sal_Int32 _nPos,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet>& _xCol) { return new OFILEOperandAttr(_nPos,_xCol); } + }; + } +} +#endif // _CONNECTIVITY_FILE_FANALYZER_HXX_ + diff --git a/connectivity/source/inc/file/fcode.hxx b/connectivity/source/inc/file/fcode.hxx new file mode 100644 index 000000000000..ff391fbb99d3 --- /dev/null +++ b/connectivity/source/inc/file/fcode.hxx @@ -0,0 +1,394 @@ +/************************************************************************* + * + * $RCSfile: fcode.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_FCODE_HXX_ +#define _CONNECTIVITY_FILE_FCODE_HXX_ + +#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_ +#include "connectivity/sqliterator.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _RTTI_HXX //autogen +#include <tools/rtti.hxx> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _CONNECTIVITY_FILE_VALUE_HXX_ +#include "file/FValue.hxx" +#endif + + +namespace connectivity +{ + class OSQLParseNode; + namespace file + { + + class OOperand; + typedef ::std::stack<OOperand*> OCodeStack; + class OBoolOperator; + typedef ::std::map<sal_Int32,sal_Int32> OEvaluateSet; + + typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> OFileColumns; + + + class OCode + { + public: + virtual ~OCode(); + + TYPEINFO(); + }; + + + // operands that the parsetree generate + class OOperand : public OCode + { + protected: + sal_Int32 m_eDBType; + + OOperand(const sal_Int32& _rType) : m_eDBType(_rType){} + OOperand() : m_eDBType(::com::sun::star::sdbc::DataType::OTHER){} + + public: + virtual ::com::sun::star::uno::Any getValue() const = 0; + virtual void setValue(const ::com::sun::star::uno::Any& _rVal) = 0; + + virtual sal_Int32 getDBType() const {return m_eDBType;} + virtual OEvaluateSet* preProcess(OBoolOperator* pOp, OOperand* pRight = 0); + inline sal_Bool isValid() const; + + TYPEINFO(); + }; + + class OOperandRow : public OOperand + { + sal_uInt16 m_nRowPos; + protected: + OValueRow m_pRow; + + OOperandRow(sal_uInt16 _nPos, sal_Int32 _rType) : OOperand(_rType) + , m_nRowPos(_nPos){} + public: + sal_uInt16 getRowPos() const {return m_nRowPos;} + virtual ::com::sun::star::uno::Any getValue() const; + virtual void setValue(const ::com::sun::star::uno::Any& _rVal) + { + (*m_pRow)[m_nRowPos] = _rVal; + } + void bindValue(OValueRow _pRow); // Bindung an den Wert, den der Operand reprsentiert + + TYPEINFO(); + }; + + // Attribute aus einer Ergebniszeile + class OOperandAttr : public OOperandRow + { + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet> m_xColumn; + + public: + OOperandAttr(sal_uInt16 _nPos,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet>& _xColumn); + + virtual sal_Bool isIndexed() const {return sal_False;} + virtual OEvaluateSet* preProcess(OBoolOperator* pOp, OOperand* pRight = 0) { return NULL;} + TYPEINFO(); + }; + + // Attribute aus einer Ergebniszeile + class OFILEOperandAttr : public OOperandAttr + { + public: + OFILEOperandAttr(sal_uInt16 _nPos,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet>& _xColumn); + + virtual sal_Bool isIndexed() const + { + return ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>(m_xColumn,::com::sun::star::uno::UNO_QUERY)->getPropertySetInfo()->hasPropertyByName(connectivity::PROPERTY_ISASCENDING); + } + virtual OEvaluateSet* preProcess(OBoolOperator* pOp, OOperand* pRight = 0); + TYPEINFO(); + }; + + + // Parameter fr ein Prdikat + class OOperandParam : public OOperandRow + { + public: + OOperandParam(connectivity::OSQLParseNode* pNode, ::vos::ORef<connectivity::OSQLColumns> _xParamColumns); + void describe(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet>& _xColumn, ::vos::ORef<connectivity::OSQLColumns> _xParamColumns); + + TYPEINFO(); + }; + + + // WerteOperanden + class OOperandValue : public OOperand + { + protected: + ::com::sun::star::uno::Any m_aValue; + + protected: + OOperandValue(){} + OOperandValue(const ::com::sun::star::uno::Any& _rVar, sal_Int32 eDbType) + : OOperand(eDbType) + , m_aValue(_rVar) + {} + + OOperandValue(sal_Int32 eDbType) :OOperand(eDbType){} + public: + virtual ::com::sun::star::uno::Any getValue() const; + virtual void setValue(const ::com::sun::star::uno::Any& _rVal) { m_aValue = _rVal; } + + TYPEINFO(); + }; + + + // Konstanten + class OOperandConst : public OOperandValue + { + public: + OOperandConst(const connectivity::OSQLParseNode& rColumnRef, const rtl::OUString& aStrValue); + + TYPEINFO(); + }; + + + // Ergebnis Operanden + class OOperandResult : public OOperandValue + { + protected: + OOperandResult(const ::com::sun::star::uno::Any& _rVar, sal_Int32 eDbType) + :OOperandValue(_rVar, eDbType) {} + OOperandResult(sal_Int32 eDbType) + :OOperandValue(eDbType) {} + public: + TYPEINFO(); + }; + + + class OOperandResultBOOL : public OOperandResult + { + public: + OOperandResultBOOL(sal_Bool bResult):OOperandResult(::com::sun::star::sdbc::DataType::BIT) + { + m_aValue <<= bResult ? 1.0 : 0.0; + } + }; + + class OOperandResultNUM : public OOperandResult + { + public: + OOperandResultNUM(double fNum):OOperandResult(::com::sun::star::sdbc::DataType::DOUBLE) + { + m_aValue <<= fNum; + } + }; + + + // Operatoren + + class OOperator : public OCode + { + public: + virtual void Exec(OCodeStack&) = 0; + virtual sal_uInt16 getRequestedOperands() const; // Anzahl bentigter Operanden + // Standard ist 2 + TYPEINFO(); + }; + + + // boolsche Operatoren + + class OBoolOperator : public OOperator + { + public: + TYPEINFO(); + virtual void Exec(OCodeStack&); + virtual sal_Bool operate(const OOperand*, const OOperand*) const; + }; + + + class OOp_AND : public OBoolOperator + { + public: + TYPEINFO(); + + protected: + virtual sal_Bool operate(const OOperand*, const OOperand*) const; + }; + + class OOp_OR : public OBoolOperator + { + public: + TYPEINFO(); + protected: + virtual sal_Bool operate(const OOperand*, const OOperand*) const; + }; + + class OOp_ISNULL : public OBoolOperator + { + public: + TYPEINFO(); + public: + virtual void Exec(OCodeStack&); + virtual sal_uInt16 getRequestedOperands() const; + virtual sal_Bool operate(const OOperand*, const OOperand* = NULL) const; + }; + + class OOp_ISNOTNULL : public OOp_ISNULL + { + public: + TYPEINFO(); + virtual sal_Bool operate(const OOperand*, const OOperand* = NULL) const; + }; + + class OOp_LIKE : public OBoolOperator + { + public: + TYPEINFO(); + protected: + const sal_Unicode cEscape; + + public: + OOp_LIKE(const sal_Unicode cEsc = L'\0'):cEscape(cEsc){}; + + virtual sal_Bool operate(const OOperand*, const OOperand*) const; + }; + + class OOp_NOTLIKE : public OOp_LIKE + { + public: + TYPEINFO(); + public: + OOp_NOTLIKE(const char cEsc = '\0'):OOp_LIKE(cEsc){}; + + virtual sal_Bool operate(const OOperand*, const OOperand*) const; + }; + + class OOp_COMPARE : public OBoolOperator + { + connectivity::OSQLPredicateType aPredicateType; + + public: + TYPEINFO(); + OOp_COMPARE(connectivity::OSQLPredicateType aPType) + :aPredicateType(aPType) {} + + connectivity::OSQLPredicateType getPredicateType() const {return aPredicateType;} + virtual sal_Bool operate(const OOperand*, const OOperand*) const; + }; + + // numerische Operatoren + + class ONumOperator : public OOperator + { + public: + virtual void Exec(OCodeStack&); + + TYPEINFO(); + + protected: + virtual double operate(double fLeft, double fRight) const = 0; + }; + + class OOp_ADD : public ONumOperator + { + protected: + virtual double operate(double fLeft, double fRight) const; + }; + + class OOp_SUB : public ONumOperator + { + protected: + virtual double operate(double fLeft, double fRight) const; + }; + + class OOp_MUL : public ONumOperator + { + protected: + virtual double operate(double fLeft, double fRight) const; + }; + + class OOp_DIV : public ONumOperator + { + protected: + virtual double operate(double fLeft, double fRight) const; + }; + + inline sal_Bool OOperand::isValid() const + { + ::com::sun::star::uno::Any aVal = getValue(); + return aVal.hasValue() && aVal.getValueTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE && connectivity::getDouble(aVal) != 0; + } + } +} + +#endif // _CONNECTIVITY_FILE_FCODE_HXX_ + diff --git a/connectivity/source/inc/file/fcomp.hxx b/connectivity/source/inc/file/fcomp.hxx new file mode 100644 index 000000000000..01bb73c8c210 --- /dev/null +++ b/connectivity/source/inc/file/fcomp.hxx @@ -0,0 +1,140 @@ +/************************************************************************* + * + * $RCSfile: fcomp.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_FCOMP_HXX_ +#define _CONNECTIVITY_FILE_FCOMP_HXX_ + +#ifndef _CONNECTIVITY_FILE_FCODE_HXX_ +#include "file/fcode.hxx" +#endif +#ifndef _LIST_ +#include <list> +#endif + +namespace connectivity +{ + class OSQLParseNode; + namespace file + { + class OCode; + class OOperand; + typedef::std::vector<OCode*> OCodeList; + + class OPredicateCompiler + { + friend class OPredicateInterpreter; + friend class OSQLAnalyzer; + + OCodeList m_aCodeList; + OFileColumns m_orgColumns; // in filecurs this are the filecolumns + ::vos::ORef< connectivity::OSQLColumns> m_aParameterColumns; + OSQLAnalyzer* m_pAnalyzer; + sal_Bool m_bORCondition; + + public: + OPredicateCompiler(OSQLAnalyzer* pAnalyzer); + + virtual ~OPredicateCompiler(); + + void start(connectivity::OSQLParseNode* pSQLParseNode); + OOperand* execute(connectivity::OSQLParseNode* pPredicateNode); + + void Clean(); + sal_Bool isClean() const {return m_aCodeList.empty();} + sal_Bool hasCode() const {return !isClean();} + sal_Bool hasORCondition() const {return m_bORCondition;} + void setOrigColumns(const OFileColumns& rCols) { m_orgColumns = rCols; } + const OFileColumns getOrigColumns() const { return m_orgColumns; } + + void setParameterColumns(::vos::ORef< connectivity::OSQLColumns > _rParaCols) + { + m_aParameterColumns = _rParaCols; + } + + protected: + OOperand* execute_COMPARE(connectivity::OSQLParseNode* pPredicateNode); + OOperand* execute_LIKE(connectivity::OSQLParseNode* pPredicateNode); + OOperand* execute_ISNULL(connectivity::OSQLParseNode* pPredicateNode); + OOperand* execute_Operand(connectivity::OSQLParseNode* pPredicateNode); + + private: + // OCursor& Cursor() const; + }; + + + class OPredicateInterpreter + { + OCodeStack m_aStack; + OPredicateCompiler& m_rCompiler; + + public: + OPredicateInterpreter(OPredicateCompiler& rComp) : m_rCompiler(rComp){} + virtual ~OPredicateInterpreter(); + + sal_Bool start() + { + return evaluate(m_rCompiler.m_aCodeList); + } + sal_Bool evaluate(OCodeList& rCodeList); + }; + } +} +#endif // _CONNECTIVITY_FILE_FCOMP_HXX_ + diff --git a/connectivity/source/inc/internalnode.hxx b/connectivity/source/inc/internalnode.hxx new file mode 100644 index 000000000000..819b3dbef122 --- /dev/null +++ b/connectivity/source/inc/internalnode.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * $RCSfile: internalnode.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_SQLINTERNALNODE_HXX +#define _CONNECTIVITY_SQLINTERNALNODE_HXX + +#ifndef _CONNECTIVITY_SQLNODE_HXX +#include <connectivity/sqlnode.hxx> +#endif + +namespace connectivity +{ + //========================================================================== + //= OSQLInternalNode + //========================================================================== + /** special node for avoiding memory leaks + */ + class OSQLInternalNode : public OSQLParseNode + { + public: + OSQLInternalNode(const sal_Char* pNewValue, + SQLNodeType eNodeType, + sal_uInt32 nNodeID = 0); + OSQLInternalNode(const ByteString& _rNewValue, + SQLNodeType eNodeType, + sal_uInt32 nNodeID = 0); + OSQLInternalNode(const sal_Unicode* pNewValue, + SQLNodeType eNodeType, + sal_uInt32 nNodeID = 0); + OSQLInternalNode(const String& _rNewValue, + SQLNodeType eNodeType, + sal_uInt32 nNodeID = 0); + + virtual ~OSQLInternalNode(); + }; +} + +#endif //_CONNECTIVITY_SQLINTERNALNODE_HXX diff --git a/connectivity/source/inc/java/io/InputStream.hxx b/connectivity/source/inc/java/io/InputStream.hxx new file mode 100644 index 000000000000..7b8c5b996731 --- /dev/null +++ b/connectivity/source/inc/java/io/InputStream.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * $RCSfile: InputStream.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_IO_INPUTSTREAM_HXX_ +#define _CONNECTIVITY_JAVA_IO_INPUTSTREAM_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ +#include <com/sun/star/io/XInputStream.hpp> +#endif + +namespace connectivity +{ + + //************************************************************** + //************ Class: java.io.InputStream + //************************************************************** + class java_io_InputStream : public java_lang_Object, + public ::cppu::WeakImplHelper1< ::com::sun::star::io::XInputStream> + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_io_InputStream(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_io_InputStream( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + // XInputStream + virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _CONNECTIVITY_JAVA_IO_INPUTSTREAM_HXX_ + diff --git a/connectivity/source/inc/java/io/Reader.hxx b/connectivity/source/inc/java/io/Reader.hxx new file mode 100644 index 000000000000..446f6b524c23 --- /dev/null +++ b/connectivity/source/inc/java/io/Reader.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * $RCSfile: Reader.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_IO_READER_HXX_ +#define _CONNECTIVITY_JAVA_IO_READER_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ +#include <com/sun/star/io/XInputStream.hpp> +#endif + +namespace connectivity +{ + //************************************************************** + //************ Class: java.io.InputStream + //************************************************************** + class java_io_Reader : public java_lang_Object, + public ::cppu::WeakImplHelper1< ::com::sun::star::io::XInputStream> + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_io_Reader(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_io_Reader( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + // XInputStream + virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _CONNECTIVITY_JAVA_IO_READER_HXX_ + diff --git a/connectivity/source/inc/java/lang/Boolean.hxx b/connectivity/source/inc/java/lang/Boolean.hxx new file mode 100644 index 000000000000..ac92587af1f6 --- /dev/null +++ b/connectivity/source/inc/java/lang/Boolean.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * $RCSfile: Boolean.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_JAVA_LANG_BOOLEAN_HXX_ +#define _CONNECTIVITY_JAVA_LANG_BOOLEAN_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +//************************************************************** +//************ Class: java.lang.Boolean +//************************************************************** +namespace connectivity +{ + class java_lang_Boolean : public java_lang_Object + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_lang_Boolean(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_lang_Boolean( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + java_lang_Boolean( sal_Bool _par0 ); + }; +} + +#endif // _CONNECTIVITY_JAVA_LANG_BOOLEAN_HXX_ + + diff --git a/connectivity/source/inc/java/lang/Class.hxx b/connectivity/source/inc/java/lang/Class.hxx new file mode 100644 index 000000000000..3ee5265e7622 --- /dev/null +++ b/connectivity/source/inc/java/lang/Class.hxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * $RCSfile: Class.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_JAVA_LANG_CLASS_HXX_ +#define _CONNECTIVITY_JAVA_LANG_CLASS_HXX_ +//************************************************************** +//************ Class: java.lang.Class +//************************************************************** +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif + +namespace connectivity +{ + class java_lang_Class : public java_lang_Object + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_lang_Class(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_lang_Class( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + static java_lang_Class * forName( const ::rtl::OUString &_par0 ); + sal_Bool isAssignableFrom( java_lang_Class * _par0 ); + java_lang_Object * newInstance(); + ::rtl::OUString getName(); + }; +} + +#endif // _CONNECTIVITY_JAVA_LANG_CLASS_HXX_ + diff --git a/connectivity/source/inc/java/lang/Exception.hxx b/connectivity/source/inc/java/lang/Exception.hxx new file mode 100644 index 000000000000..48bcb9391b77 --- /dev/null +++ b/connectivity/source/inc/java/lang/Exception.hxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * $RCSfile: Exception.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_JAVA_LANG_EXCEPTION_HXX_ +#define _CONNECTIVITY_JAVA_LANG_EXCEPTION_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_THROWABLE_HXX_ +#include "java/lang/Throwable.hxx" +#endif + +namespace connectivity +{ + + //************************************************************** + //************ Class: java.lang.Exception + //************************************************************** + class java_lang_Exception : public java_lang_Throwable{ + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_lang_Exception(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_lang_Exception( JNIEnv * pEnv, jobject myObj ) : java_lang_Throwable( pEnv, myObj ){} + + }; +} +#endif // _CONNECTIVITY_JAVA_LANG_EXCEPTION_HXX_ + diff --git a/connectivity/source/inc/java/lang/Object.hxx b/connectivity/source/inc/java/lang/Object.hxx new file mode 100644 index 000000000000..d5e84074dc32 --- /dev/null +++ b/connectivity/source/inc/java/lang/Object.hxx @@ -0,0 +1,166 @@ +/************************************************************************* + * + * $RCSfile: Object.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_JAVA_LANG_OBJECT_HXX_ +#define _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ + +#if STLPORT_VERSION>=321 +// jni.h needs cstdarg for std::va_list +#include <cstdarg> +#endif +#include <jni.h> + +#ifdef OS2 +#include <typedefs.h> +#endif + +#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_ +#include <com/sun/star/sdbc/SQLException.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +//===================================================================== + +#ifdef HAVE_64BIT_POINTERS +#error "no 64 bit pointer" +#else +#ifdef OS2 +#define INT64_TO_PVOID(x) (void *)x.lo +inline jlong Make_Os2_Int64( sal_Int32 hi, sal_Int32 lo ) {jlong x = CONST64( hi, lo ); return x; } +#define PVOID_TO_INT64(x) Make_Os2_Int64( 0, (sal_Int32)x ) +#else //OS2 +#define PVOID_TO_INT64(x) (jlong)(sal_Int32)x +#define INT64_TO_PVOID(x) (void *)x +#endif //Os2 +#endif //HAVE_64BIT_POINTERS + +namespace connectivity +{ + + class SDBThreadAttach + { + sal_Bool bDetach; + protected: + void attachThread(JNIEnv * &pEnv,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory=NULL); + void detachThread(); + void xInit(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory=NULL); + int StartJava(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory=NULL); + + void setError(); + public: + JNIEnv * pEnv; + + SDBThreadAttach(); + SDBThreadAttach(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); + ~SDBThreadAttach(); + + static sal_Bool IsJavaErrorOccured(); + }; + //===================================================================== + class java_lang_Class; + class java_lang_Object + { + // Zuweisungsoperator und Copy Konstruktor sind verboten + java_lang_Object& operator = (java_lang_Object&) { return *this;}; + java_lang_Object(java_lang_Object&) {}; + + static jclass getMyClass(); + // nur zum Zerstoeren des C++ Pointers in vom JSbxObject + // abgeleiteten Java Objekten + //static jclass getJSbxObjectClass(); + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; + + protected: + // der JAVA Handle zu dieser Klasse + jobject object; + // Klassendefinition + + // neu in SJ2: + static jclass theClass; // die Klasse braucht nur einmal angefordert werden ! + static jclass theJSbxObjectClass; // die Klasse braucht nur einmal angefordert werden ! + static sal_uInt32 nObjCount; // Zaehler fuer die Anzahl der Instanzen + + static void ThrowSQLException(JNIEnv * pEnv,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> & _rContext) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + public: + // der Konstruktor, der fuer die abgeleiteten Klassen verwendet + // werden soll. + java_lang_Object( JNIEnv * pEnv, jobject myObj ); + // der eigentliche Konstruktor + java_lang_Object(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory=NULL); + + virtual ~java_lang_Object(); + + void saveRef( JNIEnv * pEnv, jobject myObj ); + jobject getJavaObject() const { return object; } + java_lang_Object * GetWrapper() { return this; } + + java_lang_Class * getClass(); + + ::rtl::OUString toString(); + }; +} +#endif //_CONNECTIVITY_JAVA_LANG_OBJJECT_HXX_ + + diff --git a/connectivity/source/inc/java/lang/String.hxx b/connectivity/source/inc/java/lang/String.hxx new file mode 100644 index 000000000000..09f8c161547c --- /dev/null +++ b/connectivity/source/inc/java/lang/String.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * $RCSfile: String.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_JAVA_LANG_STRING_HXX_ +#define _CONNECTIVITY_JAVA_LANG_STRING_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif + +namespace connectivity +{ + class java_lang_String : public java_lang_Object + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_lang_String(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_lang_String( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + java_lang_String( const ::rtl::OUString& _par0 ); + operator ::rtl::OUString(); + }; + +} + +#endif // _CONNECTIVITY_JAVA_LANG_STRING_HXX_ + diff --git a/connectivity/source/inc/java/lang/Throwable.hxx b/connectivity/source/inc/java/lang/Throwable.hxx new file mode 100644 index 000000000000..e2eb14d01b94 --- /dev/null +++ b/connectivity/source/inc/java/lang/Throwable.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * $RCSfile: Throwable.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_JAVA_LANG_THROWABLE_HXX_ +#define _CONNECTIVITY_JAVA_LANG_THROWABLE_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif + +namespace connectivity +{ + //************************************************************** + //************ Class: java.lang.Throwable + //************************************************************** + class java_lang_Throwable : public java_lang_Object + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_lang_Throwable(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_lang_Throwable( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + ::rtl::OUString getMessage() const; + ::rtl::OUString getLocalizedMessage() const; + ::rtl::OUString toString() const; + }; +} +#endif // _CONNECTIVITY_JAVA_LANG_THROWABLE_HXX_ + diff --git a/connectivity/source/inc/java/sql/Array.hxx b/connectivity/source/inc/java/sql/Array.hxx new file mode 100644 index 000000000000..675c2b6f94b7 --- /dev/null +++ b/connectivity/source/inc/java/sql/Array.hxx @@ -0,0 +1,106 @@ +/************************************************************************* + * + * $RCSfile: Array.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_ARRAY_HXX_ +#define _CONNECTIVITY_JAVA_SQL_ARRAY_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif + +#ifndef _COM_SUN_STAR_SDBC_XARRAY_HPP_ +#include <com/sun/star/sdbc/XArray.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + +namespace connectivity +{ + + //************************************************************** + //************ Class: java.sql.SQLWarning + //************************************************************** + class java_sql_Array : public java_lang_Object, + public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XArray> + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_Array(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_Array( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + // XArray + virtual ::rtl::OUString SAL_CALL getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBaseType( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getArray( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getArrayAtIndex( sal_Int32 index, sal_Int32 count, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSetAtIndex( sal_Int32 index, sal_Int32 count, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_ARRAY_HXX_ + diff --git a/connectivity/source/inc/java/sql/Blob.hxx b/connectivity/source/inc/java/sql/Blob.hxx new file mode 100644 index 000000000000..ae5b8e9315a5 --- /dev/null +++ b/connectivity/source/inc/java/sql/Blob.hxx @@ -0,0 +1,106 @@ +/************************************************************************* + * + * $RCSfile: Blob.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_BLOB_HXX_ +#define _CONNECTIVITY_JAVA_SQL_BLOB_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif + +#ifndef _COM_SUN_STAR_SDBC_XBLOB_HPP_ +#include <com/sun/star/sdbc/XBlob.hpp> +#endif + +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + +namespace connectivity +{ + + //************************************************************** + //************ Class: java.sql.SQLWarning + //************************************************************** + class java_sql_Blob : public java_lang_Object, + public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XBlob> + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_Blob(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_Blob( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + // XBlob + virtual sal_Int64 SAL_CALL length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int64 pos, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL position( const ::com::sun::star::uno::Sequence< sal_Int8 >& pattern, sal_Int64 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& pattern, sal_Int64 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_BLOB_HXX_ + diff --git a/connectivity/source/inc/java/sql/CallableStatement.hxx b/connectivity/source/inc/java/sql/CallableStatement.hxx new file mode 100644 index 000000000000..ccb0b1eeb603 --- /dev/null +++ b/connectivity/source/inc/java/sql/CallableStatement.hxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * $RCSfile: CallableStatement.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_CALLABLESTATEMENT_HXX_ +#define _CONNECTIVITY_JAVA_SQL_CALLABLESTATEMENT_HXX_ + +#ifndef _CONNECTIVITY_JAVA_SQL_PREPAREDSTATEMENT_HXX_ +#include "java/sql/PreparedStatement.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XOUTPARAMETERS_HPP_ +#include <com/sun/star/sdbc/XOutParameters.hpp> +#endif + +namespace connectivity +{ + + //************************************************************** + //************ Class: java.sql.CallableStatement + //************************************************************** + + class java_sql_CallableStatement : public java_sql_PreparedStatement, + public ::com::sun::star::sdbc::XRow, + public ::com::sun::star::sdbc::XOutParameters + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + DECLARE_CTY_DEFAULTS(java_sql_PreparedStatement); + DECLARE_SERVICE_INFO(); + static jclass getMyClass(); + virtual ~java_sql_CallableStatement() {} ; + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_CallableStatement( JNIEnv * pEnv, jobject myObj,java_sql_Connection* _pCon ) : java_sql_PreparedStatement( pEnv, myObj, _pCon ){} + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XOutParameters + virtual void SAL_CALL registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_CALLABLESTATEMENT_HXX_ + diff --git a/connectivity/source/inc/java/sql/Clob.hxx b/connectivity/source/inc/java/sql/Clob.hxx new file mode 100644 index 000000000000..51973701788a --- /dev/null +++ b/connectivity/source/inc/java/sql/Clob.hxx @@ -0,0 +1,104 @@ +/************************************************************************* + * + * $RCSfile: Clob.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_CLOB_HXX_ +#define _CONNECTIVITY_JAVA_SQL_CLOB_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XCLOB_HPP_ +#include <com/sun/star/sdbc/XClob.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + +namespace connectivity +{ + + //************************************************************** + //************ Class: java.sql.SQLWarning + //************************************************************** + class java_sql_Clob : public java_lang_Object, + public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XClob> + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_Clob(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_Clob( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + // XClob + virtual sal_Int64 SAL_CALL length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSubString( sal_Int64 pos, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL position( const ::rtl::OUString& searchstr, sal_Int32 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL positionOfClob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& pattern, sal_Int64 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_CLOB_HXX_ + diff --git a/connectivity/source/inc/java/sql/Connection.hxx b/connectivity/source/inc/java/sql/Connection.hxx new file mode 100644 index 000000000000..41c75be37704 --- /dev/null +++ b/connectivity/source/inc/java/sql/Connection.hxx @@ -0,0 +1,161 @@ +/************************************************************************* + * + * $RCSfile: Connection.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_CONNECTION_HXX_ +#define _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +#ifndef _CPPUHELPER_COMPBASE3_HXX_ +#include <cppuhelper/compbase3.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CONNECTIVITY_OSUBCOMPONENT_HXX_ +#include "OSubComponent.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + + +namespace connectivity +{ + class java_sql_Driver; + + typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XConnection, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::lang::XServiceInfo> java_sql_Connection_BASE; + + class java_sql_Connection : public java_sql_Connection_BASE, + public java_lang_Object, + public OSubComponent<java_sql_Connection> + { + friend class OSubComponent<java_sql_Connection>; + + ::osl::Mutex m_aMutex; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + OWeakRefArray m_aStatements; // vector containing a list + // of all the Statement objects + // for this Connection + java_sql_Driver* m_pDriver; + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static int TRANSACTION_NONE; + static int TRANSACTION_READ_COMMITTED; + static int TRANSACTION_READ_UNCOMMITTED; + static int TRANSACTION_REPEATABLE_READ; + static int TRANSACTION_SERIALIZABLE; + + static jclass getMyClass(); + virtual ~java_sql_Connection(); + DECLARE_SERVICE_INFO(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_Connection( JNIEnv * pEnv, jobject myObj,java_sql_Driver* _pDriver ) :java_sql_Connection_BASE(m_aMutex), + java_lang_Object( pEnv, myObj ), + OSubComponent<java_sql_Connection>((::cppu::OWeakObject*)_pDriver), + m_xMetaData(NULL), + m_pDriver(_pDriver){} + + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); + + // XConnection + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_ + diff --git a/connectivity/source/inc/java/sql/DatabaseMetaData.hxx b/connectivity/source/inc/java/sql/DatabaseMetaData.hxx new file mode 100644 index 000000000000..3a9396bd49ba --- /dev/null +++ b/connectivity/source/inc/java/sql/DatabaseMetaData.hxx @@ -0,0 +1,248 @@ +/************************************************************************* + * + * $RCSfile: DatabaseMetaData.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_DATABASEMETADATA_HXX_ +#define _CONNECTIVITY_JAVA_SQL_DATABASEMETADATA_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +namespace connectivity +{ + class java_sql_Connection; + //************************************************************** + //************ Class: java.sql.DatabaseMetaDataDate + //************************************************************** + + class java_sql_DatabaseMetaData : public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XDatabaseMetaData >, + public java_lang_Object + { + java_sql_Connection* m_pConnection; + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_DatabaseMetaData(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_DatabaseMetaData( JNIEnv * pEnv, jobject myObj,java_sql_Connection* _pConnection ) + : java_lang_Object( pEnv, myObj ),m_pConnection(_pConnection){} + + virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getUserName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCatalogAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogSeparator( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxStatements( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_DATABASEMETADATA_HXX_ + diff --git a/connectivity/source/inc/java/sql/Driver.hxx b/connectivity/source/inc/java/sql/Driver.hxx new file mode 100644 index 000000000000..612c60de9e8e --- /dev/null +++ b/connectivity/source/inc/java/sql/Driver.hxx @@ -0,0 +1,118 @@ +/************************************************************************* + * + * $RCSfile: Driver.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_DRIVER_HXX_ +#define _CONNECTIVITY_JAVA_SQL_DRIVER_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_ +#include <com/sun/star/sdbc/XDriver.hpp> +#endif +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif + +namespace connectivity +{ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL java_sql_Driver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ); + + class java_sql_Driver : public ::cppu::WeakImplHelper2< ::com::sun::star::sdbc::XDriver,::com::sun::star::lang::XServiceInfo>, + public java_lang_Object + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_Driver(); + + java_sql_Driver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); + java_sql_Driver( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + static rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // XDriver + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Int32 SAL_CALL getMajorVersion( ) throw(::com::sun::star::uno::RuntimeException) ; + virtual sal_Int32 SAL_CALL getMinorVersion( ) throw(::com::sun::star::uno::RuntimeException) ; + }; + +} +#endif //_CONNECTIVITY_JAVA_SQL_DRIVER_HXX_ + diff --git a/connectivity/source/inc/java/sql/DriverManager.hxx b/connectivity/source/inc/java/sql/DriverManager.hxx new file mode 100644 index 000000000000..9e8e54de2ffb --- /dev/null +++ b/connectivity/source/inc/java/sql/DriverManager.hxx @@ -0,0 +1,99 @@ +/************************************************************************* + * + * $RCSfile: DriverManager.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_DRIVERMANAGER_HXX_ +#define _CONNECTIVITY_JAVA_SQL_DRIVERMANAGER_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif + +namespace connectivity +{ + class java_sql_Driver; + class java_sql_Connection; + // class java_util_Properties; + //************************************************************** + //************ Class: java.sql.DriverManager + //************************************************************** + class java_sql_DriverManager : public java_lang_Object + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_DriverManager(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_DriverManager( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + static jobject getDriver(const ::rtl::OUString &url); + + // static java_sql_Connection * getConnection( const ::rtl::OUString* _par0 ); + // static java_sql_Connection * getConnection( const String* _par0, java_util_Properties * _par1 ); + // static java_sql_Connection * getConnection( const String* _par0, const String* _par1, const String* _par2 ); + // static java_util_Enumeration * getDrivers(); + static void setLoginTimeout(sal_Int32 _par0); + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_DRIVERMANAGER_HXX_ + diff --git a/connectivity/source/inc/java/sql/DriverPropertyInfo.hxx b/connectivity/source/inc/java/sql/DriverPropertyInfo.hxx new file mode 100644 index 000000000000..5a30b13054da --- /dev/null +++ b/connectivity/source/inc/java/sql/DriverPropertyInfo.hxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * $RCSfile: DriverPropertyInfo.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_DRIVERPOPERTYINFO_HXX_ +#define _CONNECTIVITY_JAVA_SQL_DRIVERPOPERTYINFO_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_DRIVERPROPERTYINFO_HPP_ +#include <com/sun/star/sdbc/DriverPropertyInfo.hpp> +#endif + +namespace connectivity +{ + +//************************************************************** +//************ Class: java.sql.DriverManager +//************************************************************** + class java_sql_DriverPropertyInfo : public java_lang_Object + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_DriverPropertyInfo(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_DriverPropertyInfo( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + operator ::com::sun::star::sdbc::DriverPropertyInfo(); + + ::rtl::OUString name() const; + ::rtl::OUString description() const; + ::rtl::OUString value() const; + sal_Bool required() const; + ::com::sun::star::uno::Sequence< ::rtl::OUString> choices() const; + }; +} + +#endif // _CONNECTIVITY_JAVA_SQL_DRIVERPOPERTYINFO_HXX_ + diff --git a/connectivity/source/inc/java/sql/PreparedStatement.hxx b/connectivity/source/inc/java/sql/PreparedStatement.hxx new file mode 100644 index 000000000000..1fd2131714e3 --- /dev/null +++ b/connectivity/source/inc/java/sql/PreparedStatement.hxx @@ -0,0 +1,146 @@ +/************************************************************************* + * + * $RCSfile: PreparedStatement.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_PREPAREDSTATEMENT_HXX_ +#define _CONNECTIVITY_JAVA_SQL_PREPAREDSTATEMENT_HXX_ + +#ifndef _CONNECTIVITY_JAVA_SQL_STATEMENT_HXX_ +#include "java/sql/Statement.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_ +#include <com/sun/star/sdbc/XPreparedStatement.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_ +#include <com/sun/star/sdbc/XParameters.hpp> +#endif +// #include <com/sun/star/sdbc/XClearParameters.hpp> +#ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HPP_ +#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +namespace connectivity +{ + //************************************************************** + //************ Class: java.sql.PreparedStatement + //************************************************************** + + class java_sql_PreparedStatement : public OStatement_BASE2, + public ::com::sun::star::sdbc::XPreparedStatement, + public ::com::sun::star::sdbc::XParameters, + public ::com::sun::star::sdbc::XPreparedBatchExecution, + public ::com::sun::star::lang::XServiceInfo + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + DECLARE_CTY_DEFAULTS(OStatement_BASE2); + DECLARE_SERVICE_INFO(); + static jclass getMyClass(); + virtual ~java_sql_PreparedStatement(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_PreparedStatement( JNIEnv * pEnv, jobject myObj,java_sql_Connection* _pCon ) : OStatement_BASE2( pEnv, myObj, _pCon ){} + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XPreparedStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XParameters + virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XPreparedBatchExecution + virtual void SAL_CALL addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_PREPAREDSTATEMENT_HXX_ + diff --git a/connectivity/source/inc/java/sql/Ref.hxx b/connectivity/source/inc/java/sql/Ref.hxx new file mode 100644 index 000000000000..7fd64e5ddc7b --- /dev/null +++ b/connectivity/source/inc/java/sql/Ref.hxx @@ -0,0 +1,99 @@ +/************************************************************************* + * + * $RCSfile: Ref.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_REF_HXX_ +#define _CONNECTIVITY_JAVA_SQL_REF_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XREF_HPP_ +#include <com/sun/star/sdbc/XRef.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + +namespace connectivity +{ + //************************************************************** + //************ Class: java.sql.Ref + //************************************************************** + class java_sql_Ref : public java_lang_Object, + public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XRef> + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_Ref(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_Ref( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + // XRef + virtual ::rtl::OUString SAL_CALL getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_REF_HXX_ + diff --git a/connectivity/source/inc/java/sql/ResultSet.hxx b/connectivity/source/inc/java/sql/ResultSet.hxx new file mode 100644 index 000000000000..996afc54e07f --- /dev/null +++ b/connectivity/source/inc/java/sql/ResultSet.hxx @@ -0,0 +1,272 @@ +/************************************************************************* + * + * $RCSfile: ResultSet.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_RESULTSET_HXX_ +#define _CONNECTIVITY_JAVA_SQL_RESULTSET_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_ +#include <com/sun/star/sdbc/XCloseable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_ +#include <com/sun/star/sdbc/XColumnLocate.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ +#include <com/sun/star/util/XCancellable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_ +#include <com/sun/star/sdbc/XRowUpdate.hpp> +#endif +#ifndef _CPPUHELPER_COMPBASE10_HXX_ +#include <cppuhelper/compbase10.hxx> +#endif +#ifndef _UNOTOOLS_PROPERTY_ARRAY_HELPER_HXX_ +#include <unotools/proparrhlp.hxx> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_STATEMENT_HXX_ +#include "java/sql/Statement.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +namespace connectivity +{ + + /* + ** java_sql_ResultSet + */ + typedef ::cppu::WeakComponentImplHelper10< ::com::sun::star::sdbc::XResultSet, + ::com::sun::star::sdbc::XRow, + ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + ::com::sun::star::util::XCancellable, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::sdbc::XResultSetUpdate, + ::com::sun::star::sdbc::XRowUpdate, + ::com::sun::star::sdbc::XCloseable, + ::com::sun::star::sdbc::XColumnLocate, + ::com::sun::star::lang::XServiceInfo> java_sql_ResultSet_BASE; + + class java_sql_ResultSet : public OBaseMutex, + public java_sql_ResultSet_BASE, + public java_lang_Object, + public ::cppu::OPropertySetHelper, + public ::utl::OPropertyArrayUsageHelper<java_sql_ResultSet> + { + ::com::sun::star::uno::WeakReferenceHelper m_aStatement; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; + + sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + virtual sal_Bool SAL_CALL convertFastPropertyValue( + ::com::sun::star::uno::Any & rConvertedValue, + ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle + ) const; + public: + DECLARE_CTY_DEFAULTS(java_sql_ResultSet_BASE); + DECLARE_SERVICE_INFO(); + static jclass getMyClass(); + virtual ~java_sql_ResultSet(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_ResultSet( JNIEnv * pEnv, jobject myObj,java_sql_Statement_Base* pStmt=NULL ) : java_sql_ResultSet_BASE(m_aMutex), + OPropertySetHelper(java_sql_ResultSet_BASE::rBHelper), + m_aStatement((::cppu::OWeakObject*)pStmt), + java_lang_Object( pEnv, myObj ) + {} + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) + { + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); + } + // XResultSet + virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetUpdate + virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRowUpdate + virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XColumnLocate + virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_RESULTSET_HXX_ + diff --git a/connectivity/source/inc/java/sql/ResultSetMetaData.hxx b/connectivity/source/inc/java/sql/ResultSetMetaData.hxx new file mode 100644 index 000000000000..43ced3ff4463 --- /dev/null +++ b/connectivity/source/inc/java/sql/ResultSetMetaData.hxx @@ -0,0 +1,118 @@ +/************************************************************************* + * + * $RCSfile: ResultSetMetaData.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_RESULTSETMETADATA_HXX_ +#define _CONNECTIVITY_JAVA_SQL_RESULTSETMETADATA_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + +namespace connectivity +{ + //************************************************************** + //************ Class: java.sql.ResultSetMetaData + //************************************************************** + + class java_sql_ResultSetMetaData : public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData>, + public java_lang_Object + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_ResultSetMetaData(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_ResultSetMetaData( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_RESULTSETMETADATA_HXX_ + diff --git a/connectivity/source/inc/java/sql/SQLException.hxx b/connectivity/source/inc/java/sql/SQLException.hxx new file mode 100644 index 000000000000..5dc1f898acfe --- /dev/null +++ b/connectivity/source/inc/java/sql/SQLException.hxx @@ -0,0 +1,106 @@ +/************************************************************************* + * + * $RCSfile: SQLException.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_SQLEXCEPTION_HXX_ +#define _CONNECTIVITY_JAVA_SQL_SQLEXCEPTION_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_EXCEPTION_HXX_ +#include "java/lang/Exception.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_ +#include <com/sun/star/sdbc/SQLException.hpp> +#endif + +namespace connectivity +{ + namespace starsdbc = ::com::sun::star::sdbc; + //************************************************************** + //************ Class: java.sql.SQLException + //************************************************************** + class java_sql_SQLException_BASE; + class java_sql_SQLException : public starsdbc::SQLException + { + public: + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_SQLException(){} + java_sql_SQLException( const java_sql_SQLException_BASE& _rException,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> & _rContext); + }; + + class java_sql_SQLException_BASE : public java_lang_Exception + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_SQLException_BASE(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_SQLException_BASE( JNIEnv * pEnv, jobject myObj ); + + ::rtl::OUString getSQLState() const; + sal_Int32 getErrorCode() const; + starsdbc::SQLException getNextException() const; + }; + +} +#endif // _CONNECTIVITY_JAVA_SQL_SQLEXCEPTION_HXX_ + diff --git a/connectivity/source/inc/java/sql/SQLWarning.hxx b/connectivity/source/inc/java/sql/SQLWarning.hxx new file mode 100644 index 000000000000..fa1e7e3d6f27 --- /dev/null +++ b/connectivity/source/inc/java/sql/SQLWarning.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * $RCSfile: SQLWarning.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_SQLWARNING_HXX_ +#define _CONNECTIVITY_JAVA_SQL_SQLWARNING_HXX_ + +#ifndef _CONNECTIVITY_JAVA_SQL_SQLEXCEPTION_HXX_ +#include "java/sql/SQLException.hxx" +#endif +//#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ +//#include <com/sun/star/sdbc/SQLWarning.hpp> +//#endif + +namespace connectivity +{ + // namespace starsdbc = ::com::sun::star::sdbc; + // namespace ::com::sun::star::uno = ::com::sun::star::uno; + //************************************************************** + //************ Class: java.sql.SQLWarning + //************************************************************** + class java_sql_SQLWarning_BASE : public java_sql_SQLException_BASE + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_SQLWarning_BASE(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_SQLWarning_BASE( JNIEnv * pEnv, jobject myObj ) : java_sql_SQLException_BASE( pEnv, myObj ){} + + }; + + class java_sql_SQLWarning : public java_sql_SQLException + { + public: + java_sql_SQLWarning(const java_sql_SQLWarning_BASE& _rW,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> & _rContext) + : java_sql_SQLException(_rW,_rContext) {} + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_SQLWARNING_HXX_ + diff --git a/connectivity/source/inc/java/sql/Timestamp.hxx b/connectivity/source/inc/java/sql/Timestamp.hxx new file mode 100644 index 000000000000..7729d38f71ed --- /dev/null +++ b/connectivity/source/inc/java/sql/Timestamp.hxx @@ -0,0 +1,151 @@ +/************************************************************************* + * + * $RCSfile: Timestamp.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_SQL_TIMESTAMP_HXX_ +#define _CONNECTIVITY_JAVA_SQL_TIMESTAMP_HXX_ + +#ifndef _CONNECTIVITY_JAVA_UTIL_DATE_HXX_ +#include "java/util/Date.hxx" +#endif +#ifndef _COM_SUN_STAR_UTIL_TIME_HPP_ +#include <com/sun/star/util/Time.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ +#include <com/sun/star/util/DateTime.hpp> +#endif + + +namespace connectivity +{ + //************************************************************** + //************ Class: java.sql.Date + //************************************************************** + + class java_sql_Date : public java_util_Date + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_Date(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_Date( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){} + 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()); + } + }; + + + //************************************************************** + //************ Class: java.sql.Time + //************************************************************** + + class java_sql_Time : public java_util_Date + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_Time(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_Time( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){} + 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()); + } + }; + + //************************************************************** + //************ Class: java.sql.Timestamp + //************************************************************** + class java_sql_Timestamp : public java_util_Date + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_sql_Timestamp(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_sql_Timestamp( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){} + 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()); + } + + sal_Int32 getNanos(); + void setNanos(sal_Int32 n); + }; +} +#endif // _CONNECTIVITY_JAVA_SQL_TIMESTAMP_HXX_ + diff --git a/connectivity/source/inc/java/tools.hxx b/connectivity/source/inc/java/tools.hxx new file mode 100644 index 000000000000..c65ee9f6745f --- /dev/null +++ b/connectivity/source/inc/java/tools.hxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * $RCSfile: tools.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:26 $ + * + * 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_JAVA_TOOLS_HXX_ +#define _CONNECTIVITY_JAVA_TOOLS_HXX_ + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif + +#ifndef JNI_H +#include <jni.h> +#endif +#ifndef _CONNECTIVITY_JAVA_SQL_SQLEXCEPTION_HXX_ +#include "java/sql/SQLException.hxx" +#endif + +#ifndef _UTL_UNO3_HXX_ +#include <unotools/uno3.hxx> +#endif + +//FORWARD_DECLARE_INTERFACE(container,XNameAccess) +//FORWARD_DECLARE_INTERFACE(uno,Reference) +#include <com/sun/star/container/XNameAccess.hpp> +#ifndef _COM_SUN_STAR_UTIL_TIME_HPP_ +#include <com/sun/star/util/Time.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ +#include <com/sun/star/util/Date.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ +#include <com/sun/star/util/DateTime.hpp> +#endif + + +namespace connectivity +{ + + jstring convertwchar_tToJavaString(JNIEnv *pEnv,const ::rtl::OUString& _Temp); + ::rtl::OUString JavaString2String(JNIEnv *pEnv,jstring _Str); + + jobjectArray createStringPropertyArray(JNIEnv *pEnv,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + template<class T,class JT> ::com::sun::star::uno::Sequence< T > copyArrayAndDelete(JNIEnv *pEnv,jobjectArray _Array,const T& _rD1,const JT& _rD2) + { + ::com::sun::star::uno::Sequence< T > xOut; + if(_Array) + { + jsize nLen = pEnv->GetArrayLength(_Array); + xOut.realloc(nLen); + for(jsize i=0;i<nLen;++i) + { + JT xInfo(pEnv,pEnv->GetObjectArrayElement(_Array,i)); + xOut.getArray()[i] = xInfo; + } + pEnv->DeleteLocalRef(_Array); + } + return xOut; + } + + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > Map2XNameAccess(JNIEnv *pEnv,jobject _pMap); + jobject XNameAccess2Map(JNIEnv *pEnv,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & _rMap); +} + +#endif // _CONNECTIVITY_JAVA_TOOLS_HXX_ + diff --git a/connectivity/source/inc/java/util/Date.hxx b/connectivity/source/inc/java/util/Date.hxx new file mode 100644 index 000000000000..121cce620d7c --- /dev/null +++ b/connectivity/source/inc/java/util/Date.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * $RCSfile: Date.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_JAVA_UTIL_DATE_HXX_ +#define _CONNECTIVITY_JAVA_UTIL_DATE_HXX_ + +#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ +#include "java/lang/Object.hxx" +#endif +#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ +#include <com/sun/star/util/Date.hpp> +#endif + +namespace connectivity +{ + + //************************************************************** + //************ Class: java.util.Date + //************************************************************** + + class java_util_Date : public java_lang_Object + { + protected: + // statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); + public: + static jclass getMyClass(); + virtual ~java_util_Date(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + java_util_Date( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + java_util_Date( const ::com::sun::star::util::Date& _rOut ); + + sal_Int32 getMonth(); + sal_Int32 getYear(); + sal_Int32 getDate(); + + sal_Int32 getMinutes(); + sal_Int32 getSeconds(); + sal_Int32 getHours(); + }; +} +#endif // _CONNECTIVITY_JAVA_UTIL_DATE_HXX_ + diff --git a/connectivity/source/inc/java/util/Property.hxx b/connectivity/source/inc/java/util/Property.hxx new file mode 100644 index 000000000000..ca24b386f895 --- /dev/null +++ b/connectivity/source/inc/java/util/Property.hxx @@ -0,0 +1,74 @@ +/************************************************************************* + * + * $RCSfile: Property.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +class java_util_Property : public java_lang_Object +{ +protected: +// statische Daten fuer die Klasse + static jclass theClass; + // der Destruktor um den Object-Counter zu aktualisieren + static void saveClassRef( jclass pClass ); +public: + static jclass getMyClass(); + virtual ~java_util_Property(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: +}; java_util_Property( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} diff --git a/connectivity/source/inc/odbc/OBoundParam.hxx b/connectivity/source/inc/odbc/OBoundParam.hxx new file mode 100644 index 000000000000..d7badbf6f207 --- /dev/null +++ b/connectivity/source/inc/odbc/OBoundParam.hxx @@ -0,0 +1,271 @@ +/************************************************************************* + * + * $RCSfile: OBoundParam.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_OBOUNPARAM_HXX_ +#define _CONNECTIVITY_OBOUNPARAM_HXX_ + +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ +#include <com/sun/star/io/XInputStream.hpp> +#endif + +namespace connectivity +{ + namespace odbc + { + class OBoundParam + { + + public: + OBoundParam() + { + pA1=0; + pA2=0; + pB1=0; + pB2=0; + pC1=0; + pC2=0; + pS1=0; + pS2=0; + } + //-------------------------------------------------------------------- + // initialize + // Perform an necessary initialization + //-------------------------------------------------------------------- + void initialize () + { + // Allocate storage for the length. Note - the length is + // stored in native format, and will have to be converted + // to a Java sal_Int32. The jdbcodbc 'C' bridge provides an + // interface to do this. + + paramLength = new sal_Int8[4]; + } + + //-------------------------------------------------------------------- + // allocBindDataBuffer + // Allocates and returns a new bind data buffer of the specified + // length + //-------------------------------------------------------------------- + sal_Int8* allocBindDataBuffer (sal_Int32 bufLen) + { + binaryData = new sal_Int8[bufLen]; + + // Reset the input stream, we are doing a new bind + setInputStream (NULL, 0); + + return binaryData; + } + + //-------------------------------------------------------------------- + // getBindDataBuffer + // Returns the data buffer to be used when binding to a parameter + //-------------------------------------------------------------------- + sal_Int8* getBindDataBuffer () + { + return binaryData; + } + + //-------------------------------------------------------------------- + // getBindLengthBuffer + // Returns the length buffer to be used when binding to a parameter + //-------------------------------------------------------------------- + sal_Int8* getBindLengthBuffer () + { + return paramLength; + } + + //-------------------------------------------------------------------- + // setInputStream + // Sets the input stream for the bound parameter + //-------------------------------------------------------------------- + void setInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& inputStream, + sal_Int32 len) + { + paramInputStream = inputStream; + paramInputStreamLen = len; + } + + //-------------------------------------------------------------------- + // getInputStream + // Gets the input stream for the bound parameter + //-------------------------------------------------------------------- + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> getInputStream () + { + return paramInputStream; + } + + //-------------------------------------------------------------------- + // getInputStreamLen + // Gets the input stream length for the bound parameter + //-------------------------------------------------------------------- + sal_Int32 getInputStreamLen () + { + return paramInputStreamLen; + } + + //-------------------------------------------------------------------- + // setSqlType + // Sets the Java sql type used to register an OUT parameter + //-------------------------------------------------------------------- + + void setSqlType(sal_Int32 type) + { + sqlType = type; + } + + //-------------------------------------------------------------------- + // getSqlType + // Gets the Java sql type used to register an OUT parameter + //-------------------------------------------------------------------- + + sal_Int32 getSqlType () + { + return sqlType; + } + + //-------------------------------------------------------------------- + // setStreamType + // Sets the input stream type used to register an OUT parameter + //-------------------------------------------------------------------- + + void setStreamType (sal_Int32 type) + { + streamType = type; + } + + //-------------------------------------------------------------------- + // getStreamType + // Gets the input stream type used to register an OUT parameter + //-------------------------------------------------------------------- + + sal_Int32 getStreamType () + { + return streamType; + } + + //-------------------------------------------------------------------- + // setOutputParameter + // Sets the flag indicating if this is an OUTPUT parameter + //-------------------------------------------------------------------- + + void setOutputParameter (sal_Bool output) + { + outputParameter = output; + } + + //-------------------------------------------------------------------- + // isOutputParameter + // Gets the OUTPUT parameter flag + //-------------------------------------------------------------------- + + sal_Bool isOutputParameter () + { + return outputParameter; + } + + protected: + //==================================================================== + // Data attributes + //==================================================================== + + sal_Int8* binaryData; // Storage area to be used + // when binding the parameter + + sal_Int8* paramLength; // Storage area to be used + // for the bound length of the + // parameter. Note that this + // data is in native format. + + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> paramInputStream; + // When an input stream is + // bound to a parameter, the + // input stream is saved + // until needed. + + sal_Int32 paramInputStreamLen; // Length of input stream + + sal_Int32 sqlType; // Java SQL type used to + // register an OUT parameter + + sal_Int32 streamType; // Input stream type + // (ASCII, BINARY, UNICODE) + + + sal_Bool outputParameter; // true for OUTPUT parameters + + + sal_Int32 pA1; //pointers + sal_Int32 pA2; + sal_Int32 pB1; + sal_Int32 pB2; + sal_Int32 pC1; + sal_Int32 pC2; + sal_Int32 pS1; + sal_Int32 pS2;// reserved for strings(UTFChars) + + public: + static int ASCII; + static int UNICODE; + static int BINARY; + }; + } +} +#endif // _CONNECTIVITY_OBOUNPARAM_HXX_ + diff --git a/connectivity/source/inc/odbc/OConnection.hxx b/connectivity/source/inc/odbc/OConnection.hxx new file mode 100644 index 000000000000..f4676efc88f2 --- /dev/null +++ b/connectivity/source/inc/odbc/OConnection.hxx @@ -0,0 +1,192 @@ +/************************************************************************* + * + * $RCSfile: OConnection.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_ODBC_OCONNECTION_HXX_ +#define _CONNECTIVITY_ODBC_OCONNECTION_HXX_ + +#ifndef _CPPUHELPER_COMPBASE3_HXX_ +#include <cppuhelper/compbase3.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ +#include <com/sun/star/sdbc/SQLWarning.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _CONNECTIVITY_OFUNCTIONDEFS_HXX_ +#include "odbc/OFunctiondefs.hxx" +#endif +#ifndef _CONNECTIVITY_OSUBCOMPONENT_HXX_ +#include "OSubComponent.hxx" +#endif +#ifndef _MAP_ +#include <map> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CONNECTIVITY_OTYPEINFO_HXX_ +#include "OTypeInfo.hxx" +#endif + +namespace connectivity +{ + namespace odbc + { + + class OStatement_Base; + class ODBCDriver; + class ODatabaseMetaData; + + typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XConnection, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::lang::XServiceInfo + > OConnection_BASE; + + class OConnection : public OConnection_BASE, + public connectivity::OSubComponent<OConnection> + { + friend class connectivity::OSubComponent<OConnection>; + + protected: + ::osl::Mutex m_aMutex; + //==================================================================== + // Data attributes + //==================================================================== + ::std::vector<connectivity::OTypeInfo> m_aTypeInfo; // vector containing an entry + // for each row returned by + // DatabaseMetaData.getTypeInfo. + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + + connectivity::OWeakRefArray m_aStatements; // vector containing a list + // of all the Statement objects + // for this Connection + + ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by + // an operation + ::rtl::OUString m_aURL; // URL of connection + ODBCDriver* m_pDriver; // Pointer to the owning + // driver object + + SQLHANDLE m_aConnectionHandle; + SQLHANDLE m_pDriverHandleCopy; // performance reason + sal_Bool m_bClosed; + + + SQLRETURN OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, sal_Bool bSilent); + + void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException); + public: + virtual SQLRETURN Construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException); + + OConnection(const SQLHANDLE _pDriverHandle,ODBCDriver* _pDriver); + // OConnection(const SQLHANDLE _pConnectionHandle); + virtual ~OConnection(); + + void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + DECLARE_SERVICE_INFO(); + + // XConnection + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // + SQLHANDLE getConnection() { return m_aConnectionHandle; } + }; + } +} +#endif // _CONNECTIVITY_ODBC_OCONNECTION_HXX_ + diff --git a/connectivity/source/inc/odbc/ODatabaseMetaData.hxx b/connectivity/source/inc/odbc/ODatabaseMetaData.hxx new file mode 100644 index 000000000000..4eb2cbfa048c --- /dev/null +++ b/connectivity/source/inc/odbc/ODatabaseMetaData.hxx @@ -0,0 +1,244 @@ +/************************************************************************* + * + * $RCSfile: ODatabaseMetaData.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_ODBC_ODATABASEMETADATA_HXX_ +#define _CONNECTIVITY_ODBC_ODATABASEMETADATA_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _CONNECTIVITY_ODBC_OCONNECTION_HXX_ +#include "odbc/OConnection.hxx" +#endif +namespace connectivity +{ + namespace odbc + { + //************************************************************** + //************ Class: java.sql.DatabaseMetaDataDate + //************************************************************** + + class ODatabaseMetaData : public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XDatabaseMetaData > + { + SQLHANDLE m_aConnectionHandle; + OConnection* m_pConnection; + public: + + ODatabaseMetaData(const SQLHANDLE _pHandle,OConnection* _pCon); + ~ODatabaseMetaData(); + // XDatabaseMetaData + virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getUserName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCatalogAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogSeparator( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxStatements( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ODBC_ODATABASEMETADATA_HXX_ + diff --git a/connectivity/source/inc/odbc/ODefs3.hxx b/connectivity/source/inc/odbc/ODefs3.hxx new file mode 100644 index 000000000000..de1fd44057c5 --- /dev/null +++ b/connectivity/source/inc/odbc/ODefs3.hxx @@ -0,0 +1,126 @@ +/************************************************************************* + * + * $RCSfile: ODefs3.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_ODBC_ODEFS_HXX_ +#define _CONNECTIVITY_ODBC_ODEFS_HXX_ + +#define N3SQLAllocHandle SQLAllocHandle +#define N3SQLConnect SQLConnect +#define N3SQLDriverConnect SQLDriverConnect +#define N3SQLBrowseConnect SQLBrowseConnect +#define N3SQLDataSources SQLDataSources +#define N3SQLDrivers SQLDrivers +#define N3SQLGetInfo SQLGetInfo +#define N3SQLGetFunctions SQLGetFunctions +#define N3SQLGetTypeInfo SQLGetTypeInfo +#define N3SQLSetConnectAttr SQLSetConnectAttr +#define N3SQLGetConnectAttr SQLGetConnectAttr +#define N3SQLSetEnvAttr SQLSetEnvAttr +#define N3SQLGetEnvAttr SQLGetEnvAttr +#define N3SQLSetStmtAttr SQLSetStmtAttr +#define N3SQLGetStmtAttr SQLgetStmtAttr +#define N3SQLSetDescField SQLSetDescField +#define N3SQLGetDescField SQLGetDescField +#define N3SQLGetDescRec SQLGetDescRec +#define N3SQLSetDescRec SQLSetDescRec +#define N3SQLPrepare SQLPrepare +#define N3SQLBindParameter SQLBindParameter +#define N3SQLGetCursorName SQLGetCursorName +#define N3SQLSetCursorName SQLSetCursorName +#define N3SQLExecute SQLExecute +#define N3SQLExecDirect SQLExecDirect +#define N3SQLNativeSql SQLNativeSql +#define N3SQLDescribeParam SQLDescribeParam +#define N3SQLNumParams SQLNumParams +#define N3SQLParamData SQLParamData +#define N3SQLPutData SQLPutData +#define N3SQLRowCount SQLRowCount +#define N3SQLNumResultCols SQLNumResultCols +#define N3SQLDescribeCol SQLDescribeCol +#define N3SQLColAttribute SQLColAttribute +#define N3SQLBindCol SQLBindCol +#define N3SQLFetch SQLFetch +#define N3SQLFetchScroll SQLFetchScroll +#define N3SQLGetData SQLGetData +#define N3SQLSetPos SQLSetPos +#define N3SQLBulkOperations SQLBulkOperations +#define N3SQLMoreResults SQLMoreResults +#define N3SQLGetDiagField SQLGetDiagField +#define N3SQLGetDiagRec SQLGetDiagRec +#define N3SQLColumnPrivileges SQLColumnPrivileges +#define N3SQLColumns SQLColumns +#define N3SQLForeignKeys SQLForeignKeys +#define N3SQLPrimaryKeys SQLPrimaryKeys +#define N3SQLProcedureColumns SQLProcedureColumns +#define N3SQLProcedures SQLProcedures +#define N3SQLSpecialColumns SQLSpecialColumns +#define N3SQLStatistics SQLStatistics +#define N3SQLTablePrivileges SQLTablePrivileges +#define N3SQLTables SQLTables +#define N3SQLFreeStmt SQLFreeStmt +#define N3SQLCloseCursor SQLCloseCursor +#define N3SQLCancel SQLCancel +#define N3SQLEndTran SQLEndTran +#define N3SQLDisconnect SQLDisconnect +#define N3SQLFreeHandle SQLFreeHandle +#define N3SQLGetCursorName SQLGetCursorName + +#endif // _CONNECTIVITY_ODBC_ODEFS_HXX_ + diff --git a/connectivity/source/inc/odbc/ODriver.hxx b/connectivity/source/inc/odbc/ODriver.hxx new file mode 100644 index 000000000000..d11769c582b5 --- /dev/null +++ b/connectivity/source/inc/odbc/ODriver.hxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * $RCSfile: ODriver.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_ODBC_ODRIVER_HXX_ +#define _CONNECTIVITY_ODBC_ODRIVER_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_ +#include <com/sun/star/sdbc/XDriver.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _CPPUHELPER_COMPBASE2_HXX_ +#include <cppuhelper/compbase2.hxx> +#endif +#ifndef _CONNECTIVITY_OFUNCTIONDEFS_HXX_ +#include "odbc/OFunctiondefs.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif + +namespace connectivity +{ + namespace odbc + { + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODBCDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ); + + typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XDriver, ::com::sun::star::lang::XServiceInfo > ODriver_BASE; + + class ODBCDriver : public ODriver_BASE + { + protected: + ::osl::Mutex m_aMutex; + + connectivity::OWeakRefArray m_xConnections; // vector containing a list + // of all the Connection objects + // for this Driver + + SQLHANDLE m_pDriverHandle; + + virtual SQLHANDLE EnvironmentHandle(::rtl::OUString &_rPath); + public: + + ODBCDriver(); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // XDriver + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); + }; + } + +} +#endif //_CONNECTIVITY_ODBC_ODRIVER_HXX_ + + diff --git a/connectivity/source/inc/odbc/OFunctiondefs.hxx b/connectivity/source/inc/odbc/OFunctiondefs.hxx new file mode 100644 index 000000000000..49fee156367c --- /dev/null +++ b/connectivity/source/inc/odbc/OFunctiondefs.hxx @@ -0,0 +1,232 @@ +/************************************************************************* + * + * $RCSfile: OFunctiondefs.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_OFUNCTIONDEFS_HXX_ +#define _CONNECTIVITY_OFUNCTIONDEFS_HXX_ + +#if defined(WIN) || defined(WNT) + +// #include "odbc3imp.hxx" +#include <tools/prewin.h> +#include <odbc/sqlext.h> +#include <tools/postwin.h> + + + + +#ifndef SQL_C_BOOKMARK +#define SQL_C_BOOKMARK SQL_C_ULONG /* BOOKMARK */ +#endif + +#ifndef SQL_OPT_TRACE_OFF +#define SQL_OPT_TRACE_OFF 0UL +#endif + +#define SDB_ODBC_CHAR UCHAR + +#endif + +//-------------------------------------------------------------------------- + +#ifdef MAC + +#include <mac_start.h> + +#define sal_Bool SQLBOOL +#define PFUNC SQLPFUNC + +#ifdef __powerc + +#ifndef _ODBCCFM_H +#include <ODBCCfm.h> +#endif + +#else + +#ifndef __ODBCSHAREDLIBRARY__ + #include <odbc/ODBCSharedLibrary.h> +#endif + +#endif + +#ifndef __SQLEXT + #include <odbc/sqlext.h> +#endif + +#include <mac_end.h> + +// Schnell wieder weg mit dem ganzen Zeug + +#undef sal_Bool +#undef PFUNC + +#ifdef __powerc + // Herkoemmliche Version (DLL-Bindung automatisch beim Start des Programms). + // odbcdefs.hxx biegt die in den Quellen benutzten NSQL-Methoden auf die + // herkoemmlichen SQL...-Aufrufe um. + // #include "odbc3defs.hxx" +#else + // Stub-Version: dynamische Bindung an die DLL zur Laufzeit. + // odbcstub definiert die in den Quellen benutzten NSQL...-Methoden + // als indirekte Funktionsaufrufe. + // odbcimp zieht sich selbst preos2, odbc und postos2 an. + // #include "odbc3imp.hxx" +#endif + +#define SDB_ODBC_CHAR UCHAR + +#endif + +//-------------------------------------------------------------------------- + +#ifdef OS2 + +#ifdef ODBCIMP + +// Stub-Version: dynamische Bindung an die DLL zur Laufzeit. +// odbcstub definiert die in den Quellen benutzten NSQL...-Methoden +// als indirekte Funktionsaufrufe. +// odbcimp zieht sich selbst preos2, odbc und postos2 an. +// #include "odbc3imp.hxx" + +#else + +// Zur Zeit verwenden wir die ODBC-DLL von Watcom-SQL direkt (ueber die +// mitgelieferte Lib). + +#ifndef ODBC_OS2 +#define ODBC_OS2 +#endif + +#include <svpm.h> +#include <odbc.h> +#define SQL_API __syscall +#ifndef SQL_MAX_MESSAGE_LENGTH +#define SQL_MAX_MESSAGE_LENGTH MAX_MESSAGE_LENGTH +#endif +#ifndef SQL_MAX_DSN_LENGTH +#define SQL_MAX_DSN_LENGTH MAX_DSN_LENGTH +#endif +#ifndef SQL_AUTOCOMMIT_ON +#define SQL_AUTOCOMMIT_ON 1UL +#endif +#ifndef SQL_AUTOCOMMIT_OFF +#define SQL_AUTOCOMMIT_OFF 0UL +#endif + +#define SQL_FETCH_PRIOR SQL_FETCH_PREV +#define SQL_NO_TOTAL (-4) + +// #include "odbc3defs.hxx" + +#endif + +// In der ODBC.H von Watcom werden Strings als char * erwartet +// (nicht, wie sonst bei ODBC ueblich, als UCHAR *). +#if defined( ICC ) || defined( WTC ) +#define SDB_ODBC_CHAR unsigned char +#else +#define SDB_ODBC_CHAR char +#endif + +#endif + +//-------------------------------------------------------------------------- + +#ifdef UNX + +#ifdef ODBCIMP +// Stub-Version: dynamische Bindung an die shared library zur Laufzeit. +// odbcstub definiert die in den Quellen benutzten NSQL...-Methoden +// als indirekte Funktionsaufrufe. +// odbcimp zieht sich selbst preos2, odbc und postos2 an. +// #include "odbc3imp.hxx" + +#else + +// Zur Zeit verwenden wir die ODBC-shared library von Q+E direkt (ueber die +// mitgelieferte Lib). + +#ifndef ODBC_UNX +#define ODBC_UNX +#endif +#include <odbc/qeodbc.h> +#define CALLBACK +#define EXPORT +#include <odbc/sqlext.h> +#undef sal_Bool // Ist in qeodbc.h definiert, wird aber von solar.h noch einmal + // definiert. + +// #include "odbc3defs.hxx" + +#endif // ODBCIMP + +#define SDB_ODBC_CHAR UCHAR +#define SQL_WCHAR (-8) +#define SQL_WVARCHAR (-9) +#define SQL_WLONGVARCHAR (-10) +#define SQL_C_WCHAR SQL_WCHAR + + +#endif // UNX +#endif // _CONNECTIVITY_OFUNCTIONDEFS_HXX_ + diff --git a/connectivity/source/inc/odbc/OFunctions.hxx b/connectivity/source/inc/odbc/OFunctions.hxx new file mode 100644 index 000000000000..bbfeefb91351 --- /dev/null +++ b/connectivity/source/inc/odbc/OFunctions.hxx @@ -0,0 +1,596 @@ +/************************************************************************* + * + * $RCSfile: OFunctions.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_ODBC_OFUNCTIONS_HXX_ +#define _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_ + +#ifndef _CONNECTIVITY_OFUNCTIONDEFS_HXX_ +#include "odbc/OFunctiondefs.hxx" +#endif +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif +#ifndef _OSL_MODULE_H_ +#include <osl/module.h> +#endif + +namespace connectivity +{ + + sal_Bool LoadFunctions(oslModule pODBCso, sal_Bool _bDS=sal_True); + sal_Bool LoadLibrary_ODBC3(::rtl::OUString &_rPath); + sal_Bool LoadLibrary_ADABAS(::rtl::OUString &_rPath); + + // Connecting to a data source + typedef SQLRETURN (SQL_API *T3SQLAllocHandle) (SQLSMALLINT HandleType,SQLHANDLE InputHandle,SQLHANDLE * OutputHandlePtr); + extern T3SQLAllocHandle pODBC3SQLAllocHandle; + #define N3SQLAllocHandle(a,b,c) (*pODBC3SQLAllocHandle)(a,b,c) + + typedef SQLRETURN (SQL_API *T3SQLConnect) (SQLHDBC ConnectionHandle,SQLCHAR *ServerName,SQLSMALLINT NameLength1,SQLCHAR *UserName,SQLSMALLINT NameLength2,SQLCHAR *Authentication,SQLSMALLINT NameLength3); + extern T3SQLConnect pODBC3SQLConnect; + #define N3SQLConnect(a,b,c,d,e,f,g) (*pODBC3SQLConnect)(a,b,c,d,e,f,g) + + typedef SQLRETURN (SQL_API *T3SQLDriverConnect) ( SQLHDBC ConnectionHandle, + HWND WindowHandle, + SQLCHAR * InConnectionString, + SQLSMALLINT StringLength1, + SQLCHAR * OutConnectionString, + SQLSMALLINT BufferLength, + SQLSMALLINT * StringLength2Ptr, + SQLUSMALLINT DriverCompletion); + extern T3SQLDriverConnect pODBC3SQLDriverConnect; + #define N3SQLDriverConnect(a,b,c,d,e,f,g,h) (*pODBC3SQLDriverConnect)(a,b,c,d,e,f,g,h) + + typedef SQLRETURN (SQL_API *T3SQLBrowseConnect) ( SQLHDBC ConnectionHandle, + SQLCHAR * InConnectionString, + SQLSMALLINT StringLength1, + SQLCHAR * OutConnectionString, + SQLSMALLINT BufferLength, + SQLSMALLINT * StringLength2Ptr); + extern T3SQLBrowseConnect pODBC3SQLBrowseConnect; + #define N3SQLBrowseConnect(a,b,c,d,e,f) (*pODBC3SQLBrowseConnect)(a,b,c,d,e,f) + + // Obtaining information about a driver and data source + typedef SQLRETURN (SQL_API *T3SQLDataSources) ( SQLHENV EnvironmentHandle, + SQLUSMALLINT Direction, + SQLCHAR * ServerName, + SQLSMALLINT BufferLength1, + SQLSMALLINT * NameLength1Ptr, + SQLCHAR * Description, + SQLSMALLINT BufferLength2, + SQLSMALLINT * NameLength2Ptr); + extern T3SQLDataSources pODBC3SQLDataSources; + #define N3SQLDataSources(a,b,c,d,e,f,g,h) (*pODBC3SQLDataSources)(a,b,c,d,e,f,g,h) + + typedef SQLRETURN (SQL_API *T3SQLDrivers) ( SQLHENV EnvironmentHandle, + SQLUSMALLINT Direction, + SQLCHAR * DriverDescription, + SQLSMALLINT BufferLength1, + SQLSMALLINT * DescriptionLengthPtr, + SQLCHAR * DriverAttributes, + SQLSMALLINT BufferLength2, + SQLSMALLINT * AttributesLengthPtr); + extern T3SQLDrivers pODBC3SQLDrivers; + #define N3SQLDrivers(a,b,c,d,e,f,g,h) (*pODBC3SQLDrivers)(a,b,c,d,e,f,g,h) + + typedef SQLRETURN (SQL_API *T3SQLGetInfo) ( SQLHDBC ConnectionHandle, + SQLUSMALLINT InfoType, + SQLPOINTER InfoValuePtr, + SQLSMALLINT BufferLength, + SQLSMALLINT * StringLengthPtr); + extern T3SQLGetInfo pODBC3SQLGetInfo; + #define N3SQLGetInfo(a,b,c,d,e) (*pODBC3SQLGetInfo)(a,b,c,d,e) + + typedef SQLRETURN (SQL_API *T3SQLGetFunctions) (SQLHDBC ConnectionHandle, + SQLUSMALLINT FunctionId, + SQLUSMALLINT * SupportedPtr); + extern T3SQLGetFunctions pODBC3SQLGetFunctions; + #define N3SQLGetFunctions(a,b,c) (*pODBC3SQLGetFunctions)(a,b,c) + + typedef SQLRETURN (SQL_API *T3SQLGetTypeInfo) ( SQLHSTMT StatementHandle, + SQLSMALLINT DataType); + extern T3SQLGetTypeInfo pODBC3SQLGetTypeInfo; + #define N3SQLGetTypeInfo(a,b) (*pODBC3SQLGetTypeInfo)(a,b) + + // Setting and retrieving driver attributes + typedef SQLRETURN (SQL_API *T3SQLSetConnectAttr)(SQLHDBC ConnectionHandle, + SQLINTEGER Attribute, + SQLPOINTER ValuePtr, + SQLINTEGER StringLength); + extern T3SQLSetConnectAttr pODBC3SQLSetConnectAttr; + #define N3SQLSetConnectAttr(a,b,c,d) (*pODBC3SQLSetConnectAttr)(a,b,c,d) + + typedef SQLRETURN (SQL_API *T3SQLGetConnectAttr) (SQLHDBC ConnectionHandle, + SQLINTEGER Attribute, + SQLPOINTER ValuePtr, + SQLINTEGER BufferLength, + SQLINTEGER* StringLength); + extern T3SQLGetConnectAttr pODBC3SQLGetConnectAttr; + #define N3SQLGetConnectAttr(a,b,c,d,e) (*pODBC3SQLGetConnectAttr)(a,b,c,d,e) + + + typedef SQLRETURN (SQL_API *T3SQLSetEnvAttr) ( SQLHENV EnvironmentHandle, + SQLINTEGER Attribute, + SQLPOINTER ValuePtr, + SQLINTEGER StringLength); + extern T3SQLSetEnvAttr pODBC3SQLSetEnvAttr; + #define N3SQLSetEnvAttr(a,b,c,d) (*pODBC3SQLSetEnvAttr)(a,b,c,d) + + typedef SQLRETURN (SQL_API *T3SQLGetEnvAttr) ( SQLHENV EnvironmentHandle, + SQLINTEGER Attribute, + SQLPOINTER ValuePtr, + SQLINTEGER BufferLength, + SQLINTEGER* StringLength); + extern T3SQLGetEnvAttr pODBC3SQLGetEnvAttr; + #define N3SQLGetEnvAttr(a,b,c,d,e) (*pODBC3SQLGetEnvAttr)(a,b,c,d,e) + + + typedef SQLRETURN (SQL_API *T3SQLSetStmtAttr) ( SQLHSTMT StatementHandle, + SQLINTEGER Attribute, + SQLPOINTER ValuePtr, + SQLINTEGER StringLength); + extern T3SQLSetStmtAttr pODBC3SQLSetStmtAttr; + #define N3SQLSetStmtAttr(a,b,c,d) (*pODBC3SQLSetStmtAttr)(a,b,c,d) + + typedef SQLRETURN (SQL_API *T3SQLGetStmtAttr) ( SQLHSTMT StatementHandle, + SQLINTEGER Attribute, + SQLPOINTER ValuePtr, + SQLINTEGER BufferLength, + SQLINTEGER* StringLength); + extern T3SQLGetStmtAttr pODBC3SQLGetStmtAttr; + #define N3SQLGetStmtAttr(a,b,c,d,e) (*pODBC3SQLGetStmtAttr)(a,b,c,d,e) + + // Setting and retrieving descriptor fields + /*typedef SQLRETURN (SQL_API *T3SQLSetDescField) (SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, + SQLSMALLINT FieldIdentifier, + SQLPOINTER ValuePtr, + SQLINTEGER BufferLength); + extern T3SQLSetDescField pODBC3SQLSetDescField; + #define N3SQLSetDescField(a,b,c,d,e) (*pODBC3SQLSetDescField)(a,b,c,d,e) + + typedef SQLRETURN (SQL_API *T3SQLGetDescField) ( SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, + SQLSMALLINT FieldIdentifier, + SQLPOINTER ValuePtr, + SQLINTEGER BufferLength, + SQLINTEGER * StringLengthPtr); + extern T3SQLGetDescField pODBC3SQLGetDescField; + #define N3SQLGetDescField(a,b,c,d,e,f) (*pODBC3SQLGetDescField)(a,b,c,d,e,f) + + + typedef SQLRETURN (SQL_API *T3SQLGetDescRec) ( SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, + SQLCHAR * Name, + SQLSMALLINT BufferLength, + SQLSMALLINT * StringLengthPtr, + SQLSMALLINT * TypePtr, + SQLSMALLINT * SubTypePtr, + SQLINTEGER * LengthPtr, + SQLSMALLINT * PrecisionPtr, + SQLSMALLINT * ScalePtr, + SQLSMALLINT * NullablePtr); + extern T3SQLGetDescRec pODBC3SQLGetDescRec; + #define N3SQLGetDescRec(a,b,c,d,e,f,g,h,i,j,k) (*pODBC3SQLGetDescRec)(a,b,c,d,e,f,g,h,i,j,k) + + + typedef SQLRETURN (SQL_API *T3SQLSetDescRec) ( SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, + SQLSMALLINT Type, + SQLSMALLINT SubType, + SQLINTEGER Length, + SQLSMALLINT Precision, + SQLSMALLINT Scale, + SQLPOINTER DataPtr, + SQLINTEGER * StringLengthPtr, + SQLINTEGER * IndicatorPtr); + extern T3SQLSetDescRec pODBC3SQLSetDescRec; + #define N3SQLSetDescRec(a,b,c,d,e,f,g,h,i,j) (*pODBC3SQLSetDescRec)(a,b,c,d,e,f,g,h,i,j) + */ + + // Preparing SQL requests + typedef SQLRETURN (SQL_API *T3SQLPrepare) ( SQLHSTMT StatementHandle, + SQLCHAR * StatementText, + SQLINTEGER TextLength); + extern T3SQLPrepare pODBC3SQLPrepare; + #define N3SQLPrepare(a,b,c) (*pODBC3SQLPrepare)(a,b,c) + + typedef SQLRETURN (SQL_API *T3SQLBindParameter) (SQLHSTMT StatementHandle, + SQLUSMALLINT ParameterNumber, + SQLSMALLINT InputOutputType, + SQLSMALLINT ValueType, + SQLSMALLINT ParameterType, + SQLUINTEGER ColumnSize, + SQLSMALLINT DecimalDigits, + SQLPOINTER ParameterValuePtr, + SQLINTEGER BufferLength, + SQLINTEGER * StrLen_or_IndPtr); + extern T3SQLBindParameter pODBC3SQLBindParameter; + #define N3SQLBindParameter(a,b,c,d,e,f,g,h,i,j) (*pODBC3SQLBindParameter)(a,b,c,d,e,f,g,h,i,j) + + /*typedef SQLRETURN (SQL_API *T3SQLGetCursorName) (SQLHSTMT StatementHandle, + SQLCHAR * CursorName, + SQLSMALLINT BufferLength, + SQLSMALLINT * NameLengthPtr); + extern T3SQLGetCursorName pODBC3SQLGetCursorName; + #define N3SQLGetCursorName(a,b,c,d) (*pODBC3SQLGetCursorName)(a,b,c,d) + */ + + typedef SQLRETURN (SQL_API *T3SQLSetCursorName) (SQLHSTMT StatementHandle, + SQLCHAR * CursorName, + SQLSMALLINT NameLength); + extern T3SQLSetCursorName pODBC3SQLSetCursorName; + #define N3SQLSetCursorName(a,b,c) (*pODBC3SQLSetCursorName)(a,b,c) + + // Submitting requests + typedef SQLRETURN (SQL_API *T3SQLExecute) ( SQLHSTMT StatementHandle); + extern T3SQLExecute pODBC3SQLExecute; + #define N3SQLExecute(a) (*pODBC3SQLExecute)(a) + + typedef SQLRETURN (SQL_API *T3SQLExecDirect) ( SQLHSTMT StatementHandle, + SQLCHAR * StatementText, + SQLINTEGER TextLength); + extern T3SQLExecDirect pODBC3SQLExecDirect; + #define N3SQLExecDirect(a,b,c) (*pODBC3SQLExecDirect)(a,b,c) + + /*typedef SQLRETURN (SQL_API *T3SQLNativeSql) ( SQLHDBC ConnectionHandle, + SQLCHAR * InStatementText, + SQLINTEGER TextLength1, + SQLCHAR * utStatementText, + SQLINTEGER BufferLength, + SQLINTEGER * TextLength2Ptr); + extern T3SQLNativeSql pODBC3SQLNativeSql; + #define N3SQLNativeSql(a,b,c,d,e,f) (*pODBC3SQLNativeSql)(a,b,c,d,e,f)*/ + + typedef SQLRETURN (SQL_API *T3SQLDescribeParam) (SQLHSTMT StatementHandle, + SQLUSMALLINT ParameterNumber, + SQLSMALLINT * DataTypePtr, + SQLUINTEGER * ParameterSizePtr, + SQLSMALLINT * DecimalDigitsPtr, + SQLSMALLINT * NullablePtr); + extern T3SQLDescribeParam pODBC3SQLDescribeParam; + #define N3SQLDescribeParam(a,b,c,d,e,f) (*pODBC3SQLDescribeParam)(a,b,c,d,e,f) + + typedef SQLRETURN (SQL_API *T3SQLNumParams) ( SQLHSTMT StatementHandle, + SQLSMALLINT * ParameterCountPtr); + extern T3SQLNumParams pODBC3SQLNumParams; + #define N3SQLNumParams(a,b) (*pODBC3SQLNumParams)(a,b) + + typedef SQLRETURN (SQL_API *T3SQLParamData) ( SQLHSTMT StatementHandle, + SQLPOINTER * ValuePtrPtr); + extern T3SQLParamData pODBC3SQLParamData; + #define N3SQLParamData(a,b) (*pODBC3SQLParamData)(a,b) + + typedef SQLRETURN (SQL_API *T3SQLPutData) ( SQLHSTMT StatementHandle, + SQLPOINTER DataPtr, + SQLINTEGER StrLen_or_Ind); + extern T3SQLPutData pODBC3SQLPutData; + #define N3SQLPutData(a,b,c) (*pODBC3SQLPutData)(a,b,c) + + // Retrieving results and information about results + typedef SQLRETURN (SQL_API *T3SQLRowCount) ( SQLHSTMT StatementHandle, + SQLINTEGER * RowCountPtr); + extern T3SQLRowCount pODBC3SQLRowCount; + #define N3SQLRowCount(a,b) (*pODBC3SQLRowCount)(a,b) + + typedef SQLRETURN (SQL_API *T3SQLNumResultCols) (SQLHSTMT StatementHandle, + SQLSMALLINT * ColumnCountPtr); + extern T3SQLNumResultCols pODBC3SQLNumResultCols; + #define N3SQLNumResultCols(a,b) (*pODBC3SQLNumResultCols)(a,b) + + typedef SQLRETURN (SQL_API *T3SQLDescribeCol) ( SQLHSTMT StatementHandle, + SQLSMALLINT ColumnNumber, + SQLCHAR * ColumnName, + SQLSMALLINT BufferLength, + SQLSMALLINT * NameLengthPtr, + SQLSMALLINT * DataTypePtr, + SQLUINTEGER * ColumnSizePtr, + SQLSMALLINT * DecimalDigitsPtr, + SQLSMALLINT * NullablePtr); + extern T3SQLDescribeCol pODBC3SQLDescribeCol; + #define N3SQLDescribeCol(a,b,c,d,e,f,g,h,i) (*pODBC3SQLDescribeCol)(a,b,c,d,e,f,g,h,i) + + typedef SQLRETURN (SQL_API *T3SQLColAttribute) (SQLHSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, + SQLUSMALLINT FieldIdentifier, + SQLPOINTER CharacterAttributePtr, + SQLSMALLINT BufferLength, + SQLSMALLINT * StringLengthPtr, + SQLPOINTER NumericAttributePtr); + extern T3SQLColAttribute pODBC3SQLColAttribute; + #define N3SQLColAttribute(a,b,c,d,e,f,g) (*pODBC3SQLColAttribute)(a,b,c,d,e,f,g) + + typedef SQLRETURN (SQL_API *T3SQLBindCol) ( SQLHSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, + SQLSMALLINT TargetType, + SQLPOINTER TargetValuePtr, + SQLINTEGER BufferLength, + SQLINTEGER * StrLen_or_IndPtr); + extern T3SQLBindCol pODBC3SQLBindCol; + #define N3SQLBindCol(a,b,c,d,e,f) (*pODBC3SQLBindCol)(a,b,c,d,e,f) + + typedef SQLRETURN (SQL_API *T3SQLFetch) ( SQLHSTMT StatementHandle); + extern T3SQLFetch pODBC3SQLFetch; + #define N3SQLFetch(a) (*pODBC3SQLFetch)(a) + + typedef SQLRETURN (SQL_API *T3SQLFetchScroll) ( SQLHSTMT StatementHandle, + SQLSMALLINT FetchOrientation, + SQLINTEGER FetchOffset); + extern T3SQLFetchScroll pODBC3SQLFetchScroll; + #define N3SQLFetchScroll(a,b,c) (*pODBC3SQLFetchScroll)(a,b,c) + + typedef SQLRETURN (SQL_API *T3SQLGetData) ( SQLHSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, + SQLSMALLINT TargetType, + SQLPOINTER TargetValuePtr, + SQLINTEGER BufferLength, + SQLINTEGER * StrLen_or_IndPtr); + extern T3SQLGetData pODBC3SQLGetData; + #define N3SQLGetData(a,b,c,d,e,f) (*pODBC3SQLGetData)(a,b,c,d,e,f) + + typedef SQLRETURN (SQL_API *T3SQLSetPos) ( SQLHSTMT StatementHandle, + SQLUSMALLINT RowNumber, + SQLUSMALLINT Operation, + SQLUSMALLINT LockType); + extern T3SQLSetPos pODBC3SQLSetPos; + #define N3SQLSetPos(a,b,c,d) (*pODBC3SQLSetPos)(a,b,c,d) + + typedef SQLRETURN (SQL_API *T3SQLBulkOperations) ( SQLHSTMT StatementHandle, + SQLUSMALLINT Operation); + extern T3SQLBulkOperations pODBC3SQLBulkOperations; + #define N3SQLBulkOperations(a,b) (*pODBC3SQLBulkOperations)(a,b) + + typedef SQLRETURN (SQL_API *T3SQLMoreResults) ( SQLHSTMT StatementHandle); + extern T3SQLMoreResults pODBC3SQLMoreResults; + #define N3SQLMoreResults(a) (*pODBC3SQLMoreResults)(a) + + /*typedef SQLRETURN (SQL_API *T3SQLGetDiagField) (SQLSMALLINT HandleType, + SQLHANDLE Handle, + SQLSMALLINT RecNumber, + SQLSMALLINT DiagIdentifier, + SQLPOINTER DiagInfoPtr, + SQLSMALLINT BufferLength, + SQLSMALLINT * StringLengthPtr); + extern T3SQLGetDiagField pODBC3SQLGetDiagField; + #define N3SQLGetDiagField(a,b,c,d,e,f,g) (*pODBC3SQLGetDiagField)(a,b,c,d,e,f,g)*/ + + typedef SQLRETURN (SQL_API *T3SQLGetDiagRec) ( SQLSMALLINT HandleType, + SQLHANDLE Handle, + SQLSMALLINT RecNumber, + SQLCHAR * Sqlstate, + SQLINTEGER * NativeErrorPtr, + SQLCHAR * MessageText, + SQLSMALLINT BufferLength, + SQLSMALLINT * TextLengthPtr); + + extern T3SQLGetDiagRec pODBC3SQLGetDiagRec; + #define N3SQLGetDiagRec(a,b,c,d,e,f,g,h) (*pODBC3SQLGetDiagRec)(a,b,c,d,e,f,g,h) + + // Obtaining information about the data sources system tables (catalog functions) + typedef SQLRETURN (SQL_API *T3SQLColumnPrivileges) (SQLHSTMT StatementHandle, + SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR * TableName, + SQLSMALLINT NameLength3, + SQLCHAR * ColumnName, + SQLSMALLINT NameLength4); + extern T3SQLColumnPrivileges pODBC3SQLColumnPrivileges; + #define N3SQLColumnPrivileges(a,b,c,d,e,f,g,h,i) (*pODBC3SQLColumnPrivileges)(a,b,c,d,e,f,g,h,i) + + typedef SQLRETURN (SQL_API *T3SQLColumns) ( SQLHSTMT StatementHandle, + SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR * TableName, + SQLSMALLINT NameLength3, + SQLCHAR * ColumnName, + SQLSMALLINT NameLength4); + extern T3SQLColumns pODBC3SQLColumns; + #define N3SQLColumns(a,b,c,d,e,f,g,h,i) (*pODBC3SQLColumns)(a,b,c,d,e,f,g,h,i) + + typedef SQLRETURN (SQL_API *T3SQLForeignKeys) ( SQLHSTMT StatementHandle, + SQLCHAR * PKCatalogName, + SQLSMALLINT NameLength1, + SQLCHAR * PKSchemaName, + SQLSMALLINT NameLength2, + SQLCHAR * PKTableName, + SQLSMALLINT NameLength3, + SQLCHAR * FKCatalogName, + SQLSMALLINT NameLength4, + SQLCHAR * FKSchemaName, + SQLSMALLINT NameLength5, + SQLCHAR * FKTableName, + SQLSMALLINT NameLength6); + extern T3SQLForeignKeys pODBC3SQLForeignKeys; + #define N3SQLForeignKeys(a,b,c,d,e,f,g,h,i,j,k,l,m) (*pODBC3SQLForeignKeys)(a,b,c,d,e,f,g,h,i,j,k,l,m) + + typedef SQLRETURN (SQL_API *T3SQLPrimaryKeys) ( SQLHSTMT StatementHandle, + SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR * TableName, + SQLSMALLINT NameLength3); + extern T3SQLPrimaryKeys pODBC3SQLPrimaryKeys; + #define N3SQLPrimaryKeys(a,b,c,d,e,f,g) (*pODBC3SQLPrimaryKeys)(a,b,c,d,e,f,g) + + typedef SQLRETURN (SQL_API *T3SQLProcedureColumns) (SQLHSTMT StatementHandle, + SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR * ProcName, + SQLSMALLINT NameLength3, + SQLCHAR * ColumnName, + SQLSMALLINT NameLength4); + extern T3SQLProcedureColumns pODBC3SQLProcedureColumns; + #define N3SQLProcedureColumns(a,b,c,d,e,f,g,h,i) (*pODBC3SQLProcedureColumns)(a,b,c,d,e,f,g,h,i) + + typedef SQLRETURN (SQL_API *T3SQLProcedures) ( SQLHSTMT StatementHandle, + SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR * ProcName, + SQLSMALLINT NameLength3); + extern T3SQLProcedures pODBC3SQLProcedures; + #define N3SQLProcedures(a,b,c,d,e,f,g) (*pODBC3SQLProcedures)(a,b,c,d,e,f,g) + + typedef SQLRETURN (SQL_API *T3SQLSpecialColumns) (SQLHSTMT StatementHandle, + SQLSMALLINT IdentifierType, + SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR * TableName, + SQLSMALLINT NameLength3, + SQLSMALLINT Scope, + SQLSMALLINT Nullable); + extern T3SQLSpecialColumns pODBC3SQLSpecialColumns; + #define N3SQLSpecialColumns(a,b,c,d,e,f,g,h,i,j) (*pODBC3SQLSpecialColumns)(a,b,c,d,e,f,g,h,i,j) + + typedef SQLRETURN (SQL_API *T3SQLStatistics) ( SQLHSTMT StatementHandle, + SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR * TableName, + SQLSMALLINT NameLength3, + SQLUSMALLINT Unique, + SQLUSMALLINT Reserved); + extern T3SQLStatistics pODBC3SQLStatistics; + #define N3SQLStatistics(a,b,c,d,e,f,g,h,i) (*pODBC3SQLStatistics)(a,b,c,d,e,f,g,h,i) + + typedef SQLRETURN (SQL_API *T3SQLTablePrivileges) (SQLHSTMT StatementHandle, + SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR * TableName, + SQLSMALLINT NameLength3); + extern T3SQLTablePrivileges pODBC3SQLTablePrivileges; + #define N3SQLTablePrivileges(a,b,c,d,e,f,g) (*pODBC3SQLTablePrivileges)(a,b,c,d,e,f,g) + + typedef SQLRETURN (SQL_API *T3SQLTables) ( SQLHSTMT StatementHandle, + SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, + SQLCHAR * TableName, + SQLSMALLINT NameLength3, + SQLCHAR * TableType, + SQLSMALLINT NameLength4); + extern T3SQLTables pODBC3SQLTables; + #define N3SQLTables(a,b,c,d,e,f,g,h,i) (*pODBC3SQLTables)(a,b,c,d,e,f,g,h,i) + + // Terminating a statement + typedef SQLRETURN (SQL_API *T3SQLFreeStmt) ( SQLHSTMT StatementHandle, + SQLUSMALLINT Option); + extern T3SQLFreeStmt pODBC3SQLFreeStmt; + #define N3SQLFreeStmt(a,b) (*pODBC3SQLFreeStmt)(a,b) + + typedef SQLRETURN (SQL_API *T3SQLCloseCursor) (SQLHSTMT StatementHandle); + extern T3SQLCloseCursor pODBC3SQLCloseCursor; + #define N3SQLCloseCursor(a) (*pODBC3SQLCloseCursor)(a) + + typedef SQLRETURN (SQL_API *T3SQLCancel) ( SQLHSTMT StatementHandle); + extern T3SQLCancel pODBC3SQLCancel; + #define N3SQLCancel(a) (*pODBC3SQLCancel)(a) + + typedef SQLRETURN (SQL_API *T3SQLEndTran) ( SQLSMALLINT HandleType, + SQLHANDLE Handle, + SQLSMALLINT CompletionType); + extern T3SQLEndTran pODBC3SQLEndTran; + #define N3SQLEndTran(a,b,c) (*pODBC3SQLEndTran)(a,b,c) + + // Terminating a connection + typedef SQLRETURN (SQL_API *T3SQLDisconnect) (SQLHDBC ConnectionHandle); + extern T3SQLDisconnect pODBC3SQLDisconnect; + #define N3SQLDisconnect(a) (*pODBC3SQLDisconnect)(a) + + typedef SQLRETURN (SQL_API *T3SQLFreeHandle) (SQLSMALLINT HandleType, + SQLHANDLE Handle); + extern T3SQLFreeHandle pODBC3SQLFreeHandle; + #define N3SQLFreeHandle(a,b) (*pODBC3SQLFreeHandle)(a,b) + + typedef SQLRETURN (SQL_API *T3SQLGetCursorName) ( SQLHSTMT StatementHandle, + SQLCHAR * CursorName, + SQLSMALLINT BufferLength, + SQLSMALLINT* NameLength2); + extern T3SQLGetCursorName pODBC3SQLGetCursorName; + #define N3SQLGetCursorName(a,b,c,d) (*pODBC3SQLGetCursorName)(a,b,c,d) + + typedef SQLRETURN (SQL_API *T3SQLNativeSql) ( SQLHSTMT ConnectionHandle, + SQLCHAR * InStatementText, + SQLINTEGER TextLength1, + SQLCHAR * OutStatementText, + SQLINTEGER BufferLength, + SQLINTEGER * TextLength2Ptr); + extern T3SQLNativeSql pODBC3SQLNativeSql; + #define N3SQLNativeSql(a,b,c,d,e,f) (*pODBC3SQLNativeSql)(a,b,c,d,e,f) +} + +#endif // _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_ + + diff --git a/connectivity/source/inc/odbc/OPreparedStatement.hxx b/connectivity/source/inc/odbc/OPreparedStatement.hxx new file mode 100644 index 000000000000..f8bb8a24056a --- /dev/null +++ b/connectivity/source/inc/odbc/OPreparedStatement.hxx @@ -0,0 +1,188 @@ +/************************************************************************* + * + * $RCSfile: OPreparedStatement.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_ODBC_OPREPAREDSTATEMENT_HXX_ +#define _CONNECTIVITY_ODBC_OPREPAREDSTATEMENT_HXX_ + + +#ifndef _CONNECTIVITY_ODBC_OSTATEMENT_HXX_ +#include "odbc/OStatement.hxx" +#endif + +#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_ +#include <com/sun/star/sdbc/XPreparedStatement.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_ +#include <com/sun/star/sdbc/XParameters.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +// #include <com/sun/star/sdbc/XClearParameters.hpp> +#ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HPP_ +#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ +#include <com/sun/star/io/XInputStream.hpp> +#endif + +namespace connectivity +{ + namespace odbc + { + + class OBoundParam; + + class OPreparedStatement : public OStatement_BASE2, + public ::com::sun::star::sdbc::XPreparedStatement, + public ::com::sun::star::sdbc::XParameters, + public ::com::sun::star::sdbc::XPreparedBatchExecution, + public ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + public ::com::sun::star::lang::XServiceInfo + + { + protected: + //==================================================================== + // Data attributes + //==================================================================== + ::std::vector<OTypeInfo> m_aTypeInfo; // Hashtable containing an entry + // for each row returned by + // DatabaseMetaData.getTypeInfo. + + int numParams; // Number of parameter markers + // for the prepared statement + + OBoundParam* boundParams; + // Array of bound parameter + // objects. Each parameter + // marker will have a + // corresponding object to + // hold bind information, and + // resulting data. + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData; + + void FreeParams(); + void putParamData (sal_Int32 index) throw(::com::sun::star::sdbc::SQLException); + void setChar(sal_Int32 parameterIndex,sal_Int32 SQLtype,sal_Int32 scale,const ::rtl::OUString& x) throw(::com::sun::star::sdbc::SQLException); + void setBinary(sal_Int32 parameterIndex,sal_Int32 SQLtype,const ::com::sun::star::uno::Sequence< sal_Int8 >& x) throw(::com::sun::star::sdbc::SQLException); + void setStream (sal_Int32 ParameterIndex,const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x, + sal_Int32 length,sal_Int32 SQLtype,sal_Int32 streamType) throw(::com::sun::star::sdbc::SQLException); + sal_Int32 getParamLength ( sal_Int32 index); + sal_Int8* getLengthBuf (sal_Int32 index); + sal_Int8* getDataBuf (sal_Int32 index); + sal_Int8* allocBindBuf ( sal_Int32 index, sal_Int32 bufLen); + void initBoundParam () throw(::com::sun::star::sdbc::SQLException); + + sal_Int32 getPrecision ( sal_Int32 sqlType); + + public: + DECLARE_CTY_DEFAULTS(OStatement_BASE2); + DECLARE_SERVICE_INFO(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OPreparedStatement( OConnection* _pConnection,const ::std::vector<OTypeInfo>& _TypeInfo,const ::rtl::OUString& sql); + + //XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XPreparedStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XParameters + virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XPreparedBatchExecution + virtual void SAL_CALL addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ODBC_OPREPAREDSTATEMENT_HXX_ + diff --git a/connectivity/source/inc/odbc/OResultSet.hxx b/connectivity/source/inc/odbc/OResultSet.hxx new file mode 100644 index 000000000000..c38e5002960b --- /dev/null +++ b/connectivity/source/inc/odbc/OResultSet.hxx @@ -0,0 +1,363 @@ +/************************************************************************* + * + * $RCSfile: OResultSet.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_ODBC_ORESULTSET_HXX_ +#define _CONNECTIVITY_ODBC_ORESULTSET_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_ +#include <com/sun/star/sdbc/XCloseable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_ +#include <com/sun/star/sdbc/XColumnLocate.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ +#include <com/sun/star/util/XCancellable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_ +#include <com/sun/star/sdbc/XRowUpdate.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_ +#include <com/sun/star/sdbcx/XRowLocate.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDELETEROWS_HPP_ +#include <com/sun/star/sdbcx/XDeleteRows.hpp> +#endif +#ifndef _CPPUHELPER_COMPBASE12_HXX_ +#include <cppuhelper/compbase12.hxx> +#endif +#ifndef _UNOTOOLS_PROPERTY_ARRAY_HELPER_HXX_ +#include <unotools/proparrhlp.hxx> +#endif +#ifndef _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_ +#include "odbc/OFunctions.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OSTATEMENT_HXX_ +#include "odbc/OStatement.hxx" +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif + +namespace connectivity +{ + namespace odbc + { + + /* + ** java_sql_ResultSet + */ + typedef ::cppu::WeakComponentImplHelper12< ::com::sun::star::sdbc::XResultSet, + ::com::sun::star::sdbc::XRow, + ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + ::com::sun::star::util::XCancellable, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::sdbc::XResultSetUpdate, + ::com::sun::star::sdbc::XRowUpdate, + ::com::sun::star::sdbcx::XRowLocate, + ::com::sun::star::sdbcx::XDeleteRows, + ::com::sun::star::sdbc::XCloseable, + ::com::sun::star::sdbc::XColumnLocate, + ::com::sun::star::lang::XServiceInfo> OResultSet_BASE; + + + + class OResultSet : public OBaseMutex, + public OResultSet_BASE, + public ::cppu::OPropertySetHelper, + public ::utl::OPropertyArrayUsageHelper<OResultSet> + { + + ::std::vector<void*> m_aBindVector; + ::std::vector<sal_Int32> m_aLengthVector; + ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime + ::std::vector< ::com::sun::star::uno::Any> m_aRow; // only used when SQLGetData can't be called in any order + SQLHANDLE m_aStatementHandle; + SQLHANDLE m_aConnectionHandle; + ::com::sun::star::uno::WeakReferenceHelper m_aStatement; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; + SQLUSMALLINT* m_pRowStatusArray; + sal_Int32 m_nRowPos; + sal_Int32 m_nLastColumnPos; // used for m_aRow just to know where we are + SQLRETURN m_nCurrentFetchState; + sal_Bool m_bWasNull; + sal_Bool m_bBOF; // before first record + sal_Bool m_bEOF; // after last record + sal_Bool m_bLastRecord; + sal_Bool m_bFreeHandle; + sal_Bool m_bInserting; + sal_Bool m_bFetchData; // true when SQLGetaData can be called in any order or when fetching data for m_aRow + + sal_Bool isBookmarkable() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + + void fillRow(sal_Int32 _nToColumn); + void allocBuffer(sal_Bool _bAllocRow); + void releaseBuffer(); + + protected: + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + virtual sal_Bool SAL_CALL convertFastPropertyValue( + ::com::sun::star::uno::Any & rConvertedValue, + ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle + ) const; + public: + DECLARE_CTY_DEFAULTS(OResultSet_BASE); + DECLARE_SERVICE_INFO(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OResultSet( SQLHANDLE _pStatementHandle,OStatement_Base* pStmt); + OResultSet( SQLHANDLE _pStatementHandle); + ~OResultSet(); + + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *() + { + return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(OResultSet_BASE*)this); + } + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) + { + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); + } + // XResultSet + virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetUpdate + virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRowUpdate + virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XColumnLocate + virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRowLocate + virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XDeleteRows + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // special methods + inline sal_Int32 mapColumn(sal_Int32 column); + void openTablesTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openTypeInfo() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openCatalogs() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openSchemas() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openTables(const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern )throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern )throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern,const ::rtl::OUString& columnNamePattern )throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern)throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openVersionColumns(const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table)throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table,sal_Int32 scope,sal_Bool nullable )throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openForeignKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString* schema,const ::rtl::OUString* table, + const ::com::sun::star::uno::Any& catalog2, const ::rtl::OUString* schema2,const ::rtl::OUString* table2)throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openExportedKeys(const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema,const ::rtl::OUString& table)throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openImportedKeys(const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema,const ::rtl::OUString& table)throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openPrimaryKeys(const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema,const ::rtl::OUString& table)throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openTablePrivileges(const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern)throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openSpecialColumns(sal_Bool _bRowVer,const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table,sal_Int32 scope, sal_Bool nullable )throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void openIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, + const ::rtl::OUString& table,sal_Bool unique,sal_Bool approximate )throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + }; + // ------------------------------------------------------------------------- + inline sal_Int32 OResultSet::mapColumn (sal_Int32 column) + { + sal_Int32 map = column; + + if (m_aColMapping.size()) + { + // Validate column number + OSL_ENSHURE(column>0,"OResultSet::mapColumn column <= 0"); + map = m_aColMapping[column]; + } + + return map; + } + } +} +#endif // _CONNECTIVITY_ODBC_ORESULTSET_HXX_ + + diff --git a/connectivity/source/inc/odbc/OResultSetMetaData.hxx b/connectivity/source/inc/odbc/OResultSetMetaData.hxx new file mode 100644 index 000000000000..b4f147c73adc --- /dev/null +++ b/connectivity/source/inc/odbc/OResultSetMetaData.hxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * $RCSfile: OResultSetMetaData.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_ODBC_ORESULTSETMETADATA_HXX_ +#define _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_ +#include "odbc/OFunctions.hxx" +#endif +#ifndef _VECTOR_ +#include <vector> +#endif + +namespace connectivity +{ + namespace odbc + { + //************************************************************** + //************ Class: ResultSetMetaData + //************************************************************** + typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE; + + class OResultSetMetaData : public OResultSetMetaData_BASE + { + ::std::vector<sal_Int32> m_vMapping; // when not every column is needed + + SQLHANDLE m_aStatementHandle; + sal_Int32 m_nColCount; + + ::rtl::OUString getCharColAttrib(sal_Int32 column,sal_Int32 ident) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getNumColAttrib(sal_Int32 column,sal_Int32 ident) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + public: + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OResultSetMetaData( SQLHANDLE _pStmt ) : m_aStatementHandle( _pStmt ),m_nColCount(-1){} + OResultSetMetaData( SQLHANDLE _pStmt ,const ::std::vector<sal_Int32> & _vMapping) + : m_aStatementHandle( _pStmt ),m_vMapping(_vMapping),m_nColCount(_vMapping.size()-1){} + ~OResultSetMetaData(); + + /// Avoid ambigous cast error from the compiler. + inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw() + { return this; } + + virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_ + diff --git a/connectivity/source/inc/odbc/OStatement.hxx b/connectivity/source/inc/odbc/OStatement.hxx new file mode 100644 index 000000000000..86839c2daf5c --- /dev/null +++ b/connectivity/source/inc/odbc/OStatement.hxx @@ -0,0 +1,272 @@ +/************************************************************************* + * + * $RCSfile: OStatement.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_ODBC_OSTATEMENT_HXX_ +#define _CONNECTIVITY_ODBC_OSTATEMENT_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_ +#include <com/sun/star/sdbc/XStatement.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XMULTIPLERESULTS_HPP_ +#include <com/sun/star/sdbc/XMultipleResults.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XBATCHEXECUTION_HPP_ +#include <com/sun/star/sdbc/XBatchExecution.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_ +#include <com/sun/star/sdbc/XCloseable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ +#include <com/sun/star/sdbc/SQLWarning.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ +#include <com/sun/star/util/XCancellable.hpp> +#endif +#ifndef _UNOTOOLS_PROPERTY_ARRAY_HELPER_HXX_ +#include <unotools/proparrhlp.hxx> +#endif +#ifndef _CPPUHELPER_COMPBASE5_HXX_ +#include <cppuhelper/compbase5.hxx> +#endif +#ifndef _UTL_UNO3_HXX_ +#include <unotools/uno3.hxx> +#endif +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "connectivity/CommonTools.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_ +#include "odbc/OFunctions.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OCONNECTION_HXX_ +#include "odbc/OConnection.hxx" +#endif +#ifndef _LIST_ +#include <list> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +namespace connectivity +{ + namespace odbc + { + + typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::util::XCancellable, + ::com::sun::star::sdbc::XCloseable, + ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE; + + //************************************************************** + //************ Class: java.sql.Statement + //************************************************************** + class OStatement_Base : public OBaseMutex, + public OStatement_BASE, + public ::cppu::OPropertySetHelper, + public ::utl::OPropertyArrayUsageHelper<OStatement_Base> + + { + ::com::sun::star::sdbc::SQLWarning m_aLastWarning; + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created + // for this Statement + protected: + ::std::list< ::rtl::OUString> m_aBatchList; + + OConnection* m_pConnection;// The owning Connection object + SQLHANDLE m_aStatementHandle; + SQLUSMALLINT* m_pRowStatusArray; + + //using OStatement_BASE::rBHelper; + private: + + sal_Int32 getQueryTimeOut() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getMaxFieldSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getMaxRows() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + sal_Bool isUsingBookmarks() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + void setQueryTimeOut(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setMaxFieldSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setMaxRows(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setResultSetType(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setResultSetConcurrency(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setCursorName(const ::rtl::OUString &_par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void setUsingBookmarks(sal_Bool _bUseBookmark) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + protected: + + void reset () throw( ::com::sun::star::sdbc::SQLException); + void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException); + void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException); + sal_Bool lockIfNecessary (const ::rtl::OUString& sql) throw( ::com::sun::star::sdbc::SQLException); + sal_Int32 getColumnCount () throw( ::com::sun::star::sdbc::SQLException); + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > getResultSet (sal_Bool checkCount) throw( ::com::sun::star::sdbc::SQLException); + sal_Int32 getRowCount () throw( ::com::sun::star::sdbc::SQLException); + sal_Int32 getStmtOption (short fOption) const throw( ::com::sun::star::sdbc::SQLException); + + void disposeResultSet(); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + virtual sal_Bool SAL_CALL convertFastPropertyValue( + ::com::sun::star::uno::Any & rConvertedValue, + ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle + ) const; + public: + ::cppu::OBroadcastHelper& rBHelper; + DECLARE_CTY_ACQUIRE(OStatement_BASE); + OStatement_Base(OConnection* _pConnection ); + // #if SUPD > 569 + using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; + //#else + // using OStatement_BASE::operator ::com::sun::star::uno::XInterface*; + //#endif + // OComponentHelper + virtual void SAL_CALL disposing(void){OStatement_BASE::disposing();} + // XInterface + virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException){} + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) + { + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); + } + // XStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XMultipleResults + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // other methods + SQLHANDLE getConnectionHandle() { return m_pConnection->getConnection(); } + }; + + class OStatement_BASE2 : public OStatement_Base, + public OSubComponent< OStatement_BASE2> + + { + friend class OSubComponent< OStatement_BASE2>; + public: + OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ), + OSubComponent< OStatement_BASE2>((::cppu::OWeakObject*)_pConnection){} + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); + }; + + class OStatement : public OStatement_BASE2, + public ::com::sun::star::sdbc::XBatchExecution, + public ::com::sun::star::lang::XServiceInfo + { + public: + DECLARE_CTY_DEFAULTS(OStatement_BASE2); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){} + DECLARE_SERVICE_INFO(); + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + // XBatchExecution + virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_ODBC_OSTATEMENT_HXX_ + diff --git a/connectivity/source/inc/odbc/OTools.hxx b/connectivity/source/inc/odbc/OTools.hxx new file mode 100644 index 000000000000..f88be11e3d9f --- /dev/null +++ b/connectivity/source/inc/odbc/OTools.hxx @@ -0,0 +1,559 @@ +/************************************************************************* + * + * $RCSfile: OTools.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * + * 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_OTOOLS_HXX_ +#define _CONNECTIVITY_OTOOLS_HXX_ + +#ifndef _CONNECTIVITY_OFUNCTIONDEFS_HXX_ +#include "odbc/OFunctiondefs.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_ +#include <com/sun/star/sdbc/SQLException.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ +#include <com/sun/star/util/Date.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_TIME_HPP_ +#include <com/sun/star/util/Time.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ +#include <com/sun/star/util/DateTime.hpp> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif + +namespace connectivity +{ + namespace odbc + { + + const sal_uInt32 ODBC_FRACTION_UNITS_PER_HSECOND = 10000000L; + const sal_Int32 MAX_PUT_DATA_LENGTH = 2000; + + class OTools + { + public: + static void ThrowException( SQLRETURN _rRetCode,SQLHANDLE _pContext,SQLSMALLINT _nHandleType, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,sal_Bool _bNoFound=sal_True) + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + static void GetInfo(SQLHANDLE _aConnectionHandle,SQLUSMALLINT _nInfo,::rtl::OUString &_rValue, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + static void GetInfo(SQLHANDLE _aConnectionHandle,SQLUSMALLINT _nInfo,sal_Int32 &_rValue,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + static void GetInfo(SQLHANDLE _aConnectionHandle,SQLUSMALLINT _nInfo,sal_Bool &_rValue,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 MapOdbcType2Jdbc(sal_Int32 _nType); + static sal_Int32 jdbcTypeToOdbc(sal_Int32 jdbcType); + + static DATE_STRUCT DateToOdbcDate(const ::com::sun::star::util::Date& x) + { + DATE_STRUCT aVal; + aVal.year = x.Year; + aVal.month = x.Month; + aVal.day = x.Day; + return aVal; + } + static TIME_STRUCT TimeToOdbcTime(const ::com::sun::star::util::Time& x) + { + TIME_STRUCT aVal; + aVal.hour = x.Hours; + aVal.minute = x.Minutes; + aVal.second = x.Seconds; + return aVal; + } + static TIMESTAMP_STRUCT DateTimeToTimestamp(const ::com::sun::star::util::DateTime& x) + { + TIMESTAMP_STRUCT aVal; + aVal.year = x.Year; + aVal.month = x.Month; + aVal.day = x.Day; + aVal.hour = x.Hours; + aVal.minute = x.Minutes; + aVal.second = x.Seconds; + aVal.fraction = x.HundredthSeconds * ODBC_FRACTION_UNITS_PER_HSECOND; + return aVal; + } + static void getBindTypes(sal_Bool _bUseWChar,sal_Bool _bUseOldTimeDate, + sal_Int32 jdbcType,SQLSMALLINT& fCType,SQLSMALLINT& fSqlType, + SQLUINTEGER& nColumnSize,SQLSMALLINT& nDecimalDigits); + static ::rtl::OUString getStringValue(SQLHANDLE _aStatementHandle,sal_Int32 columnIndex,SWORD _fSqlType,sal_Bool &_bWasNull, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + static ::com::sun::star::uno::Sequence<sal_Int8> OTools::getBytesValue(SQLHANDLE _aStatementHandle,sal_Int32 columnIndex,SWORD _fSqlType,sal_Bool &_bWasNull, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + + template <class T> T getValue( SQLHANDLE _aStatementHandle,sal_Int32 columnIndex, + SQLSMALLINT _nType,sal_Bool &_bWasNull, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,const T& _rValue) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) + { + SQLINTEGER pcbValue; + T nValue = _rValue; + OTools::ThrowException(N3SQLGetData(_aStatementHandle, + columnIndex, + _nType, + &nValue, + (SQLINTEGER)sizeof nValue, + &pcbValue), + _aStatementHandle,SQL_HANDLE_STMT,_xInterface,sal_False); + _bWasNull = pcbValue == SQL_NULL_DATA; + return nValue; + } + + //----------------------------------------------------------------------------- + template < class T > void bindData(SWORD fSqlType,sal_Bool _bUseWChar,void *&_pData,SDWORD*& pLen,const T* _pValue) + { + SDWORD nMaxLen = 0; + + switch (fSqlType) + { + case SQL_CHAR: + case SQL_VARCHAR: + if(_bUseWChar) + { + *pLen = SQL_NTS; + *((rtl::OUString*)_pData) = *(::rtl::OUString*)_pValue; + + // Zeiger auf Char* + _pData = (void*)((rtl::OUString*)_pData)->getStr(); + } + else + { + ::rtl::OString aString(::rtl::OUStringToOString(*(::rtl::OUString*)_pValue,osl_getThreadTextEncoding())); + *pLen = SQL_NTS; + memcpy(_pData,aString.getStr(),aString.getLength()); + ((sal_Int8*)_pData)[aString.getLength()] = '\0'; + } break; + + case SQL_BIGINT: + case SQL_DECIMAL: + case SQL_NUMERIC: + if(_bUseWChar) + { + ::rtl::OUString aString = rtl::OUString::valueOf(*(double*)_pValue); + nMaxLen = aString.getLength(); + *pLen = nMaxLen; + *((rtl::OUString*)_pData) = aString; + // Zeiger auf Char* + _pData = (void*)((rtl::OUString*)_pData)->getStr(); + } + else + { + ::rtl::OString aString = ::rtl::OString::valueOf(*(double*)_pValue); + nMaxLen = aString.getLength(); + *pLen = nMaxLen; + memcpy(_pData,aString.getStr(),aString.getLength()); + ((sal_Int8*)_pData)[aString.getLength()] = '\0'; + } break; + case SQL_BIT: + *((sal_Int8*)_pData) = *(sal_Int8*)_pValue; + *pLen = sizeof(sal_Int8); + break; + case SQL_TINYINT: + case SQL_SMALLINT: + *((sal_Int16*)_pData) = *(sal_Int16*)_pValue; + *pLen = sizeof(sal_Int16); + break; + case SQL_INTEGER: + *((sal_Int32*)_pData) = *(sal_Int32*)_pValue; + *pLen = sizeof(sal_Int32); + break; + case SQL_REAL: + *((float*)_pData) = *(float*)_pValue; + *pLen = sizeof(float); + break; + case SQL_DOUBLE: + *((double*)_pData) = *(double*)_pValue; + *pLen = sizeof(double); + break; + case SQL_BINARY: + case SQL_VARBINARY: + _pData = (void*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray(); + *pLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength(); + break; + case SQL_LONGVARBINARY: + { + sal_Int32 nLen = 0; + nLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength(); + *pLen = (SDWORD)SQL_LEN_DATA_AT_EXEC(nLen); + } + break; + case SQL_LONGVARCHAR: + { + _pData = 0;//(void*)&rCol; + sal_Int32 nLen = 0; + if(_bUseWChar) + nLen = sizeof(sal_Unicode) * ((::rtl::OUString*)_pValue)->getLength(); + else + { + ::rtl::OString aString(::rtl::OUStringToOString(*(::rtl::OUString*)_pValue, + osl_getThreadTextEncoding() + )); + nLen = aString.getLength(); + } + *pLen = (SDWORD)SQL_LEN_DATA_AT_EXEC(nLen); + } break; + case SQL_DATE: + *(DATE_STRUCT*)_pData = *(DATE_STRUCT*)_pValue; + *pLen = (SDWORD)sizeof(DATE_STRUCT); + break; + case SQL_TIME: + *(TIME_STRUCT*)_pData = *(TIME_STRUCT*)_pValue; + *pLen = (SDWORD)sizeof(TIME_STRUCT); + break; + case SQL_TIMESTAMP: + *(TIMESTAMP_STRUCT*)_pData = *(TIMESTAMP_STRUCT*)_pValue; + *pLen = (SDWORD)sizeof(TIMESTAMP_STRUCT); + break; + } + } + + //----------------------------------------------------------------------------- + template < class T > sal_Bool bindParameter( SQLHANDLE _hStmt,sal_Int32 nPos, sal_Int8* pDataBuffer, + sal_Int8* pLenBuffer,SQLSMALLINT _nJDBCtype, + sal_Bool _bUseWChar,sal_Bool _bUseOldTimeDate,const T* _pValue, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) + { + SQLRETURN nRetcode; + SWORD fSqlType; + SWORD fCType; + SDWORD nMaxLen = 0; + void* pData = pDataBuffer; + SDWORD* pLen = (SDWORD*)pLenBuffer; + SQLUINTEGER nColumnSize=0; + SQLSMALLINT nDecimalDigits=0; + SQLSMALLINT nNullable=0; + + OTools::getBindTypes(_bUseWChar,_bUseOldTimeDate,_nJDBCtype,fSqlType,fCType,nColumnSize,nDecimalDigits); + + bindData< T >(fSqlType,_bUseWChar,pData,pLen,_pValue); + if(fSqlType == SQL_LONGVARCHAR || fSqlType == SQL_LONGVARBINARY) + memcpy(pData,&nPos,sizeof(nPos)); + + nRetcode = N3SQLDescribeParam(_hStmt,nPos,&fSqlType,&nColumnSize,&nDecimalDigits,&nNullable); + + nRetcode = N3SQLBindParameter(_hStmt, + nPos, + SQL_PARAM_INPUT, + fCType, + fSqlType, + nColumnSize, + nDecimalDigits, + pData, + nMaxLen, + pLen); + + OTools::ThrowException(nRetcode,_hStmt,SQL_HANDLE_STMT,_xInterface); + return sal_True; + } + + + template <class T> void bindValue(SQLHANDLE _aStatementHandle,sal_Int32 columnIndex, + SQLSMALLINT _nType,SQLSMALLINT _nMaxLen,SQLSMALLINT _nScale, + const T* _pValue,void* _pData,SQLINTEGER *pLen, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) + { + SQLRETURN nRetcode; + SWORD fSqlType; + SWORD fCType; + + switch(_nType) + { + case SQL_CHAR: //if(GetODBCConnection()->m_bUserWChar) + // { + // fCType = SQL_C_WCHAR; + // fSqlType = SQL_WCHAR; + // } + // else + { + fCType = SQL_C_CHAR; + fSqlType = SQL_CHAR; + } + break; + case SQL_VARCHAR: //if(GetODBCConnection()->m_bUserWChar) + // { + // fCType = SQL_C_WCHAR; + // fSqlType = SQL_WVARCHAR; + // } + // else + { + fCType = SQL_C_CHAR; + fSqlType = SQL_VARCHAR; + } + break; + case SQL_LONGVARCHAR: //if(GetODBCConnection()->m_bUserWChar) + // { + // fCType = SQL_C_WCHAR; + // fSqlType = SQL_WLONGVARCHAR; + // } + // else + { + fCType = SQL_C_CHAR; + fSqlType = SQL_LONGVARCHAR; + } + break; + case SQL_DECIMAL: fCType = SQL_C_CHAR;//GetODBCConnection()->m_bUserWChar ? SQL_C_WCHAR : SQL_C_CHAR; + fSqlType = SQL_DECIMAL; break; + case SQL_NUMERIC: fCType = SQL_C_CHAR;//GetODBCConnection()->m_bUserWChar ? SQL_C_WCHAR : SQL_C_CHAR; + fSqlType = SQL_NUMERIC; break; + case SQL_BIT: fCType = SQL_C_TINYINT; + fSqlType = SQL_INTEGER; break; + case SQL_TINYINT: fCType = SQL_C_SHORT; + fSqlType = SQL_TINYINT; break; + case SQL_SMALLINT: fCType = SQL_C_SHORT; + fSqlType = SQL_SMALLINT; break; + case SQL_INTEGER: fCType = SQL_C_LONG; + fSqlType = SQL_INTEGER; break; + case SQL_BIGINT: fCType = SQL_C_CHAR;//GetODBCConnection()->m_bUserWChar ? SQL_C_WCHAR : SQL_C_CHAR; + fSqlType = SQL_BIGINT; break; + case SQL_REAL: fCType = SQL_C_FLOAT; + fSqlType = SQL_REAL; break; + case SQL_DOUBLE: fCType = SQL_C_DOUBLE; + fSqlType = SQL_DOUBLE; break; + case SQL_BINARY: fCType = SQL_C_BINARY; + fSqlType = SQL_BINARY; break; + case SQL_VARBINARY: + fCType = SQL_C_BINARY; + fSqlType = SQL_VARBINARY; break; + case SQL_LONGVARBINARY: fCType = SQL_C_BINARY; + fSqlType = SQL_LONGVARBINARY; break; + case SQL_DATE: + // if(((SdbODBC3Connection*)GetODBCConnection())->m_bUseOldTimeDate) + { + fCType = SQL_C_DATE; + fSqlType = SQL_DATE; + } + // else + // { + // fCType = SQL_C_TYPE_DATE; + // fSqlType = SQL_TYPE_DATE; + // } + break; + case SQL_TIME: + // if(((SdbODBC3Connection*)GetODBCConnection())->m_bUseOldTimeDate) + { + fCType = SQL_C_TIME; + fSqlType = SQL_TIME; + } + // else + // { + // fCType = SQL_C_TYPE_TIME; + // fSqlType = SQL_TYPE_TIME; + // } + break; + case SQL_TIMESTAMP: + // if(((SdbODBC3Connection*)GetODBCConnection())->m_bUseOldTimeDate) + { + fCType = SQL_C_TIMESTAMP; + fSqlType = SQL_TIMESTAMP; + } + // else + // { + // fCType = SQL_C_TYPE_TIMESTAMP; + // fSqlType = SQL_TYPE_TIMESTAMP; + // } + break; + default: fCType = SQL_C_BINARY; + fSqlType = SQL_LONGVARBINARY; break; + } + + if (columnIndex != 0 && !_pValue) + { + *pLen = SQL_NULL_DATA; + nRetcode = N3SQLBindCol(_aStatementHandle, + columnIndex, + fCType, + _pData, + _nMaxLen, + pLen + ); + } + else + { + try + { + switch (_nType) + { + case SQL_CHAR: + case SQL_VARCHAR: + //if(GetODBCConnection()->m_bUserWChar) + // { + // _nMaxLen = rCol.GetPrecision(); + // *pLen = SQL_NTS; + // *((rtl::OUString*)pData) = (rtl::OUString)_aValue; + // + // // Zeiger auf Char* + // pData = (void*)((rtl::OUString*)pData)->getStr(); + // } + // else + { + ::rtl::OString aString(::rtl::OUStringToOString(*(::rtl::OUString*)_pValue,osl_getThreadTextEncoding())); + *pLen = SQL_NTS; + *((::rtl::OString*)_pData) = aString; + _nMaxLen = aString.getLength(); + + // Zeiger auf Char* + _pData = (void*)aString.getStr(); + } break; + case SQL_BIGINT: + case SQL_DECIMAL: + case SQL_NUMERIC: + //if(GetODBCConnection()->m_bUserWChar) + // { + // rtl::OUString aString(rtl::OUString(SdbTools::ToString(ODbTypeConversion::toDouble(*pVariable),rCol.GetScale()))); + // *pLen = _nMaxLen; + // *((rtl::OUString*)_pData) = aString; + // // Zeiger auf Char* + // _pData = (void*)((rtl::OUString*)_pData)->getStr(); + // } + // else + { + ::rtl::OString aString = ::rtl::OString::valueOf(*(double*)_pValue); + _nMaxLen = aString.getLength(); + *pLen = _nMaxLen; + *((::rtl::OString*)_pData) = aString; + // Zeiger auf Char* + _pData = (void*)((::rtl::OString*)_pData)->getStr(); + } break; + case SQL_BIT: + *((sal_Int8*)_pData) = *(sal_Int8*)_pValue; + *pLen = sizeof(sal_Int8); + break; + case SQL_TINYINT: + case SQL_SMALLINT: + *((sal_Int16*)_pData) = *(sal_Int16*)_pValue; + *pLen = sizeof(sal_Int16); + break; + case SQL_INTEGER: + *((sal_Int32*)_pData) = *(sal_Int32*)_pValue; + *pLen = sizeof(sal_Int32); + break; + case SQL_REAL: + *((float*)_pData) = *(float*)_pValue; + *pLen = sizeof(float); + break; + case SQL_DOUBLE: + *((double*)_pData) = *(double*)_pValue; + *pLen = sizeof(double); + break; + case SQL_BINARY: + case SQL_VARBINARY: + // if (_pValue == ::getCppuType((const ::com::sun::star::uno::Sequence< sal_Int8 > *)0)) + { + _pData = (void*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray(); + *pLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength(); + } break; + case SQL_LONGVARBINARY: + { + sal_Int32 nLen = 0; + nLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength(); + *pLen = (SDWORD)SQL_LEN_DATA_AT_EXEC(nLen); + } + break; + case SQL_LONGVARCHAR: + { + sal_Int32 nLen = 0; + nLen = ((::rtl::OUString*)_pValue)->getLength(); + *pLen = (SDWORD)SQL_LEN_DATA_AT_EXEC(nLen); + } break; + case SQL_DATE: + *pLen = sizeof(DATE_STRUCT); + *((DATE_STRUCT*)_pData) = *(DATE_STRUCT*)_pValue; + break; + case SQL_TIME: + *pLen = sizeof(TIME_STRUCT); + *((TIME_STRUCT*)_pData) = *(TIME_STRUCT*)_pValue; + break; + case SQL_TIMESTAMP: + *pLen = sizeof(TIMESTAMP_STRUCT); + *((TIMESTAMP_STRUCT*)_pData) = *(TIMESTAMP_STRUCT*)_pValue; + } + } + catch ( ... ) + { + } +// SQLINTEGER *pLen = &aLen; +// bindData< T >(fSqlType,sal_False,_pData,pLen,_pValue); + + + nRetcode = N3SQLBindCol(_aStatementHandle, + columnIndex, + fCType, + _pData, + _nMaxLen, + pLen + ); + } + + OTools::ThrowException(nRetcode,_aStatementHandle,SQL_HANDLE_STMT,_xInterface); + } + } +} +#endif // _CONNECTIVITY_OTOOLS_HXX_ + diff --git a/connectivity/source/inc/propertyids.hxx b/connectivity/source/inc/propertyids.hxx new file mode 100644 index 000000000000..9df0f2e94d73 --- /dev/null +++ b/connectivity/source/inc/propertyids.hxx @@ -0,0 +1,196 @@ +/************************************************************************* + * + * $RCSfile: propertyids.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_PROPERTYIDS_HXX_ +#define _CONNECTIVITY_PROPERTYIDS_HXX_ + + +namespace connectivity +{ + struct UStringDescription + { + const sal_Char* pZeroTerminatedName; + + UStringDescription(sal_Char* _pName) { pZeroTerminatedName = _pName; } + operator ::rtl::OUString() const { return ::rtl::OUString::createFromAscii(pZeroTerminatedName); } + private: + UStringDescription(); + }; + +#define DECLARE_CONSTASCII_USTRING(name) \ + extern connectivity::UStringDescription name; + +#define IMPLEMENT_CONSTASCII_USTRING(name, asciivalue) \ + connectivity::UStringDescription name(asciivalue) + + + DECLARE_CONSTASCII_USTRING(PROPERTY_CURSORNAME) + DECLARE_CONSTASCII_USTRING(PROPERTY_RESULTSETCONCURRENCY) + DECLARE_CONSTASCII_USTRING(PROPERTY_RESULTSETTYPE) + DECLARE_CONSTASCII_USTRING(PROPERTY_FETCHDIRECTION) + DECLARE_CONSTASCII_USTRING(PROPERTY_FETCHSIZE) + DECLARE_CONSTASCII_USTRING(PROPERTY_QUERYTIMEOUT) + DECLARE_CONSTASCII_USTRING(PROPERTY_MAXFIELDSIZE) + DECLARE_CONSTASCII_USTRING(PROPERTY_MAXROWS) + DECLARE_CONSTASCII_USTRING(PROPERTY_ESCAPEPROCESSING) + DECLARE_CONSTASCII_USTRING(PROPERTY_USEBOOKMARKS) + + DECLARE_CONSTASCII_USTRING(PROPERTY_NAME) + DECLARE_CONSTASCII_USTRING(PROPERTY_TYPE) + DECLARE_CONSTASCII_USTRING(PROPERTY_TYPENAME) + DECLARE_CONSTASCII_USTRING(PROPERTY_PRECISION) + DECLARE_CONSTASCII_USTRING(PROPERTY_SCALE) + DECLARE_CONSTASCII_USTRING(PROPERTY_ISNULLABLE) + DECLARE_CONSTASCII_USTRING(PROPERTY_ISAUTOINCREMENT) + DECLARE_CONSTASCII_USTRING(PROPERTY_ISROWVERSION) + DECLARE_CONSTASCII_USTRING(PROPERTY_DESCRIPTION) + DECLARE_CONSTASCII_USTRING(PROPERTY_DEFAULTVALUE) + + DECLARE_CONSTASCII_USTRING(PROPERTY_REFERENCEDTABLE) + DECLARE_CONSTASCII_USTRING(PROPERTY_UPDATERULE) + DECLARE_CONSTASCII_USTRING(PROPERTY_DELETERULE) + + DECLARE_CONSTASCII_USTRING(PROPERTY_CATALOG) + DECLARE_CONSTASCII_USTRING(PROPERTY_ISUNIQUE) + DECLARE_CONSTASCII_USTRING(PROPERTY_ISPRIMARYKEYINDEX) + DECLARE_CONSTASCII_USTRING(PROPERTY_ISCLUSTERED) + DECLARE_CONSTASCII_USTRING(PROPERTY_ISASCENDING) + + DECLARE_CONSTASCII_USTRING(PROPERTY_SCHEMANAME) + DECLARE_CONSTASCII_USTRING(PROPERTY_CATALOGNAME) + DECLARE_CONSTASCII_USTRING(PROPERTY_COMMAND) + DECLARE_CONSTASCII_USTRING(PROPERTY_CHECKOPTION) + DECLARE_CONSTASCII_USTRING(PROPERTY_PASSWORD) + DECLARE_CONSTASCII_USTRING(PROPERTY_REFERENCEDCOLUMN) + + DECLARE_CONSTASCII_USTRING(PROPERTY_FUNCTION) + DECLARE_CONSTASCII_USTRING(PROPERTY_TABLENAME) + DECLARE_CONSTASCII_USTRING(PROPERTY_REALNAME) + DECLARE_CONSTASCII_USTRING(PROPERTY_DBASEPRECISIONCHANGED) + DECLARE_CONSTASCII_USTRING(PROPERTY_ISCURRENCY) + DECLARE_CONSTASCII_USTRING(PROPERTY_ISBOOKMARKABLE) + + // error msg + DECLARE_CONSTASCII_USTRING(STAT_INVALID_INDEX) +} + + +//------------------------------------------------------------------------------ +#define DECL_PROP1IMPL(varname, type) \ + pProperties[nPos++] = ::com::sun::star::beans::Property(connectivity::PROPERTY_##varname, PROPERTY_ID_##varname, ::getCppuType(reinterpret_cast< type*>(NULL)), +//------------------------------------------------------------------------------ +#define DECL_PROP0(varname, type) \ + DECL_PROP1IMPL(varname, type) 0) +//------------------------------------------------------------------------------ +#define DECL_BOOL_PROP1IMPL(varname) \ + pProperties[nPos++] = ::com::sun::star::beans::Property(connectivity::PROPERTY_##varname, PROPERTY_ID_##varname, ::getBooleanCppuType(), +//------------------------------------------------------------------------------ +#define DECL_BOOL_PROP0(varname) \ + DECL_BOOL_PROP1IMPL(varname) 0) + + +#define PROPERTY_ID_QUERYTIMEOUT 1 +#define PROPERTY_ID_MAXFIELDSIZE 2 +#define PROPERTY_ID_MAXROWS 3 +#define PROPERTY_ID_CURSORNAME 4 +#define PROPERTY_ID_RESULTSETCONCURRENCY 5 +#define PROPERTY_ID_RESULTSETTYPE 6 +#define PROPERTY_ID_FETCHDIRECTION 7 +#define PROPERTY_ID_FETCHSIZE 8 +#define PROPERTY_ID_ESCAPEPROCESSING 9 +#define PROPERTY_ID_USEBOOKMARKS 10 +// Column +#define PROPERTY_ID_NAME 11 +#define PROPERTY_ID_TYPE 12 +#define PROPERTY_ID_TYPENAME 13 +#define PROPERTY_ID_PRECISION 14 +#define PROPERTY_ID_SCALE 15 +#define PROPERTY_ID_ISNULLABLE 16 +#define PROPERTY_ID_ISAUTOINCREMENT 17 +#define PROPERTY_ID_ISROWVERSION 18 +#define PROPERTY_ID_DESCRIPTION 19 +#define PROPERTY_ID_DEFAULTVALUE 20 + +#define PROPERTY_ID_REFERENCEDTABLE 21 +#define PROPERTY_ID_UPDATERULE 22 +#define PROPERTY_ID_DELETERULE 23 +#define PROPERTY_ID_CATALOG 24 +#define PROPERTY_ID_ISUNIQUE 25 +#define PROPERTY_ID_ISPRIMARYKEYINDEX 26 +#define PROPERTY_ID_ISCLUSTERED 27 +#define PROPERTY_ID_ISASCENDING 28 +#define PROPERTY_ID_SCHEMANAME 29 +#define PROPERTY_ID_CATALOGNAME 30 + +#define PROPERTY_ID_COMMAND 31 +#define PROPERTY_ID_CHECKOPTION 32 +#define PROPERTY_ID_PASSWORD 33 +#define PROPERTY_ID_REFERENCEDCOLUMN 34 + +#define PROPERTY_ID_FUNCTION 35 +#define PROPERTY_ID_TABLENAME 36 +#define PROPERTY_ID_REALNAME 37 +#define PROPERTY_ID_DBASEPRECISIONCHANGED 38 +#define PROPERTY_ID_ISCURRENCY 39 +#define PROPERTY_ID_ISBOOKMARKABLE 40 + +#endif // _CONNECTIVITY_PROPERTYIDS_HXX_ + + diff --git a/connectivity/source/inc/sqlscan.hxx b/connectivity/source/inc/sqlscan.hxx new file mode 100644 index 000000000000..70d23ca6ef67 --- /dev/null +++ b/connectivity/source/inc/sqlscan.hxx @@ -0,0 +1,119 @@ +/************************************************************************* + * + * $RCSfile: sqlscan.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:24 $ + * + * 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_SQLSCAN_HXX +#define _CONNECTIVITY_SQLSCAN_HXX + +#include <stdarg.h> + +#ifndef _DEBUG_HXX //autogen +#include <tools/debug.hxx> +#endif +#ifndef _STRING_HXX //autogen wg. String +#include <tools/string.hxx> +#endif + +namespace connectivity +{ + class OParseContext; + //========================================================================== + //= OSQLScanner + //========================================================================== + /** Scanner for SQL92 + */ + class OSQLScanner + { + OParseContext* m_pContext; // context for parse, knows all international stuff + ByteString m_sStatement; // statement to parse + String m_sErrorMessage; + + xub_StrLen m_nCurrentPos; // next position to read from the statement + sal_Bool m_bInternational; // do we have a statement which may uses + sal_Int32 m_nRule; // rule to be set + + public: + OSQLScanner(); + ~OSQLScanner(); + + virtual int SQLyygetc(void); + virtual void SQLyyerror(char *fmt); + virtual void output(int) { DBG_ERROR("Internal error in sdblex.l: output not possible"); } + virtual void ECHO(void) { DBG_ERROR("Internal error in sdblex.l: ECHO not possible"); } + virtual int getInternationalTokenID(const char* sToken) const; + + // setting the new information before scanning + void prepareScan(const String & rNewStatement, OParseContext* pContext, sal_Bool bInternational); + const String& getErrorMessage() const {return m_sErrorMessage;} + + int SQLlex(); + // set this as scanner for flex + void setScanner(sal_Bool _bNull=sal_False); + // rules settings + void SetRule(int nRule) {m_nRule = nRule;} + int GetCurrentRule() const; + int GetGERRule() const; + int GetENGRule() const; + int GetSQLRule() const; + int GetDATERule() const; + int GetSTRINGRule() const; + }; +} + +#endif diff --git a/connectivity/source/manager/exports.dxp b/connectivity/source/manager/exports.dxp new file mode 100644 index 000000000000..9630d7e06768 --- /dev/null +++ b/connectivity/source/manager/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/connectivity/source/manager/makefile.mk b/connectivity/source/manager/makefile.mk new file mode 100644 index 000000000000..aaff11348e0a --- /dev/null +++ b/connectivity/source/manager/makefile.mk @@ -0,0 +1,137 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:14: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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. +PRJINC=.. +PRJNAME=connectivity +TARGET=sdbc + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/version.mk + +# --- Types ------------------------------------- + + +UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb + +UNOUCROUT=$(PRJ)$/common$/inc +INCPRE+=$(UNOUCROUT) + +# --- Types ------------------------------------- + +UNOTYPES+= \ + com.sun.star.sdbc.XDriverManager \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.uno.TypeClass \ + com.sun.star.container.XEnumerationAccess \ + com.sun.star.container.XContentEnumerationAccess\ + com.sun.star.uno.XWeak \ + com.sun.star.uno.XAggregation \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.lang.XServiceInfo \ + com.sun.star.uno.XNamingService \ + com.sun.star.sdbc.XDriver \ + com.sun.star.sdbc.XDriverAccess \ + com.sun.star.lang.IllegalArgumentException + +# --- Files ------------------------------------- + +SLOFILES=\ + $(SLO)$/mdrivermanager.obj \ + $(SLO)$/registration.obj + +# --- Library ----------------------------------- + +SHL1TARGET= $(SDBC_TARGET)$(SDBC_MAJOR) +SHL1VERSIONMAP= $(TARGET).map +SHL1OBJS=$(SLOFILES) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(OSLLIB) \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(SHL1TARGET) + +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + + diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx new file mode 100644 index 000000000000..2cad40cbe691 --- /dev/null +++ b/connectivity/source/manager/mdrivermanager.cxx @@ -0,0 +1,400 @@ +/************************************************************************* + * + * $RCSfile: mdrivermanager.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_DRIVERMANAGER_HXX_ +#include "drivermanager.hxx" +#endif + +#ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_ +#include <com/sun/star/sdbc/XDriver.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCONTENTENUMERATIONACCESS_HPP_ +#include <com/sun/star/container/XContentEnumerationAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_ELEMENTEXISTEXCEPTION_HPP_ +#include <com/sun/star/container/ElementExistException.hpp> +#endif + +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::osl; + +#define SERVICE_SDBC_DRIVER ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver") + +//========================================================================== +//= ODriverEnumeration +//========================================================================== +class ODriverEnumeration : public ::cppu::ImplHelper1< XEnumeration > +{ + friend class OSDBCDriverManager; + + oslInterlockedCount m_refCount; + + DECLARE_STL_VECTOR(OSDBCDriverManager::SdbcDriver, Drivers); + Drivers m_aDrivers; + sal_Int32 m_nPos; + + ~ODriverEnumeration(); +public: + ODriverEnumeration(const Drivers& _rDriverSequence); + +// XInterface + virtual void SAL_CALL acquire() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); + +// XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements( ) throw(RuntimeException); + virtual Any SAL_CALL nextElement( ) throw(NoSuchElementException, WrappedTargetException, RuntimeException); +}; + +//-------------------------------------------------------------------------- +ODriverEnumeration::ODriverEnumeration(const Drivers& _rDriverSequence) + :m_aDrivers(_rDriverSequence) + ,m_nPos(0) +{ +} + +//-------------------------------------------------------------------------- +ODriverEnumeration::~ODriverEnumeration() +{ +} + +//-------------------------------------------------------------------------- +void SAL_CALL ODriverEnumeration::acquire() throw(::com::sun::star::uno::RuntimeException) +{ + osl_incrementInterlockedCount(&m_refCount); +} + +//-------------------------------------------------------------------------- +void SAL_CALL ODriverEnumeration::release() throw(::com::sun::star::uno::RuntimeException) +{ + osl_decrementInterlockedCount(&m_refCount); +} + +//-------------------------------------------------------------------------- +sal_Bool SAL_CALL ODriverEnumeration::hasMoreElements( ) throw(RuntimeException) +{ + return m_nPos < m_aDrivers.size(); +} + +//-------------------------------------------------------------------------- +Any SAL_CALL ODriverEnumeration::nextElement( ) throw(NoSuchElementException, WrappedTargetException, RuntimeException) +{ + if (!hasMoreElements()) + throw NoSuchElementException(); + return makeAny(m_aDrivers[m_nPos++]); +} + +//========================================================================== +//= OSDBCDriverManager +//========================================================================== +//-------------------------------------------------------------------------- +OSDBCDriverManager::OSDBCDriverManager(const Reference< XMultiServiceFactory >& _rxFactory) + :m_xServiceFactory(_rxFactory) + ,m_nLoginTimeout(NULL) +{ + // bootstrap all objects supporting the .sdb.Driver service + + Reference< XContentEnumerationAccess > xEnumAccess(_rxFactory, UNO_QUERY); + Reference< XEnumeration > xEnumDrivers; + if (xEnumAccess.is()) + xEnumDrivers = xEnumAccess->createContentEnumeration(SERVICE_SDBC_DRIVER); + + if (xEnumDrivers.is()) + { + while (xEnumDrivers->hasMoreElements()) + { + Any aCurrent = xEnumDrivers->nextElement(); + Reference< XSingleServiceFactory > xFactory; + + if (!::cppu::extractInterface(xFactory, aCurrent)) + continue; + + Reference< XDriver > xDriver(xFactory->createInstance(), UNO_QUERY); + if (xDriver.is()) + m_aDriversBS.push_back(xDriver); + } + } +} + +//-------------------------------------------------------------------------- +void SAL_CALL OSDBCDriverManager::acquire() throw(::com::sun::star::uno::RuntimeException) +{ + osl_incrementInterlockedCount(&m_refCount); +} + +//-------------------------------------------------------------------------- +void SAL_CALL OSDBCDriverManager::release() throw(::com::sun::star::uno::RuntimeException) +{ + osl_decrementInterlockedCount(&m_refCount); +} + +//-------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL OSDBCDriverManager::getConnection( const ::rtl::OUString& _rURL ) throw(SQLException, RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + + Reference< XConnection > xConnection; + Reference< XDriver > xDriver = implGetDriverForURL(_rURL); + if (xDriver.is()) + // TODO : handle the login timeout + xConnection = xDriver->connect(_rURL, Sequence< PropertyValue >()); + // may throw an exception + + return xConnection; +} + +//-------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL OSDBCDriverManager::getConnectionWithInfo( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rInfo ) throw(SQLException, RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + + Reference< XConnection > xConnection; + Reference< XDriver > xDriver = implGetDriverForURL(_rURL); + if (xDriver.is()) + // TODO : handle the login timeout + xConnection = xDriver->connect(_rURL, _rInfo); + // may throw an exception + + return xConnection; +} + +//-------------------------------------------------------------------------- +void SAL_CALL OSDBCDriverManager::setLoginTimeout( sal_Int32 seconds ) throw(RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + m_nLoginTimeout = seconds; +} + +//-------------------------------------------------------------------------- +sal_Int32 SAL_CALL OSDBCDriverManager::getLoginTimeout( ) throw(RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + return m_nLoginTimeout; +} + +//-------------------------------------------------------------------------- +Reference< XEnumeration > SAL_CALL OSDBCDriverManager::createEnumeration( ) throw(RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + + ODriverEnumeration::Drivers aDrivers(m_aDriversBS); + for (ConstRuntimeDriversIterator aLoop = m_aDriversRT.begin(); aLoop != m_aDriversRT.end(); ++aLoop) + aDrivers.push_back(aLoop->second); + + return new ODriverEnumeration(aDrivers); +} + +//-------------------------------------------------------------------------- +::com::sun::star::uno::Type SAL_CALL OSDBCDriverManager::getElementType( ) throw(::com::sun::star::uno::RuntimeException) +{ + return ::getCppuType(static_cast< Reference< XDriver >* >(NULL)); +} + +//-------------------------------------------------------------------------- +sal_Bool SAL_CALL OSDBCDriverManager::hasElements( ) throw(::com::sun::star::uno::RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + return (m_aDriversBS.size() + m_aDriversRT.size()) != 0; +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OSDBCDriverManager::getImplementationName( ) throw(RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + return getImplementationName_Static(); +} + +//-------------------------------------------------------------------------- +sal_Bool SAL_CALL OSDBCDriverManager::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) + if (pSupported->equals(_rServiceName)) + return sal_True; + + return sal_False; +} + +//-------------------------------------------------------------------------- +Sequence< ::rtl::OUString > SAL_CALL OSDBCDriverManager::getSupportedServiceNames( ) throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +//-------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL OSDBCDriverManager::CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory) +{ + return static_cast<XDriverManager*>(new OSDBCDriverManager(_rxFactory)); +} + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OSDBCDriverManager::getImplementationName_Static( ) throw(RuntimeException) +{ + return ::rtl::OUString::createFromAscii("com.sun.star.sdbc.OSDBCDriverManager"); +} + +//-------------------------------------------------------------------------- +Sequence< ::rtl::OUString > SAL_CALL OSDBCDriverManager::getSupportedServiceNames_Static( ) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(1); + aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.DriverManager"); + return aSupported; +} + +//-------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL OSDBCDriverManager::getRegisteredObject( const ::rtl::OUString& _rName ) throw(Exception, RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + ConstRuntimeDriversIterator aSearch = m_aDriversRT.find(_rName); + if (aSearch == m_aDriversRT.end()) + throw NoSuchElementException(); + + return aSearch->second; +} + +//-------------------------------------------------------------------------- +void SAL_CALL OSDBCDriverManager::registerObject( const ::rtl::OUString& _rName, const Reference< XInterface >& _rxObject ) throw(Exception, RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + ConstRuntimeDriversIterator aSearch = m_aDriversRT.find(_rName); + if (aSearch != m_aDriversRT.end()) + throw ElementExistException(); + + Reference< XDriver > xNewDriver(_rxObject, UNO_QUERY); + if (!xNewDriver.is()) + throw IllegalArgumentException(); + + m_aDriversRT[_rName] = xNewDriver; +} + +//-------------------------------------------------------------------------- +void SAL_CALL OSDBCDriverManager::revokeObject( const ::rtl::OUString& _rName ) throw(Exception, RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + ConstRuntimeDriversIterator aSearch = m_aDriversRT.find(_rName); + if (aSearch == m_aDriversRT.end()) + throw NoSuchElementException(); + + m_aDriversRT.erase(_rName); +} + +//-------------------------------------------------------------------------- +Reference< XDriver > SAL_CALL OSDBCDriverManager::getDriverByURL( const ::rtl::OUString& _rURL ) throw(RuntimeException) +{ + return implGetDriverForURL(_rURL); +} + +//-------------------------------------------------------------------------- +Reference< XDriver > OSDBCDriverManager::implGetDriverForURL(const ::rtl::OUString& _rURL) +{ + // search all bootstrapped drivers + for ( ConstBootstrappedDriversIterator aSearchBS = m_aDriversBS.begin(); + aSearchBS != m_aDriversBS.end(); + ++aSearchBS + ) + { + try + { + if ((*aSearchBS)->acceptsURL(_rURL)) + return *aSearchBS; + } + catch(SQLException&) + { + } + } + + // search all drivers registered at runtime + for ( ConstRuntimeDriversIterator aSearchRT = m_aDriversRT.begin(); + aSearchRT != m_aDriversRT.end(); + ++aSearchRT + ) + { + try + { + if (aSearchRT->second->acceptsURL(_rURL)) + return aSearchRT->second; + } + catch(SQLException&) + { + } + } + + + return Reference< XDriver >(); +} + + diff --git a/connectivity/source/manager/sdbc.map b/connectivity/source/manager/sdbc.map new file mode 100644 index 000000000000..2d8534b22e21 --- /dev/null +++ b/connectivity/source/manager/sdbc.map @@ -0,0 +1,8 @@ +SDBC_1_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + local: + *; +}; diff --git a/connectivity/source/parse/PColumn.cxx b/connectivity/source/parse/PColumn.cxx new file mode 100644 index 000000000000..2644abc2c6f6 --- /dev/null +++ b/connectivity/source/parse/PColumn.cxx @@ -0,0 +1,134 @@ +/************************************************************************* + * + * $RCSfile: PColumn.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_SDBCX_COLUMN_HXX_ +#include "connectivity/PColumn.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity; +using namespace connectivity::parse; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// ------------------------------------------------------------------------- +OParseColumn::OParseColumn(const Reference<XFastPropertySet>& _xColumn,sal_Bool _bCase) + : connectivity::sdbcx::OColumn( getString(_xColumn->getFastPropertyValue(PROPERTY_ID_NAME)) + , getString(_xColumn->getFastPropertyValue(PROPERTY_ID_TYPENAME)) + , getString(_xColumn->getFastPropertyValue(PROPERTY_ID_DEFAULTVALUE)) + , getINT32(_xColumn->getFastPropertyValue(PROPERTY_ID_ISNULLABLE)) + , getINT32(_xColumn->getFastPropertyValue(PROPERTY_ID_PRECISION)) + , getINT32(_xColumn->getFastPropertyValue(PROPERTY_ID_SCALE)) + , getINT32(_xColumn->getFastPropertyValue(PROPERTY_ID_TYPE)) + , getBOOL(_xColumn->getFastPropertyValue(PROPERTY_ID_ISAUTOINCREMENT)) + , sal_False + , getBOOL(_xColumn->getFastPropertyValue(PROPERTY_ID_ISCURRENCY)) + , _bCase + ) + , m_bFunction(sal_False) + , m_bDbasePrecisionChanged(sal_False) +{ + construct(); +} +// ------------------------------------------------------------------------- +OParseColumn::OParseColumn( const ::rtl::OUString& _Name, + const ::rtl::OUString& _TypeName, + const ::rtl::OUString& _DefaultValue, + sal_Int32 _IsNullable, + sal_Int32 _Precision, + sal_Int32 _Scale, + sal_Int32 _Type, + sal_Bool _IsAutoIncrement, + sal_Bool _IsCurrency, + sal_Bool _bCase + ) : connectivity::sdbcx::OColumn(_Name, + _TypeName, + _DefaultValue, + _IsNullable, + _Precision, + _Scale, + _Type, + _IsAutoIncrement, + sal_False, + _IsCurrency, + _bCase) + , m_bFunction(sal_False) + , m_bDbasePrecisionChanged(sal_False) +{ + construct(); +} +// ------------------------------------------------------------------------- +OParseColumn::~OParseColumn() +{ +} +// ------------------------------------------------------------------------- +void OParseColumn::construct() +{ + sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; + + registerProperty(connectivity::PROPERTY_FUNCTION, PROPERTY_ID_FUNCTION, nAttrib,&m_bFunction, ::getCppuType(reinterpret_cast< sal_Bool*>(NULL))); + registerProperty(connectivity::PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, nAttrib,&m_aTableName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(connectivity::PROPERTY_REALNAME, PROPERTY_ID_REALNAME, nAttrib,&m_aRealName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(connectivity::PROPERTY_DBASEPRECISIONCHANGED, PROPERTY_ID_DBASEPRECISIONCHANGED, nAttrib,&m_bDbasePrecisionChanged, ::getCppuType(reinterpret_cast<sal_Bool*>(NULL))); + +} + diff --git a/connectivity/source/parse/internalnode.cxx b/connectivity/source/parse/internalnode.cxx new file mode 100644 index 000000000000..57d5dbd6d7e6 --- /dev/null +++ b/connectivity/source/parse/internalnode.cxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * $RCSfile: internalnode.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_SQLINTERNALNODE_HXX +#include "internalnode.hxx" +#endif + +#include <stl_algo.h> +#ifndef _CONNECTIVITY_SQLPARSE_HXX +#include <connectivity/sqlparse.hxx> +#endif +#ifndef _DEBUG_HXX //autogen +#include <tools/debug.hxx> +#endif + +using namespace connectivity; + +//----------------------------------------------------------------------------- +OSQLInternalNode::OSQLInternalNode(const sal_Char* pNewValue, + SQLNodeType eNodeType, + sal_uInt32 nNodeID) + :OSQLParseNode(pNewValue,eNodeType,nNodeID) +{ + DBG_ASSERT(OSQLParser::s_pGarbageCollector, "Collector not initialized") + OSQLParser::s_pGarbageCollector->push_back(this); +} + +//----------------------------------------------------------------------------- +OSQLInternalNode::OSQLInternalNode(const ByteString &_NewValue, + SQLNodeType eNodeType, + sal_uInt32 nNodeID) + :OSQLParseNode(_NewValue,eNodeType,nNodeID) +{ + DBG_ASSERT(OSQLParser::s_pGarbageCollector, "Collector not initialized") + OSQLParser::s_pGarbageCollector->push_back(this); +} + +//----------------------------------------------------------------------------- +OSQLInternalNode::OSQLInternalNode(const sal_Unicode* pNewValue, + SQLNodeType eNodeType, + sal_uInt32 nNodeID) + :OSQLParseNode(pNewValue,eNodeType,nNodeID) +{ + DBG_ASSERT(OSQLParser::s_pGarbageCollector, "Collector not initialized") + OSQLParser::s_pGarbageCollector->push_back(this); +} + +//----------------------------------------------------------------------------- +OSQLInternalNode::OSQLInternalNode(const String &_NewValue, + SQLNodeType eNodeType, + sal_uInt32 nNodeID) + :OSQLParseNode(_NewValue,eNodeType,nNodeID) +{ + DBG_ASSERT(OSQLParser::s_pGarbageCollector, "Collector not initialized") + OSQLParser::s_pGarbageCollector->push_back(this); +} + + +//----------------------------------------------------------------------------- +OSQLInternalNode::~OSQLInternalNode() +{ + // remove the node from the garbage list + DBG_ASSERT(OSQLParser::s_pGarbageCollector, "Collector not initialized") + if (!OSQLParser::s_pGarbageCollector->empty()) + { + OSQLParser::s_pGarbageCollector->erase( + ::std::find(OSQLParser::s_pGarbageCollector->begin(), OSQLParser::s_pGarbageCollector->end(), + this)); + } +} diff --git a/connectivity/source/parse/makefile.mk b/connectivity/source/parse/makefile.mk new file mode 100644 index 000000000000..4d33aac1f973 --- /dev/null +++ b/connectivity/source/parse/makefile.mk @@ -0,0 +1,114 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:14: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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=connectivity +TARGET=sql + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Files -------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/sqlbison.obj \ + $(SLO)$/sqlflex.obj \ + $(SLO)$/PColumn.obj \ + $(SLO)$/sqliterator.obj \ + $(SLO)$/sqlnode.obj \ + $(SLO)$/fcode.obj \ + $(SLO)$/fcomp.obj \ + $(SLO)$/fanalyzer.obj \ + $(SLO)$/internalnode.obj + + +EXCEPTIONSFILES= \ + $(SLO)$/sqlbison.obj \ + $(SLO)$/PColumn.obj \ + $(SLO)$/sqliterator.obj \ + $(SLO)$/internalnode.obj \ + $(SLO)$/fcode.obj \ + $(SLO)$/fcomp.obj \ + $(SLO)$/fanalyzer.obj \ + $(SLO)$/sqlnode.obj + +all: \ + $(MISC)$/sqlflex.cxx \ + $(MISC)$/sqlbison.cxx \ + ALLTAR +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + + +$(MISC)$/sqlflex.cxx: sqlflex.l + +flex -i -8 -PSQLyy -L -o$(MISC)$/sqlflex.cxx sqlflex.l + +$(MISC)$/sqlbison.cxx: sqlbison.y + +bison -v -d -pSQLyy -l -bsql -o$(MISC)$/sqlbison.cxx sqlbison.y + -$(MKDIR) $(OUT)$/inc$/connectivity + +$(COPY) $(MISC)$/sqlbison.cxx.h $(OUT)$/inc$/connectivity$/sqlbison.hxx + diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y new file mode 100644 index 000000000000..f8aa3daf6254 --- /dev/null +++ b/connectivity/source/parse/sqlbison.y @@ -0,0 +1,4232 @@ +%{ +//-------------------------------------------------------------------------- +// +// $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/connectivity/source/parse/sqlbison.y,v 1.1.1.1 2000-09-18 16:14:28 hr Exp $ +// +// Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. +// +// First creation: +// OJ +// +// Last change: +// $Author: hr $ $Date: 2000-09-18 16:14:28 $ $Revision: 1.1.1.1 $ +// +// Description: +// +// +//-------------------------------------------------------------------------- + +#ifndef _VECTOR_ +#include <vector> +#endif + +#ifndef _SOLAR_H +#include <tools/solar.h> +#endif + +#ifndef _CONNECTIVITY_SQLNODE_HXX +#include <connectivity/sqlnode.hxx> +#endif +#ifndef _CONNECTIVITY_SQLPARSE_HXX +#include <connectivity/sqlparse.hxx> +#endif +#ifndef _CONNECTIVITY_SQLINTERNALNODE_HXX +#include <internalnode.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_ +#include <com/sun/star/lang/Locale.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ +#include <com/sun/star/util/Date.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_ +#include <com/sun/star/util/XNumberFormatter.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_ +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATS_HPP_ +#include <com/sun/star/util/XNumberFormats.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_ +#include <com/sun/star/util/NumberFormat.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_ +#include <com/sun/star/util/XNumberFormatTypes.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _TOOLS_SOLMATH_HXX //autogen wg. SolarMath +#include <tools/solmath.hxx> +#endif +#ifndef _ISOLANG_HXX +#include <tools/isolang.hxx> +#endif +#ifndef _DATETIME_HXX +#include <tools/datetime.hxx> +#endif +#ifndef _TOOLS_INTN_HXX //autogen wg. International +#include <tools/intn.hxx> +#endif +#ifndef _CONNECTIVITY_SQLSCAN_HXX +#include "sqlscan.hxx" +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +static String aEmptyString; + +static connectivity::OSQLInternalNode* newNode(const sal_Char* pNewValue, + const connectivity::SQLNodeType eNodeType, + const UINT16 nNodeID = 0) +{ + + return new connectivity::OSQLInternalNode(pNewValue, eNodeType, nNodeID); +} + +static connectivity::OSQLInternalNode* newNode(const ByteString& _NewValue, + const connectivity::SQLNodeType eNodeType, + const UINT16 nNodeID = 0) +{ + + return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID); +} + +static connectivity::OSQLInternalNode* newNode(const String& _NewValue, + const connectivity::SQLNodeType eNodeType, + const UINT16 nNodeID = 0) +{ + + return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID); +} + + +// yyi ist die interne Nr. der Regel, die gerade reduziert wird. +// Ueber die Mapping-Tabelle yyrmap wird daraus eine externe Regel-Nr. +#define SQL_NEW_RULE newNode(aEmptyString, SQL_NODE_RULE, yyr1[yyn]) +#define SQL_NEW_LISTRULE newNode(aEmptyString, SQL_NODE_LISTRULE, yyr1[yyn]) +#define SQL_NEW_COMMALISTRULE newNode(aEmptyString, SQL_NODE_COMMALISTRULE, yyr1[yyn]) + + +connectivity::OSQLParser* xxx_pGLOBAL_SQLPARSER; + +#define YYERROR_VERBOSE + +#define SQLyyerror(s) \ +{ \ + xxx_pGLOBAL_SQLPARSER->error(s); \ +} + +using namespace connectivity; +#define SQLyylex xxx_pGLOBAL_SQLPARSER->SQLlex +%} + /* symbolic tokens */ + +%union { + connectivity::OSQLParseNode * pParseNode; +} +%type <pParseNode> '(' ')' ',' ':' ';' '?' '[' ']' '{' '}' '.' + +%token <pParseNode> SQL_TOKEN_STRING SQL_TOKEN_ACCESS_DATE SQL_TOKEN_INT SQL_TOKEN_REAL_NUM +%token <pParseNode> SQL_TOKEN_INTNUM SQL_TOKEN_APPROXNUM SQL_TOKEN_NOT SQL_TOKEN_NAME + + /* operators */ +%left <pParseNode> SQL_TOKEN_NAME +%left <pParseNode> SQL_TOKEN_OR +%left <pParseNode> SQL_TOKEN_AND + +%left <pParseNode> LESSEQ GREATEQ NOTEQUAL LESS GREAT EQUAL /* '<' '>' = <> < > <= >= != */ +%left <pParseNode> '+' '-' +%left <pParseNode> '*' '/' +%left <pParseNode> SQL_TOKEN_NATURAL SQL_TOKEN_CROSS SQL_TOKEN_FULL SQL_TOKEN_LEFT SQL_TOKEN_RIGHT +%left <pParseNode> ')' +%right <pParseNode> '=' +%right <pParseNode> '.' +%right <pParseNode> '(' + + +%nonassoc <pParseNode> SQL_TOKEN_UMINUS + + + + /* literal keyword tokens */ + +%token <pParseNode> SQL_TOKEN_ALL SQL_TOKEN_ALTER SQL_TOKEN_AMMSC SQL_TOKEN_ANY SQL_TOKEN_AS SQL_TOKEN_ASC SQL_TOKEN_AT SQL_TOKEN_AUTHORIZATION SQL_TOKEN_AVG + +%token <pParseNode> SQL_TOKEN_BETWEEN SQL_TOKEN_BIT SQL_TOKEN_BIT_LENGTH SQL_TOKEN_BOTH SQL_TOKEN_BY + +%token <pParseNode> SQL_TOKEN_CAST SQL_TOKEN_CHARACTER SQL_TOKEN_CHAR_LENGTH SQL_TOKEN_CHECK SQL_TOKEN_COLLATE SQL_TOKEN_COMMIT SQL_TOKEN_CONTINUE SQL_TOKEN_CONVERT SQL_TOKEN_COUNT SQL_TOKEN_CREATE SQL_TOKEN_CROSS +%token <pParseNode> SQL_TOKEN_CURRENT SQL_TOKEN_CURRENT_DATE SQL_TOKEN_CURRENT_TIME SQL_TOKEN_CURRENT_TIMESTAMP SQL_TOKEN_CURSOR + +%token <pParseNode> SQL_TOKEN_DATE SQL_TOKEN_DAY SQL_TOKEN_DEC SQL_TOKEN_DECIMAL SQL_TOKEN_DECLARE SQL_TOKEN_DEFAULT SQL_TOKEN_DELETE SQL_TOKEN_DESC +%token <pParseNode> SQL_TOKEN_DISTINCT SQL_TOKEN_DOUBLE SQL_TOKEN_DROP + +%token <pParseNode> SQL_TOKEN_ESCAPE SQL_TOKEN_EXCEPT SQL_TOKEN_EXISTS SQL_TOKEN_EXTRACT SQL_TOKEN_FALSE SQL_TOKEN_FETCH SQL_TOKEN_FLOAT SQL_TOKEN_FOR SQL_TOKEN_FOREIGN SQL_TOKEN_FOUND SQL_TOKEN_FROM SQL_TOKEN_FULL + +%token <pParseNode> SQL_TOKEN_GRANT SQL_TOKEN_GROUP SQL_TOKEN_HAVING SQL_TOKEN_HOUR SQL_TOKEN_IN SQL_TOKEN_INDICATOR SQL_TOKEN_INNER SQL_TOKEN_INSERT SQL_TOKEN_INTEGER SQL_TOKEN_INTO SQL_TOKEN_IS SQL_TOKEN_INTERSECT + +%token <pParseNode> SQL_TOKEN_JOIN SQL_TOKEN_KEY SQL_TOKEN_LEADING SQL_TOKEN_LEFT SQL_TOKEN_LIKE SQL_TOKEN_LOCAL SQL_TOKEN_LOWER SQL_TOKEN_MINUTE SQL_TOKEN_MONTH +%token <pParseNode> SQL_TOKEN_MAX SQL_TOKEN_MIN SQL_TOKEN_NATURAL SQL_TOKEN_NCHAR SQL_TOKEN_NULL SQL_TOKEN_NUMERIC + +%token <pParseNode> SQL_TOKEN_OCTECT_LENGTH SQL_TOKEN_OF SQL_TOKEN_ON SQL_TOKEN_OPTION SQL_TOKEN_ORDER SQL_TOKEN_OUTER + +%token <pParseNode> SQL_TOKEN_POSITION SQL_TOKEN_PRECISION SQL_TOKEN_PRIMARY SQL_TOKEN_PRIVILEGES SQL_TOKEN_PROCEDURE SQL_TOKEN_PUBLIC +%token <pParseNode> SQL_TOKEN_REAL SQL_TOKEN_REFERENCES SQL_TOKEN_ROLLBACK SQL_TOKEN_RIGHT + +%token <pParseNode> SQL_TOKEN_SCHEMA SQL_TOKEN_SECOND SQL_TOKEN_SELECT SQL_TOKEN_SET SQL_TOKEN_SIZE SQL_TOKEN_SMALLINT SQL_TOKEN_SOME SQL_TOKEN_SQLCODE SQL_TOKEN_SQLERROR SQL_TOKEN_SUBSTRING SQL_TOKEN_SUM + +%token <pParseNode> SQL_TOKEN_TABLE SQL_TOKEN_TIME SQL_TOKEN_TIMESTAMP SQL_TOKEN_TIMEZONE_HOUR SQL_TOKEN_TIMEZONE_MINUTE SQL_TOKEN_TO SQL_TOKEN_TRAILING SQL_TOKEN_TRANSLATE SQL_TOKEN_TRIM SQL_TOKEN_TRUE SQL_TOKEN_UNION +%token <pParseNode> SQL_TOKEN_UNIQUE SQL_TOKEN_UNKNOWN SQL_TOKEN_UPDATE SQL_TOKEN_UPPER SQL_TOKEN_USAGE SQL_TOKEN_USER SQL_TOKEN_USING SQL_TOKEN_VALUES SQL_TOKEN_VIEW +%token <pParseNode> SQL_TOKEN_WHERE SQL_TOKEN_WITH SQL_TOKEN_WORK SQL_TOKEN_YEAR SQL_TOKEN_ZONE + +/* ODBC KEYWORDS */ +%token <pParseNode> SQL_TOKEN_CALL SQL_TOKEN_D SQL_TOKEN_FN SQL_TOKEN_T SQL_TOKEN_TS SQL_TOKEN_OJ + + +%token <pParseNode> SQL_TOKEN_INVALIDSYMBOL + +/*%type <pParseNode> sql_single_statement */ + +%type <pParseNode> sql /*schema */ +%type <pParseNode> column_def_opt_list column_def_opt table_constraint_def column_commalist +%type <pParseNode> view_def opt_with_check_option opt_column_commalist privilege_def +%type <pParseNode> opt_with_grant_option privileges operation_commalist operation +%type <pParseNode> grantee_commalist grantee opt_order_by_clause ordering_spec_commalist +%type <pParseNode> ordering_spec opt_asc_desc manipulative_statement commit_statement +%type <pParseNode> /*delete_statement_positioned*/ delete_statement_searched fetch_statement +%type <pParseNode> insert_statement values_or_query_spec +%type <pParseNode> rollback_statement select_statement_into opt_all_distinct +%type <pParseNode> /*update_statement_positioned*/ assignment_commalist assignment +%type <pParseNode> update_statement_searched target_commalist target opt_where_clause +%type <pParseNode> select_statement selection table_exp from_clause table_ref_commalist table_ref +%type <pParseNode> where_clause opt_group_by_clause column_ref_commalist opt_having_clause +%type <pParseNode> search_condition predicate comparison_predicate between_predicate +%type <pParseNode> like_predicate opt_escape test_for_null in_predicate +%type <pParseNode> all_or_any_predicate any_all_some existence_test subquery +%type <pParseNode> scalar_exp_commalist parameter_ref literal +%type <pParseNode> column_ref data_type column cursor parameter range_variable user /*like_check*/ +/* neue Regeln bei OJ */ +%type <pParseNode> derived_column as_clause table_name num_primary term num_value_exp +%type <pParseNode> value_exp_primary num_value_fct unsigned_value_spec cast_spec set_fct_spec scalar_subquery +%type <pParseNode> position_exp extract_exp length_exp general_value_spec +%type <pParseNode> general_set_fct set_fct_type query_exp non_join_query_exp joined_table +%type <pParseNode> non_join_query_term non_join_query_primary simple_table +%type <pParseNode> table_value_const_list row_value_constructor row_value_const_list row_value_constructor_elem +%type <pParseNode> qualified_join value_exp query_term join_type outer_join_type join_condition boolean_term +%type <pParseNode> boolean_factor truth_value boolean_test boolean_primary named_columns_join join_spec +%type <pParseNode> cast_operand cast_target factor datetime_value_exp /*interval_value_exp*/ datetime_term datetime_factor +%type <pParseNode> datetime_primary datetime_value_fct time_zone time_zone_specifier /*interval_term*/ /*interval_qualifier*/ +%type <pParseNode> /*start_field*/ non_second_datetime_field /*end_field*/ /*single_datetime_field*/ extract_field datetime_field time_zone_field +%type <pParseNode> extract_source char_length_exp octet_length_exp bit_length_exp select_sublist string_value_exp +%type <pParseNode> char_value_exp concatenation char_factor char_primary string_value_fct char_substring_fct fold +%type <pParseNode> form_conversion char_translation trim_fct trim_operands trim_spec bit_value_fct bit_substring_fct op_column_commalist +%type <pParseNode> /*bit_concatenation*/ bit_value_exp bit_factor bit_primary collate_clause char_value_fct unique_spec value_exp_commalist in_predicate_value unique_test update_source +%type <pParseNode> all query_primary as not for_length upper_lower comparison column_val cross_union /*opt_schema_element_list*/ +%type <pParseNode> /*op_authorization op_schema*/ nil_fkt schema_element base_table_def base_table_element base_table_element_commalist +%type <pParseNode> column_def odbc_fct_spec odbc_call_spec odbc_fct_type op_parameter union_statement +%type <pParseNode> op_odbc_call_parameter odbc_parameter_commalist odbc_parameter +%% + +/* Parse Tree an OSQLParser zurueckliefern + * (der Zugriff ueber yyval nach Aufruf des Parsers scheitert, + * + */ +sql_single_statement: + sql + { xxx_pGLOBAL_SQLPARSER->setParseTree( $1 ); } + | sql ';' + { xxx_pGLOBAL_SQLPARSER->setParseTree( $1 ); } + ; +/* +sql_list: + sql_ ';' + {$$ = SQL_NEW_LISTRULE; + $$->append($1); + pSqlParseTreeRoot = $1; -- obsolete - Ergebnis in yyval! rdm } + | sql_list sql ';' + {$1->append($2); + $$ = $1;} + ; +*/ + + + /* schema definition language */ + /* Note: other ``sql:'' rules appear later in the grammar */ +/*** +sql: + schema + ; + +op_authorization: + {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_AUTHORIZATION user + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +op_schema: + {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_NAME + | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + ; + +schema: + SQL_TOKEN_CREATE SQL_TOKEN_SCHEMA op_schema op_authorization opt_schema_element_list + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + } + ; + +opt_schema_element_list: + /* empty * / {$$ = SQL_NEW_RULE;} + | schema_glement_list + ; + +schema_element_list: + schema_element + {$$ = SQL_NEW_LISTRULE; + $$->append($1);} + | schema_element_list schema_element + {$1->append($2); + $$ = $1;} + ; +*/ +sql: + schema_element + {$$ = SQL_NEW_RULE; + $$->append($1); + } + ; + +schema_element: + base_table_def + | view_def + | privilege_def + ; + +base_table_def: + SQL_TOKEN_CREATE SQL_TOKEN_TABLE table_name '(' base_table_element_commalist ')' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($5); + $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));} + ; + +base_table_element_commalist: + base_table_element + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + | base_table_element_commalist ',' base_table_element + {$1->append($3); + $$ = $1;} + ; + +base_table_element: + column_def + | table_constraint_def + ; + +column_def: + column data_type column_def_opt_list + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; + +column_def_opt_list: + /* empty */ {$$ = SQL_NEW_LISTRULE;} + | column_def_opt_list column_def_opt + {$1->append($2); + $$ = $1;} + ; + +nil_fkt: + datetime_value_fct + ; +unique_spec: + SQL_TOKEN_UNIQUE + | SQL_TOKEN_PRIMARY SQL_TOKEN_KEY + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +column_def_opt: + SQL_TOKEN_NOT SQL_TOKEN_NULL + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + | unique_spec + | SQL_TOKEN_DEFAULT literal + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + | SQL_TOKEN_DEFAULT SQL_TOKEN_NULL + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + | SQL_TOKEN_DEFAULT SQL_TOKEN_USER + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + | SQL_TOKEN_DEFAULT nil_fkt + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + | SQL_TOKEN_CHECK + | SQL_TOKEN_CHECK '(' search_condition ')' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));} + | SQL_TOKEN_REFERENCES table_name + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + | SQL_TOKEN_REFERENCES table_name '(' column_commalist ')' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($4); + $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));} + ; + +table_constraint_def: + unique_spec '(' column_commalist ')' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));} + | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_name + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($4); + $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION)); + $$->append($6); + $$->append($7);} + | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_name '(' column_commalist ')' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($4); + $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION)); + $$->append($6); + $$->append($7); + $$->append($8 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($9); + $$->append($10 = newNode(")", SQL_NODE_PUNCTUATION));} + | SQL_TOKEN_CHECK '(' search_condition ')' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));} + ; +op_column_commalist: + /* empty */ {$$ = SQL_NEW_RULE;} + | '(' column_commalist ')' + {$$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +column_commalist: + column_commalist ',' column + {$1->append($3); + $$ = $1;} + | column + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + ; + +view_def: + SQL_TOKEN_CREATE SQL_TOKEN_VIEW table_name opt_column_commalist SQL_TOKEN_AS select_statement opt_with_check_option + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6); + $$->append($7);} + ; + +opt_with_check_option: + /* empty */ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_WITH SQL_TOKEN_CHECK SQL_TOKEN_OPTION + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3);} + ; + +opt_column_commalist: + /* empty */ {$$ = SQL_NEW_RULE;} + | '(' column_commalist ')' + {$$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));} + ; + +privilege_def: + SQL_TOKEN_GRANT privileges SQL_TOKEN_ON table_name SQL_TOKEN_TO grantee_commalist + opt_with_grant_option + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6); + $$->append($7);} + ; + +opt_with_grant_option: + /* empty */ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_WITH SQL_TOKEN_GRANT SQL_TOKEN_OPTION + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3);} + ; + +privileges: + SQL_TOKEN_ALL SQL_TOKEN_PRIVILEGES + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + | operation_commalist + ; + +operation_commalist: + operation + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + | operation_commalist ',' operation + {$1->append($3); + $$ = $1;} + ; + +operation: + SQL_TOKEN_SELECT + | SQL_TOKEN_INSERT opt_column_commalist + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + | SQL_TOKEN_DELETE + | SQL_TOKEN_UPDATE opt_column_commalist + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + | SQL_TOKEN_REFERENCES opt_column_commalist + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + | SQL_TOKEN_USAGE + ; + + +grantee_commalist: + grantee + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + | grantee_commalist ',' grantee + {$1->append($3); + $$ = $1;} + ; + +grantee: + SQL_TOKEN_PUBLIC + | user + ; + + /* module language */ + +opt_order_by_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_ORDER SQL_TOKEN_BY ordering_spec_commalist + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3);} + ; + +ordering_spec_commalist: + ordering_spec + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + | ordering_spec_commalist ',' ordering_spec + {$1->append($3); + $$ = $1;} + ; + +ordering_spec: +/* SQL_TOKEN_INTNUM opt_asc_desc + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} +*/ + predicate opt_asc_desc + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + + | row_value_constructor_elem opt_asc_desc + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + ; + +opt_asc_desc: + {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_ASC + | SQL_TOKEN_DESC + ; + + +/*** +manipulative_statement_list: + manipulative_statement + {$$ = SQL_NEW_LISTRULE; + $$->append($1);} + | manipulative_statement_list manipulative_statement + {$1->append($2); + $$ = $1;} + ; +***/ + +sql: + {$$ = SQL_NEW_LISTRULE;} + ; +not: + {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_NOT + ; + /* manipulative statements */ + +sql: manipulative_statement + ; + +manipulative_statement: + commit_statement +/* | delete_statement_positioned*/ + | delete_statement_searched + | fetch_statement + | insert_statement + | rollback_statement + | select_statement_into +/* | update_statement_positioned*/ + | update_statement_searched + | union_statement + | '{' odbc_call_spec '}' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("{", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode("}", SQL_NODE_PUNCTUATION)); + } + ; + +union_statement: + select_statement + | union_statement SQL_TOKEN_UNION all select_statement + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + ; +commit_statement: + SQL_TOKEN_COMMIT SQL_TOKEN_WORK + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + ; +/* +delete_statement_positioned: + SQL_TOKEN_DELETE SQL_TOKEN_FROM table_name SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6); + $$->append($7);} + ; +*/ +delete_statement_searched: + SQL_TOKEN_DELETE SQL_TOKEN_FROM table_name opt_where_clause + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4);} + ; + +fetch_statement: + SQL_TOKEN_FETCH cursor SQL_TOKEN_INTO target_commalist + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4);} + ; + +insert_statement: + SQL_TOKEN_INSERT SQL_TOKEN_INTO table_name opt_column_commalist values_or_query_spec + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5);} + ; +values_or_query_spec: + SQL_TOKEN_VALUES table_value_const_list + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; + +table_value_const_list: + row_value_constructor + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + | table_value_const_list ',' row_value_constructor + {$1->append($3); + $$ = $1;} + ; +row_value_const_list: + row_value_constructor_elem + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + | row_value_const_list ',' row_value_constructor_elem + {$1->append($3); + $$ = $1;} + ; +row_value_constructor: + row_value_constructor_elem + | '(' row_value_const_list ')' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } +/* | subquery + { + $$ = SQL_NEW_RULE; + $$->append($1); + }*/ + ; +row_value_constructor_elem: + value_exp /*[^')']*/ + | SQL_TOKEN_NULL + | SQL_TOKEN_DEFAULT + ; + + +rollback_statement: + SQL_TOKEN_ROLLBACK SQL_TOKEN_WORK + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + ; + + + /* INTO target_commalist herausgenommen */ +select_statement_into: + SQL_TOKEN_SELECT opt_all_distinct selection SQL_TOKEN_INTO target_commalist table_exp + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6); } + ; + +opt_all_distinct: + {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_ALL + | SQL_TOKEN_DISTINCT + + ; +/* +update_statement_positioned: + SQL_TOKEN_UPDATE table_name SQL_TOKEN_SET assignment_commalist + SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6); + $$->append($7); + $$->append($8);} + ; +*/ +assignment_commalist: + assignment + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + | assignment_commalist ',' assignment + {$1->append($3); + $$ = $1;} + ; + +assignment: + column EQUAL update_source + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3);} + ; +update_source: + value_exp + | SQL_TOKEN_NULL + | SQL_TOKEN_DEFAULT + ; +update_statement_searched: + SQL_TOKEN_UPDATE table_name SQL_TOKEN_SET assignment_commalist opt_where_clause + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5);} + ; + +target_commalist: + target + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + | target_commalist ',' target + {$1->append($3); + $$ = $1;} + ; + +target: + parameter_ref + ; + +opt_where_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | where_clause + ; + + /* query expressions */ + +query_term: + non_join_query_term + { + $$ = SQL_NEW_RULE; + $$->append($1); + } +/* | joined_table + { + $$ = SQL_NEW_RULE; + $$->append($1); + } +*/ ; +/* SELECT STATEMENT */ +select_statement: + SQL_TOKEN_SELECT opt_all_distinct selection table_exp + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + ; + +selection: + '*' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("*", SQL_NODE_PUNCTUATION)); + } + | scalar_exp_commalist + ; + +table_exp: + from_clause + opt_where_clause + opt_group_by_clause + opt_having_clause + opt_order_by_clause + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5);} + ; + +from_clause: + SQL_TOKEN_FROM table_ref_commalist + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + ; + +table_ref_commalist: + table_ref + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + | table_ref_commalist ',' table_ref /*[^SQL_TOKEN_CROSS SQL_TOKEN_FULL SQL_TOKEN_UNION SQL_TOKEN_LEFT SQL_TOKEN_RIGHT SQL_TOKEN_INNER SQL_TOKEN_NATURAL]*/ + {$1->append($3); + $$ = $1;} + ; +as: + {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_AS + { + $$ = SQL_NEW_RULE; + } + ; +table_ref: + table_name + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | table_name as range_variable op_column_commalist + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + | '(' joined_table ')' as range_variable op_column_commalist + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + $$->append($4); + $$->append($5); + $$->append($6); + } + | joined_table + | '{' SQL_TOKEN_OJ joined_table '}' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("{", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3); + $$->append($4 = newNode("}", SQL_NODE_PUNCTUATION)); + } + ; +where_clause: + SQL_TOKEN_WHERE search_condition + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + ; + +opt_group_by_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_GROUP SQL_TOKEN_BY column_ref_commalist + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3);} + ; + +column_ref_commalist: + column_ref + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + | column_ref_commalist ',' column_ref + {$1->append($3); + $$ = $1;} + ; + +opt_having_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_HAVING search_condition + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + ; + + /* search conditions */ +truth_value: + SQL_TOKEN_TRUE + | SQL_TOKEN_FALSE + | SQL_TOKEN_UNKNOWN + ; +boolean_primary: + predicate + | '(' search_condition ')' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +subroutine: + { + if(!xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + YYERROR; + } + ; +boolean_test: + boolean_primary + | boolean_primary SQL_TOKEN_IS truth_value + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + | boolean_primary SQL_TOKEN_IS SQL_TOKEN_NOT truth_value %prec SQL_TOKEN_IS + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + | subroutine SQL_TOKEN_NOT SQL_TOKEN_LIKE string_value_exp opt_escape + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME)); + + $$ = SQL_NEW_RULE; + $$->append(pColumnRef); + $$->append($2); + $$->append($3); + if (xxx_pGLOBAL_SQLPARSER->buildLikeRule($$,$4,$5)) + $$->append($5); + else + { + delete $$; + YYABORT; + } + } + else + YYERROR; + } + ; +boolean_factor: + boolean_test + | SQL_TOKEN_NOT boolean_test + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +boolean_term: + boolean_factor + | boolean_term SQL_TOKEN_AND boolean_factor + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + | row_value_constructor_elem '\n' /*[^')' ',']*/ + { + $$ = SQL_NEW_RULE; + INT16 nErg = xxx_pGLOBAL_SQLPARSER->buildComparsionRule($$,$1); + if(nErg == 1) + { + OSQLParseNode* pTemp = $$; + $$ = pTemp->removeAt((ULONG)0); + delete pTemp; + } + else + { + delete $$; + if(nErg) + YYERROR; + else + YYABORT; + } + } + | boolean_term SQL_TOKEN_AND literal + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + INT16 nErg = xxx_pGLOBAL_SQLPARSER->buildComparsionRule($$,$3); + if(nErg < 1) + { + delete $$; + if(nErg) + YYERROR; + else + YYABORT; + } + + } + | boolean_term SQL_TOKEN_AND SQL_TOKEN_STRING + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + INT16 nErg = xxx_pGLOBAL_SQLPARSER->buildComparsionRule($$,$3); + if(nErg < 1) + { + delete $$; + if(nErg) + YYERROR; + else + YYABORT; + } + + } + ; +search_condition: + boolean_term + | search_condition SQL_TOKEN_OR boolean_term + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; +predicate: + comparison_predicate + | between_predicate + | all_or_any_predicate + | existence_test + | unique_test + | test_for_null + | in_predicate + | like_predicate + ; + +comparison_predicate: + row_value_constructor comparison row_value_constructor + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + | comparison row_value_constructor + { + $$ = SQL_NEW_RULE; + INT16 nErg = xxx_pGLOBAL_SQLPARSER->buildComparsionRule($$,$2,$1); + if(nErg == 1) + { + OSQLParseNode* pTemp = $$; + $$ = pTemp->removeAt((ULONG)0); + delete pTemp; + } + else + { + delete $$; + YYABORT; + } + } + ; +comparison: + LESS + | NOTEQUAL + | EQUAL + | GREAT + | LESSEQ + | GREATEQ + ; +between_predicate: + row_value_constructor SQL_TOKEN_BETWEEN row_value_constructor SQL_TOKEN_AND row_value_constructor + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + } + | row_value_constructor SQL_TOKEN_NOT SQL_TOKEN_BETWEEN row_value_constructor SQL_TOKEN_AND row_value_constructor + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6); + } + | subroutine SQL_TOKEN_NOT SQL_TOKEN_BETWEEN row_value_constructor SQL_TOKEN_AND row_value_constructor + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME)); + + $$ = SQL_NEW_RULE; + $$->append(pColumnRef); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6); + } + else + YYERROR; + } + | subroutine SQL_TOKEN_BETWEEN row_value_constructor SQL_TOKEN_AND row_value_constructor + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME)); + + $$ = SQL_NEW_RULE; + $$->append(pColumnRef); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + } + else + YYERROR; + } + ; + +like_predicate: + row_value_constructor SQL_TOKEN_NOT SQL_TOKEN_LIKE string_value_exp opt_escape + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + } + | row_value_constructor SQL_TOKEN_LIKE string_value_exp opt_escape + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + | row_value_constructor SQL_TOKEN_NOT SQL_TOKEN_LIKE value_exp_primary opt_escape + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + } + | row_value_constructor SQL_TOKEN_LIKE value_exp_primary opt_escape + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + /*| SQL_TOKEN_NOT + { + if(!xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + YYERROR; + } SQL_TOKEN_LIKE string_value_exp opt_escape + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME)); + + $$ = SQL_NEW_RULE; + $$->append(pColumnRef); + $$->append($1); + $$->append($3); + if (xxx_pGLOBAL_SQLPARSER->buildLikeRule($$,$4,$5)) + $$->append($5); + else + { + delete $$; + YYABORT; + } + } + else + YYERROR; + } + */| SQL_TOKEN_LIKE string_value_exp opt_escape + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME)); + + $$ = SQL_NEW_RULE; + $$->append(pColumnRef); + $$->append($1); + if (xxx_pGLOBAL_SQLPARSER->buildLikeRule($$,$2,$3)) + $$->append($3); + else + { + delete $$; + YYABORT; + } + } + else + YYERROR; + } + | SQL_TOKEN_LIKE value_exp_primary opt_escape + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME)); + + $$ = SQL_NEW_RULE; + $$->append(pColumnRef); + $$->append($1); + if (xxx_pGLOBAL_SQLPARSER->buildLikeRule($$,$2,$3)) + $$->append($3); + else + { + delete $$; + YYABORT; + } + } + else + YYERROR; + } + | subroutine SQL_TOKEN_NOT SQL_TOKEN_LIKE value_exp_primary opt_escape + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME)); + + $$ = SQL_NEW_RULE; + $$->append(pColumnRef); + $$->append($2); + $$->append($3); + if (xxx_pGLOBAL_SQLPARSER->buildLikeRule($$,$4,$5)) + $$->append($5); + else + { + delete $$; + YYABORT; + } + } + else + YYERROR; + } + ; + +opt_escape: + /* empty */ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_ESCAPE string_value_exp + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + | '{' SQL_TOKEN_ESCAPE SQL_TOKEN_STRING '}' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("{", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3); + $$->append($4 = newNode("}", SQL_NODE_PUNCTUATION)); + } + ; + +test_for_null: + row_value_constructor SQL_TOKEN_IS not SQL_TOKEN_NULL + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + | SQL_TOKEN_IS not SQL_TOKEN_NULL + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME)); + + $$ = SQL_NEW_RULE; + $$->append(pColumnRef); + $$->append($1); + $$->append($2); + $$->append($3); + } + else + YYERROR; + } + ; +in_predicate_value: + subquery + {$$ = SQL_NEW_RULE; + $$->append($1); + } + | '(' value_exp_commalist ')' + {$$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +in_predicate: + row_value_constructor not SQL_TOKEN_IN in_predicate_value + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + | subroutine SQL_TOKEN_IN in_predicate_value + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME)); + + $$ = SQL_NEW_RULE; + $$->append(pColumnRef); + $$->append($2); + $$->append($3); + /*$$->append($3);*/ + } + else + YYERROR; + } + ; +all_or_any_predicate: + row_value_constructor comparison any_all_some subquery + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + | comparison any_all_some subquery + { + if(xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME)); + + $$ = SQL_NEW_RULE; + $$->append(pColumnRef); + $$->append($1); + $$->append($2); + $$->append($3); + } + else + YYERROR; + } + ; + +any_all_some: + SQL_TOKEN_ANY + | SQL_TOKEN_ALL + | SQL_TOKEN_SOME + ; + +existence_test: + SQL_TOKEN_EXISTS subquery + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + ; +unique_test: + SQL_TOKEN_UNIQUE subquery + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + ; +subquery: + '(' query_exp ')' + {$$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));} + ; + + /* scalar expressions */ +scalar_exp_commalist: + select_sublist + { + $$ = SQL_NEW_COMMALISTRULE; + $$->append($1); + } + | scalar_exp_commalist ',' select_sublist + { + $1->append($3); + $$ = $1; + } + ; +select_sublist: + table_name '.' '*' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($3 = newNode("*", SQL_NODE_PUNCTUATION)); + } + | derived_column + + ; + +parameter_ref: + parameter + ; + +/* +op_like: + '*' + { + $$ = newNode("*", SQL_NODE_PUNCTUATION); + } + | '?' + { + $$ = newNode("?", SQL_NODE_PUNCTUATION); + } + | op_like '*' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION)); + xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, FALSE); + } + | op_like '?' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("?", SQL_NODE_PUNCTUATION)); + xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, FALSE); + } + ; +*/ + +literal: +/* SQL_TOKEN_STRING + | */SQL_TOKEN_INT + | SQL_TOKEN_REAL_NUM + | SQL_TOKEN_INTNUM + | SQL_TOKEN_APPROXNUM + | SQL_TOKEN_ACCESS_DATE +/* rules for predicate check */ + | literal SQL_TOKEN_STRING + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, TRUE); + } + else + YYERROR; + } + | literal SQL_TOKEN_INT + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, TRUE); + } + else + YYERROR; + } + | literal SQL_TOKEN_REAL_NUM + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, TRUE); + } + else + YYERROR; + } + | literal SQL_TOKEN_APPROXNUM + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, TRUE); + } + else + YYERROR; + } + ; + + /* miscellaneous */ +as_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_AS column + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + | column + ; +position_exp: + SQL_TOKEN_POSITION '(' string_value_exp SQL_TOKEN_IN string_value_exp ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +num_value_fct: + position_exp + | extract_exp + | length_exp + ; +char_length_exp: + SQL_TOKEN_CHAR_LENGTH '(' string_value_exp ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +octet_length_exp: + SQL_TOKEN_OCTECT_LENGTH '(' string_value_exp ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +bit_length_exp: + SQL_TOKEN_BIT_LENGTH '(' string_value_exp ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +length_exp: + char_length_exp + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | octet_length_exp + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | bit_length_exp + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +datetime_field: + non_second_datetime_field + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_SECOND + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +extract_field: + datetime_field + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | time_zone_field + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +time_zone_field: + SQL_TOKEN_TIMEZONE_HOUR + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_TIMEZONE_MINUTE + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +extract_source: + datetime_value_exp + { + $$ = SQL_NEW_RULE; + $$->append($1); + } +/* | interval_value_exp + { + $$ = SQL_NEW_RULE; + $$->append($1); + } */ + ; +extract_exp: + SQL_TOKEN_EXTRACT '(' extract_field SQL_TOKEN_FROM extract_source ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +unsigned_value_spec: + literal + | general_value_spec + ; +general_value_spec: + parameter + | SQL_TOKEN_USER + ; +set_fct_spec: + general_set_fct + | '{' odbc_fct_spec '}' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("{", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode("}", SQL_NODE_PUNCTUATION)); + } + | SQL_TOKEN_NAME '(' value_exp_commalist ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +op_parameter: + {$$ = SQL_NEW_RULE;} + | '?' EQUAL + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("?", SQL_NODE_PUNCTUATION)); + $$->append($2); + } + ; +odbc_call_spec: + op_parameter SQL_TOKEN_CALL table_name op_odbc_call_parameter + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + ; + +op_odbc_call_parameter: + {$$ = SQL_NEW_RULE;} + | '(' odbc_parameter_commalist ')' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; + +odbc_parameter_commalist: + odbc_parameter + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + | odbc_parameter_commalist ',' odbc_parameter + { + $1->append($3); + $$ = $1; + } + ; +odbc_parameter: + /* empty */ {$$ = SQL_NEW_RULE;} + | literal + | parameter + ; + +odbc_fct_spec: + odbc_fct_type SQL_TOKEN_STRING + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; + +odbc_fct_type: + SQL_TOKEN_FN + | SQL_TOKEN_D + | SQL_TOKEN_T + | SQL_TOKEN_TS + ; + +general_set_fct: + set_fct_type '(' opt_all_distinct value_exp ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4); + $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION)); + } + | SQL_TOKEN_COUNT '(' '*' ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3 = newNode("*", SQL_NODE_PUNCTUATION)); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + | SQL_TOKEN_COUNT '(' opt_all_distinct value_exp ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4); + $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +set_fct_type: + SQL_TOKEN_AVG + | SQL_TOKEN_MAX + | SQL_TOKEN_MIN + | SQL_TOKEN_SUM + ; + +outer_join_type: + SQL_TOKEN_LEFT %prec SQL_TOKEN_LEFT + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_RIGHT %prec SQL_TOKEN_RIGHT + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_FULL %prec SQL_TOKEN_FULL + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +join_condition: + SQL_TOKEN_ON search_condition + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +join_spec: + join_condition + | named_columns_join + ; +join_type: + SQL_TOKEN_INNER + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | outer_join_type + | outer_join_type SQL_TOKEN_OUTER + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +cross_union: + table_ref /*[SQL_TOKEN_CROSS]*/ SQL_TOKEN_CROSS SQL_TOKEN_JOIN table_ref %prec SQL_TOKEN_CROSS + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + ; + +qualified_join: + /* wenn SQL_TOKEN_NATURAL, dann keine join_spec */ + table_ref /*[SQL_TOKEN_NATURAL]*/ SQL_TOKEN_NATURAL join_type SQL_TOKEN_JOIN table_ref %prec SQL_TOKEN_NATURAL + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + } + | table_ref join_type SQL_TOKEN_JOIN table_ref join_spec + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + } + | cross_union + ; +joined_table: + qualified_join +/* | query_exp*/ + | '(' joined_table ')' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + + ; +named_columns_join: + SQL_TOKEN_USING '(' column_commalist ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +simple_table: + select_statement + | values_or_query_spec + ; + +non_join_query_primary: + simple_table + | '(' non_join_query_exp ')' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +non_join_query_term: + non_join_query_primary + | query_term SQL_TOKEN_INTERSECT all query_primary + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + ; +query_primary: + non_join_query_primary + /*| joined_table*/ + ; +non_join_query_exp: + non_join_query_term + | query_exp SQL_TOKEN_UNION all query_term + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + | query_exp SQL_TOKEN_EXCEPT all query_term + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + ; +all: + /* empty*/ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_ALL + ; +query_exp: + non_join_query_exp /*[^')']*/ + ; +scalar_subquery: + subquery + ; +cast_operand: + value_exp + | SQL_TOKEN_NULL + ; +cast_target: + table_name + | data_type + ; +cast_spec: + SQL_TOKEN_CAST '(' cast_operand SQL_TOKEN_AS cast_target ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +value_exp_primary: + unsigned_value_spec + | column_ref + | set_fct_spec + | scalar_subquery + | '(' value_exp ')' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + | cast_spec + ; + +num_primary: + value_exp_primary + | num_value_fct + ; +factor: + num_primary + | '-' num_primary %prec SQL_TOKEN_UMINUS + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("-", SQL_NODE_PUNCTUATION)); + $$->append($2); + } + | '+' num_primary %prec SQL_TOKEN_UMINUS + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("+", SQL_NODE_PUNCTUATION)); + $$->append($2); + } + ; + +term: + factor + | term '*' factor + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + | term '/' factor + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("/", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + ; + +num_value_exp: + term + | num_value_exp '+' term + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + | num_value_exp '-' term + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + ; +datetime_primary: +/* value_exp_primary + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + |*/ datetime_value_fct + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +datetime_value_fct: + SQL_TOKEN_CURRENT_DATE + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_CURRENT_TIME + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_CURRENT_TIMESTAMP + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +time_zone: + SQL_TOKEN_AT time_zone_specifier + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +time_zone_specifier: + SQL_TOKEN_LOCAL + { + $$ = SQL_NEW_RULE; + $$->append($1); + } +/* | SQL_TOKEN_TIME SQL_TOKEN_ZONE interval_value_exp + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + }*/ + ; +datetime_factor: + datetime_primary + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | datetime_primary time_zone + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +datetime_term: + datetime_factor + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +/* +interval_term: + literal + | interval_term '*' factor + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + | interval_term '/' factor + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("/", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + ; +*/ +datetime_value_exp: + datetime_term + { + $$ = SQL_NEW_RULE; + $$->append($1); + } +/* | interval_value_exp '+' datetime_term + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + | datetime_value_exp '+' interval_term + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + | datetime_value_exp '-' interval_term + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION)); + $$->append($3); + } +*/ ; +/* +interval_value_exp: + interval_term + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | interval_value_exp '+' interval_term + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + | interval_value_exp '-' interval_term + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + | '(' datetime_value_exp '-' datetime_term ')' interval_qualifier + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode("-", SQL_NODE_PUNCTUATION)); + $$->append($4); + $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION)); + $$->append($6); + } + ; +*/ +non_second_datetime_field: + SQL_TOKEN_YEAR + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_MONTH + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_DAY + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_HOUR + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_MINUTE + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +/*start_field: + non_second_datetime_field + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | non_second_datetime_field '(' SQL_TOKEN_INTNUM ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +end_field: + non_second_datetime_field + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_SECOND + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_SECOND '(' SQL_TOKEN_INTNUM ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +*/ +/* +single_datetime_field: + non_second_datetime_field + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | non_second_datetime_field '(' SQL_TOKEN_INTNUM ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + | SQL_TOKEN_SECOND + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | SQL_TOKEN_SECOND '(' SQL_TOKEN_INTNUM ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + | SQL_TOKEN_SECOND '(' SQL_TOKEN_INTNUM ',' SQL_TOKEN_INTNUM ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(",", SQL_NODE_PUNCTUATION)); + $$->append($5); + $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +*/ +/* +interval_qualifier: + start_field SQL_TOKEN_TO end_field + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + | single_datetime_field + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +*/ +value_exp_commalist: + value_exp + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + | value_exp_commalist ',' value_exp + {$1->append($3); + $$ = $1;} + /* this rule is only valid if we check predicates */ + | value_exp_commalist ';' value_exp + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + $1->append($3); + $$ = $1; + } + else + YYERROR; + } + ; +value_exp: + num_value_exp /*[^')']*/ + | string_value_exp + | datetime_value_exp + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +string_value_exp: + char_value_exp +/* | bit_value_exp + { + $$ = SQL_NEW_RULE; + $$->append($1); + } +*/ ; +char_value_exp: + char_factor + | concatenation + ; +concatenation: + char_value_exp '+' char_factor + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + ; + +char_primary: + SQL_TOKEN_STRING + | string_value_fct + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +collate_clause: + SQL_TOKEN_COLLATE table_name + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +char_factor: + char_primary + | char_primary collate_clause + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +string_value_fct: + char_value_fct + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | bit_value_fct + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +bit_value_fct: + bit_substring_fct + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +bit_substring_fct: + SQL_TOKEN_SUBSTRING '(' bit_value_exp SQL_TOKEN_FROM string_value_exp for_length ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6); + $$->append($7 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +bit_value_exp: + bit_factor + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +/* + bit_concatenation + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | +bit_concatenation: + bit_value_exp '+' bit_factor + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION)); + $$->append($3); + } + ; +*/ +bit_factor: + bit_primary + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +bit_primary: + {$$ = SQL_NEW_RULE;} +/* value_exp_primary + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | string_value_fct + { + $$ = SQL_NEW_RULE; + $$->append($1); + }*/ + ; +char_value_fct: + char_substring_fct + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | fold + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | form_conversion + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | char_translation + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + | trim_fct + { + $$ = SQL_NEW_RULE; + $$->append($1); + } + ; +for_length: + {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_FOR string_value_exp + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +char_substring_fct: + SQL_TOKEN_SUBSTRING '(' string_value_exp SQL_TOKEN_FROM string_value_exp for_length ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6); + $$->append($7 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +upper_lower: + SQL_TOKEN_UPPER + | SQL_TOKEN_LOWER + ; +fold: + upper_lower '(' string_value_exp ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +form_conversion: + SQL_TOKEN_CONVERT '(' string_value_exp SQL_TOKEN_USING table_name ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +char_translation: + SQL_TOKEN_TRANSLATE '(' string_value_exp SQL_TOKEN_USING table_name ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4); + $$->append($5); + $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +trim_fct: + SQL_TOKEN_TRIM '(' trim_operands ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +trim_operands: + string_value_exp + | trim_spec string_value_exp SQL_TOKEN_FROM string_value_exp + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + | trim_spec SQL_TOKEN_FROM string_value_exp + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; +trim_spec: + SQL_TOKEN_BOTH + | SQL_TOKEN_LEADING + | SQL_TOKEN_TRAILING + ; + +derived_column: + value_exp as_clause + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +/* Tabellenname */ +table_name: + SQL_TOKEN_NAME + {$$ = SQL_NEW_RULE; + $$->append($1);} + | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME %prec SQL_TOKEN_NAME + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($3);} + | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME %prec SQL_TOKEN_NAME + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2= newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($5);} + | SQL_TOKEN_NAME ':' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2= newNode(":", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($5);} +/* | SQL_TOKEN_NAME ';' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2= newNode(";", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($5);} +*/ ; +column_ref: + column + {$$ = SQL_NEW_RULE; + $$->append($1);} + | SQL_TOKEN_NAME '.' column_val %prec '.' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($3);} + | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($5);} + | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2= newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($5); + $$->append($6 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($7); + } + | SQL_TOKEN_NAME ':' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2= newNode(":", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($5); + $$->append($6 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($7); + } +/* | SQL_TOKEN_NAME ';' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2= newNode(";", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($5); + $$->append($6 = newNode(".", SQL_NODE_PUNCTUATION)); + $$->append($7); + } +*/ ; + + /* data types */ +column_val: + column + {$$ = SQL_NEW_RULE; + $$->append($1);} + | '*' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("*", SQL_NODE_PUNCTUATION)); + } + ; +data_type: + SQL_TOKEN_CHARACTER + | SQL_TOKEN_CHARACTER '(' SQL_TOKEN_INTNUM ')' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));} + | SQL_TOKEN_NUMERIC + | SQL_TOKEN_NUMERIC '(' SQL_TOKEN_INTNUM ')' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));} + | SQL_TOKEN_NUMERIC '(' SQL_TOKEN_INTNUM ',' SQL_TOKEN_INTNUM ')' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(",", SQL_NODE_PUNCTUATION)); + $$->append($5); + $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));} + | SQL_TOKEN_DECIMAL + | SQL_TOKEN_DECIMAL '(' SQL_TOKEN_INTNUM ')' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));} + | SQL_TOKEN_DECIMAL '(' SQL_TOKEN_INTNUM ',' SQL_TOKEN_INTNUM ')' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(",", SQL_NODE_PUNCTUATION)); + $$->append($5); + $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));} + | SQL_TOKEN_INTEGER + | SQL_TOKEN_SMALLINT + | SQL_TOKEN_FLOAT + | SQL_TOKEN_FLOAT '(' SQL_TOKEN_INTNUM ')' + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));} + | SQL_TOKEN_REAL + | SQL_TOKEN_DOUBLE SQL_TOKEN_PRECISION + {$$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2);} + ; + + /* the various things you can name */ + +column: + SQL_TOKEN_NAME + | SQL_TOKEN_POSITION + { + UINT16 nNod = $$->getRuleID(); + delete $$; + $$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME); + } + | SQL_TOKEN_CHAR_LENGTH + { + UINT16 nNod = $$->getRuleID(); + delete $$; + $$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME); + } + | SQL_TOKEN_EXTRACT + { + UINT16 nNod = $$->getRuleID(); + delete $$; + $$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME); + } + ; + +cursor: SQL_TOKEN_NAME + {$$ = SQL_NEW_RULE; + $$->append($1);} + ; + +/*** +module: SQL_TOKEN_NAME + {$$ = SQL_NEW_RULE; + $$->append($1);} + ; +***/ + +parameter: + ':' SQL_TOKEN_NAME + {$$ = SQL_NEW_RULE; + $$->append($1 = newNode(":", SQL_NODE_PUNCTUATION)); + $$->append($2);} + | '?' + {$$ = SQL_NEW_RULE; + $$->append($1 = newNode("?", SQL_NODE_PUNCTUATION));} + | '[' SQL_TOKEN_NAME ']' + {$$ = SQL_NEW_RULE; + $$->append($1 = newNode("[", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode("]", SQL_NODE_PUNCTUATION));} + ; + +/*** +procedure: SQL_TOKEN_NAME + {$$ = SQL_NEW_RULE; + $$->append($1);} + ; +***/ + +range_variable: SQL_TOKEN_NAME + ; + +user: SQL_TOKEN_NAME + ; + +/* PREDICATECHECK RULES */ +sql: + search_condition /* checking predicats */ + { + if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) + { + $$ = $1; + } + else + YYERROR; + } +%% + + +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::osl; +// using namespace connectivity; + +//============================================================ +//= a helper for static ascii pseudo-unicode strings +//============================================================ +// string constants +struct _ConstAsciiString_ +{ + sal_Int32 length; + sal_Char const* str; + + operator rtl::OUString () const { return rtl::OUString(str, length, RTL_TEXTENCODING_ASCII_US); } +// operator String () const { return String(str, length, RTL_TEXTENCODING_ASCII_US); } + operator const sal_Char * () const { return str; } +}; + +#define IMPLEMENT_CONSTASCII_STRING( name, string ) \ + _ConstAsciiString_ const name = { sizeof(string)-1, string } + +IMPLEMENT_CONSTASCII_STRING(ERROR_STR_GENERAL, "Syntax error in SQL expression"); +IMPLEMENT_CONSTASCII_STRING(ERROR_STR_GENERAL_HINT, "before \"#\" expression." ); +IMPLEMENT_CONSTASCII_STRING(ERROR_STR_VALUE_NO_LIKE, "The value # can not be used with LIKE!"); +IMPLEMENT_CONSTASCII_STRING(ERROR_STR_FIELD_NO_LIKE, "LIKE can not be used with this field!"); +IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_COMPARE, "The entered criterion can not be compared with this field!"); +IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_STRING_COMPARE, "The field can not be compared with a string!"); +IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_DATE_COMPARE, "The field can not be compared with a date!"); +IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_REAL_COMPARE, "The field can not be compared with a floating point number!"); +IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_INT_COMPARE, "The field can not be compared with a number!"); + +IMPLEMENT_CONSTASCII_STRING(KEY_STR_LIKE, "LIKE"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_NOT, "NOT"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_NULL, "NULL"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_TRUE, "TRUE"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_FALSE, "FALSE"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_IS, "IS"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_BETWEEN, "BETWEEN"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_OR, "OR"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_AND, "AND"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_AVG, "AVG"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_COUNT, "COUNT"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_MAX, "MAX"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_MIN, "MIN"); +IMPLEMENT_CONSTASCII_STRING(KEY_STR_SUM, "SUM"); + +IMPLEMENT_CONSTASCII_STRING(FIELD_STR_LOCALE, "Locale"); +IMPLEMENT_CONSTASCII_STRING(FIELD_STR_REALNAME, "RealName"); +IMPLEMENT_CONSTASCII_STRING(FIELD_STR_FORMATKEY, "FormatKey"); +IMPLEMENT_CONSTASCII_STRING(FIELD_STR_NAME, "Name"); +IMPLEMENT_CONSTASCII_STRING(FIELD_STR_TYPE, "Type"); +IMPLEMENT_CONSTASCII_STRING(FIELD_STR_NULLDATE, "NullDate"); + +IMPLEMENT_CONSTASCII_STRING(STR_SQL_TOKEN, "SQL_TOKEN_"); + +//========================================================================== +//= OParseContext +//========================================================================== +DBG_NAME(OParseContext); +//----------------------------------------------------------------------------- +OParseContext::OParseContext() +{ + DBG_CTOR(OParseContext,NULL); +} + +//----------------------------------------------------------------------------- +OParseContext::~OParseContext() +{ + DBG_DTOR(OParseContext,NULL); +} + +//----------------------------------------------------------------------------- +String OParseContext::getErrorMessage(ErrorCode _eCode) const +{ + String aMsg; + switch (_eCode) + { + case ERROR_GENERAL: aMsg = ERROR_STR_GENERAL; break; + case ERROR_GENERAL_HINT: aMsg = ERROR_STR_GENERAL_HINT; break; + case ERROR_VALUE_NO_LIKE: aMsg = ERROR_STR_VALUE_NO_LIKE; break; + case ERROR_FIELD_NO_LIKE: aMsg = ERROR_STR_FIELD_NO_LIKE; break; + case ERROR_INVALID_COMPARE: aMsg = ERROR_STR_INVALID_COMPARE; break; + case ERROR_INVALID_INT_COMPARE: aMsg = ERROR_STR_INVALID_INT_COMPARE; break; + case ERROR_INVALID_STRING_COMPARE: aMsg = ERROR_STR_INVALID_STRING_COMPARE; break; + case ERROR_INVALID_DATE_COMPARE: aMsg = ERROR_STR_INVALID_DATE_COMPARE; break; + case ERROR_INVALID_REAL_COMPARE: aMsg = ERROR_STR_INVALID_REAL_COMPARE; break; + } + return aMsg; +} + +//----------------------------------------------------------------------------- +ByteString OParseContext::getIntlKeywordAscii(InternationalKeyCode _eKey) const +{ + ByteString aKeyword; + switch (_eKey) + { + case KEY_LIKE: aKeyword = KEY_STR_LIKE; break; + case KEY_NOT: aKeyword = KEY_STR_NOT; break; + case KEY_NULL: aKeyword = KEY_STR_NULL; break; + case KEY_TRUE: aKeyword = KEY_STR_TRUE; break; + case KEY_FALSE: aKeyword = KEY_STR_FALSE; break; + case KEY_IS: aKeyword = KEY_STR_IS; break; + case KEY_BETWEEN: aKeyword = KEY_STR_BETWEEN; break; + case KEY_OR: aKeyword = KEY_STR_OR; break; + case KEY_AND: aKeyword = KEY_STR_AND; break; + case KEY_AVG: aKeyword = KEY_STR_AVG; break; + case KEY_COUNT: aKeyword = KEY_STR_COUNT; break; + case KEY_MAX: aKeyword = KEY_STR_MAX; break; + case KEY_MIN: aKeyword = KEY_STR_MIN; break; + case KEY_SUM: aKeyword = KEY_STR_SUM; break; + } + return aKeyword; +} + +//----------------------------------------------------------------------------- +OParseContext::InternationalKeyCode OParseContext::getIntlKeyCode(const ByteString& rToken) const +{ + static OParseContext::InternationalKeyCode Intl_TokenID[] = + { + KEY_LIKE, KEY_NOT, KEY_NULL, KEY_TRUE, + KEY_FALSE, KEY_IS, KEY_BETWEEN, KEY_OR, + KEY_AND, KEY_AVG, KEY_COUNT, KEY_MAX, + KEY_MIN, KEY_SUM + }; + + sal_uInt32 nCount = sizeof Intl_TokenID / sizeof Intl_TokenID[0]; + for (sal_uInt32 i = 0; i < nCount; i++) + { + ByteString aKey = getIntlKeywordAscii(Intl_TokenID[i]); + if (rToken.EqualsIgnoreCaseAscii(aKey)) + return Intl_TokenID[i]; + } + + return KEY_NONE; +} + +//------------------------------------------------------------------------------ +const International& OParseContext::getDefaultInternational() +{ + static International aIntl(LANGUAGE_ENGLISH_US); + static BOOL bInitialized = FALSE; + if (!bInitialized) + { // ensure that the two members we're interested in are really set + // (if the system doesn't know the locale en_US aIntl would be initialized with the + // system language which may be anything - which we don't want ...) + // 74342 - 21.03.00 - FS + aIntl.SetNumThousandSep(','); + aIntl.SetNumDecimalSep('.'); + bInitialized = TRUE; + } + return aIntl; +} + +//========================================================================== +//= misc +//========================================================================== +// Der (leider globale) yylval fuer die Uebergabe von +// Werten vom Scanner an den Parser. Die globale Variable +// wird nur kurzzeitig verwendet, der Parser liest die Variable +// sofort nach dem Scanner-Aufruf in eine gleichnamige eigene +// Member-Variable. + +const double fMilliSecondsPerDay = 86400000.0; + +//------------------------------------------------------------------------------ +Date getNULLDate(const Reference< ::com::sun::star::util::XNumberFormatsSupplier > &xSupplier) +{ + DBG_ASSERT(xSupplier.is(), "getNULLDate : the formatter doesn't implement a supplier !"); + if (xSupplier.is()) + { + try + { + // get the null date + ::com::sun::star::util::Date aDate; + xSupplier->getNumberFormatSettings()->getPropertyValue(FIELD_STR_NULLDATE) >>= aDate; + return Date(aDate.Day, aDate.Month, aDate.Year); + } + catch ( ... ) + { + } + } + + return Date(1,1,1900); +} + +//------------------------------------------------------------------------------ +Any getNumberFormatProperty(const Reference< ::com::sun::star::util::XNumberFormatsSupplier > &xSupplier, + sal_Int32 nKey, + const rtl::OUString& aPropertyName) +{ + DBG_ASSERT(xSupplier.is(), "getNumberFormatProperty : the formatter doesn't implement a supplier !"); + Reference< ::com::sun::star::util::XNumberFormats > xFormats = xSupplier->getNumberFormats(); + + if (xFormats.is()) + { + try + { + Reference< XPropertySet > xProperties(xFormats->getByKey(nKey)); + return xProperties->getPropertyValue(aPropertyName); + } + catch( ... ) + { + } + } + return Any(); +} + +// date time conversion +//------------------------------------------------------------------ +DateTime ToDateTime(const Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xSupplier, + const double& fSbxDate) +{ + + long nDays = (long)fSbxDate; + long nMSeconds = long((fSbxDate - (double)nDays) * fMilliSecondsPerDay + 0.5); + + // Datum: + DateTime x(getNULLDate(xSupplier)); + + if (nDays >= 0) + x += (sal_uInt32)nDays; + else + x -= (sal_uInt32)(-nDays); + + // Zeit: + x.MakeTimeFromMS(nMSeconds); + if (x.GetTime() < 0) + x += Time(23,59,59,99); + return x; +} + +//------------------------------------------------------------------ +double ToDouble(const Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xSupplier, const Date& rDate) +{ + long nDays = 0; + Date aNullDate(getNULLDate(xSupplier)); + if (aNullDate >= rDate) + { + nDays = (long)(aNullDate - rDate); + nDays *= -1; + } + else + nDays = (long)(rDate - aNullDate); + + return (double)nDays; +} + +//------------------------------------------------------------------ +double ToDouble(const Time& rTime) +{ + return (double)rTime.GetMSFromTime() / fMilliSecondsPerDay; +} + +//------------------------------------------------------------------ +Date ToDate(const Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xSupplier, const double& fSbxDate) +{ + // count the days + long nDays = (long)fSbxDate; + Date aNullDate(getNULLDate(xSupplier)); + + if (nDays >= 0) + aNullDate += (sal_uInt32)nDays; + else + aNullDate -= (sal_uInt32)(-nDays); + + return aNullDate; +} + +//------------------------------------------------------------------ +Time ToTime(const double& fSbxDate) +{ + long nDays = (long)fSbxDate; + long nMSeconds = long((fSbxDate - (double)nDays) * fMilliSecondsPerDay + 0.5); + + Time x; + x.MakeTimeFromMS(nMSeconds); + if (x.GetTime() < 0) + x += Time(23,59,59,99); + return x; +} + +//------------------------------------------------------------------ +String ToDateString(const Date& rDate) +{ + sal_Char s[11]; + sprintf(s,"%04d-%02d-%02d", + (int)rDate.GetYear(), + (int)rDate.GetMonth(), + (int)rDate.GetDay()); + s[10] = 0; + return String::CreateFromAscii(s); +} + +//------------------------------------------------------------------ +String ToTimeString(const Time& rTime) +{ + sal_Char s[9]; + sprintf(s,"%02d:%02d:%02d", + (int)rTime.GetHour(), + (int)rTime.GetMin(), + (int)rTime.GetSec()); + s[8] = 0; + return String::CreateFromAscii(s); +} + +//------------------------------------------------------------------ +String ToDateTimeString(const DateTime& rDateTime) +{ + String aTemp(ToDateString(rDateTime)); + aTemp += String::CreateFromAscii(" "); + aTemp += ToTimeString(rDateTime); + return aTemp; +} + + +//------------------------------------------------------------------ +String ConvertLikeToken(const OSQLParseNode* pTokenNode, const OSQLParseNode* pEscapeNode, sal_Bool bInternational) +{ + String aMatchStr; + if (pTokenNode->isToken()) + { + char cEscape = 0; + if (pEscapeNode->count()) + cEscape = pEscapeNode->getChild(1)->getTokenValue().GetChar(0); + + // Platzhalter austauschen + aMatchStr = pTokenNode->getTokenValue(); + sal_uInt16 nLen = aMatchStr.Len(); + const char* sSearch = bInternational ? "%_" : "*?"; + const char* sReplace = bInternational ? "*?" : "%_"; + for (sal_uInt16 i = 0; i < nLen; i++) + { + char c = aMatchStr.GetChar(i); + if (c == sSearch[0] || c == sSearch[1]) + { + if (i > 0 && aMatchStr.GetChar(i-1) == cEscape) + continue; + else if (c == sSearch[0]) + aMatchStr.SetChar(i,sReplace[0]); + else + aMatchStr.SetChar(i,sReplace[1]); + } + } + } + return aMatchStr; +} + +//========================================================================== +//= OSQLParser +//========================================================================== +DBG_NAME(OSQLParser); + +sal_uInt32 OSQLParser::s_nRuleIDs[OSQLParseNode::rule_count + 1]; +OParseContext OSQLParser::s_aDefaultContext; + +sal_Int32 OSQLParser::s_nRefCount = 0; +::osl::Mutex OSQLParser::s_aMutex; +OSQLScanner* OSQLParser::s_pScanner = 0; +OSQLParseNodes* OSQLParser::s_pGarbageCollector = 0; + +//----------------------------------------------------------------------------- +OSQLParser::OSQLParser(OParseContext* _pContext) + :m_pContext(_pContext) + ,m_pParseTree(NULL) + ,m_pIntl(NULL) + ,m_nFormatKey(0) +{ + DBG_CTOR(OSQLParser,NULL); + + xxx_pGLOBAL_SQLPARSER = this; + +#ifdef SQLYYDEBUG +#ifdef SQLYYDEBUG_ON + SQLyydebug = 1; +#endif +#endif + + ::osl::MutexGuard aGuard(s_aMutex); + // do we have to initialize the data + if (s_nRefCount == 0) + { + s_pScanner = new OSQLScanner(); + s_pScanner->setScanner(); + s_pGarbageCollector = new OSQLParseNodes(); + + // auf 0 zuruecksetzen + memset(OSQLParser::s_nRuleIDs,0,sizeof(sal_uInt16) * OSQLParseNode::rule_count+1); + } + ++s_nRefCount; + + if (m_pContext == NULL) + // take the default context + m_pContext = &s_aDefaultContext; +} + +//----------------------------------------------------------------------------- +OSQLParser::~OSQLParser() +{ + { + ::osl::MutexGuard aGuard(s_aMutex); + DBG_ASSERT(s_nRefCount > 0, "OSQLParser::~OSQLParser() : suspicious call : have a refcount of 0 !"); + if (!--s_nRefCount) + { + s_pScanner->setScanner(sal_True); + delete s_pScanner; + s_pScanner = NULL; + + delete s_pGarbageCollector; + s_pGarbageCollector = NULL; + } + } + + delete m_pIntl; + + DBG_DTOR(OSQLParser,NULL); +} + +//----------------------------------------------------------------------------- +OSQLParseNode* OSQLParser::parseTree(String& rErrorMessage, + const String& rStatement, + sal_Bool bInternational) +{ + DBG_CHKTHIS(OSQLParser,NULL); + + // Guard the parsing + ::osl::MutexGuard aGuard(s_aMutex); + + // defines how to scan + s_pScanner->SetRule(s_pScanner->GetSQLRule()); // initial + s_pScanner->prepareScan(rStatement, m_pContext, bInternational); + + SQLyylval.pParseNode = NULL; + // SQLyypvt = NULL; + m_pParseTree = NULL; + m_sErrorMessage.Erase(); + + // ... und den Parser anwerfen ... + if (SQLyyparse() != 0) + { + // only set the error message, if it's not already set + if (!m_sErrorMessage.Len()) + m_sErrorMessage = s_pScanner->getErrorMessage(); + if (!m_sErrorMessage.Len()) + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_GENERAL); + + rErrorMessage = m_sErrorMessage; + + // clear the garbage collector + while (!s_pGarbageCollector->empty()) + { + OSQLParseNode* pNode = *s_pGarbageCollector->begin(); + while (pNode->getParent()) + pNode = pNode->getParent(); + delete pNode; + } + return NULL; + } + else + { + s_pGarbageCollector->clear(); + + // Das Ergebnis liefern (den Root Parse Node): + + // DBG_ASSERT(Sdbyyval.pParseNode != NULL,"OSQLParser: Parser hat keinen ParseNode geliefert"); + // return Sdbyyval.pParseNode; + // geht nicht wegen Bug in MKS YACC-erzeugtem Code (es wird ein falscher ParseNode + // geliefert). + + // Stattdessen setzt die Parse-Routine jetzt den Member pParseTree + // - einfach diesen zurueckliefern: + DBG_ASSERT(m_pParseTree != NULL,"OSQLParser: Parser hat keinen ParseTree geliefert"); + return m_pParseTree; + } +} + +static char* __READONLY_DATA PREDICATE_CHECK = "PREDICATE "; +//----------------------------------------------------------------------------- +OSQLParseNode* OSQLParser::predicateTree(String& rErrorMessage, const String& rStatement, + const Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter, + const Reference< XPropertySet > & xField) +{ + DBG_CHKTHIS(OSQLParser,NULL); + + // mutex for parsing + static ::osl::Mutex aMutex; + + // Guard the parsing + ::osl::MutexGuard aGuard(s_aMutex); + + // reset the parser + if (!m_pIntl) + m_pIntl = new International(m_pContext->getDefaultInternational()); + + m_xField = xField; + m_xFormatter = xFormatter; + + if (m_xField.is()) + { + sal_Int32 nType=0; + try + { + // get the field name + rtl::OUString aString; + + // retrieve the fields name + // #75243# use the RealName of the column if there is any otherwise the name which could be the alias + // of the field + if (m_xField->getPropertySetInfo()->hasPropertyByName(FIELD_STR_REALNAME)) + m_xField->getPropertyValue(FIELD_STR_REALNAME) >>= aString; + else + m_xField->getPropertyValue(FIELD_STR_NAME) >>= aString; + + m_sFieldName = aString; + + // get the field format key + m_xField->getPropertyValue(FIELD_STR_FORMATKEY) >>= m_nFormatKey; + + // get the field type + m_xField->getPropertyValue(FIELD_STR_TYPE) >>= nType; + } + catch ( ... ) + { + } + + if (m_nFormatKey && m_xFormatter.is()) + { + Any aValue = getNumberFormatProperty(m_xFormatter->getNumberFormatsSupplier(), m_nFormatKey, FIELD_STR_LOCALE); + DBG_ASSERT(aValue.getValueType() == ::getCppuType((const ::com::sun::star::lang::Locale*)0), "OSQLParser::PredicateTree : invalid language property !"); + + if (aValue.getValueType() == ::getCppuType((const ::com::sun::star::lang::Locale*)0)) + { + com::sun::star::lang::Locale aLocale; + aValue >>= aLocale; + *m_pIntl = International(ConvertIsoNamesToLanguage(aLocale.Language.getStr(), + aLocale.Country.getStr())); + } + } + else + *m_pIntl = m_pContext->getDefaultInternational(); + + switch (nType) + { + case DataType::DATE: + case DataType::TIME: + case DataType::TIMESTAMP: + s_pScanner->SetRule(s_pScanner->GetDATERule()); + break; + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + s_pScanner->SetRule(s_pScanner->GetSTRINGRule()); + break; + default: + if (m_pIntl->GetNumDecimalSep() == ',') + s_pScanner->SetRule(s_pScanner->GetGERRule()); + else + s_pScanner->SetRule(s_pScanner->GetENGRule()); + } + + } + else + s_pScanner->SetRule(s_pScanner->GetSQLRule()); + + s_pScanner->prepareScan(rStatement, m_pContext, sal_True); + + SQLyylval.pParseNode = NULL; + // SQLyypvt = NULL; + m_pParseTree = NULL; + m_sErrorMessage.Erase(); + + // ... und den Parser anwerfen ... + if (SQLyyparse() != 0) + { + m_sFieldName.Erase(); + m_xField = NULL; + m_xFormatter = NULL; + m_nFormatKey = 0; + + if (!m_sErrorMessage.Len()) + m_sErrorMessage = s_pScanner->getErrorMessage(); + if (!m_sErrorMessage.Len()) + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_GENERAL); + + rErrorMessage = m_sErrorMessage; + + // clear the garbage collector + while (!s_pGarbageCollector->empty()) + { + OSQLParseNode* pNode = *s_pGarbageCollector->begin(); + while (pNode->getParent()) + pNode = pNode->getParent(); + delete pNode; + } + return NULL; + } + else + { + s_pGarbageCollector->clear(); + + m_sFieldName.Erase(); + m_xField = NULL; + m_xFormatter = NULL; + m_nFormatKey = 0; + + // Das Ergebnis liefern (den Root Parse Node): + + // Stattdessen setzt die Parse-Routine jetzt den Member pParseTree + // - einfach diesen zurueckliefern: + DBG_ASSERT(m_pParseTree != NULL,"OSQLParser: Parser hat keinen ParseTree geliefert"); + return m_pParseTree; + } +} + +//----------------------------------------------------------------------------- +ByteString OSQLParser::TokenIDToStr(sal_uInt32 nTokenID, OParseContext* pContext) +{ + ByteString aStr; + if (pContext) + aStr = pContext->getIntlKeywordAscii((OParseContext::InternationalKeyCode)nTokenID); + + if (!aStr.Len()) + { + aStr = yytname[YYTRANSLATE(nTokenID)]; + if(aStr.EqualsIgnoreCaseAscii("SQL_TOKEN_",0,10)) + aStr.Erase(0,10); + } + return aStr; +} + +//----------------------------------------------------------------------------- +/*sal_uInt32 OSQLParser::StrToTokenID(const ByteString & rName) +{ + ByteString aName; + if (rName.IsAlphaNumericAscii()) + aName = rName; + else + { + aName = "'"; + aName += rName; + aName += "'"; + } + + // Gewuenschten Token-Namen suchen: + for (sal_uInt32 i = 0; i < SQLyyntoken; i++) + { + if (aName == TokenTypes[i].name) + return TokenTypes[i].token; + } + + // Nicht gefunden + return 0; +}*/ + +//----------------------------------------------------------------------------- +String OSQLParser::RuleIDToStr(sal_uInt32 nRuleID) +{ + OSL_ENSHURE(nRuleID >= (sizeof yytname/sizeof yytname[0]), "Invalid nRuleId!"); + return String::CreateFromAscii(yytname[nRuleID]); +} + +//----------------------------------------------------------------------------- +sal_uInt32 OSQLParser::StrToRuleID(const ByteString & rValue) +{ + // In yysvar nach dem angegebenen Namen suchen, den ::com::sun::star::sdbcx::Index zurueckliefern + // (oder 0, wenn nicht gefunden) + static sal_Int32 nLen = sizeof(yytname)/sizeof(yytname[0]); + for (sal_uInt32 i = YYTRANSLATE(SQL_TOKEN_INVALIDSYMBOL); i < (nLen-1); i++) + { + if (yytname && rValue == yytname[i]) + return i; + } + + // Nicht gefunden + return 0; +} + +//----------------------------------------------------------------------------- +sal_uInt32 OSQLParser::RuleID(OSQLParseNode::Rule eRule) +{ + if (!s_nRuleIDs[eRule]) + { + switch (eRule) + { + case OSQLParseNode::select_statement: + s_nRuleIDs[eRule] = StrToRuleID("select_statement"); break; + case OSQLParseNode::from_clause: + s_nRuleIDs[eRule] = StrToRuleID("from_clause"); break; + case OSQLParseNode::table_ref_commalist: + s_nRuleIDs[eRule] = StrToRuleID("table_ref_commalist"); break; + case OSQLParseNode::table_exp: + s_nRuleIDs[eRule] = StrToRuleID("table_exp"); break; + case OSQLParseNode::table_ref: + s_nRuleIDs[eRule] = StrToRuleID("table_ref"); break; + case OSQLParseNode::table_name: + s_nRuleIDs[eRule] = StrToRuleID("table_name"); break; + case OSQLParseNode::opt_column_commalist: + s_nRuleIDs[eRule] = StrToRuleID("opt_column_commalist"); break; + case OSQLParseNode::column_commalist: + s_nRuleIDs[eRule] = StrToRuleID("column_commalist"); break; + case OSQLParseNode::column_ref_commalist: + s_nRuleIDs[eRule] = StrToRuleID("column_ref_commalist"); break; + case OSQLParseNode::column_ref: + s_nRuleIDs[eRule] = StrToRuleID("column_ref"); break; + case OSQLParseNode::opt_order_by_clause: + s_nRuleIDs[eRule] = StrToRuleID("opt_order_by_clause"); break; + case OSQLParseNode::ordering_spec_commalist: + s_nRuleIDs[eRule] = StrToRuleID("ordering_spec_commalist"); break; + case OSQLParseNode::ordering_spec: + s_nRuleIDs[eRule] = StrToRuleID("ordering_spec"); break; + case OSQLParseNode::opt_asc_desc: + s_nRuleIDs[eRule] = StrToRuleID("opt_asc_desc"); break; + case OSQLParseNode::where_clause: + s_nRuleIDs[eRule] = StrToRuleID("where_clause"); break; + case OSQLParseNode::opt_where_clause: + s_nRuleIDs[eRule] = StrToRuleID("opt_where_clause"); break; + case OSQLParseNode::search_condition: + s_nRuleIDs[eRule] = StrToRuleID("search_condition"); break; + case OSQLParseNode::comparison_predicate: + s_nRuleIDs[eRule] = StrToRuleID("comparison_predicate"); break; + case OSQLParseNode::between_predicate: + s_nRuleIDs[eRule] = StrToRuleID("between_predicate"); break; + case OSQLParseNode::like_predicate: + s_nRuleIDs[eRule] = StrToRuleID("like_predicate"); break; + case OSQLParseNode::opt_escape: + s_nRuleIDs[eRule] = StrToRuleID("opt_escape"); break; + case OSQLParseNode::test_for_null: + s_nRuleIDs[eRule] = StrToRuleID("test_for_null"); break; + case OSQLParseNode::scalar_exp_commalist: + s_nRuleIDs[eRule] = StrToRuleID("scalar_exp_commalist"); break; + case OSQLParseNode::scalar_exp: + s_nRuleIDs[eRule] = StrToRuleID("scalar_exp"); break; + case OSQLParseNode::parameter_ref: + s_nRuleIDs[eRule] = StrToRuleID("parameter_ref"); break; + case OSQLParseNode::parameter: + s_nRuleIDs[eRule] = StrToRuleID("parameter"); break; + case OSQLParseNode::general_set_fct: + s_nRuleIDs[eRule] = StrToRuleID("general_set_fct"); break; + case OSQLParseNode::range_variable: + s_nRuleIDs[eRule] = StrToRuleID("range_variable"); break; + case OSQLParseNode::column: + s_nRuleIDs[eRule] = StrToRuleID("column"); break; + case OSQLParseNode::delete_statement_positioned: + s_nRuleIDs[eRule] = StrToRuleID("delete_statement_positioned"); break; + case OSQLParseNode::delete_statement_searched: + s_nRuleIDs[eRule] = StrToRuleID("delete_statement_searched"); break; + case OSQLParseNode::update_statement_positioned: + s_nRuleIDs[eRule] = StrToRuleID("update_statement_positioned"); break; + case OSQLParseNode::update_statement_searched: + s_nRuleIDs[eRule] = StrToRuleID("update_statement_searched"); break; + case OSQLParseNode::assignment_commalist: + s_nRuleIDs[eRule] = StrToRuleID("assignment_commalist"); break; + case OSQLParseNode::assignment: + s_nRuleIDs[eRule] = StrToRuleID("assignment"); break; + case OSQLParseNode::values_or_query_spec: + s_nRuleIDs[eRule] = StrToRuleID("values_or_query_spec"); break; + case OSQLParseNode::insert_statement: + s_nRuleIDs[eRule] = StrToRuleID("insert_statement"); break; + case OSQLParseNode::insert_atom_commalist: + s_nRuleIDs[eRule] = StrToRuleID("insert_atom_commalist"); break; + case OSQLParseNode::insert_atom: + s_nRuleIDs[eRule] = StrToRuleID("insert_atom"); break; + case OSQLParseNode::predicate_check: + s_nRuleIDs[eRule] = StrToRuleID("predicate_check"); break; + case OSQLParseNode::qualified_join: + s_nRuleIDs[eRule] = StrToRuleID("qualified_join"); break; + case OSQLParseNode::cross_union: + s_nRuleIDs[eRule] = StrToRuleID("cross_union"); break; + case OSQLParseNode::select_sublist: + s_nRuleIDs[eRule] = StrToRuleID("select_sublist"); break; + case OSQLParseNode::derived_column: + s_nRuleIDs[eRule] = StrToRuleID("derived_column"); break; + case OSQLParseNode::column_val: + s_nRuleIDs[eRule] = StrToRuleID("column_val"); break; + case OSQLParseNode::set_fct_spec: + s_nRuleIDs[eRule] = StrToRuleID("set_fct_spec"); break; + case OSQLParseNode::boolean_term: + s_nRuleIDs[eRule] = StrToRuleID("boolean_term"); break; + case OSQLParseNode::boolean_primary: + s_nRuleIDs[eRule] = StrToRuleID("boolean_primary"); break; + case OSQLParseNode::num_value_exp: + s_nRuleIDs[eRule] = StrToRuleID("num_value_exp"); break; + case OSQLParseNode::join_type: + s_nRuleIDs[eRule] = StrToRuleID("join_type"); break; + case OSQLParseNode::position_exp: + s_nRuleIDs[eRule] = StrToRuleID("position_exp"); break; + case OSQLParseNode::extract_exp: + s_nRuleIDs[eRule] = StrToRuleID("extract_exp"); break; + case OSQLParseNode::length_exp: + s_nRuleIDs[eRule] = StrToRuleID("length_exp"); break; + case OSQLParseNode::char_value_fct: + s_nRuleIDs[eRule] = StrToRuleID("char_value_fct"); break; + case OSQLParseNode::odbc_call_spec: + s_nRuleIDs[eRule] = StrToRuleID("odbc_call_spec"); break; + case OSQLParseNode::in_predicate: + s_nRuleIDs[eRule] = StrToRuleID("in_predicate"); break; + case OSQLParseNode::existence_test: + s_nRuleIDs[eRule] = StrToRuleID("existence_test"); break; + case OSQLParseNode::unique_test: + s_nRuleIDs[eRule] = StrToRuleID("unique_test"); break; + case OSQLParseNode::all_or_any_predicate: + s_nRuleIDs[eRule] = StrToRuleID("all_or_any_predicate"); break; + case OSQLParseNode::named_columns_join: + s_nRuleIDs[eRule] = StrToRuleID("named_columns_join"); break; + case OSQLParseNode::join_condition: + s_nRuleIDs[eRule] = StrToRuleID("join_condition"); break; + case OSQLParseNode::joined_table: + s_nRuleIDs[eRule] = StrToRuleID("joined_table"); break; + case OSQLParseNode::boolean_factor: + s_nRuleIDs[eRule] = StrToRuleID("boolean_factor"); break; + case OSQLParseNode::not: + s_nRuleIDs[eRule] = StrToRuleID("not"); break; + case OSQLParseNode::boolean_test: + s_nRuleIDs[eRule] = StrToRuleID("boolean_test"); break; + case OSQLParseNode::manipulative_statement: + s_nRuleIDs[eRule] = StrToRuleID("manipulative_statement"); break; + case OSQLParseNode::subquery: + s_nRuleIDs[eRule] = StrToRuleID("subquery"); break; + case OSQLParseNode::value_exp_commalist: + s_nRuleIDs[eRule] = StrToRuleID("value_exp_commalist"); break; + case OSQLParseNode::odbc_fct_spec: + s_nRuleIDs[eRule] = StrToRuleID("odbc_fct_spec"); break; + case OSQLParseNode::union_statement: + s_nRuleIDs[eRule] = StrToRuleID("union_statement"); break; + case OSQLParseNode::outer_join_type: + s_nRuleIDs[eRule] = StrToRuleID("outer_join_type"); break; + case OSQLParseNode::char_value_exp: + s_nRuleIDs[eRule] = StrToRuleID("char_value_exp"); break; + case OSQLParseNode::term: + s_nRuleIDs[eRule] = StrToRuleID("term"); break; + case OSQLParseNode::value_exp_primary: + s_nRuleIDs[eRule] = StrToRuleID("value_exp_primary"); break; + case OSQLParseNode::value_exp: + s_nRuleIDs[eRule] = StrToRuleID("value_exp"); break; + default: + DBG_ERROR("interner Fehler: Regel nicht bekannt, in OSQLParser::RuleID nachtragen!"); + } + } + return s_nRuleIDs[(sal_uInt16)eRule]; +} + +//----------------------------------------------------------------------------- +sal_Int16 OSQLParser::buildNode(OSQLParseNode*& pAppend,OSQLParseNode* pLiteral,OSQLParseNode*& pCompare) +{ + OSQLParseNode* pColumnRef = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(new OSQLInternalNode(m_sFieldName,SQL_NODE_NAME)); + OSQLParseNode* pComp = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::comparison_predicate)); + pComp->append(pColumnRef); + pComp->append(pCompare); + pComp->append(pLiteral); + pAppend->append(pComp); + return 1; +} + +//----------------------------------------------------------------------------- +sal_Int16 OSQLParser::buildNode_STR_NUM(OSQLParseNode*& pAppend,OSQLParseNode*& pLiteral,OSQLParseNode*& pCompare) +{ + OSQLParseNode* pColumnRef = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(new OSQLInternalNode(m_sFieldName,SQL_NODE_NAME)); + OSQLParseNode* pComp = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::comparison_predicate)); + pComp->append(pColumnRef); + pComp->append(pCompare); + + if (m_nFormatKey) + { + sal_Int16 nScale = 0; + try + { + Any aValue = getNumberFormatProperty(m_xFormatter->getNumberFormatsSupplier(), + m_nFormatKey, rtl::OUString::createFromAscii("Decimals")); + aValue >>= nScale; + } + catch ( ... ) + { + } + + int nErrno=0; + double dValue = SolarMath::StringToDouble(pLiteral->getTokenValue().GetBuffer(), *m_pIntl, nErrno); + String aValue; + SolarMath::DoubleToString(aValue, dValue, 'F', nScale, m_pIntl->GetNumDecimalSep(), sal_True); + pComp->append(new OSQLInternalNode(aValue,SQL_NODE_STRING)); + } + else + pComp->append(new OSQLInternalNode(pLiteral->getTokenValue(),SQL_NODE_STRING)); + + pAppend->append(pComp); + + delete pLiteral; + pLiteral = NULL; + + return 1; +} + +//----------------------------------------------------------------------------- +sal_Int16 OSQLParser::buildNode_Date(const double& fValue, sal_Int16 nType, OSQLParseNode*& pAppend,OSQLParseNode* pLiteral,OSQLParseNode*& pCompare) +{ + OSQLParseNode* pColumnRef = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref)); + pColumnRef->append(new OSQLInternalNode(m_sFieldName,SQL_NODE_NAME)); + OSQLParseNode* pComp = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::comparison_predicate)); + pComp->append(pColumnRef); + pComp->append(pCompare); + + OSQLParseNode* pNewNode = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::set_fct_spec)); + pNewNode->append(new OSQLInternalNode(String::CreateFromAscii("{"), SQL_NODE_PUNCTUATION)); + OSQLParseNode* pDateNode = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::odbc_fct_spec)); + pNewNode->append(pDateNode); + pNewNode->append(new OSQLInternalNode(String::CreateFromAscii("}"), SQL_NODE_PUNCTUATION)); + + switch (nType) + { + case DataType::DATE: + { + Date aDate = ToDate(m_xFormatter->getNumberFormatsSupplier(), fValue); + String aString = ToDateString(aDate); + pDateNode->append(new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD, SQL_TOKEN_D)); + pDateNode->append(new OSQLInternalNode(aString, SQL_NODE_STRING)); + break; + } + case DataType::TIME: + { + Time aTime = ToTime(fValue); + String aString = ToTimeString(aTime); + pDateNode->append(new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD, SQL_TOKEN_T)); + pDateNode->append(new OSQLInternalNode(aString, SQL_NODE_STRING)); + break; + } + case DataType::TIMESTAMP: + { + DateTime aDateTime = ToDateTime(m_xFormatter->getNumberFormatsSupplier(), fValue); + if (aDateTime.GetMSFromTime() / fMilliSecondsPerDay) + { + String aString = ToDateTimeString(aDateTime); + pDateNode->append(new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD, SQL_TOKEN_TS)); + pDateNode->append(new OSQLInternalNode(aString, SQL_NODE_STRING)); + } + else + { + pDateNode->append(new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD, SQL_TOKEN_D)); + pDateNode->append(new OSQLInternalNode(ToDateString(aDateTime), SQL_NODE_STRING)); + } + break; + } + } + + pComp->append(pNewNode); + pAppend->append(pComp); + + delete pLiteral; + pLiteral = NULL; + + return 1; +} + +//----------------------------------------------------------------------------- +sal_Int16 OSQLParser::buildLikeRule(OSQLParseNode*& pAppend, OSQLParseNode*& pLiteral, const OSQLParseNode* pEscape) +{ + sal_Int16 nErg = 0; + sal_Int32 nType = 0; + + if (!m_xField.is()) + return nErg; + try + { + Any aValue; + { + aValue = m_xField->getPropertyValue(FIELD_STR_TYPE); + aValue >>= nType; + } + } + catch ( ... ) + { + return nErg; + } + + switch (nType) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + if(pLiteral->isRule()) + { + pAppend->append(pLiteral); + nErg = 1; + } + else + { + switch(pLiteral->getNodeType()) + { + case SQL_NODE_STRING: + pLiteral->m_aNodeValue = ConvertLikeToken(pLiteral, pEscape, sal_False); + pAppend->append(pLiteral); + nErg = 1; + break; + case SQL_NODE_APPROXNUM: + if (m_xFormatter.is() && m_nFormatKey) + { + sal_Int16 nScale = 0; + try + { + Any aValue = getNumberFormatProperty(m_xFormatter->getNumberFormatsSupplier(), + m_nFormatKey, rtl::OUString::createFromAscii("Decimals")); + aValue >>= nScale; + } + catch ( ... ) + { + } + + int nErrno=0; + String aValue; + double dValue = SolarMath::StringToDouble(pLiteral->getTokenValue().GetBuffer(), OParseContext::getDefaultInternational(), nErrno); + SolarMath::DoubleToString(aValue, dValue, 'F', nScale, '.', sal_True); + pAppend->append(new OSQLInternalNode(aValue,SQL_NODE_STRING)); + } + else + pAppend->append(new OSQLInternalNode(pLiteral->getTokenValue(),SQL_NODE_STRING)); + + delete pLiteral; + nErg = 1; + break; + default: + { + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_VALUE_NO_LIKE); + m_sErrorMessage.SearchAndReplace(String::CreateFromAscii("#1"),pLiteral->getTokenValue()); + } + } + } + break; + default: + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_FIELD_NO_LIKE); + } + return nErg; +} +//----------------------------------------------------------------------------- +sal_Int16 OSQLParser::buildStringNodes(OSQLParseNode*& pLiteral) +{ + if(!pLiteral) + return 1; + + if(SQL_ISRULE(pLiteral,set_fct_spec) || SQL_ISRULE(pLiteral,general_set_fct) || SQL_ISRULE(pLiteral,column_ref) + || SQL_ISRULE(pLiteral,subquery)) + return 1; // here I have a function that I can't transform into a string + + if(pLiteral->getNodeType() == SQL_NODE_INTNUM || pLiteral->getNodeType() == SQL_NODE_APPROXNUM || pLiteral->getNodeType() == SQL_NODE_ACCESS_DATE) + { + OSQLParseNode* pParent = pLiteral->getParent(); + + OSQLParseNode* pNewNode = new OSQLInternalNode(pLiteral->getTokenValue(), SQL_NODE_STRING); + pParent->replace(pLiteral, pNewNode); + delete pLiteral; + pLiteral = NULL; + return 1; + } + + for(sal_uInt32 i=0;i<pLiteral->count();++i) + { + OSQLParseNode* pChild = pLiteral->getChild(i); + buildStringNodes(pChild); + } + if(SQL_ISRULE(pLiteral,term) || SQL_ISRULE(pLiteral,value_exp_primary)) + { + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_COMPARE); + return 0; + } + return 1; +} +//----------------------------------------------------------------------------- +sal_Int16 OSQLParser::buildComparsionRule(OSQLParseNode*& pAppend,OSQLParseNode* pLiteral) +{ + OSQLParseNode* pComp = new OSQLInternalNode(String('='), SQL_NODE_EQUAL); + return buildComparsionRule(pAppend,pLiteral,pComp); +} + +//----------------------------------------------------------------------------- +sal_Int16 OSQLParser::buildComparsionRule(OSQLParseNode*& pAppend,OSQLParseNode* pLiteral,OSQLParseNode*& pCompare) +{ + sal_Int16 nErg = 0; + if (m_xField.is()) + { + sal_Int32 nType = 0; + try + { + Any aValue; + { + aValue = m_xField->getPropertyValue(FIELD_STR_TYPE); + aValue >>= nType; + } + } + catch ( ... ) + { + return nErg; + } + + if (pLiteral->isRule() && !SQL_ISRULE(pLiteral,value_exp)) + { + switch(nType) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + if(!SQL_ISRULE(pLiteral,char_value_exp) && !buildStringNodes(pLiteral)) + break; + default: + nErg = buildNode(pAppend,pLiteral,pCompare); + } + } + else + { + switch(pLiteral->getNodeType()) + { + case SQL_NODE_STRING: + switch(nType) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + nErg = buildNode(pAppend,pLiteral,pCompare); + break; + case DataType::DATE: + case DataType::TIME: + case DataType::TIMESTAMP: + if (m_xFormatter.is()) + { + try + { + // do we have a date + double fValue = m_xFormatter->convertStringToNumber(m_nFormatKey, pLiteral->getTokenValue().GetBuffer()); + nErg = buildNode_Date(fValue, nType, pAppend,pLiteral,pCompare); + } + catch ( ... ) + { + try + { + Reference< ::com::sun::star::util::XNumberFormatsSupplier > xFormatSup = m_xFormatter->getNumberFormatsSupplier(); + Reference< ::com::sun::star::util::XNumberFormatTypes > xFormatTypes(xFormatSup->getNumberFormats(),UNO_QUERY); + if (xFormatTypes.is()) + { + String sLanguage, sCountry; + ConvertLanguageToIsoNames(m_pIntl->GetLanguage(), sLanguage, sCountry); + ::com::sun::star::lang::Locale aLocale(sLanguage.GetBuffer(), + sCountry.GetBuffer(), + rtl::OUString()); + + double fValue = m_xFormatter->convertStringToNumber( + xFormatTypes->getStandardFormat(::com::sun::star::util::NumberFormat::DATE, aLocale), + pLiteral->getTokenValue().GetBuffer()); + nErg = buildNode_Date(fValue, nType, pAppend,pLiteral,pCompare); + } + else + { + nErg = -1; + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_DATE_COMPARE); + } + + } + catch ( ... ) + { + nErg = -1; + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_DATE_COMPARE); + } + } + } + else + nErg = buildNode(pAppend,pLiteral,pCompare); + + break; + default: + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_DATE_COMPARE); + } + break; + case SQL_NODE_ACCESS_DATE: + switch(nType) + { + case DataType::DATE: + case DataType::TIME: + case DataType::TIMESTAMP: + if (m_xFormatter.is()) + { + try + { + // do we have a date + double fValue = m_xFormatter->convertStringToNumber(m_nFormatKey, pLiteral->getTokenValue().GetBuffer()); + nErg = buildNode_Date(fValue, nType, pAppend,pLiteral,pCompare); + } + catch ( ... ) + { + try + { + Reference< ::com::sun::star::util::XNumberFormatsSupplier > xFormatSup = m_xFormatter->getNumberFormatsSupplier(); + Reference< ::com::sun::star::util::XNumberFormatTypes > xFormatTypes(xFormatSup->getNumberFormats(),UNO_QUERY); + if (xFormatTypes.is()) + { + String sLanguage, sCountry; + ConvertLanguageToIsoNames(m_pIntl->GetLanguage(), sLanguage, sCountry); + ::com::sun::star::lang::Locale aLocale(sLanguage.GetBuffer(), + sCountry.GetBuffer(), + rtl::OUString()); + + double fValue = m_xFormatter->convertStringToNumber( + xFormatTypes->getStandardFormat(::com::sun::star::util::NumberFormat::DATE, aLocale), + pLiteral->getTokenValue().GetBuffer()); + nErg = buildNode_Date(fValue, nType, pAppend,pLiteral,pCompare); + } + else + { + nErg = -1; + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_DATE_COMPARE); + } + } + catch ( ... ) + { + nErg = -1; + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_DATE_COMPARE); + } + } + } + else + { + nErg = -1; + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_DATE_COMPARE); + } + break; + default: + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_DATE_COMPARE); + } + break; + case SQL_NODE_INTNUM: + switch(nType) + { + case DataType::BIT: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + case DataType::BIGINT: + case DataType::REAL: + case DataType::DOUBLE: + // kill thousand seperators if any + if (m_pIntl->GetNumDecimalSep() == ',' ) + { + pLiteral->m_aNodeValue.SearchAndReplaceAll('.', String()); + // and replace decimal + pLiteral->m_aNodeValue.SearchAndReplaceAll(',', '.'); + } + else + pLiteral->m_aNodeValue.SearchAndReplaceAll(',', String()); + nErg = buildNode(pAppend,pLiteral,pCompare); + break; + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + nErg = buildNode_STR_NUM(pAppend,pLiteral,pCompare); + break; + default: + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_INT_COMPARE); + } + break; + case SQL_NODE_APPROXNUM: + switch(nType) + { + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::REAL: + case DataType::DOUBLE: + if (inPredicateCheck()) + { + // kill thousand seperators if any + if (m_pIntl->GetNumDecimalSep() == ',' ) + { + pLiteral->m_aNodeValue.SearchAndReplaceAll('.', String()); + // and replace decimal + pLiteral->m_aNodeValue.SearchAndReplaceAll(',', '.'); + } + else + pLiteral->m_aNodeValue.SearchAndReplaceAll(',', String()); + } + nErg = buildNode(pAppend,pLiteral,pCompare); + break; + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + nErg = buildNode_STR_NUM(pAppend,pLiteral,pCompare); + break; + case DataType::INTEGER: + default: + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_REAL_COMPARE); + } + break; + } + } + if (!nErg) + --nErg; + } + if (!pCompare->getParent()) // I have no parent so I was not used and I must die :-) + delete pCompare; + return nErg; +} + +//----------------------------------------------------------------------------- +void OSQLParser::reduceLiteral(OSQLParseNode*& pLiteral, sal_Bool bAppendBlank) +{ + DBG_ASSERT(pLiteral->isRule(), "This is no ::com::sun::star::chaos::Rule"); + DBG_ASSERT(pLiteral->count() == 2, "OSQLParser::ReduceLiteral() Invalid count"); + OSQLParseNode* pTemp = pLiteral; + String aValue; + if (bAppendBlank) + { + ((aValue = pLiteral->getChild(0)->getTokenValue()) += String(' ')) += + pLiteral->getChild(1)->getTokenValue(); + } + else + (aValue = pLiteral->getChild(0)->getTokenValue()) += + pLiteral->getChild(1)->getTokenValue(); + + pLiteral = new OSQLInternalNode(aValue,SQL_NODE_STRING); + delete pTemp; +} +// ------------------------------------------------------------------------- +void OSQLParser::error(char *fmt) +{ + if(!m_sErrorMessage.Len()) + { + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_GENERAL); + m_sErrorMessage.AppendAscii(": "); + m_sErrorMessage += m_pContext->getErrorMessage(OParseContext::ERROR_GENERAL_HINT); + m_sErrorMessage.SearchAndReplaceAscii("#",String::CreateFromAscii(fmt)); + } +} +// ------------------------------------------------------------------------- +int OSQLParser::SQLlex() +{ + return s_pScanner->SQLlex(); +} +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.1 2000/07/25 10:39:29 oj + new revision + + Revision 1.0 21.07.2000 12:27:34 oj +------------------------------------------------------------------------*/ + diff --git a/connectivity/source/parse/sqlflex.l b/connectivity/source/parse/sqlflex.l new file mode 100644 index 000000000000..446ec2454aea --- /dev/null +++ b/connectivity/source/parse/sqlflex.l @@ -0,0 +1,592 @@ +%{ + +//-------------------------------------------------------------------------- +// +// $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/connectivity/source/parse/sqlflex.l,v 1.1.1.1 2000-09-18 16:14:28 hr Exp $ +// +// Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. +// +// First creation: +// OJ +// +// Last change: +// $Author: hr $ $Date: 2000-09-18 16:14:28 $ $Revision: 1.1.1.1 $ +// +// Description: +// +// +//-------------------------------------------------------------------------- + +#define YY_EXIT 1 // YY_FATAL will not halt the application + +#ifndef _CSTDARG_ +#include <cstdarg> // std::va_list +#endif + +#ifndef _INC_STRING +#include <string.h> +#endif +#ifndef _SOLAR_H +#include <tools/solar.h> +#endif + +#ifndef _CONNECTIVITY_SQLINTERNALNODE_HXX +#include "internalnode.hxx" +#endif + +#ifndef _CONNECTIVITY_SQLYACC_HXX +#define _CONNECTIVITY_SQLYACC_HXX + +#ifndef SQLYYDEBUG +#define SQLYYDEBUG 1 +#endif + +#include "connectivity/sqlbison.hxx" +#endif +#ifndef _CONNECTIVITY_SQLSCAN_HXX +#include "sqlscan.hxx" +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _CONNECTIVITY_SQLPARSE_HXX +#include <connectivity/sqlparse.hxx> +#endif +using namespace connectivity; + +//============================================================================= +// +// Erzeugung der Blaetter fuer die Token +// Blaetter werden generell vom Lexer erzeugt + +static String aEmptyString; + +static int gatherString(int delim, int nTyp); +static int gatherName(const char*); +static int gatherNamePre(const char* ); +// has to be set before the parser starts +OSQLScanner* xxx_pGLOBAL_SQLSCAN = NULL; + +#define SQL_NEW_NODE(text, token) \ + SQLyylval.pParseNode = new OSQLInternalNode(text, token); + +#define SQL_NEW_KEYWORD(token) \ + SQLyylval.pParseNode = new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD, (token)); + +#define SQL_NEW_NAME SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_NAME) +#define SQL_NEW_INTNUM SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_INTNUM) +#define SQL_NEW_APPROXNUM SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_APPROXNUM) +#define SQL_NEW_STRING SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_STRING) +#define SQL_NEW_COMPARISON SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_COMPARISON) +#define SQL_NEW_AMMSC SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_AMMSC) +#define SQL_NEW_DATE SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_ACCESS_DATE) + +#define YY_INPUT(buf,result,max_size) \ +{ \ + buf[0] = xxx_pGLOBAL_SQLSCAN->SQLyygetc(); \ + result = buf[0] != -1; \ +} + +#define YY_FATAL_ERROR(msg) \ +{ \ + xxx_pGLOBAL_SQLSCAN->SQLyyerror(msg); \ +} + +// +//============================================================================= + +%} +%e 2500 +%n 2900 +%p 8500 + +%s SQL +%s PREDICATE_ENG +%s PREDICATE_GER +%s DATE +%s STRING + +%option noyywrap +%option never-interactive +%% + +[Aa][Ll][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_ALL); return SQL_TOKEN_ALL; } +[Aa][Ll][Tt][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_ALTER); return SQL_TOKEN_ALTER; } +[Aa][Nn][Dd] {SQL_NEW_KEYWORD(SQL_TOKEN_AND); return SQL_TOKEN_AND; } +[Aa][Nn][Yy] {SQL_NEW_KEYWORD(SQL_TOKEN_ANY); return SQL_TOKEN_ANY; } +[Aa][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_AS); return SQL_TOKEN_AS; } +[Aa][Ss][Cc] {SQL_NEW_KEYWORD(SQL_TOKEN_ASC); return SQL_TOKEN_ASC; } +[Aa][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_AT); return SQL_TOKEN_AT; } +[Aa][Uu][Tt][Hh][Oo][Rr][Ii][Zz][Aa][Tt][Ii][Oo][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_AUTHORIZATION); return SQL_TOKEN_AUTHORIZATION; } +[Aa][Vv][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_AVG); return SQL_TOKEN_AVG; } + +[Bb][Ee][Tt][Ww][Ee][Ee][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_BETWEEN); return SQL_TOKEN_BETWEEN; } +[Bb][Ii][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_BIT); return SQL_TOKEN_BIT; } +[Bb][Ii][Tt]_[Ll][Ee][Nn][Gg][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_BIT_LENGTH); return SQL_TOKEN_BIT_LENGTH; } +[Bb][Oo][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_BOTH); return SQL_TOKEN_BOTH; } +[Bb][Yy] {SQL_NEW_KEYWORD(SQL_TOKEN_BY); return SQL_TOKEN_BY; } + +[Cc][Aa][Ll][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_CALL); return SQL_TOKEN_CALL; } +[Cc][Aa][Ss][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_CAST); return SQL_TOKEN_CAST; } +[Cc][Hh][Aa][Rr]([Aa][Cc][Tt][Ee][Rr])? {SQL_NEW_KEYWORD(SQL_TOKEN_CHARACTER); return SQL_TOKEN_CHARACTER; } +[Cc][Hh][Aa][Rr]([Aa][Cc][Tt][Ee][Rr])?_[Ll][Ee][Nn][Gg][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_CHAR_LENGTH); return SQL_TOKEN_CHAR_LENGTH; } +[Cc][Hh][Ee][Cc][Kk] {SQL_NEW_KEYWORD(SQL_TOKEN_CHECK); return SQL_TOKEN_CHECK; } +[Cc][Oo][Ll][Ll][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_COLLATE); return SQL_TOKEN_COLLATE; } +[Cc][Oo][Mm][Mm][Ii][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_COMMIT); return SQL_TOKEN_COMMIT; } +[Cc][Oo][Nn][Tt][Ii][Nn][Uu][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_CONTINUE); return SQL_TOKEN_CONTINUE; } +[Cc][Oo][Nn][Vv][Ee][Rr][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_CONVERT); return SQL_TOKEN_CONVERT; } +[Cc][Oo][Uu][Nn][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_COUNT); return SQL_TOKEN_COUNT; } +[Cc][Rr][Ee][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_CREATE); return SQL_TOKEN_CREATE; } +[Cc][Rr][Oo][Ss][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_CROSS); return SQL_TOKEN_CROSS; } +[Cc][Uu][Rr][Rr][Ee][Nn][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT); return SQL_TOKEN_CURRENT; } +[Cc][Uu][Rr][Rr][Ee][Nn][Tt]_[Dd][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_DATE); return SQL_TOKEN_CURRENT_DATE; } +[Cc][Uu][Rr][Rr][Ee][Nn][Tt]_[Tt][Ii][Mm][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_TIME); return SQL_TOKEN_CURRENT_TIME; } +[Cc][Uu][Rr][Rr][Ee][Nn][Tt]_[Tt][Ii][Mm][Ee][Ss][Tt][Aa][Mm][Pp] {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_TIMESTAMP); return SQL_TOKEN_CURRENT_TIMESTAMP; } +[Cc][Uu][Rr][Ss][Oo][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_CURSOR); return SQL_TOKEN_CURSOR; } + +[Dd] {SQL_NEW_KEYWORD(SQL_TOKEN_D); return SQL_TOKEN_D; } +[Dd][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_DATE); return SQL_TOKEN_DATE; } +[Dd][Aa][Yy] {SQL_NEW_KEYWORD(SQL_TOKEN_DAY); return SQL_TOKEN_DAY; } +[Dd][Ee][Cc] {SQL_NEW_KEYWORD(SQL_TOKEN_DEC); return SQL_TOKEN_DEC; } +[Dd][Ee][Cc][Ii][Mm][Aa][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_DECIMAL); return SQL_TOKEN_DECIMAL; } +[Dd][Ee][Cc][Ll][Aa][Rr][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_DECLARE); return SQL_TOKEN_DECLARE; } +[Dd][Ee][Ff][Aa][Uu][Ll][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_DEFAULT); return SQL_TOKEN_DEFAULT; } +[Dd][Ee][Ll][Ee][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_DELETE); return SQL_TOKEN_DELETE; } +[Dd][Ee][Ss][Cc] {SQL_NEW_KEYWORD(SQL_TOKEN_DESC); return SQL_TOKEN_DESC; } +[Dd][Ii][Ss][Tt][Ii][Nn][Cc][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_DISTINCT); return SQL_TOKEN_DISTINCT; } +[Dd][Oo][Uu][Bb][Ll][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_DOUBLE); return SQL_TOKEN_DOUBLE; } +[Dd][Rr][Oo][Pp] {SQL_NEW_KEYWORD(SQL_TOKEN_DROP); return SQL_TOKEN_DROP; } + +[Ee][Ss][Cc][Aa][Pp][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_ESCAPE); return SQL_TOKEN_ESCAPE; } +[Ee][Xx][Cc][Ee][Pp][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_EXCEPT); return SQL_TOKEN_EXCEPT; } +[Ee][Xx][Ii][Ss][Tt][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_EXISTS); return SQL_TOKEN_EXISTS; } +[Ee][Xx][Tt][Rr][Aa][Cc][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_EXTRACT); return SQL_TOKEN_EXTRACT; } + +[Ff][Aa][Ll][Ss][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_FALSE); return SQL_TOKEN_FALSE; } +[Ff][Ee][Tt][Cc][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_FETCH); return SQL_TOKEN_FETCH; } +[Ff][Ll][Oo][Aa][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_FLOAT); return SQL_TOKEN_FLOAT; } +[Ff][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_FN); return SQL_TOKEN_FN; } +[Ff][Oo][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_FOR); return SQL_TOKEN_FOR; } +[Ff][Oo][Rr][Ee][Ii][Gg][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_FOREIGN); return SQL_TOKEN_FOREIGN; } +[Ff][Oo][Uu][Nn][Dd] {SQL_NEW_KEYWORD(SQL_TOKEN_FOUND); return SQL_TOKEN_FOUND; } +[Ff][Rr][Oo][Mm] {SQL_NEW_KEYWORD(SQL_TOKEN_FROM); return SQL_TOKEN_FROM; } +[Ff][Uu][Ll][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_FULL); return SQL_TOKEN_FULL; } + +[Gg][Rr][Aa][Nn][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_GRANT); return SQL_TOKEN_GRANT; } +[Gg][Rr][Oo][Uu][Pp] {SQL_NEW_KEYWORD(SQL_TOKEN_GROUP); return SQL_TOKEN_GROUP; } + +[Hh][Aa][Vv][Ii][Nn][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_HAVING); return SQL_TOKEN_HAVING; } +[Hh][Oo][Uu][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_HOUR); return SQL_TOKEN_HOUR; } + +[Ii][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_IN); return SQL_TOKEN_IN; } +[Ii][Nn][Nn][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_INNER); return SQL_TOKEN_INNER; } +[Ii][Nn][Ss][Ee][Rr][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_INSERT); return SQL_TOKEN_INSERT; } +[Ii][Nn][Tt]([Ee][Gg][Ee][Rr])? {SQL_NEW_KEYWORD(SQL_TOKEN_INTEGER); return SQL_TOKEN_INTEGER; } +[Ii][Nn][Tt][Ee][Rr][Ss][Ee][Cc][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_INTERSECT); return SQL_TOKEN_INTERSECT; } +[Ii][Nn][Tt][Oo] {SQL_NEW_KEYWORD(SQL_TOKEN_INTO); return SQL_TOKEN_INTO; } +[Ii][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_IS); return SQL_TOKEN_IS; } + +[Jj][Oo][Ii][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_JOIN); return SQL_TOKEN_JOIN; } + +[Kk][Ee][Yy] {SQL_NEW_KEYWORD(SQL_TOKEN_KEY); return SQL_TOKEN_KEY; } + +[Ll][Ee][Aa][Dd][Ii][Nn][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_LEADING); return SQL_TOKEN_LEADING; } +[Ll][Ee][Ff][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_LEFT); return SQL_TOKEN_LEFT; } +[Ll][Ii][Kk][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_LIKE); return SQL_TOKEN_LIKE; } +[Ll][Oo][Cc][Aa][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_LOCAL); return SQL_TOKEN_LOCAL; } +[Ll][Oo][Ww][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_LOWER); return SQL_TOKEN_LOWER; } + +[Mm][Aa][Xx] {SQL_NEW_KEYWORD(SQL_TOKEN_MAX); return SQL_TOKEN_MAX; } +[Mm][Ii][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_MIN); return SQL_TOKEN_MIN; } +[Mm][Ii][Nn][Uu][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_MINUTE); return SQL_TOKEN_MINUTE; } +[Mm][Oo][Nn][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_MONTH); return SQL_TOKEN_MONTH; } + +[Nn][Aa][Tt][Uu][Rr][Aa][LL] {SQL_NEW_KEYWORD(SQL_TOKEN_NATURAL); return SQL_TOKEN_NATURAL; } +[Nn][Cc][Hh][Aa][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_NCHAR); return SQL_TOKEN_NCHAR; } +[Nn][Oo][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_NOT); return SQL_TOKEN_NOT; } +[Nn][Uu][Ll][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_NULL); return SQL_TOKEN_NULL; } +[Nn][Uu][Mm][Ee][Rr][Ii][Cc] {SQL_NEW_KEYWORD(SQL_TOKEN_NUMERIC); return SQL_TOKEN_NUMERIC; } + +[Oo][Cc][Tt][Ee][Tt]_[Ll][Ee][Nn][Gg][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_OCTECT_LENGTH); return SQL_TOKEN_OCTECT_LENGTH; } +[Oo][Ff] {SQL_NEW_KEYWORD(SQL_TOKEN_OF); return SQL_TOKEN_OF; } +[Oo][Jj] {SQL_NEW_KEYWORD(SQL_TOKEN_OJ); return SQL_TOKEN_OJ; } +[Oo][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_ON); return SQL_TOKEN_ON; } +[Oo][Pp][Tt][Ii][Oo][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_OPTION); return SQL_TOKEN_OPTION; } +[Oo][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_OR); return SQL_TOKEN_OR; } +[Oo][Rr][Dd][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_ORDER); return SQL_TOKEN_ORDER; } +[Oo][Uu][Tt][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_OUTER); return SQL_TOKEN_OUTER; } + +[Pp][Oo][Ss][Ii][Tt][Ii][Oo][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_POSITION); return SQL_TOKEN_POSITION; } +[Pp][Rr][Ee][Cc][Ii][Ss][Ii][Oo][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_PRECISION); return SQL_TOKEN_PRECISION; } +[Pp][Rr][Ii][Mm][Aa][Rr][Yy] {SQL_NEW_KEYWORD(SQL_TOKEN_PRIMARY); return SQL_TOKEN_PRIMARY; } +[Pp][Rr][Ii][Vv][Ii][Ll][Ee][Gg][Ee][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_PRIVILEGES); return SQL_TOKEN_PRIVILEGES; } +[Pp][Rr][Oo][Cc][Ee][Dd][Uu][Rr][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_PROCEDURE); return SQL_TOKEN_PROCEDURE; } +[Pp][Uu][Bb][Ll][Ii][Cc] {SQL_NEW_KEYWORD(SQL_TOKEN_PUBLIC); return SQL_TOKEN_PUBLIC; } + +[Rr][Ee][Aa][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_REAL); return SQL_TOKEN_REAL; } +[Rr][Ee][Ff][Ee][Rr][Ee][Nn][Cc][Ee][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_REFERENCES); return SQL_TOKEN_REFERENCES; } +[Rr][Oo][Ll][Ll][Bb][Aa][Cc][Kk] {SQL_NEW_KEYWORD(SQL_TOKEN_ROLLBACK); return SQL_TOKEN_ROLLBACK; } +[Rr][Ii][Gg][Hh][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_RIGHT); return SQL_TOKEN_RIGHT; } + +[Ss][Cc][Hh][Ee][Mm][Aa] {SQL_NEW_KEYWORD(SQL_TOKEN_SCHEMA); return SQL_TOKEN_SCHEMA; } +[Ss][Ee][Cc][Ee][Oo][Nn][Dd] {SQL_NEW_KEYWORD(SQL_TOKEN_SECOND); return SQL_TOKEN_SECOND; } +[Ss][Ee][Ll][Ee][Cc][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_SELECT); return SQL_TOKEN_SELECT; } +[Ss][Ee][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_SET); return SQL_TOKEN_SET; } +[Ss][Ii][Zz][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_SIZE); return SQL_TOKEN_SIZE; } +[Ss][Mm][Aa][Ll][Ll][Ii][Nn][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_SMALLINT); return SQL_TOKEN_SMALLINT; } +[Ss][Oo][Mm][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_SOME); return SQL_TOKEN_SOME; } +[Ss][Uu][Bb][Ss][Tt][Rr][Ii][Nn][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_SUBSTRING); return SQL_TOKEN_SUBSTRING; } +[Ss][Uu][Mm] {SQL_NEW_KEYWORD(SQL_TOKEN_SUM); return SQL_TOKEN_SUM; } + +[Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_T); return SQL_TOKEN_T; } +[Tt][Aa][Bb][Ll][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_TABLE); return SQL_TOKEN_TABLE; } +[Tt][Ii][Mm][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_TIME); return SQL_TOKEN_TIME; } +[Tt][Ii][Mm][Ee][Ss][Tt][Aa][Mm][Pp] {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMP); return SQL_TOKEN_TIMESTAMP; } +[Tt][Ii][Mm][Ee][Zz][Oo][Nn][Ee]_[Hh][Oo][Uu][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_TIMEZONE_HOUR); return SQL_TOKEN_TIMEZONE_HOUR; } +[Tt][Ii][Mm][Ee][Zz][Oo][Nn][Ee]_[Mm][Ii][Nn][Uu][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_TIMEZONE_MINUTE); return SQL_TOKEN_TIMEZONE_MINUTE; } +[Tt][Oo] {SQL_NEW_KEYWORD(SQL_TOKEN_TO); return SQL_TOKEN_TO; } +[Tt][Rr][Aa][Ii][Ll][Ii][Nn][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_TRAILING); return SQL_TOKEN_TRAILING; } +[Tt][Rr][Aa][Nn][Ss][Ll][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_TRANSLATE); return SQL_TOKEN_TRANSLATE; } +[Tt][Rr][Ii][Mm] {SQL_NEW_KEYWORD(SQL_TOKEN_TRIM); return SQL_TOKEN_TRIM; } +[Tt][Rr][Uu][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_TRUE); return SQL_TOKEN_TRUE; } +[Tt][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_TS); return SQL_TOKEN_TS; } + +[Uu][Nn][Ii][Oo][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_UNION); return SQL_TOKEN_UNION; } +[Uu][Nn][Ii][Qq][Uu][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_UNIQUE); return SQL_TOKEN_UNIQUE; } +[Uu][Nn][Kk][Nn][Oo][Ww][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_UNKNOWN); return SQL_TOKEN_UNKNOWN; } +[Uu][Pp][Pp][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_UPPER); return SQL_TOKEN_UPPER; } +[Uu][Pp][Dd][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_UPDATE); return SQL_TOKEN_UPDATE; } +[Uu][Ss][Aa][Gg][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_USAGE); return SQL_TOKEN_USAGE; } +[Uu][Ss][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_USER); return SQL_TOKEN_USER; } +[Uu][Ss][Ii][Nn][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_USING); return SQL_TOKEN_USING; } + +[Vv][Aa][Ll][Uu][Ee][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_VALUES); return SQL_TOKEN_VALUES; } +[Vv][Ii][Ee][Ww] {SQL_NEW_KEYWORD(SQL_TOKEN_VIEW); return SQL_TOKEN_VIEW; } + +[Ww][Hh][Ee][Rr][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_WHERE); return SQL_TOKEN_WHERE; } +[Ww][Ii][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_WITH); return SQL_TOKEN_WITH; } +[Ww][Oo][Rr][Kk] {SQL_NEW_KEYWORD(SQL_TOKEN_WORK); return SQL_TOKEN_WORK; } + +[Yy][Ee][Aa][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_YEAR); return SQL_TOKEN_YEAR; } + +[Zz][Oo][Nn][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_ZONE); return SQL_TOKEN_ZONE; } + +"<" { SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_LESS);return LESS;} +">" { SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_GREAT);return GREAT;} +"=" { SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_EQUAL);return EQUAL;} +"<=" { SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_LESSEQ);return LESSEQ;} +">=" { SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_GREATEQ);return GREATEQ;} +"<>" { SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_NOTEQUAL);return NOTEQUAL;} +"!=" { SQL_NEW_NODE(String::CreateFromAscii(SQLyytext), SQL_NODE_NOTEQUAL);return NOTEQUAL;} + + +[-+*/:(),.;?{}] { return SQLyytext[0]; } + +<SQL>[A-Za-z][A-Za-z0-9_]* {return gatherName( SQLyytext);} + +<SQL>([0-9]+) | +<SQL>([0-9]+"."[0-9]*) | +<SQL>("."[0-9]*) {SQL_NEW_INTNUM; return SQL_TOKEN_INTNUM;} + +<SQL>[0-9]+[eE][+-]?[0-9]+ | +<SQL>[0-9]+"."[0-9]*[eE][+-]?[0-9]+ | +<SQL>"."[0-9]*[eE][+-]?[0-9]+ {SQL_NEW_APPROXNUM; return SQL_TOKEN_APPROXNUM; } + +<PREDICATE_GER,PREDICATE_ENG,DATE>[A-Za-z][A-Za-z0-9_%.,*?]* {return gatherNamePre(SQLyytext);} + +<PREDICATE_GER,PREDICATE_ENG>([0-9]+) {SQL_NEW_INTNUM; return SQL_TOKEN_INTNUM;} +<PREDICATE_ENG>([0-9]{1,3}(","[0-9]{3})+) {SQL_NEW_INTNUM; return SQL_TOKEN_INTNUM;} +<PREDICATE_GER>([0-9]{1,3}("."[0-9]{3})+) {SQL_NEW_INTNUM; return SQL_TOKEN_INTNUM;} + +<PREDICATE_ENG>([0-9]+"."[0-9]+) | +<PREDICATE_ENG>([0-9]{1,3}(","[0-9]{3})+"."[0-9]+) | +<PREDICATE_ENG>("."[0-9]+) {SQL_NEW_APPROXNUM; return SQL_TOKEN_APPROXNUM; } +<PREDICATE_ENG>[0-9]+[eE][+-]?[0-9]+ | +<PREDICATE_ENG>[0-9]+"."[0-9]*[eE][+-]?[0-9]+ | +<PREDICATE_ENG>"."[0-9]*[eE][+-]?[0-9]+ {SQL_NEW_APPROXNUM; return SQL_TOKEN_APPROXNUM; } + +<PREDICATE_GER>([0-9]+","[0-9]+) | +<PREDICATE_GER>([0-9]{1,3}("."[0-9]{3})+","[0-9]+) | +<PREDICATE_GER>(","[0-9]+) {SQL_NEW_APPROXNUM; return SQL_TOKEN_APPROXNUM; } +<PREDICATE_GER>[0-9]+[eE][+-]?[0-9]+ | +<PREDICATE_GER>[0-9]+","[0-9]*[eE][+-]?[0-9]+ | +<PREDICATE_GER>","[0-9]*[eE][+-]?[0-9]+ {SQL_NEW_APPROXNUM; return SQL_TOKEN_APPROXNUM; } + +<PREDICATE_GER,PREDICATE_ENG>[0-9.,][A-Za-z0-9_.,%]* {return gatherNamePre(SQLyytext);} + +<SQL>\" { return gatherString('\"',0); } +<SQL>` { return gatherString('`' ,0); } + +<PREDICATE_GER,PREDICATE_ENG,DATE>"[" { return gatherString(']' ,0);} + +\' { return gatherString('\'',1); } + +<PREDICATE_GER,PREDICATE_ENG,DATE># { return gatherString('#' ,2); } + +<DATE>[0-9]{1,4}[^ ]*[0-9] | +<DATE>[0-9]{1,4}[^ ]*[0-9][ ][0-9]{1,4}[^ ]*[0-9] { SQL_NEW_DATE; return SQL_TOKEN_ACCESS_DATE;} + +<STRING>["-""+""*""/"":""("")"",""."";""?""{""}"] { return SQLyytext[0]; } /* */ +<STRING>"[" { return gatherString(']' ,0); } +<STRING>[^ ':[]* { return gatherNamePre(SQLyytext); } + +\n {} + +[ \t\r]+ ; + +"--".*$ ; + +. {YY_FATAL_ERROR("Invalid symbol"); return SQL_TOKEN_INVALIDSYMBOL;} + +%% + +/* + * Read SQL string literal + * Valid strings: + * '' 'a string' 'quote '' within string' + * "" "a string" "quote "" within string" + * nTyp == 0 -> SQL_NODE_NAME + * nTyp == 1 -> SQL_NODE_STRING + * nTyp == 2 -> SQL_NODE_ACCESS_DATE + */ +int gatherString( int delim, int nTyp) +{ + int ch; + static sal_Int32 BUFFERSIZE = 256; + static char* Buffer = new char[BUFFERSIZE]; + + char *s = Buffer; + int nPos = 0; + + while ((ch = yyinput()) != EOF) + { + if (ch == delim) + { + if ((ch = yyinput()) != delim) + { + if (ch != EOF) + unput(ch); + + *s = '\0'; + + switch(nTyp) + { + case 0: + SQL_NEW_NODE(String(Buffer,RTL_TEXTENCODING_UTF8), SQL_NODE_NAME); + return SQL_TOKEN_NAME; + case 1: + SQL_NEW_NODE(String(Buffer,RTL_TEXTENCODING_UTF8), SQL_NODE_STRING); + return SQL_TOKEN_STRING; + case 2: + SQL_NEW_NODE(String(Buffer,RTL_TEXTENCODING_UTF8), SQL_NODE_ACCESS_DATE); + return SQL_TOKEN_ACCESS_DATE; + } + } + else + { + *s++ = ch; + if (++nPos == BUFFERSIZE) + { + ByteString aBuf(Buffer); + delete Buffer; + BUFFERSIZE *=2; + Buffer = new char[BUFFERSIZE]; + for(xub_StrLen i=0;i<aBuf.Len();++i,++Buffer) + *Buffer = aBuf.GetChar(i); + s = &Buffer[nPos]; + } + } + + } + else if (ch == '\r' || ch == '\n') + break; + else + { + *s++ = ch; + if (++nPos == BUFFERSIZE) + { + ByteString aBuf(Buffer); + delete Buffer; + BUFFERSIZE *=2; + Buffer = new char[BUFFERSIZE]; + for(xub_StrLen i=0;i<aBuf.Len();++i,++Buffer) + *Buffer = aBuf.GetChar(i); + s = &Buffer[nPos]; + } + } + } + *s = '\0'; + YY_FATAL_ERROR("Unterminated name string"); + return SQL_TOKEN_INVALIDSYMBOL; +} + +/* + * Read SQL Name literal + * Valid Names or internatioanl keywords: + * As we have international keywords, we test first on them + */ +int gatherName(const char* text) +{ + OSL_ENSHURE(xxx_pGLOBAL_SQLSCAN,"You forgot to set the scanner!"); + int nToken = xxx_pGLOBAL_SQLSCAN->getInternationalTokenID(text); + switch (nToken) + { + case SQL_TOKEN_LIKE: + case SQL_TOKEN_NOT: + case SQL_TOKEN_NULL: + case SQL_TOKEN_TRUE: + case SQL_TOKEN_FALSE: + case SQL_TOKEN_IS: + case SQL_TOKEN_BETWEEN: + case SQL_TOKEN_OR: + case SQL_TOKEN_AND: + case SQL_TOKEN_COUNT: + case SQL_TOKEN_AVG: + case SQL_TOKEN_MAX: + case SQL_TOKEN_MIN: + case SQL_TOKEN_SUM: + SQL_NEW_KEYWORD(nToken); + return nToken; + default: + SQL_NEW_NODE(String::CreateFromAscii(text), SQL_NODE_NAME); + return SQL_TOKEN_NAME; + } +} +/** + Read SQL Name literal for predicate check + Valid Names or internatioanl keywords: + As we have international keywords, we test first on them +*/ +int gatherNamePre(const char* text) +{ + OSL_ENSHURE(xxx_pGLOBAL_SQLSCAN,"You forgot to set the scanner!"); + int nToken = xxx_pGLOBAL_SQLSCAN->getInternationalTokenID(text); + switch (nToken) + { + case SQL_TOKEN_LIKE: + case SQL_TOKEN_NOT: + case SQL_TOKEN_NULL: + case SQL_TOKEN_TRUE: + case SQL_TOKEN_FALSE: + case SQL_TOKEN_IS: + case SQL_TOKEN_BETWEEN: + case SQL_TOKEN_OR: + case SQL_TOKEN_AND: + case SQL_TOKEN_COUNT: + case SQL_TOKEN_AVG: + case SQL_TOKEN_MAX: + case SQL_TOKEN_MIN: + case SQL_TOKEN_SUM: + SQL_NEW_KEYWORD(nToken); + return nToken; + default: + // we need a special handling for parameter + if (yy_hold_char == ':') + { + SQL_NEW_NODE(String::CreateFromAscii(text), SQL_NODE_NAME); + return SQL_TOKEN_NAME; + } + else + { + SQL_NEW_NODE(String::CreateFromAscii(text), SQL_NODE_STRING); + return SQL_TOKEN_STRING; + } + } +} + +using namespace connectivity; + +static sal_uInt32 Intl_TokenID[] = +{ + SQL_TOKEN_LIKE, SQL_TOKEN_NOT, SQL_TOKEN_NULL, SQL_TOKEN_TRUE, + SQL_TOKEN_FALSE, SQL_TOKEN_IS, SQL_TOKEN_BETWEEN, SQL_TOKEN_OR, + SQL_TOKEN_AND, SQL_TOKEN_AVG, SQL_TOKEN_COUNT, SQL_TOKEN_MAX, + SQL_TOKEN_MIN, SQL_TOKEN_SUM +}; + +DBG_NAME(OSQLScanner); + +//------------------------------------------------------------------------------ +OSQLScanner::OSQLScanner() + : m_nCurrentPos(0) + , m_bInternational(sal_False) + , m_pContext(NULL) + , m_nRule(0) // 0 is INITIAL +{ + DBG_CTOR(OSQLScanner,NULL); +} + +//------------------------------------------------------------------------------ +OSQLScanner::~OSQLScanner() +{ + DBG_DTOR(OSQLScanner,NULL); +} + +//------------------------------------------------------------------------------ +void OSQLScanner::SQLyyerror(char *fmt) +{ + DBG_ASSERT(m_pContext, "OSQLScanner::SQLyyerror: No Context set"); + m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_GENERAL); + if (m_nCurrentPos < m_sStatement.Len()) + { + m_sErrorMessage.AppendAscii(": "); + m_sErrorMessage += m_pContext->getErrorMessage(OParseContext::ERROR_GENERAL_HINT); + m_sErrorMessage.SearchAndReplaceAscii("#",String::CreateFromAscii(SQLyytext)); + } +} + +//------------------------------------------------------------------------------ +void OSQLScanner::prepareScan(const String & rNewStatement, OParseContext* pContext, sal_Bool bInternational) +{ + DBG_CHKTHIS(OSQLScanner,NULL); + + BEGIN(m_nRule); + + m_sErrorMessage.Erase(); + m_sStatement = ByteString(rNewStatement, RTL_TEXTENCODING_UTF8); + m_nCurrentPos = 0; + m_bInternational = bInternational; + m_pContext = pContext; +} + +//------------------------------------------------------------------------------ +int OSQLScanner::SQLyygetc(void) +{ + return (m_nCurrentPos >= m_sStatement.Len()) ? -1 : m_sStatement.GetChar(m_nCurrentPos++); +} + +//------------------------------------------------------------------------------ +int OSQLScanner::getInternationalTokenID(const char* sToken) const +{ + DBG_ASSERT(m_pContext, "OSQLScanner::getInternationalTokenID: No Context set"); + return (m_bInternational) ? m_pContext->getIntlKeyCode(ByteString(sToken, RTL_TEXTENCODING_ASCII_US)) : 0; +} +// ------------------------------------------------------------------------- +int OSQLScanner::GetCurrentRule() const { return m_nRule; } +int OSQLScanner::GetGERRule() const { return PREDICATE_GER; } +int OSQLScanner::GetENGRule() const { return PREDICATE_ENG; } +int OSQLScanner::GetSQLRule() const { return SQL; } +int OSQLScanner::GetDATERule() const { return DATE; } +int OSQLScanner::GetSTRINGRule() const { return STRING; } +// ------------------------------------------------------------------------- +void OSQLScanner::setScanner(sal_Bool _bNull) +{ + xxx_pGLOBAL_SQLSCAN = _bNull ? NULL : this; +} +// ------------------------------------------------------------------------- +int OSQLScanner::SQLlex() +{ + return SQLyylex(); +} +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.2 2000/08/01 14:26:02 oj + modified + + Revision 1.1 2000/07/25 10:39:47 oj + new revision + + Revision 1.0 21.07.2000 10:54:08 oj +------------------------------------------------------------------------*/ + diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx new file mode 100644 index 000000000000..88e98fa418a7 --- /dev/null +++ b/connectivity/source/parse/sqliterator.cxx @@ -0,0 +1,1583 @@ +/************************************************************************* + * + * $RCSfile: sqliterator.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_PARSE_SQLITERATOR_HXX_ +#include "connectivity/sqliterator.hxx" +#endif + +#ifndef _CONNECTIVITY_SQLPARSE_HXX +#include <connectivity/sqlparse.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifdef SQL_TEST_PARSETREEITERATOR +#include <iostream.h> +#endif +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/PColumn.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity; +using namespace connectivity::parse; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbc; + +DBG_NAME(OSQLParseTreeIterator); +static String aEmptyString; + +class OPrivateColumns : public sdbcx::OCollection +{ + OSQLColumns m_aColumns; +protected: + virtual Reference< XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(RuntimeException) {} + virtual Reference< XPropertySet > createEmptyObject() + { + return NULL; + } +public: + OPrivateColumns(const OSQLColumns& _rColumns, + ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector + ) : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector) + ,m_aColumns(_rColumns) + {} + ~OPrivateColumns() + { + disposing(); + } +}; +// ------------------------------------------------------------------------- +Reference< XNamed > OPrivateColumns::createObject(const ::rtl::OUString& _rName) +{ + return Reference< XNamed >(*find(m_aColumns.begin(),m_aColumns.end(),_rName,isCaseSensitive()),UNO_QUERY); +} +// ------------------------------------------------------------------------- +class OPrivateTables : public sdbcx::OCollection +{ + OSQLTables m_aTables; +protected: + virtual Reference< XNamed > createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(RuntimeException) {} + virtual Reference< XPropertySet > createEmptyObject() + { + return NULL; + } +public: + OPrivateTables(const OSQLTables& _rColumns, + ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const ::std::vector< ::rtl::OUString> &_rVector + ) : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector) + ,m_aTables(_rColumns) + {} +}; +// ------------------------------------------------------------------------- +Reference< XNamed > OPrivateTables::createObject(const ::rtl::OUString& _rName) +{ + return Reference< XNamed >(m_aTables.find(_rName)->second,UNO_QUERY); +} + +//----------------------------------------------------------------------------- +OSQLParseTreeIterator::OSQLParseTreeIterator() + : m_pParseTree(NULL) + , m_xTables(NULL) + , m_xDatabaseMetaData(NULL) +{ + DBG_CTOR(OSQLParseTreeIterator,NULL); + m_aSelectColumns = new OSQLColumns(); +} +//----------------------------------------------------------------------------- +OSQLParseTreeIterator::OSQLParseTreeIterator(const Reference< XNameAccess>& _xTables , + const Reference< XDatabaseMetaData>& _xDatabaseMetaData, + const OSQLParseNode* pRoot) + : m_xTables(_xTables) + , m_xDatabaseMetaData(_xDatabaseMetaData) + , m_aTables(_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()) + , m_aCaseEqual(_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()) +{ + DBG_CTOR(OSQLParseTreeIterator,NULL); + m_aSelectColumns = new OSQLColumns();// must be done because we need an empty column at zero + setParseTree(pRoot); +} +//----------------------------------------------------------------------------- +OSQLParseTreeIterator::OSQLParseTreeIterator(const OSQLParseTreeIterator & rIter) + :m_xTables(NULL) + ,m_pParseTree(NULL) + , m_xDatabaseMetaData(NULL) +{ + DBG_CTOR(OSQLParseTreeIterator,NULL); + + DBG_ERROR("OSQLParseTreeIterator: Copy-Konstruktor nicht implementiert!"); +} + +//----------------------------------------------------------------------------- +OSQLParseTreeIterator::~OSQLParseTreeIterator() +{ + DBG_DTOR(OSQLParseTreeIterator,NULL); + m_aTables.clear(); +} +// ------------------------------------------------------------------------- +Reference< XNameAccess > OSQLParseTreeIterator::getSelectAsNameAccess(::cppu::OWeakObject& _rParent,::osl::Mutex& _rMutex) const +{ + ::std::vector< ::rtl::OUString> aNames; + for(OSQLColumns::const_iterator aIter = m_aSelectColumns->begin(); aIter != m_aSelectColumns->end();++aIter) + aNames.push_back(getString((*aIter)->getFastPropertyValue(PROPERTY_ID_NAME))); + OPrivateColumns* pCols = new OPrivateColumns(*m_aSelectColumns,_rParent,_rMutex,aNames); + return pCols; +} +// ------------------------------------------------------------------------- +Reference< XNameAccess > OSQLParseTreeIterator::getTablesAsNameAccess(::cppu::OWeakObject& _rParent,::osl::Mutex& _rMutex) const +{ + ::std::vector< ::rtl::OUString> aNames; + for(OSQLTables::const_iterator aIter = m_aTables.begin(); aIter != m_aTables.end();++aIter) + { + Reference<XNamed> xName(aIter->second,UNO_QUERY); + aNames.push_back(xName->getName()); + } + OPrivateTables* pTabs = new OPrivateTables(m_aTables,_rParent,_rMutex,aNames); + return pTabs; +} +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::setParseTree(const OSQLParseNode * pNewParseTree) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // alle Eingaben zur"uck setzen + // aIteratorStatus.Clear(); +// for(ULONG i=0; i< m_aTables.count();i++) +// delete m_aTables.getObject(i); + m_aTables.clear(); + + m_aSelectColumns->clear(); + + m_pParseTree = pNewParseTree; + if (!m_pParseTree) + { + m_eStatementType = SQL_STATEMENT_UNKNOWN; + return; + } + + // falls m_pParseTree aber keine Connection, dann Fehler + if(!m_xTables.is()) + { + //aIteratorStatus.setInvalidStatement(); + CallError(RET_BREAK); + return; + } + + // m_aTables.setCaseSensitive(TablesAreSensitive()); + + + // Statement-Typ ermitteln ... + if (SQL_ISRULE(m_pParseTree,select_statement) || SQL_ISRULE(m_pParseTree,union_statement) ) + { + m_eStatementType = SQL_STATEMENT_SELECT; + } + else if (SQL_ISRULE(m_pParseTree,insert_statement)) + { + m_eStatementType = SQL_STATEMENT_INSERT; + } + else if (SQL_ISRULE(m_pParseTree,update_statement_positioned)) + { + m_eStatementType = SQL_STATEMENT_UPDATE; + } + else if (SQL_ISRULE(m_pParseTree,update_statement_searched)) + { + m_eStatementType = SQL_STATEMENT_UPDATE; + } + else if (SQL_ISRULE(m_pParseTree,delete_statement_positioned)) + { + m_eStatementType = SQL_STATEMENT_DELETE; + } + else if (SQL_ISRULE(m_pParseTree,delete_statement_searched)) + { + m_eStatementType = SQL_STATEMENT_DELETE; + } + else if (m_pParseTree->count() == 3 && SQL_ISRULE(m_pParseTree->getChild(1),odbc_call_spec)) + { + m_eStatementType = SQL_STATEMENT_ODBC_CALL; + } + else + { + m_eStatementType = SQL_STATEMENT_UNKNOWN; + //aIteratorStatus.setInvalidStatement(); + CallError(RET_BREAK); + return; + } +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::traverseOneTableName(const OSQLParseNode * pTableName, const String & rTableRange) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + + DBG_ASSERT(pTableName != NULL,"OSQLParseTreeIterator::traverseOneTableName: pTableName == NULL"); + + String aTableName; + String aTableRange(rTableRange); + + // Tabellenname abholen + pTableName->parseNodeToStr(aTableName,m_xDatabaseMetaData,NULL,FALSE,FALSE); + // Wenn keine Range Variable angegeben, dann den Tabellennamen verwenden. + if (!aTableRange.Len()) + aTableRange = aTableName; + + if(aTableName.Len()) + { + try + { + if(!m_xTables->hasByName(aTableName)) // name not in XNameAccess + { + const ::rtl::OUString sAll = ::rtl::OUString::createFromAscii("%"); + Sequence< ::rtl::OUString > aSeq; + Reference< XResultSet> xRes = m_xDatabaseMetaData->getTables(Any(),sAll,aTableName,aSeq); + if(xRes.is() && xRes->next()) + { + ::rtl::OUString sCatalog, sSchema, sName; + Reference< XRow > xCurrentRow(xRes, UNO_QUERY); + sCatalog = xCurrentRow->getString(1); + sSchema = xCurrentRow->getString(2); + sName = xCurrentRow->getString(3); + + if(sCatalog.getLength()) + { + aTableName = sCatalog; + aTableName += m_xDatabaseMetaData->getCatalogSeparator().getStr(); + } + if(sSchema.getLength()) + { + aTableName += sSchema.getStr(); + aTableName += ::rtl::OUString::createFromAscii(".").getStr(); + } + aTableName += sName.getStr(); + } + } + Any aTable(m_xTables->getByName(aTableName)); + OSQLTable xSet; + + if(aTable >>= xSet) + m_aTables[aTableRange] = xSet; + }catch(...) + { + if (CallError(RET_CONTINUE)) + m_aTables[aTableRange] = NULL; // ich soll den Fehler ignorieren + } + + } + else + CallError(RET_BREAK,rTableRange); +} +//----------------------------------------------------------------------------- +OSQLParseNode * OSQLParseTreeIterator::getQualified_join(OSQLParseNode *pTableRef,String& aTableRange) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + aTableRange.Erase(); + + OSQLParseNode *pNode = getTableRef(pTableRef->getChild(0),aTableRange); + if(pNode) + traverseOneTableName(pNode,aTableRange); + ULONG nPos = 4; + if(SQL_ISRULE(pTableRef,cross_union) || pTableRef->getChild(1)->getTokenID() != SQL_TOKEN_NATURAL) + nPos = 3; + + + pNode = getTableRef(pTableRef->getChild(nPos),aTableRange); + if(pNode) + traverseOneTableName(pNode,aTableRange); + return pNode; +} +//----------------------------------------------------------------------------- +OSQLParseNode * OSQLParseTreeIterator::getTableRef(OSQLParseNode *pTableRef,String& aTableRange) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + OSQLParseNode *pTableName = pTableRef; + if (pTableName->count() == 4 ) + { + if(SQL_ISPUNCTUATION(pTableName->getChild(0),"{")) + { // { OJ joined_table } + getQualified_join(pTableName->getChild(2),aTableRange); + pTableName = NULL; + } + else + { + // Tabellennamen gefunden + if(!SQL_ISRULE(pTableName,table_name)) + pTableName = pTableRef->getChild(0); + aTableRange.Erase(); + if(pTableRef->count() == 4) + aTableRange = pTableRef->getChild(2)->getTokenValue(); // Tabellenrange an Pos 2 + } + } + else if(SQL_ISRULE(pTableName,qualified_join) || SQL_ISRULE(pTableName,cross_union)) + { + getQualified_join(pTableRef,aTableRange); + pTableName = NULL; + } + else if (SQL_ISRULE(pTableName,joined_table)) + { + // '(' qualified_join ')' + getQualified_join(pTableName->getChild(1),aTableRange); + pTableName = NULL; + } + else if(pTableRef->count() == 6) + { + // '(' joined_table ')' as range_variable op_column_commalist + if(SQL_ISRULE(pTableRef->getChild(1),qualified_join) || SQL_ISRULE(pTableRef->getChild(1),cross_union)) + getQualified_join(pTableRef->getChild(1),aTableRange); + else if(SQL_ISRULE(pTableRef->getChild(1),select_statement)) // Unterabfrage + getSelect_statement(pTableRef->getChild(1)); + else if(pTableRef->getChild(1)->count() == 4) + // pTableRef->getChild(1) ->> non_join_query_exp + getSelect_statement(pTableRef->getChild(0)); // query_exp SQL_TOKEN_UNION all query_term + else + {// nyi: tiefere Verschachtelung m"oglch + CallError(4); + } + } + return pTableName; +} +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::getSelect_statement(OSQLParseNode *pSelect) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + if(SQL_ISRULE(pSelect,union_statement)) + { + getSelect_statement(pSelect->getChild(0)); + //getSelect_statement(pSelect->getChild(3)); + return; + } + OSQLParseNode * pTableRefCommalist = pSelect->getChild(3)->getChild(0)->getChild(1); + + DBG_ASSERT(pTableRefCommalist != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(SQL_ISRULE(pTableRefCommalist,table_ref_commalist),"OSQLParseTreeIterator: Fehler im Parse Tree"); + + OSQLParseNode * pTableName = NULL; + String aTableRange; + for (ULONG i = 0; i < pTableRefCommalist->count(); i++) + { // from clause durchlaufen + aTableRange.Erase(); + + if (SQL_ISRULE(pTableRefCommalist->getChild(i),table_name)) + { + pTableName = pTableRefCommalist->getChild(i); + traverseOneTableName(pTableName,aTableRange);// Keine Range Variable + } + else if (SQL_ISRULE(pTableRefCommalist->getChild(i),table_ref)) + { + // Tabellenreferenz kann aus Tabellennamen, Tabellennamen (+),'('joined_table')'(+) bestehen + pTableName = pTableRefCommalist->getChild(i)->getChild(0); + if (SQL_ISRULE(pTableName,table_name)) + { // Tabellennamen gefunden + if(pTableRefCommalist->getChild(i)->count() == 4) // Tabellenrange an Pos 2 + aTableRange = pTableRefCommalist->getChild(i)->getChild(2)->getTokenValue(); + traverseOneTableName(pTableName,aTableRange); + } + else if(SQL_ISPUNCTUATION(pTableName,"{")) + getQualified_join(pTableRefCommalist->getChild(i)->getChild(2),aTableRange); + else // '(' joined_table ')' as range_variable op_column_commalist + getTableRef(pTableRefCommalist->getChild(i),aTableRange); + } + else if (SQL_ISRULE(pTableRefCommalist->getChild(i),qualified_join) || SQL_ISRULE(pTableRefCommalist->getChild(i),cross_union) ) + { + // qualified_join oder cross_union vorhanden + getQualified_join(pTableRefCommalist->getChild(i),aTableRange); + } + else if (SQL_ISRULE(pTableRefCommalist->getChild(i),joined_table)) + { + // '(' qualified_join ')' + getQualified_join(pTableRefCommalist->getChild(i)->getChild(1),aTableRange); + } + else + { + CallError(3,aTableRange); + } + + // if (! aIteratorStatus.IsSuccessful()) break; + } +} +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::traverseTableNames() +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // aIteratorStatus.Clear(); + + if (m_pParseTree == NULL) { + //aIteratorStatus.setInvalidStatement(); + CallError(3); + return; + } + + OSQLParseNode * pTableName = NULL; + String aTableRange; + + // pTableName auf den (einzigen) Tabellennamen im Statement setzen. + // Je nach Statement (SELECT, INSERT, UPDATE, DELETE) an anderer Position. + // Bei Select koennen mehrere Tabellennamen auftreten, bei den uebrigen Statements + // ist ohnehin immer nur einer moeglich. + + if (m_eStatementType == SQL_STATEMENT_SELECT) + { + OSQLParseNode *pTmp = (OSQLParseNode *)m_pParseTree; + getSelect_statement(pTmp); + } + else if (m_eStatementType == SQL_STATEMENT_INSERT) + { + pTableName = m_pParseTree->getChild(2); + traverseOneTableName(pTableName,aTableRange); + } + else if (m_eStatementType == SQL_STATEMENT_UPDATE) + { + pTableName = m_pParseTree->getChild(1); + traverseOneTableName(pTableName,aTableRange); + } + else if (m_eStatementType == SQL_STATEMENT_DELETE) + { + pTableName = m_pParseTree->getChild(2); + traverseOneTableName(pTableName,aTableRange); + } else + { + CallError(5,aTableRange); + } +} +//----------------------------------------------------------------------------- +String OSQLParseTreeIterator::getColumnAlias(const OSQLParseNode* pDerivedColumn) const +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + String aColumnAlias; + if(pDerivedColumn->getChild(1)->count() == 2) + aColumnAlias = pDerivedColumn->getChild(1)->getChild(1)->getTokenValue(); + else if(!pDerivedColumn->getChild(1)->isRule()) + aColumnAlias = pDerivedColumn->getChild(1)->getTokenValue(); + return aColumnAlias; +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::getColumnRange(const OSQLParseNode* pColumnRef,String &rColumnName,String &rTableRange) const +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + rColumnName.Erase(); + rTableRange.Erase(); + if(SQL_ISRULE(pColumnRef,column_ref))// ab hier ist es sicher eine Columnref + { + if(pColumnRef->count() > 1) + { + for(INT32 i=0;i<((INT32)pColumnRef->count())-2;i++) // mu"s signed sein, falls count == 1 + pColumnRef->getChild(i)->parseNodeToStr(rTableRange,m_xDatabaseMetaData,NULL,FALSE,FALSE); + // Spaltenname + rColumnName = pColumnRef->getChild(pColumnRef->count()-1)->getChild(0)->getTokenValue(); + } + else + rColumnName = pColumnRef->getChild(0)->getTokenValue(); + } + else if(SQL_ISRULE(pColumnRef,general_set_fct) || SQL_ISRULE(pColumnRef,set_fct_spec)) + { // Funktion + pColumnRef->parseNodeToStr(rColumnName,m_xDatabaseMetaData); + } + else if(pColumnRef->getNodeType() == SQL_NODE_NAME) + rColumnName = pColumnRef->getTokenValue(); +} + +//----------------------------------------------------------------------------- +BOOL OSQLParseTreeIterator::getColumnTableRange(const OSQLParseNode* pNode, String &rTableRange) const +{ + // Ermitteln ob alle Spalten zu einer Tabelle gehoeren + if (SQL_ISRULE(pNode,column_ref)) + { + String aColName, aTableRange; + getColumnRange(pNode, aColName, aTableRange); + if (!aTableRange.Len()) // keinen gefunden + { + // dann die Spalte in den Tabellen suchen + for (ConstOSQLTablesIterator aIter = m_aTables.begin(); aIter != m_aTables.end(); ++aIter) + { + if (aIter->second.is()) + { + try + { + Reference< XNameAccess > xColumns = aIter->second->getColumns(); + Any aColumn(xColumns->getByName(aColName)); + Reference< XFastPropertySet > xColumn; + + if (aColumn >>= xColumn) + { + aTableRange = aIter->first; + break; + } + } + catch(...) + { + } + } + } + if (!aTableRange.Len()) + return FALSE; + } + + + if (!rTableRange.Len()) + rTableRange = aTableRange; + else if (rTableRange != aTableRange) + return FALSE; + } + else + { + for (UINT32 i = 0, ncount = pNode->count(); i < ncount; i++) + { + if (!getColumnTableRange(pNode->getChild(i), rTableRange)) + return FALSE; + } + } + return TRUE; +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::traverseSelectColumnNames(const OSQLParseNode* pSelectNode) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // aIteratorStatus.Clear(); + + if (!pSelectNode || m_eStatementType != SQL_STATEMENT_SELECT || !m_aTables.size()) + { + //aIteratorStatus.setInvalidStatement(); + CallError(3); + return; + } + + if(SQL_ISRULE(pSelectNode,union_statement)) + { + traverseSelectColumnNames(pSelectNode->getChild(0)); +// traverseSelectColumnNames(pSelectNode->getChild(3)); + return; + } + + // nyi: mehr Pruefung auf korrekte Struktur! + if (pSelectNode->getChild(2)->isRule() && SQL_ISPUNCTUATION(pSelectNode->getChild(2)->getChild(0),"*")) + { + // SELECT * ... + setSelectColumnName(String::CreateFromAscii("*"), aEmptyString,aEmptyString); + } + else if (SQL_ISRULE(pSelectNode->getChild(2),scalar_exp_commalist)) + { + // SELECT column(,column) oder SELECT COUNT(*) ... + OSQLParseNode * pSelection = pSelectNode->getChild(2); + + for (ULONG i = 0; i < pSelection->count(); i++) + { + OSQLParseNode *pColumnRef = pSelection->getChild(i); + + if (SQL_ISRULE(pColumnRef,select_sublist)) + { + // alle Spalten der Tabelle + String aTableRange; + pColumnRef->getChild(0)->parseNodeToStr(aTableRange,m_xDatabaseMetaData,NULL,FALSE,FALSE); + setSelectColumnName(String::CreateFromAscii("*"), aEmptyString,aTableRange); + continue; + }else if (SQL_ISRULE(pColumnRef,derived_column)) + { + String aColumnAlias(getColumnAlias(pColumnRef)); // kann leer sein + String aColumnName; + String aTableRange; + BOOL bFkt(FALSE); + pColumnRef = pColumnRef->getChild(0); + if (SQL_ISRULE(pColumnRef,column_ref)) + { + getColumnRange(pColumnRef,aColumnName,aTableRange); + DBG_ASSERT(aColumnName.Len(),"Columnname darf nicht leer sein"); + } + else /*if (SQL_ISRULE(pColumnRef,general_set_fct) || SQL_ISRULE(pColumnRef,set_fct_spec) || + SQL_ISRULE(pColumnRef,position_exp) || SQL_ISRULE(pColumnRef,extract_exp) || + SQL_ISRULE(pColumnRef,length_exp) || SQL_ISRULE(pColumnRef,char_value_fct)|| + SQL_ISRULE(pColumnRef,num_value_exp) || SQL_ISRULE(pColumnRef,term))*/ + { + /* Funktionsaufruf vorhanden */ + pColumnRef->parseNodeToStr(aColumnName,m_xDatabaseMetaData,NULL,FALSE,TRUE); + + // gehoeren alle beteiligten Spalten der Funktion zu einer Tabelle + if (m_aTables.size() == 1) + { + aTableRange = m_aTables.begin()->first; + } + else + { + getColumnTableRange(pColumnRef,aTableRange); + } + bFkt = TRUE; + } + /* + else + { + aIteratorStatus.setStatementTooComplex(); + return; + } + */ + if(!aColumnAlias.Len()) + aColumnAlias = aColumnName; + setSelectColumnName(aColumnName,aColumnAlias,aTableRange,bFkt); + } + } + + } else + { + //aIteratorStatus.setInvalidStatement(); + CallError(3); + } +} + + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::traverseOrderByColumnNames(const OSQLParseNode* pSelectNode) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // aIteratorStatus.Clear(); + + if (pSelectNode == NULL) + { + //aIteratorStatus.setInvalidStatement(); + CallError(3); + return; + } + + if (m_eStatementType != SQL_STATEMENT_SELECT) + { + CallError(3); + //aIteratorStatus.setInvalidStatement(); + return; + } + + if(SQL_ISRULE(pSelectNode,union_statement)) + { + traverseOrderByColumnNames(pSelectNode->getChild(0)); + //traverseOrderByColumnNames(pSelectNode->getChild(3)); + return; + } + + DBG_ASSERT(pSelectNode->count() >= 4,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + OSQLParseNode * pTableExp = pSelectNode->getChild(3); + DBG_ASSERT(pTableExp != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(pTableExp->count() == 5,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + OSQLParseNode * pOptOrderByClause = pTableExp->getChild(4); + DBG_ASSERT(pOptOrderByClause != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(SQL_ISRULE(pOptOrderByClause,opt_order_by_clause),"OSQLParseTreeIterator: Fehler im Parse Tree"); + if (pOptOrderByClause->count() == 0) + return; + + DBG_ASSERT(pOptOrderByClause->count() == 3,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + OSQLParseNode * pOrderingSpecCommalist = pOptOrderByClause->getChild(2); + DBG_ASSERT(pOrderingSpecCommalist != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(pOrderingSpecCommalist->count() > 0,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + String aColumnName,aColumnAlias; + String aTableRange; + for (UINT32 i = 0; i < pOrderingSpecCommalist->count(); i++) + { + OSQLParseNode * pOrderingSpec = pOrderingSpecCommalist->getChild(i); + DBG_ASSERT(pOrderingSpec != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(SQL_ISRULE(pOrderingSpec,ordering_spec),"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(pOrderingSpec->count() == 2,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + OSQLParseNode * pColumnRef = pOrderingSpec->getChild(0); + aTableRange.Erase(); + aColumnName.Erase(); + if(SQL_ISRULE(pColumnRef,column_ref)) + { + // Column-Name (und TableRange): + if(SQL_ISRULE(pColumnRef,column_ref)) + getColumnRange(pColumnRef,aColumnName,aTableRange); + else // eine Expression + pColumnRef->parseNodeToStr(aColumnName,m_xDatabaseMetaData,NULL,FALSE,FALSE); + + DBG_ASSERT(aColumnName.Len(),"aColumnName darf nicht leer sein"); + } + else + { // here I found a predicate + pColumnRef->parseNodeToStr(aColumnName,m_xDatabaseMetaData,NULL,FALSE,FALSE); + } + DBG_ASSERT(pColumnRef != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + // Ascending/Descending + OSQLParseNode * pOptAscDesc = pOrderingSpec->getChild(1); + DBG_ASSERT(pOptAscDesc != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + BOOL bAscending = TRUE; + if(pOptAscDesc) + { + if (SQL_ISTOKEN(pOptAscDesc,ASC)) + bAscending = TRUE; + else if (SQL_ISTOKEN(pOptAscDesc,DESC)) + bAscending = FALSE; + } + + setOrderByColumnName(aColumnName, aTableRange,bAscending); +// if (! aIteratorStatus.IsSuccessful()) +// return; + + } +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::traverseSelectionCriteria(const OSQLParseNode* pSelectNode) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // aIteratorStatus.Clear(); + + if (pSelectNode == NULL) + { + CallError(3); + //aIteratorStatus.setInvalidStatement(); + return; + } + + + // Parse Tree analysieren (je nach Statement-Typ) + // und Zeiger auf WHERE-Klausel setzen: + OSQLParseNode * pWhereClause = NULL; + + if (m_eStatementType == SQL_STATEMENT_SELECT) + { + if(SQL_ISRULE(pSelectNode,union_statement)) + { + traverseSelectionCriteria(pSelectNode->getChild(0)); + traverseSelectionCriteria(pSelectNode->getChild(3)); + return; + } + DBG_ASSERT(pSelectNode->count() >= 4,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + OSQLParseNode * pTableExp = pSelectNode->getChild(3); + DBG_ASSERT(pTableExp != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(pTableExp->count() == 5,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + pWhereClause = pTableExp->getChild(1); + } else if (SQL_ISRULE(pSelectNode,update_statement_searched)) { + DBG_ASSERT(pSelectNode->count() == 5,"OSQLParseTreeIterator: Fehler im Parse Tree"); + pWhereClause = pSelectNode->getChild(4); + } else if (SQL_ISRULE(pSelectNode,update_statement_positioned)) { + // nyi + DBG_ERROR("OSQLParseTreeIterator::getSelectionCriteria: positioned nyi"); + } else if (SQL_ISRULE(pSelectNode,delete_statement_searched)) { + DBG_ASSERT(pSelectNode->count() == 4,"OSQLParseTreeIterator: Fehler im Parse Tree"); + pWhereClause = pSelectNode->getChild(3); + } else if (SQL_ISRULE(pSelectNode,delete_statement_positioned)) { + // nyi + DBG_ERROR("OSQLParseTreeIterator::getSelectionCriteria: positioned nyi"); + } else { + // Anderes Statement. Keine Selektionskriterien. + return; + } + + if (! SQL_ISRULE(pWhereClause,where_clause)) { + // Die Where Clause ist meistens optional, d. h. es koennte sich auch + // um "optional_where_clause" handeln. + DBG_ASSERT(SQL_ISRULE(pWhereClause,opt_where_clause),"OSQLParseTreeIterator: Fehler im Parse Tree"); + return; + } + + // Wenn es aber eine where_clause ist, dann darf sie nicht leer sein: + DBG_ASSERT(pWhereClause->count() == 2,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + OSQLParseNode * pComparisonPredicate = pWhereClause->getChild(1); + DBG_ASSERT(pComparisonPredicate != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + + // + // Und nun die Vergleichskriterien abarbeiten (rekursiv, alles ist erstmal ein OR-Kriterium): + // + setORCriteriaPre(); + // if (! aIteratorStatus.IsSuccessful()) return; + + traverseORCriteria(pComparisonPredicate); + // if (! aIteratorStatus.IsSuccessful()) return; + + setORCriteriaPost(); + + // Fehler wird ggf. einfach weitergereicht. +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::traverseORCriteria(OSQLParseNode * pSearchCondition) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + + if ( + pSearchCondition->count() == 3 && + SQL_ISPUNCTUATION(pSearchCondition->getChild(0),"(") && + SQL_ISPUNCTUATION(pSearchCondition->getChild(2),")") + ) + { + // Runde Klammern um den Ausdruck + traverseORCriteria(pSearchCondition->getChild(1)); + } else if (SQL_ISRULE(pSearchCondition,search_condition) && + pSearchCondition->count() == 3 && + SQL_ISTOKEN(pSearchCondition->getChild(1),OR)) + { + // OR-Verknuepfung: + + for (int i = 0; i < 3; i++) { + if (i == 1) continue; // Schluesselwort OR ueberspringen + + // Ist das erste Element wieder eine OR-Verknuepfung? + if (i == 0 && + SQL_ISRULE(pSearchCondition->getChild(0),search_condition) && + pSearchCondition->getChild(0)->count() == 3 && + SQL_ISTOKEN(pSearchCondition->getChild(0)->getChild(1),OR)) + { + // Dann rekursiv absteigen ... + traverseORCriteria(pSearchCondition->getChild(0)); + + } else { + // AND-Kriterien ... + setANDCriteriaPre(); + // if (! aIteratorStatus.IsSuccessful()) break; + + traverseANDCriteria(pSearchCondition->getChild(i)); + // if (! aIteratorStatus.IsSuccessful()) break; + + setANDCriteriaPost(); + } + + // if (! aIteratorStatus.IsSuccessful()) break; + } + } else { + // Nur *ein* Kriterium oder eine AND-Verknuepfung von Kriterien. + // Direkt die AND-Kriterien behandeln. + setANDCriteriaPre(); + // if (! aIteratorStatus.IsSuccessful()) return; + + traverseANDCriteria(pSearchCondition); + // if (! aIteratorStatus.IsSuccessful()) return; + + setANDCriteriaPost(); + } + + // Fehler einfach weiterreichen. +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::traverseANDCriteria(OSQLParseNode * pSearchCondition) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + + if ( + SQL_ISRULE(pSearchCondition,boolean_primary) && + pSearchCondition->count() == 3 && + SQL_ISPUNCTUATION(pSearchCondition->getChild(0),"(") && + SQL_ISPUNCTUATION(pSearchCondition->getChild(2),")") + ) + { + // Runde Klammern + traverseANDCriteria(pSearchCondition->getChild(1)); + } + // Das erste Element ist eine OR-Verknuepfung + else if ( SQL_ISRULE(pSearchCondition,search_condition) && pSearchCondition->count() == 3 ) + { + // Dann rekursiv absteigen (dieselbe Row benutzen) ... + traverseORCriteria(pSearchCondition->getChild(0)); +// if (! aIteratorStatus.IsSuccessful()) +// return; + + // Und mit dem rechten Child weitermachen: + traverseANDCriteria(pSearchCondition->getChild(2)); + } + // Das erste Element ist (wieder) eine AND-Verknuepfung + else if ( SQL_ISRULE(pSearchCondition,boolean_term) && pSearchCondition->count() == 3 ) + { + // Dann rekursiv absteigen (dieselbe Row benutzen) ... + traverseANDCriteria(pSearchCondition->getChild(0)); +// if (! aIteratorStatus.IsSuccessful()) +// return; + + // Und mit dem rechten Child weitermachen: + traverseANDCriteria(pSearchCondition->getChild(2)); + } + // Sonst einzelne Suchkriterien wie =, !=, ..., LIKE, IS NULL usw. behandeln: + else if (SQL_ISRULE(pSearchCondition,comparison_predicate) ) + { + OSQLPredicateType ePredicateType; + OSQLParseNode *pPrec = pSearchCondition->getChild(1); + if (pPrec->getNodeType() == SQL_NODE_EQUAL) + ePredicateType = SQL_PRED_EQUAL; + else if (pPrec->getNodeType() == SQL_NODE_NOTEQUAL) + ePredicateType = SQL_PRED_NOTEQUAL; + else if (pPrec->getNodeType() == SQL_NODE_LESS) + ePredicateType = SQL_PRED_LESS; + else if (pPrec->getNodeType() == SQL_NODE_LESSEQ) + ePredicateType = SQL_PRED_LESSOREQUAL; + else if (pPrec->getNodeType() == SQL_NODE_GREATEQ) + ePredicateType = SQL_PRED_GREATEROREQUAL; + else if (pPrec->getNodeType() == SQL_NODE_GREAT) + ePredicateType = SQL_PRED_GREATER; + + String aValue; + pSearchCondition->getChild(2)->parseNodeToStr(aValue,m_xDatabaseMetaData,NULL,FALSE,FALSE); + traverseOnePredicate(pSearchCondition->getChild(0),ePredicateType,aValue,FALSE,pSearchCondition->getChild(2)); +// if (! aIteratorStatus.IsSuccessful()) +// return; + } + else if (SQL_ISRULE(pSearchCondition,like_predicate) /*&& SQL_ISRULE(pSearchCondition->getChild(0),column_ref)*/) + { + OSQLPredicateType ePredicateType; + + DBG_ASSERT(pSearchCondition->count() >= 5,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + OSQLParseNode * pNum_value_exp = pSearchCondition->getChild(3); + OSQLParseNode * pOptEscape = pSearchCondition->getChild(4); + + if (pSearchCondition->getChild(1)->getTokenID() == SQL_TOKEN_NOT) + ePredicateType = SQL_PRED_NOTLIKE; + else + ePredicateType = SQL_PRED_LIKE; + + DBG_ASSERT(pNum_value_exp != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(pOptEscape != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + if (pOptEscape->count() != 0) + { + // aIteratorStatus.setStatementTooComplex(); + return; + } + + String aValue; + OSQLParseNode * pParam = NULL; + if (SQL_ISRULE(pNum_value_exp,parameter)) + pParam = pNum_value_exp; + else if(pNum_value_exp->isToken()) + // Normaler Wert + aValue = pNum_value_exp->getTokenValue(); + else + { + pNum_value_exp->parseNodeToStr(aValue,m_xDatabaseMetaData,NULL,FALSE,FALSE); + pParam = pNum_value_exp; + } + + traverseOnePredicate(pSearchCondition->getChild(0),ePredicateType,aValue,FALSE,pParam); +// if (! aIteratorStatus.IsSuccessful()) +// return; + } + else if (SQL_ISRULE(pSearchCondition,test_for_null) /*&& SQL_ISRULE(pSearchCondition->getChild(0),column_ref)*/) + { + OSQLPredicateType ePredicateType; + + DBG_ASSERT(pSearchCondition->count() >= 3,"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(SQL_ISTOKEN(pSearchCondition->getChild(1),IS),"OSQLParseTreeIterator: Fehler im Parse Tree") + + if (SQL_ISTOKEN(pSearchCondition->getChild(2),NOT) ) + ePredicateType = SQL_PRED_ISNOTNULL; + else + ePredicateType = SQL_PRED_ISNULL; + + String aString; + traverseOnePredicate(pSearchCondition->getChild(0),ePredicateType,aString,TRUE,NULL); + // if (! aIteratorStatus.IsSuccessful()) return; + } else { + // Etwas anderes unterstuetzen wir (noch) nicht. Basta! + // aIteratorStatus.setStatementTooComplex(); + } + // Fehler einfach weiterreichen. +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::traverseOnePredicate( + OSQLParseNode * pColumnRef, + OSQLPredicateType ePredicateType, + String& rValue, + BOOL bCompareNull, + OSQLParseNode * pParseNode) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + + // Column-Name (und TableRange): + String aColumnName; + String aTableRange; + getColumnRange(pColumnRef,aColumnName,aTableRange); + + String aName; + if (pParseNode) //event. Parameter, oder Columnref oder + { + if (SQL_ISRULE(pParseNode,parameter)) + { + DBG_ASSERT(pParseNode->count() > 0,"OSQLParseTreeIterator: Fehler im Parse Tree"); + OSQLParseNode * pMark = pParseNode->getChild(0); + + String aParameterName; + if (SQL_ISPUNCTUATION(pMark,"?")) + { + // Name = "?", da kein Parametername verfuegbar (z. B. bei Native SQL) + rValue = '?'; + aName = '?'; + } + else if (SQL_ISPUNCTUATION(pMark,":")) + { + rValue = pParseNode->getChild(1)->getTokenValue(); + aName = ':'; + } + else if (SQL_ISPUNCTUATION(pMark,"[")) + { + rValue = pParseNode->getChild(1)->getTokenValue(); + aName = '['; + } + else + { + DBG_ERROR("OSQLParseTreeIterator: Fehler im Parse Tree"); + } + } + else if (SQL_ISRULE(pParseNode,column_ref))// Column-Name (und TableRange): + getColumnRange(pParseNode,aName,rValue); + } + + // "set"-Routine aufrufen ... + if (bCompareNull) { + // nyi: was soll das? Vergleich auf NULL geht nur ueber IS NULL oder IS NOT NULL! + setPredicate(aColumnName, aTableRange,ePredicateType, String(), String()); + } else { + setPredicate(aColumnName, aTableRange, ePredicateType, rValue, aName); + } + + // Fehler einfach weiterreichen ... +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::traverseAssignments() +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + + DBG_ERROR("OSQLParseTreeIterator::traverseAssignments: noch nicht implementiert"); +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::traverseAll() +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + + traverseTableNames(); + // if (! aIteratorStatus.IsSuccessful()) return; + + if (m_eStatementType == SQL_STATEMENT_SELECT) + { + const OSQLParseNode* pSelectNode = m_pParseTree; + traverseSelectColumnNames(pSelectNode); +// if (! aIteratorStatus.IsSuccessful()) +// return; + traverseOrderByColumnNames(pSelectNode); +// if (! aIteratorStatus.IsSuccessful()) +// return; + traverseSelectionCriteria(pSelectNode); + // if (! aIteratorStatus.IsSuccessful()) + // return; + } + else if (m_eStatementType == SQL_STATEMENT_INSERT || m_eStatementType == SQL_STATEMENT_UPDATE) + { + traverseAssignments(); + // if (! aIteratorStatus.IsSuccessful()) + // return; + } else if (m_eStatementType == SQL_STATEMENT_INSERT) { + // schon alles erledigt + } else { + CallError(3); + //aIteratorStatus.setInvalidStatement(); + } +} + +// Dummy-Implementationen: + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::setTableName(const String & rTableName, const String & rDBName, const String& rOwner, + const String & rTableRange) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // nichts zu tun ... + +#ifdef SQL_TEST_PARSETREEITERATOR + cout << "OSQLParseTreeIterator::setTableName" + << (const char *) rTableName << ", " + << (const char *) rSchemaName << ", " + << (const char *) rTableRange + << "\n"; +#endif +} +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::appendColumns(const OSQLTable& _rTable) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + if (!_rTable.is()) + return; + + Reference<XNameAccess> xColumns = _rTable->getColumns(); + + Sequence< ::rtl::OUString > aColNames = xColumns->getElementNames(); + const ::rtl::OUString* pBegin = aColNames.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aColNames.getLength(); + + for(;pBegin != pEnd;++pBegin) + { + OSQLColumns::const_iterator aIter = find(m_aSelectColumns->begin(),m_aSelectColumns->end(),*pBegin,m_aCaseEqual); + ::rtl::OUString aName(*pBegin); + sal_Int32 i=1; + while(aIter != m_aSelectColumns->end()) + { + aName = *pBegin + ::rtl::OUString::valueOf(i++); + aIter = find(m_aSelectColumns->begin(),m_aSelectColumns->end(),aName,m_aCaseEqual); + } + Reference< XFastPropertySet > xColumn; + if(xColumns->getByName(*pBegin) >>= xColumn) + { + OParseColumn* pColumn = new OParseColumn(xColumn,m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()); + // pColumn->setTableName(aIter->first); + pColumn->setRealName(aName); + Reference< XFastPropertySet> xCol = pColumn; + m_aSelectColumns->push_back(xCol); + } + } +} +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::setSelectColumnName(const String & rColumnName,const String & rColumnAlias, const String & rTableRange,BOOL bFkt) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + if(rColumnName.GetChar(0) == '*' && !rTableRange.Len()) + { // Suche "uber alle vorkommenden Tabellen + for(ConstOSQLTablesIterator aIter = m_aTables.begin(); aIter != m_aTables.end();++aIter) + appendColumns(aIter->second); + } + else if(rColumnName.GetChar(0) == '*' && rTableRange.Len()) // alle Columns aus dieser Tabelle + { + ConstOSQLTablesIterator aFind = m_aTables.find(rTableRange); + + if(aFind == m_aTables.end()) + { + String strExpression = rTableRange; + strExpression += '.'; + strExpression += rColumnName; + CallError(2, strExpression); + } + else + appendColumns(aFind->second); + } + else if(!rTableRange.Len())// ein Columnname existiert + { + if(!bFkt) + { + + UINT32 ncount = m_aSelectColumns->size(); + for(OSQLTablesIterator aIter = m_aTables.begin(); aIter != m_aTables.end(); ++aIter) + { + if (aIter->second.is()) + { + Reference<XNameAccess> xColumns = aIter->second->getColumns(); + + Reference< XFastPropertySet > xColumn; + if(xColumns->getByName(rColumnName) >>= xColumn) + { + String aNewColName(getUniqueColumnName(rColumnAlias)); + + OParseColumn* pColumn = new OParseColumn(xColumn,m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()); + pColumn->setTableName(aIter->first); + pColumn->setName(aNewColName); + pColumn->setRealName(rColumnName); + + Reference< XFastPropertySet> xCol = pColumn; + m_aSelectColumns->push_back(xCol); + continue; // diese Column darf nur einmal vorkommen + } + } + } + if (ncount == m_aSelectColumns->size()) + { + String strExpression = rTableRange; + if (strExpression.Len()) + strExpression += '.'; + strExpression += rColumnName; + CallError(2, strExpression); + } + } + else + { + String aNewColName(getUniqueColumnName(rColumnAlias)); + + OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(), + ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()); + pColumn->setFunction(bFkt); + pColumn->setRealName(rColumnName); + + Reference< XFastPropertySet> xCol = pColumn; + m_aSelectColumns->push_back(xCol); + } + } + else // ColumnName und Tablename vorhanden + { + ConstOSQLTablesIterator aFind = m_aTables.find(rTableRange); + + BOOL bError = FALSE; + if (aFind->second.is()) + { + + if (bFkt) + { + String aNewColName(getUniqueColumnName(rColumnAlias)); + + OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(), + ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()); + pColumn->setFunction(sal_True); + pColumn->setRealName(rColumnName); + pColumn->setTableName(aFind->first); + + Reference< XFastPropertySet> xCol = pColumn; + m_aSelectColumns->push_back(xCol); + } + else + { + Reference< XFastPropertySet > xColumn; + if (aFind->second->getColumns()->getByName(rColumnName) >>= xColumn) + { + String aNewColName(getUniqueColumnName(rColumnAlias)); + + OParseColumn* pColumn = new OParseColumn(xColumn,m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()); + pColumn->setName(aNewColName); + pColumn->setRealName(rColumnName); + pColumn->setTableName(aFind->first); + + Reference< XFastPropertySet> xCol = pColumn; + m_aSelectColumns->push_back(xCol); + } + else + bError = TRUE; + } + } + else + bError = TRUE; + + // Tabelle existiert nicht oder Feld nicht vorhanden + if (bError) + { + String strExpression = rTableRange; + if (strExpression.Len()) + strExpression += '.'; + strExpression += rColumnName; + if (!CallError(2, strExpression)) + return; + + String aNewColName(getUniqueColumnName(rColumnAlias)); + + OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(), + ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()); + pColumn->setFunction(sal_True); + + + Reference< XFastPropertySet> xCol = pColumn; + m_aSelectColumns->push_back(xCol); + } + } +} +//----------------------------------------------------------------------------- +String OSQLParseTreeIterator::getUniqueColumnName(const String & rColumnName) const +{ + ::rtl::OUString aAlias(rColumnName); + + OSQLColumns::const_iterator aIter = find(m_aSelectColumns->begin(),m_aSelectColumns->end(),aAlias,m_aCaseEqual); + sal_Int32 i=1; + while(aIter != m_aSelectColumns->end()) + { + (aAlias = rColumnName) += ::rtl::OUString::valueOf(i++); + aIter = find(m_aSelectColumns->begin(),m_aSelectColumns->end(),aAlias,m_aCaseEqual); + } + return aAlias; +} +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::setOrderByColumnName(const String & rColumnName, const String & rTableRange,BOOL bAscending) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // nichts zu tun ... + +#ifdef SQL_TEST_PARSETREEITERATOR + cout << "OSQLParseTreeIterator::setOrderByColumnName: " + << (const char *) rColumnName << ", " + << (const char *) rTableRange << ", " + << (bAscending ? "TRUE" : "FALSE") + << "\n"; +#endif +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::setORCriteriaPre() +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // nichts zu tun ... + +#ifdef SQL_TEST_PARSETREEITERATOR + cout << "OSQLParseTreeIterator::setORCriteriaPre\n"; +#endif +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::setORCriteriaPost() +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // nichts zu tun ... + +#ifdef SQL_TEST_PARSETREEITERATOR + cout << "OSQLParseTreeIterator::setORCriteriaPost\n"; +#endif +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::setANDCriteriaPre() +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // nichts zu tun ... + +#ifdef SQL_TEST_PARSETREEITERATOR + cout << "OSQLParseTreeIterator::setANDCriteriaPre\n"; +#endif +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::setANDCriteriaPost() +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // nichts zu tun ... + +#ifdef SQL_TEST_PARSETREEITERATOR + cout << "OSQLParseTreeIterator::setANDCriteriaPost\n"; +#endif +} + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::setPredicate(const String & rColumnName, + const String & rTableRange, + OSQLPredicateType ePredicateType, + const String & rValue, + const String & rParameterName) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // nichts zu tun ... + +#ifdef SQL_TEST_PARSETREEITERATOR + cout << "OSQLParseTreeIterator::setPredicate: " + << (const char *) rColumnName << ", " + << (const char *) rTableRange << ", " + << (char) ePredicateType << ", " + << (const char *) rValue << ", " + << (const char *) rParameterName + << "\n"; +#endif +} + + +//----------------------------------------------------------------------------- +void OSQLParseTreeIterator::setAssign(const String & rColumnName, + const String & rValue, BOOL bsetNull, + const String & rParameterName) +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + // nichts zu tun ... + +#ifdef SQL_TEST_PARSETREEITERATOR + cout << "OSQLParseTreeIterator::setAssign: " + << (const char *) rColumnName << ", " + << (const char *) rValue << ", " + << (bsetNull ? "TRUE" : "FALSE") << ", " + << (const char *) rParameterName + << "\n"; +#endif +} + +//----------------------------------------------------------------------------- +const OSQLParseNode* OSQLParseTreeIterator::getWhereTree() const +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + + if (!m_pParseTree) + return NULL; + + // Parse Tree analysieren (je nach Statement-Typ) + // und Zeiger auf WHERE-Klausel setzen: + OSQLParseNode * pWhereClause = NULL; + if(getStatementType() == SQL_STATEMENT_SELECT) + { + DBG_ASSERT(m_pParseTree->count() >= 4,"ParseTreeIterator: Fehler im Parse Tree"); + OSQLParseNode * pTableExp = m_pParseTree->getChild(3); + DBG_ASSERT(pTableExp != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(pTableExp->count() == 5,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + pWhereClause = pTableExp->getChild(1); + } + else if (SQL_ISRULE(m_pParseTree,update_statement_searched) || + SQL_ISRULE(m_pParseTree,delete_statement_searched)) + { + pWhereClause = m_pParseTree->getChild(m_pParseTree->count()-1); + } + if(pWhereClause->count() != 2) + pWhereClause = NULL; + return pWhereClause; +} + +//----------------------------------------------------------------------------- +const OSQLParseNode* OSQLParseTreeIterator::getOrderTree() const +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + + if (!m_pParseTree || getStatementType() != SQL_STATEMENT_SELECT) + return NULL; + + // Parse Tree analysieren (je nach Statement-Typ) + // und Zeiger auf ORDER-Klausel setzen: + OSQLParseNode * pOrderClause = NULL; + DBG_ASSERT(m_pParseTree->count() >= 4,"ParseTreeIterator: Fehler im Parse Tree"); + OSQLParseNode * pTableExp = m_pParseTree->getChild(3); + DBG_ASSERT(pTableExp != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(pTableExp->count() == 5,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + pOrderClause = pTableExp->getChild(4); + // Wenn es aber eine order_by ist, dann darf sie nicht leer sein: + if(pOrderClause->count() != 3) + pOrderClause = NULL; + return pOrderClause; +} +//----------------------------------------------------------------------------- +const OSQLParseNode* OSQLParseTreeIterator::getGroupByTree() const +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + + if (!m_pParseTree || getStatementType() != SQL_STATEMENT_SELECT) + return NULL; + + // Parse Tree analysieren (je nach Statement-Typ) + // und Zeiger auf ORDER-Klausel setzen: + OSQLParseNode * pGroupClause = NULL; + DBG_ASSERT(m_pParseTree->count() >= 4,"ParseTreeIterator: Fehler im Parse Tree"); + OSQLParseNode * pTableExp = m_pParseTree->getChild(3); + DBG_ASSERT(pTableExp != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(pTableExp->count() == 5,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + pGroupClause = pTableExp->getChild(3); + // Wenn es aber eine order_by ist, dann darf sie nicht leer sein: + if(pGroupClause->count() != 3) + pGroupClause = NULL; + return pGroupClause; +} +//----------------------------------------------------------------------------- +const OSQLParseNode* OSQLParseTreeIterator::getHavingTree() const +{ + DBG_CHKTHIS(OSQLParseTreeIterator,NULL); + + if (!m_pParseTree || getStatementType() != SQL_STATEMENT_SELECT) + return NULL; + + // Parse Tree analysieren (je nach Statement-Typ) + // und Zeiger auf ORDER-Klausel setzen: + OSQLParseNode * pHavingClause = NULL; + DBG_ASSERT(m_pParseTree->count() >= 4,"ParseTreeIterator: Fehler im Parse Tree"); + OSQLParseNode * pTableExp = m_pParseTree->getChild(3); + DBG_ASSERT(pTableExp != NULL,"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: Fehler im Parse Tree"); + DBG_ASSERT(pTableExp->count() == 5,"OSQLParseTreeIterator: Fehler im Parse Tree"); + + pHavingClause = pTableExp->getChild(3); + // Wenn es aber eine order_by ist, dann darf sie nicht leer sein: + if(pHavingClause->count() < 1) + pHavingClause = NULL; + return pHavingClause; +} +//----------------------------------------------------------------------------- +BOOL OSQLParseTreeIterator::CallError(USHORT nError,const String& rExpression) +{ +// SdbParseIteratorErrorInfo aErrorInfo; +// aErrorInfo.aStatus = rStatus; +// aErrorInfo.nErrorCode = nError; +// aErrorInfo.aExpression = rExpression; +// +// long nResult = aErrorHdl.Call(&aErrorInfo); +// if (nResult == RET_CONTINUE) + return TRUE; + +// if (nResult == RET_HANDLED) +// { +// // aIteratorStatus.set(SQL_STAT_SUCCESS); +// return FALSE; +// } +// +// aIteratorStatus = rStatus; +// return FALSE; +// +} + diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx new file mode 100644 index 000000000000..f35c06bf8f25 --- /dev/null +++ b/connectivity/source/parse/sqlnode.cxx @@ -0,0 +1,1399 @@ +/************************************************************************* + * + * $RCSfile: sqlnode.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_SQLNODE_HXX +#include <connectivity/sqlnode.hxx> +#endif +#ifndef _CONNECTIVITY_SQLPARSE_HXX +#include <connectivity/sqlparse.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_ +#include <com/sun/star/lang/Locale.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_ +#include <com/sun/star/util/XNumberFormatter.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_ +#include <com/sun/star/util/XNumberFormatTypes.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _TOOLS_INTN_HXX //autogen wg. International +#include <tools/intn.hxx> +#endif +#ifndef _ISOLANG_HXX +#include <tools/isolang.hxx> +#endif + +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::osl; +using namespace connectivity; + +extern Any getNumberFormatProperty(const Reference< XNumberFormatsSupplier > & xFormatter, + sal_Int32 nKey, + const rtl::OUString& ); +extern double ToDouble(const Time& rTime); +extern double ToDouble(const Reference< XNumberFormatsSupplier > & xSupplier, const Date& rDate); +extern String ConvertLikeToken(const OSQLParseNode* pTokenNode, const OSQLParseNode* pEscapeNode, sal_Bool bInternational); + +//------------------------------------------------------------------ +OSQLParseNode::SQLParseNodeParameter::SQLParseNodeParameter(const String& _rIdentifierQuote, const String& _rCatalogSep, + const Reference< XNumberFormatter > & _xFormatter, const Reference< XPropertySet > & _xField, const International& _rIntl, + const OParseContext* _pContext, sal_Bool _bIntl, sal_Bool _bQuote, char _cDecSep, + sal_Bool _bPredicate) + :aIdentifierQuote(_rIdentifierQuote) + ,aCatalogSeparator(_rCatalogSep) + ,rIntl(_rIntl) + ,rContext(_pContext ? *_pContext : OSQLParser::s_aDefaultContext) + ,bInternational(_bIntl) + ,bQuote(_bQuote) + ,cDecSep(_cDecSep) + ,xField(_xField) + ,xFormatter(_xFormatter) + ,bPredicate(_bPredicate) +{ +} + +//------------------------------------------------------------------ +String SetQuotation(const String& rValue, const String& rQuot, const String& rQuotToReplace) +{ + String rNewValue = rQuot; + rNewValue += rValue; + + xub_StrLen nIndex = (xub_StrLen)-1; // Quotes durch zweifache Quotes ersetzen, sonst kriegt der Parser Probleme + + if (rQuot.Len()) + { + do + { + nIndex+= 2; + nIndex = rNewValue.SearchAndReplace(rQuot,rQuotToReplace,nIndex); + } while (nIndex != STRING_NOTFOUND); + } + // rNewValue.SearchAndReplaceAll(rQuot,rQuotToReplace); + + rNewValue += rQuot; + return rNewValue; +} + + +//----------------------------------------------------------------------------- +String OSQLParseNode::convertDateString(const SQLParseNodeParameter& rParam, const String& rString) const +{ + xub_StrLen nIndex = 0; + sal_Int32 nYear = rString.GetToken(0,'-', nIndex).ToInt32(), + nMonth = rString.GetToken(0,'-', nIndex).ToInt32(), + nDay = rString.GetToken(0,'-', nIndex).ToInt32(); + + Date aDate(nDay,nMonth,nYear); + Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier()); + Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY); + + String sLanguage, sCountry; + ConvertLanguageToIsoNames(rParam.rIntl.GetLanguage(), sLanguage, sCountry); + Locale aLocale(sLanguage,sCountry,rtl::OUString()); + + double fDate = ToDouble(xSupplier, aDate); + sal_Int32 nKey = xTypes->getStandardIndex(aLocale) + 36; // XXX hack + return rParam.xFormatter->convertNumberToString(nKey, fDate); +} + +//----------------------------------------------------------------------------- +String OSQLParseNode::convertDateTimeString(const SQLParseNodeParameter& rParam, const String& rString) const +{ + xub_StrLen nIndex = 0; + sal_Int32 nYear = rString.GetToken(0,'-', nIndex).ToInt32(), + nMonth = rString.GetToken(0,'-', nIndex).ToInt32(), + nDay = rString.GetToken(0,'-', nIndex).ToInt32(); + + nIndex = 10; // eat white space + sal_Int32 nHour = rString.GetToken(0,':', nIndex).ToInt32(), + nMinute = rString.GetToken(0,':', nIndex).ToInt32(), + nSecond = rString.GetToken(0,':', nIndex).ToInt32(); + + Date aDate(nDay,nMonth,nYear); + Time aTime(nHour,nMinute,nSecond); + Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier()); + Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY); + + String sLanguage, sCountry; + ConvertLanguageToIsoNames(rParam.rIntl.GetLanguage(), sLanguage, sCountry); + Locale aLocale(sLanguage,sCountry,rtl::OUString()); + + double fDateTime = ToDouble(xSupplier, aDate) + ToDouble(aTime); + sal_Int32 nKey = xTypes->getStandardIndex(aLocale) + 51; // XXX hack + return rParam.xFormatter->convertNumberToString(nKey, fDateTime); +} + +//----------------------------------------------------------------------------- +String OSQLParseNode::convertTimeString(const SQLParseNodeParameter& rParam, const String& rString) const +{ + xub_StrLen nIndex = 0; + sal_Int32 nHour = rString.GetToken(0,':', nIndex).ToInt32(), + nMinute = rString.GetToken(0,':', nIndex).ToInt32(), + nSecond = rString.GetToken(0,':', nIndex).ToInt32(); + + Time aTime(nHour,nMinute,nSecond); + Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier()); + + Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY); + + String sLanguage, sCountry; + ConvertLanguageToIsoNames(rParam.rIntl.GetLanguage(), sLanguage, sCountry); + Locale aLocale(sLanguage,sCountry,rtl::OUString()); + + double fTime = ToDouble(aTime); + sal_Int32 nKey = xTypes->getStandardIndex(aLocale) + 41; // XXX hack + return rParam.xFormatter->convertNumberToString(nKey, fTime); +} + +DBG_NAME(OSQLParseNode); +//----------------------------------------------------------------------------- +OSQLParseNode::OSQLParseNode(const sal_Char * pNewValue, + SQLNodeType eNewNodeType, + sal_uInt32 nNewNodeID) + : m_aNodeValue(String::CreateFromAscii(pNewValue)) + , m_eNodeType(eNewNodeType) + , m_nNodeID(nNewNodeID) + , m_pParent(NULL) +{ + DBG_CTOR(OSQLParseNode,NULL); + DBG_ASSERT(m_eNodeType >= SQL_NODE_RULE && m_eNodeType <= SQL_NODE_ACCESS_DATE,"OSQLParseNode: mit unzulaessigem NodeType konstruiert"); +} +//----------------------------------------------------------------------------- +OSQLParseNode::OSQLParseNode(const ByteString &_rNewValue, + SQLNodeType eNewNodeType, + sal_uInt32 nNewNodeID) + : m_aNodeValue(String::CreateFromAscii(_rNewValue.GetBuffer())) + , m_eNodeType(eNewNodeType) + , m_nNodeID(nNewNodeID) + , m_pParent(NULL) +{ + DBG_CTOR(OSQLParseNode,NULL); + DBG_ASSERT(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) +{ + DBG_CTOR(OSQLParseNode,NULL); + DBG_ASSERT(m_eNodeType >= SQL_NODE_RULE && m_eNodeType <= SQL_NODE_ACCESS_DATE,"OSQLParseNode: mit unzulaessigem NodeType konstruiert"); +} +//----------------------------------------------------------------------------- +OSQLParseNode::OSQLParseNode(const String &_rNewValue, + SQLNodeType eNewNodeType, + sal_uInt32 nNewNodeID) + : m_aNodeValue(_rNewValue) + , m_eNodeType(eNewNodeType) + , m_nNodeID(nNewNodeID) + , m_pParent(NULL) +{ + DBG_CTOR(OSQLParseNode,NULL); + DBG_ASSERT(m_eNodeType >= SQL_NODE_RULE && m_eNodeType <= SQL_NODE_ACCESS_DATE,"OSQLParseNode: mit unzulaessigem NodeType konstruiert"); +} +//----------------------------------------------------------------------------- +OSQLParseNode::OSQLParseNode(const OSQLParseNode& rParseNode) +{ + DBG_CTOR(OSQLParseNode,NULL); + // 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 (::std::vector<OSQLParseNode*>::const_iterator i = rParseNode.m_aChilds.begin(); + i != rParseNode.m_aChilds.end(); i++) + append(new OSQLParseNode(**i)); +} + +//----------------------------------------------------------------------------- +OSQLParseNode& OSQLParseNode::operator=(const OSQLParseNode& rParseNode) +{ + DBG_CHKTHIS(OSQLParseNode,NULL); + + 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 (::std::vector<OSQLParseNode*>::const_iterator i = m_aChilds.begin(); + i != m_aChilds.end(); i++) + delete *i; + + m_aChilds.clear(); + + for (::std::vector<OSQLParseNode*>::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 +{ + DBG_CHKTHIS(OSQLParseNode,NULL); + + // 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() +{ + DBG_DTOR(OSQLParseNode,NULL); + + for (::std::vector<OSQLParseNode*>::const_iterator i = m_aChilds.begin(); + i != m_aChilds.end(); i++) + delete *i; +} + +//----------------------------------------------------------------------------- +void OSQLParseNode::append(OSQLParseNode* pNewNode) +{ + DBG_CHKTHIS(OSQLParseNode,NULL); + DBG_ASSERT(pNewNode != NULL, "OSQLParseNode: ungueltiger NewSubTree"); + DBG_ASSERT(pNewNode->getParent() == NULL, "OSQLParseNode: Knoten ist kein Waise"); + DBG_ASSERT(::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(String& rString, + const Reference< XDatabaseMetaData > & xMeta, + OParseContext* pContext, + sal_Bool _bIntl, + sal_Bool _bQuote) const +{ + DBG_CHKTHIS(OSQLParseNode,NULL); + parseNodeToStr(rString, xMeta, Reference< XNumberFormatter >(), + Reference< XPropertySet >(), OParseContext::getDefaultInternational(), pContext, _bIntl, _bQuote, '.', sal_False); +} + +//----------------------------------------------------------------------------- +void OSQLParseNode::parseNodeToPredicateStr(String& rString, + const Reference< XDatabaseMetaData > & xMeta, + const Reference< XNumberFormatter > & xFormatter, + const International& rIntl, + OParseContext* pContext ) const +{ + DBG_CHKTHIS(OSQLParseNode,NULL); + DBG_ASSERT(xFormatter.is(), "OSQLParseNode::parseNodeToPredicateStr:: no formatter!"); + + if (xFormatter.is()) + parseNodeToStr(rString, xMeta, xFormatter, Reference< XPropertySet >(), rIntl, pContext, sal_True, sal_True, rIntl.GetNumDecimalSep(), sal_True); +} + +//----------------------------------------------------------------------------- +void OSQLParseNode::parseNodeToPredicateStr(String& rString, + const Reference< XDatabaseMetaData > & xMeta, + const Reference< XNumberFormatter > & xFormatter, + const Reference< XPropertySet > & _xField, + const International& rIntl, + OParseContext* pContext ) const +{ + DBG_CHKTHIS(OSQLParseNode,NULL); + DBG_ASSERT(xFormatter.is(), "OSQLParseNode::parseNodeToPredicateStr:: no formatter!"); + + if (xFormatter.is()) + parseNodeToStr(rString, xMeta, xFormatter, _xField, rIntl, pContext, sal_True, sal_True, rIntl.GetNumDecimalSep(), sal_True); +} + +//----------------------------------------------------------------------------- +void OSQLParseNode::parseNodeToStr(String& rString, + const Reference< XDatabaseMetaData > & xMeta, + const Reference< XNumberFormatter > & xFormatter, + const Reference< XPropertySet > & _xField, + const International& rIntl, + OParseContext* pContext, + sal_Bool _bIntl, + sal_Bool _bQuote, + char _cDecSep, + sal_Bool bPredicate) const +{ + DBG_CHKTHIS(OSQLParseNode,NULL); + DBG_ASSERT(xMeta.is(), "OSQLParseNode::parseNodeToStr:: no meta data!"); + + if (xMeta.is()) + { + String aIdentifierQuote(xMeta->getIdentifierQuoteString()); + String aCatalogSeparator(xMeta->getCatalogSeparator()); + + OSQLParseNode::parseNodeToStr(rString, + SQLParseNodeParameter(aIdentifierQuote, aCatalogSeparator, xFormatter, _xField, rIntl, pContext, _bIntl, _bQuote, _cDecSep, bPredicate)); + } +} +//----------------------------------------------------------------------------- +void OSQLParseNode::parseNodeToStr(String& rString, const SQLParseNodeParameter& rParam) const +{ + DBG_CHKTHIS(OSQLParseNode,NULL); + + if (!isToken()) + { + // einmal auswerten wieviel Subtrees dieser Knoten besitzt + sal_uInt32 nCount = count(); + + // parameter erhalten sonderbehandlung + if (SQL_ISRULE(this,parameter)) + { + if(rString.Len()) + rString += ' '; + if (nCount == 1) // ? + m_aChilds[0]->parseNodeToStr(rString, rParam); + else if (nCount == 2) // :Name + { + m_aChilds[0]->parseNodeToStr(rString, rParam); + rString += m_aChilds[1]->m_aNodeValue; + } // [Name] + else + { + m_aChilds[0]->parseNodeToStr(rString, rParam); + rString += m_aChilds[1]->m_aNodeValue; + rString += m_aChilds[2]->m_aNodeValue; + } + } + + else if(SQL_ISRULE(this,table_ref) && + ((nCount == 4 && SQL_ISPUNCTUATION(m_aChilds[0],"("))|| (nCount == 6 && SQL_ISPUNCTUATION(m_aChilds[0],"(")))) + tableRangeNodeToStr(rString, rParam); + // je nachdem ob international angegeben wird oder nicht wird like anders behandelt + // interanational: *, ? sind Platzhalter + // sonst SQL92 konform: %, _ + else if (SQL_ISRULE(this,like_predicate)) + likeNodeToStr(rString, rParam); + + else if (SQL_ISRULE(this,general_set_fct) || SQL_ISRULE(this,set_fct_spec) || + SQL_ISRULE(this,position_exp) || SQL_ISRULE(this,extract_exp) || + SQL_ISRULE(this,length_exp) || SQL_ISRULE(this,char_value_fct)) + { + if (!addDateValue(rString, rParam)) + { + // Funktionsname nicht quoten + SQLParseNodeParameter aNewParam(rParam); + aNewParam.bQuote = sal_False; + + m_aChilds[0]->parseNodeToStr(rString, aNewParam); + String aStringPara; + for (sal_uInt32 i=1; i<nCount; i++) + { + const OSQLParseNode * pSubTree = m_aChilds[i]; + if (pSubTree) + { + pSubTree->parseNodeToStr(aStringPara, rParam); + + // bei den CommaListen zwischen alle Subtrees Commas setzen + if ((m_eNodeType == SQL_NODE_COMMALISTRULE) && (i < (nCount - 1))) + aStringPara += String(','); + } + } + aStringPara.EraseTrailingChars(' '); + rString += aStringPara; + } + } + else + { + for (::std::vector<OSQLParseNode*>::const_iterator i = m_aChilds.begin(); + i != m_aChilds.end();) + { + const OSQLParseNode* pSubTree = *i; + if (pSubTree) + { + SQLParseNodeParameter aNewParam(rParam); + + // don't replace the field for subqueries + if (rParam.xField.is() && SQL_ISRULE(pSubTree,subquery)) + aNewParam.xField = NULL; + + // if there is a field given we don't display the fieldname, if there are any + if (rParam.xField.is() && SQL_ISRULE(pSubTree,column_ref)) + { + sal_Bool bFilter = sal_False; + // retrieve the fields name + String aFieldName; + try + { + // retrieve the fields name + rtl::OUString aString; + rParam.xField->getPropertyValue(String::CreateFromAscii("Name")) >>= aString; + aFieldName = aString.getStr(); + } + catch ( ... ) + { + } + + const OSQLParseNode* pCol = pSubTree->m_aChilds[pSubTree->count()-1]; + if ((SQL_ISRULE(pCol,column_val) && pCol->getChild(0)->getTokenValue().EqualsIgnoreCaseAscii(aFieldName)) || + pCol->getTokenValue().EqualsIgnoreCaseAscii(aFieldName)) + bFilter = sal_True; + + // ok we found the field, if the following node is the + // comparision operator '=' we filter it as well + if (bFilter) + { + if (SQL_ISRULE(this, comparison_predicate)) + { + ++i; + if(i != m_aChilds.end()) + { + pSubTree = *i; + if (pSubTree && pSubTree->getNodeType() == SQL_NODE_EQUAL) + i++; + } + } + else + i++; + } + else + { + pSubTree->parseNodeToStr(rString, aNewParam); + i++; + + // bei den CommaListen zwischen alle Subtrees Commas setzen + if ((m_eNodeType == SQL_NODE_COMMALISTRULE) && (i != m_aChilds.end())) + rString += String(','); + } + } + else + { + pSubTree->parseNodeToStr(rString, aNewParam); + i++; + + // bei den CommaListen zwischen alle Subtrees Commas setzen + if ((m_eNodeType == SQL_NODE_COMMALISTRULE) && (i != m_aChilds.end())) + { + if (SQL_ISRULE(this,value_exp_commalist) && rParam.bPredicate) + rString += String(';'); + else + rString += String(','); + } + } + } + } + } + } + else + { + // ein Blatt ist gefunden + // Inhalt dem Ausgabestring anfuegen + switch (m_eNodeType) + { + case SQL_NODE_KEYWORD: + { + if (rString.Len()) + rString += ' '; + + rString += String::CreateFromAscii( + OSQLParser::TokenIDToStr(m_nNodeID, &const_cast<OParseContext&>(rParam.rContext)).GetBuffer()); + } break; + case SQL_NODE_STRING: + if (rString.Len()) + rString += ' '; + rString += SetQuotation(m_aNodeValue,String::CreateFromAscii("\'"),String::CreateFromAscii("\'\'")); + break; + case SQL_NODE_NAME: + if (rString.Len()) + { + switch(ByteString::ConvertFromUnicode(rString.GetChar((rString.Len()-1)),RTL_TEXTENCODING_ASCII_US) ) + { + case ' ' : + case '.' : break; + default : + if (!rParam.aCatalogSeparator.Len() || rString.GetChar((sal_uInt32)(rString.Len()-1)) != rParam.aCatalogSeparator.GetChar(0)) + rString += ' '; break; + } + } + if (rParam.bQuote) + { + if (rParam.bPredicate) + { + rString.AppendAscii("["); + rString += m_aNodeValue; + rString.AppendAscii("]"); + } + else + rString += SetQuotation(m_aNodeValue, rParam.aIdentifierQuote.GetChar(0), rParam.aIdentifierQuote.GetChar(0)); + } + else + rString += m_aNodeValue; + break; + case SQL_NODE_ACCESS_DATE: + if (rString.Len()) + rString += ' '; + rString += '#'; + rString += m_aNodeValue; + rString += '#'; + break; + case SQL_NODE_INTNUM: + case SQL_NODE_APPROXNUM: + { + String aTmp = m_aNodeValue; + if (rParam.bInternational && rParam.bPredicate && rParam.cDecSep != '.') + aTmp.SearchAndReplaceAll('.', rParam.cDecSep); + + if (rString.Len()) + rString += ' '; + rString += aTmp; + + } break; + // fall through + default: + if (rString.Len() && m_aNodeValue.GetChar(0) != '.' && m_aNodeValue.GetChar(0) != ':' ) + { + switch( ByteString::ConvertFromUnicode(rString.GetChar(rString.Len()-1),RTL_TEXTENCODING_ASCII_US) ) + { + case ' ' : + case '.' : break; + default : + if (!rParam.aCatalogSeparator.Len() || rString.GetChar(rString.Len()-1) != rParam.aCatalogSeparator.GetChar(0)) + rString += ' '; break; + } + } + rString += m_aNodeValue; + } + } +} + +//----------------------------------------------------------------------------- +sal_Bool OSQLParseNode::addDateValue(String& 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.Len()) + rString += ' '; + rString += '#'; + 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 += '#'; + return sal_True; + } + } + return sal_False; +} + +//----------------------------------------------------------------------------- +void OSQLParseNode::replaceNodeValue(const String& rTableAlias,const String& 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(String::CreateFromAscii("."),SQL_NODE_PUNCTUATION)); + append(pCol); + } + else + getChild(i)->replaceNodeValue(rTableAlias,rColumnName); + } +} + +//----------------------------------------------------------------------------- +void OSQLParseNode::tableRangeNodeToStr(String& rString, const SQLParseNodeParameter& rParam) const +{ + sal_uInt32 nCount(count()); + rString += ' '; + + SQLParseNodeParameter aNewParam(rParam); + aNewParam.bQuote = sal_False; + if (nCount == 4) + { + m_aChilds[0]->parseNodeToStr(rString, rParam); + m_aChilds[1]->parseNodeToStr(rString, rParam); + m_aChilds[2]->parseNodeToStr(rString, aNewParam); + m_aChilds[3]->parseNodeToStr(rString, rParam); + } + else if(nCount == 6 && SQL_ISPUNCTUATION(m_aChilds[0],"(")) + { + m_aChilds[0]->parseNodeToStr(rString, rParam); + m_aChilds[1]->parseNodeToStr(rString, rParam); + m_aChilds[2]->parseNodeToStr(rString, rParam); + m_aChilds[3]->parseNodeToStr(rString, rParam); + m_aChilds[4]->parseNodeToStr(rString, aNewParam); + m_aChilds[5]->parseNodeToStr(rString, rParam); + } +} + +//----------------------------------------------------------------------------- +void OSQLParseNode::likeNodeToStr(String& rString, const SQLParseNodeParameter& rParam) const +{ + DBG_ASSERT(count() == 5,"count != 5: Prepare for GPF"); + + const OSQLParseNode* pEscNode = NULL; + const OSQLParseNode* pParaNode = NULL; + + SQLParseNodeParameter aNewParam(rParam); + aNewParam.bQuote = sal_True; + + // if there is a field given we don't display the fieldname, if there are any + sal_Bool bAddName = sal_True; + if (rParam.xField.is()) + { + // retrieve the fields name + String aFieldName; + try + { + // retrieve the fields name + rtl::OUString aString; + rParam.xField->getPropertyValue(String::CreateFromAscii("Name")) >>= aString; + aFieldName = aString.getStr(); + } + catch ( ... ) + { + } + + const OSQLParseNode* pCol = m_aChilds[0]->getChild(m_aChilds[0]->count()-1); + if ((SQL_ISRULE(pCol,column_val) && pCol->getChild(0)->getTokenValue().EqualsIgnoreCaseAscii(aFieldName)) || + pCol->getTokenValue().EqualsIgnoreCaseAscii(aFieldName) ) + bAddName = sal_False; + } + + if (bAddName) + m_aChilds[0]->parseNodeToStr(rString, aNewParam); + + m_aChilds[1]->parseNodeToStr(rString, aNewParam); + m_aChilds[2]->parseNodeToStr(rString, aNewParam); + + pParaNode = m_aChilds[3]; + pEscNode = m_aChilds[4]; + + if (pParaNode->isToken() && rParam.bInternational) + { + String aStr = ConvertLikeToken(pParaNode, pEscNode, sal_True); + rString += ' '; + rString += SetQuotation(aStr,String::CreateFromAscii("\'"),String::CreateFromAscii("\'\'")); + } + else + pParaNode->parseNodeToStr(rString, aNewParam); + + 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 (::std::vector<OSQLParseNode*>::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(String(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_term)); + pNewNode->append(pLeftLeaf); + pNewNode->append(new OSQLParseNode(String::CreateFromAscii("AND"),SQL_NODE_KEYWORD,SQL_TOKEN_AND)); + pNewNode->append(pRightLeaf); + return pNewNode; +} +//----------------------------------------------------------------------------- +OSQLParseNode* MakeORNode(OSQLParseNode *pLeftLeaf,OSQLParseNode *pRightLeaf) +{ + OSQLParseNode* pNewNode = new OSQLParseNode(String(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::search_condition)); + pNewNode->append(pLeftLeaf); + pNewNode->append(new OSQLParseNode(String::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(String(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_term)); + pNewNode->append(pSearchCondition->removeAt((sal_uInt32)0)); + pNewNode->append(new OSQLParseNode(String::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(String(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::search_condition)); + pNewNode->append(pSearchCondition->removeAt((sal_uInt32)0)); + pNewNode->append(new OSQLParseNode(String::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(String::CreateFromAscii("<>"),SQL_NODE_NOTEQUAL,NOTEQUAL); + break; + case SQL_NODE_LESS: + pNewComparison = new OSQLParseNode(String::CreateFromAscii(">="),SQL_NODE_GREATEQ,GREATEQ); + break; + case SQL_NODE_GREAT: + pNewComparison = new OSQLParseNode(String::CreateFromAscii("<="),SQL_NODE_LESSEQ,LESSEQ); + break; + case SQL_NODE_LESSEQ: + pNewComparison = new OSQLParseNode(String::CreateFromAscii(">"),SQL_NODE_GREAT,GREAT); + break; + case SQL_NODE_GREATEQ: + pNewComparison = new OSQLParseNode(String::CreateFromAscii("<"),SQL_NODE_LESS,LESS); + break; + case SQL_NODE_NOTEQUAL: + pNewComparison = new OSQLParseNode(String::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(String::CreateFromAscii("NOT"),SQL_NODE_KEYWORD,SQL_TOKEN_NOT); + else + pNotNot = new OSQLParseNode(String(),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(String(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary)); + pNewRule->append(new OSQLParseNode(String::CreateFromAscii("("),SQL_NODE_PUNCTUATION)); + pNewRule->append(pNode); + pNewRule->append(new OSQLParseNode(String::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(String(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary)); + pNewRule->append(new OSQLParseNode(String::CreateFromAscii("("),SQL_NODE_PUNCTUATION)); + pNewRule->append(pNode); + pNewRule->append(new OSQLParseNode(String::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(String(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary)); + pNewRule->append(new OSQLParseNode(String::CreateFromAscii("("),SQL_NODE_PUNCTUATION)); + pNewRule->append(pNode); + pNewRule->append(new OSQLParseNode(String::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(String(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary)); + pNewRule->append(new OSQLParseNode(String::CreateFromAscii("("),SQL_NODE_PUNCTUATION)); + pNewRule->append(pNode); + pNewRule->append(new OSQLParseNode(String::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(String& rString, sal_uInt32 nLevel) +{ + DBG_CHKTHIS(OSQLParseNode,NULL); + + if (!isToken()) + { + for (sal_uInt32 j=0; j<nLevel; j++) {rString.AppendAscii("\t");}; + // Regelnamen als rule: ... + rString.AppendAscii("RULE_ID:\t "); + rString += (String) getRuleID(); + rString.AppendAscii("("); + rString += OSQLParser::RuleIDToStr(getRuleID()); + rString.AppendAscii(")"); + rString.AppendAscii("\n"); + + // einmal auswerten wieviel Subtrees dieser Knoten besitzt + sal_uInt32 nStop = count(); + // hol dir den ersten Subtree + for (::std::vector<OSQLParseNode*>::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.AppendAscii("\t");}; + + switch (m_eNodeType) { + + case SQL_NODE_KEYWORD: + {rString.AppendAscii("SQL_KEYWORD:\t"); + rString += String::CreateFromAscii(OSQLParser::TokenIDToStr(getTokenID()).GetBuffer()); + rString.AppendAscii("\n"); + break;} + + case SQL_NODE_COMPARISON: + {rString.AppendAscii("SQL_COMPARISON:\t"); + rString += m_aNodeValue; // haenge Nodevalue an + rString.AppendAscii("\n"); // und beginne neu Zeile + break;} + + case SQL_NODE_NAME: + {rString.AppendAscii("SQL_NAME:\t"); + rString.AppendAscii("\""); + rString += m_aNodeValue; + rString.AppendAscii("\""); + rString.AppendAscii("\n"); + break;} + + case SQL_NODE_STRING: + {rString .AppendAscii("SQL_STRING:\t'"); + rString += m_aNodeValue; + rString .AppendAscii("'\n"); + break;} + + case SQL_NODE_INTNUM: + {rString .AppendAscii("SQL_INTNUM:\t"); + rString += m_aNodeValue; + rString .AppendAscii("\n"); + break;} + + case SQL_NODE_APPROXNUM: + {rString .AppendAscii("SQL_APPROXNUM:\t"); + rString += m_aNodeValue; + rString .AppendAscii("\n"); + break;} + + case SQL_NODE_PUNCTUATION: + {rString .AppendAscii("SQL_PUNCTUATION:\t"); + rString += m_aNodeValue; // haenge Nodevalue an + rString .AppendAscii("\n"); // und beginne neu Zeile + break;} + + case SQL_NODE_AMMSC: + {rString .AppendAscii("SQL_AMMSC:\t"); + rString += m_aNodeValue; // haenge Nodevalue an + rString .AppendAscii("\n"); // und beginne neu Zeile + break;} + + default: + DBG_ERROR("OSQLParser::ShowParseTree: unzulaessiger NodeType"); + } + }; +} + +// Insert-Methoden +//----------------------------------------------------------------------------- +void OSQLParseNode::insert(sal_uInt32 nPos, OSQLParseNode* pNewSubTree) +{ + DBG_ASSERT(pNewSubTree != NULL, "OSQLParseNode: ungueltiger NewSubTree"); + DBG_ASSERT(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) +{ + ::std::vector<OSQLParseNode*>::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) +{ + DBG_ASSERT(pSubTree != NULL, "OSQLParseNode: ungueltiger SubTree"); + ::std::vector<OSQLParseNode*>::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) +{ + DBG_ASSERT(pNewSubNode != NULL, "OSQLParseNode: invalid nodes"); + DBG_ASSERT(pNewSubNode->getParent() == NULL, "OSQLParseNode: node already has getParent"); + DBG_ASSERT(nPos < m_aChilds.size(), "OSQLParseNode: invalid position"); + DBG_ASSERT(::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 ) +{ + DBG_ASSERT(pOldSubNode != NULL && pNewSubNode != NULL, "OSQLParseNode: invalid nodes"); + DBG_ASSERT(pNewSubNode->getParent() == NULL, "OSQLParseNode: node already has getParent"); + DBG_ASSERT(::std::find(m_aChilds.begin(), m_aChilds.end(), pOldSubNode) != m_aChilds.end(), + "OSQLParseNode::Replace() Node not element of parent"); + DBG_ASSERT(::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; +} + + diff --git a/connectivity/source/resource/makefile.mk b/connectivity/source/resource/makefile.mk new file mode 100644 index 000000000000..5d506ad9adb8 --- /dev/null +++ b/connectivity/source/resource/makefile.mk @@ -0,0 +1,84 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:14: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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=connectivity +TARGET=resource + +# --- Settings ----------------------------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : settings.mk +# --- Files -------------------------------------------------------- + +SLOFILES=\ + $(SLO)$/ModuleContext.obj \ + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + diff --git a/connectivity/source/sdbcx/VCatalog.cxx b/connectivity/source/sdbcx/VCatalog.cxx new file mode 100644 index 000000000000..1616aedf7421 --- /dev/null +++ b/connectivity/source/sdbcx/VCatalog.cxx @@ -0,0 +1,170 @@ +/************************************************************************* + * + * $RCSfile: VCatalog.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_SDBCX_CATALOG_HXX_ +#include "connectivity/sdbcx/VCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::sdbcx; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +//------------------------------------------------------------------------------ +IMPLEMENT_SERVICE_INFO(OCatalog,"com.sun.star.sdbcx.VDatabaseDefinition","com.sun.star.sdbcx.DatabaseDefinition") +//------------------------------------------------------------------------------ +OCatalog::OCatalog(const Reference< XConnection> &_xConnection) : OCatalog_BASE(m_aMutex) + ,connectivity::OSubComponent<OCatalog>(_xConnection) + ,m_pTables(NULL) + ,m_pViews(NULL) + ,m_pGroups(NULL) + ,m_pUsers(NULL) +{ +} +//----------------------------------------------------------------------------- +OCatalog::~OCatalog() +{ + delete m_pTables; + delete m_pViews; + delete m_pGroups; + delete m_pUsers; +} +//----------------------------------------------------------------------------- +void SAL_CALL OCatalog::release() throw(RuntimeException) +{ + relase_ChildImpl(); + OCatalog_BASE::release(); +} +//------------------------------------------------------------------------------ +void SAL_CALL OCatalog::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + if(m_pTables) + m_pTables->disposing(); + if(m_pViews) + m_pViews->disposing(); + if(m_pGroups) + m_pGroups->disposing(); + if(m_pUsers) + m_pUsers->disposing(); + + dispose_ChildImpl(); + OCatalog_BASE::disposing(); +} +//------------------------------------------------------------------------------ +// XTablesSupplier +Reference< XNameAccess > SAL_CALL OCatalog::getTables( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OCatalog_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return const_cast<OCatalog*>(this)->m_pTables; +} +// ------------------------------------------------------------------------- +// XViewsSupplier +Reference< XNameAccess > SAL_CALL OCatalog::getViews( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OCatalog_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return const_cast<OCatalog*>(this)->m_pViews; +} +// ------------------------------------------------------------------------- +// XUsersSupplier +Reference< XNameAccess > SAL_CALL OCatalog::getUsers( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OCatalog_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return const_cast<OCatalog*>(this)->m_pUsers; +} +// ------------------------------------------------------------------------- +// XGroupsSupplier +Reference< XNameAccess > SAL_CALL OCatalog::getGroups( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OCatalog_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return const_cast<OCatalog*>(this)->m_pGroups; +} +// ------------------------------------------------------------------------- +void ODescriptor::construct() +{ + sal_Int32 nAttrib = isNew() ? 0 : ::com::sun::star::beans::PropertyAttribute::READONLY; + registerProperty(connectivity::PROPERTY_NAME, PROPERTY_ID_NAME ,nAttrib,&m_Name,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); +} + diff --git a/connectivity/source/sdbcx/VCollection.cxx b/connectivity/source/sdbcx/VCollection.cxx new file mode 100644 index 000000000000..aaabb43338ad --- /dev/null +++ b/connectivity/source/sdbcx/VCollection.cxx @@ -0,0 +1,238 @@ +/************************************************************************* + * + * $RCSfile: VCollection.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _CONNECTIVITY_ENUMHELPER_HXX_ +#include "enumhelper.hxx" +#endif + +using namespace connectivity::sdbcx; +using namespace connectivity; +using namespace ::com::sun::star::beans; +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::util; + +IMPLEMENT_SERVICE_INFO(OCollection,"com.sun.star.sdbcx.VContainer" , "com.sun.star.sdbcx.Container") + +// ------------------------------------------------------------------------- +void OCollection::disposing(void) +{ + m_aRefreshListeners.disposeAndClear(EventObject(static_cast<XWeak*>(this))); + + ::osl::MutexGuard aGuard(m_rMutex); + for( ObjectIter aIter = m_aNameMap.begin(); aIter != m_aNameMap.end(); ++aIter) + { + if((*aIter).second.is()) + { + Reference< XComponent > xComp2((*aIter).second, UNO_QUERY); + if(xComp2.is()) + xComp2->dispose(); + + (*aIter).second = Reference< XNamed >(); + } + } + m_aNameMap.clear(); + m_aElements.clear(); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OCollection::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (Index < 0 || Index >= getCount()) + throw IndexOutOfBoundsException(); + + ObjectIter aIter = m_aElements[Index]; + Reference< XNamed > xName = (*aIter).second; + if(!(*aIter).second.is()) + { + xName = createObject((*aIter).first); + (*aIter).second = xName; + } + + return makeAny( Reference< XPropertySet >(xName,UNO_QUERY)); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OCollection::getByName( const ::rtl::OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + ObjectIter aIter = m_aNameMap.find(aName); + if(aIter == m_aNameMap.end()) + return Any(); + Reference< XNamed > xName = (*aIter).second; + if(!(*aIter).second.is()) + { + xName = createObject(aName); + (*aIter).second = xName; + } + + return makeAny( Reference< XPropertySet >(xName,UNO_QUERY)); +} +// ------------------------------------------------------------------------- +Sequence< ::rtl::OUString > SAL_CALL OCollection::getElementNames( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + sal_Int32 nLen = getCount(); + Sequence< ::rtl::OUString > aNameList(nLen); + + sal_Int32 i=0; + ::rtl::OUString* pStringArray = aNameList.getArray(); + // for( ::std::map< ::rtl::OUString, Object_BASE, ::utl::UStringLess> ::const_iterator aIter = m_aNameMap.begin(); aIter != m_aNameMap.end(); ++aIter) + for(::std::vector< ObjectIter >::const_iterator aIter = m_aElements.begin(); aIter != m_aElements.end();++aIter) + pStringArray[i++] = (*aIter)->first; + + return aNameList; +} +// ------------------------------------------------------------------------- +void SAL_CALL OCollection::refresh( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + for( ::std::map< ::rtl::OUString, Object_BASE, ::utl::UStringLess>::iterator aIter = m_aNameMap.begin(); aIter != m_aNameMap.end(); ++aIter) + { + if((*aIter).second.is()) + { + Reference< XComponent > xComp2((*aIter).second, UNO_QUERY); + if(xComp2.is()) + xComp2->dispose(); + + (*aIter).second = Reference< XNamed >(); + } + } + m_aNameMap.clear(); + m_aElements.clear(); + + impl_refresh(); + EventObject aEvt(static_cast<XWeak*>(this)); + NOTIFY_LISTENERS(m_aRefreshListeners, XRefreshListener, refreshed, aEvt); +} +// ------------------------------------------------------------------------- +// XDataDescriptorFactory +Reference< XPropertySet > SAL_CALL OCollection::createDataDescriptor( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + return createEmptyObject(); +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OCollection::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + Reference< XNamed > xName(descriptor,UNO_QUERY); + if(xName.is()) + { + if(m_aNameMap.find(xName->getName()) != m_aNameMap.end()) + throw ElementExistException(xName->getName(),*this); + + m_aElements.push_back(m_aNameMap.insert(m_aNameMap.begin(), ObjectMap::value_type(xName->getName(),WeakReference< XNamed >(xName)))); + } +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OCollection::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + for(::std::vector< ObjectIter >::size_type i=0;i<m_aElements.size();++i) + { + if(m_aElements[i] == aIter) + { + m_aElements.erase(m_aElements.begin()+i); + m_aNameMap.erase(aIter); + } + } +} +// ------------------------------------------------------------------------- +void SAL_CALL OCollection::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if(index <0 || index > getCount()) + throw IndexOutOfBoundsException(::rtl::OUString(),*this); + + m_aNameMap.erase(m_aElements[index]); + m_aElements.erase(m_aElements.begin()+index); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OCollection::findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ObjectIter aIter = m_aNameMap.find(columnName); + if(aIter == m_aNameMap.end()) + throw ::com::sun::star::sdbc::SQLException(); + + return m_aElements.size() - (m_aElements.end() - ::std::find(m_aElements.begin(),m_aElements.end(),aIter)) +1; // because cloumns start at one +} +// ------------------------------------------------------------------------- +Reference< XEnumeration > SAL_CALL OCollection::createEnumeration( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + return new connectivity::OEnumerationByIndex( static_cast< XIndexAccess*>(this)); +} + diff --git a/connectivity/source/sdbcx/VColumn.cxx b/connectivity/source/sdbcx/VColumn.cxx new file mode 100644 index 000000000000..84b8a0dd8985 --- /dev/null +++ b/connectivity/source/sdbcx/VColumn.cxx @@ -0,0 +1,186 @@ +/************************************************************************* + * + * $RCSfile: VColumn.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif + +// ------------------------------------------------------------------------- +using namespace connectivity::sdbcx; +using namespace cppu; +using namespace connectivity; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +// using namespace ::com::sun::star::sdbc; + + +IMPLEMENT_SERVICE_INFO(OColumn,"com.sun.star.sdbcx.VColumn","com.sun.star.sdbcx.Column"); +// ------------------------------------------------------------------------- +OColumn::OColumn(sal_Bool _bCase) : OColumn_BASE(m_aMutex) + , ODescriptor(OColumn_BASE::rBHelper,_bCase,sal_True) + , m_Precision(0) + , m_Type(0) + , m_Scale(0) + , m_IsNullable(sal_True) + , m_IsAutoIncrement(sal_False) + , m_IsRowVersion(sal_False) + , m_IsCurrency(sal_False) +{ + construct(); +} +// ------------------------------------------------------------------------- +OColumn::OColumn( const ::rtl::OUString& _Name, + const ::rtl::OUString& _TypeName, + const ::rtl::OUString& _DefaultValue, + sal_Int32 _IsNullable, + sal_Int32 _Precision, + sal_Int32 _Scale, + sal_Int32 _Type, + sal_Bool _IsAutoIncrement, + sal_Bool _IsRowVersion, + sal_Bool _IsCurrency, + sal_Bool _bCase) + : OColumn_BASE(m_aMutex) + , ODescriptor(OColumn_BASE::rBHelper,_bCase) + , m_TypeName(_TypeName) + , m_DefaultValue(_DefaultValue) + , m_Precision(_Precision) + , m_Type(_Type) + , m_Scale(_Scale) + , m_IsNullable(_IsNullable) + , m_IsAutoIncrement(_IsAutoIncrement) + , m_IsRowVersion(_IsRowVersion) + , m_IsCurrency(_IsCurrency) +{ + m_Name = _Name; + + construct(); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OColumn::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ODescriptor::queryInterface( rType); + if(aRet.hasValue()) + return aRet; + return OColumn_BASE::queryInterface( rType); +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OColumn::getTypes( ) throw(RuntimeException) +{ + return ::utl::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes()); +} +// ------------------------------------------------------------------------- +void OColumn::construct() +{ + ODescriptor::construct(); + + sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; + + registerProperty(connectivity::PROPERTY_TYPENAME, PROPERTY_ID_TYPENAME, nAttrib,&m_TypeName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(connectivity::PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, nAttrib,&m_Description, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(connectivity::PROPERTY_DEFAULTVALUE, PROPERTY_ID_DEFAULTVALUE, nAttrib,&m_DefaultValue, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(connectivity::PROPERTY_PRECISION, PROPERTY_ID_PRECISION, nAttrib,&m_Precision, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(connectivity::PROPERTY_TYPE, PROPERTY_ID_TYPE, nAttrib,&m_Type, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(connectivity::PROPERTY_SCALE, PROPERTY_ID_SCALE, nAttrib,&m_Scale, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(connectivity::PROPERTY_ISNULLABLE, PROPERTY_ID_ISNULLABLE, nAttrib,&m_IsNullable, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(connectivity::PROPERTY_ISAUTOINCREMENT, PROPERTY_ID_ISAUTOINCREMENT, nAttrib,&m_IsAutoIncrement, ::getBooleanCppuType()); + registerProperty(connectivity::PROPERTY_ISROWVERSION, PROPERTY_ID_ISROWVERSION, nAttrib,&m_IsRowVersion, ::getBooleanCppuType()); + registerProperty(connectivity::PROPERTY_ISCURRENCY, PROPERTY_ID_ISCURRENCY, nAttrib,&m_IsCurrency, ::getBooleanCppuType()); +} +// ------------------------------------------------------------------------- +void OColumn::disposing(void) +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + if (OColumn_BASE::rBHelper.bDisposed) + throw DisposedException(); +} +// ------------------------------------------------------------------------- +IPropertyArrayHelper* OColumn::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +IPropertyArrayHelper & OColumn::getInfoHelper() +{ + return *const_cast<OColumn*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > SAL_CALL OColumn::createDataDescriptor( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OColumn_BASE::rBHelper.bDisposed) + throw DisposedException(); + return this; +} + diff --git a/connectivity/source/sdbcx/VGroup.cxx b/connectivity/source/sdbcx/VGroup.cxx new file mode 100644 index 000000000000..4143e1513f13 --- /dev/null +++ b/connectivity/source/sdbcx/VGroup.cxx @@ -0,0 +1,183 @@ +/************************************************************************* + * + * $RCSfile: VGroup.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_SDBCX_GROUP_HXX_ +#include "connectivity/sdbcx/VGroup.hxx" +#endif + +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#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 _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif + + +// ------------------------------------------------------------------------- +using namespace connectivity::sdbcx; +using namespace connectivity; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; + +IMPLEMENT_SERVICE_INFO(OGroup,"com.sun.star.sdbcx.VGroup","com.sun.star.sdbcx.Group"); +// ------------------------------------------------------------------------- +OGroup::OGroup(sal_Bool _bCase) : OGroup_BASE(m_aMutex) + , ODescriptor(OGroup_BASE::rBHelper,_bCase) + , m_pUsers(NULL) +{ +} +// ------------------------------------------------------------------------- +OGroup::OGroup(const ::rtl::OUString& _Name,sal_Bool _bCase) : OGroup_BASE(m_aMutex) + ,ODescriptor(OGroup_BASE::rBHelper,_bCase) + ,m_pUsers(NULL) +{ + m_Name = _Name; +} +// ------------------------------------------------------------------------- +Any SAL_CALL OGroup::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ODescriptor::queryInterface( rType); + if(aRet.hasValue()) + return aRet; + return OGroup_BASE::queryInterface( rType); +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OGroup::getTypes( ) throw(RuntimeException) +{ + return ::utl::concatSequences(ODescriptor::getTypes(),OGroup_BASE::getTypes()); +} +// ------------------------------------------------------------------------- +void OGroup::disposing(void) +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + + if(m_pUsers) + m_pUsers->disposing(); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OGroup::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & OGroup::getInfoHelper() +{ + return *const_cast<OGroup*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +Reference< XNameAccess > SAL_CALL OGroup::getUsers( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OGroup_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return const_cast<OGroup*>(this)->m_pUsers; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OGroup::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OGroup_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OGroup::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OGroup_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return 0; +} +// ------------------------------------------------------------------------- +void SAL_CALL OGroup::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OGroup_BASE::rBHelper.bDisposed) + throw DisposedException(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OGroup::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OGroup_BASE::rBHelper.bDisposed) + throw DisposedException(); +} + diff --git a/connectivity/source/sdbcx/VIndex.cxx b/connectivity/source/sdbcx/VIndex.cxx new file mode 100644 index 000000000000..982a51908e5b --- /dev/null +++ b/connectivity/source/sdbcx/VIndex.cxx @@ -0,0 +1,179 @@ +/************************************************************************* + * + * $RCSfile: VIndex.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_SDBCX_INDEX_HXX_ +#include "connectivity/sdbcx/VIndex.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +// ------------------------------------------------------------------------- +using namespace connectivity; +using namespace connectivity::sdbcx; +using namespace cppu; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +IMPLEMENT_SERVICE_INFO(OIndex,"com.sun.star.sdbcx.VIndex","com.sun.star.sdbcx.Index"); +// ------------------------------------------------------------------------- +OIndex::OIndex(sal_Bool _bCase) : OColumns_BASE(m_aMutex) + , ODescriptor(OColumns_BASE::rBHelper,_bCase,sal_True) + , m_pColumns(NULL) +{ +} +// ------------------------------------------------------------------------- +OIndex::OIndex( const ::rtl::OUString& _Name, + const ::rtl::OUString& _Catalog, + sal_Bool _isUnique, + sal_Bool _isPrimaryKeyIndex, + sal_Bool _isClustered, + sal_Bool _bCase) : OColumns_BASE(m_aMutex) + ,ODescriptor(OColumns_BASE::rBHelper,_bCase) + ,m_pColumns(NULL) + ,m_Catalog(_Catalog) + ,m_IsUnique(_isUnique) + ,m_IsPrimaryKeyIndex(_isPrimaryKeyIndex) + ,m_IsClustered(_isClustered) +{ + m_Name = _Name; +} +// ------------------------------------------------------------------------- +Any SAL_CALL OIndex::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ODescriptor::queryInterface( rType); + if(aRet.hasValue()) + return aRet; + return OColumns_BASE::queryInterface( rType); +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OIndex::getTypes( ) throw(RuntimeException) +{ + return ::utl::concatSequences(ODescriptor::getTypes(),OColumns_BASE::getTypes()); +} +// ------------------------------------------------------------------------- +void OIndex::construct() +{ + ODescriptor::construct(); + + sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; + + registerProperty(PROPERTY_CATALOG, PROPERTY_ID_CATALOG, nAttrib,&m_Catalog, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(PROPERTY_ISUNIQUE, PROPERTY_ID_ISUNIQUE, nAttrib,&m_IsUnique, ::getBooleanCppuType()); + registerProperty(PROPERTY_ISPRIMARYKEYINDEX,PROPERTY_ID_ISPRIMARYKEYINDEX, nAttrib,&m_IsPrimaryKeyIndex, ::getBooleanCppuType()); + registerProperty(PROPERTY_ISCLUSTERED, PROPERTY_ID_ISCLUSTERED, nAttrib,&m_IsClustered, ::getBooleanCppuType()); +} +// ------------------------------------------------------------------------- +void OIndex::disposing(void) +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + + if(m_pColumns) + m_pColumns->disposing(); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OIndex::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & OIndex::getInfoHelper() +{ + return *const_cast<OIndex*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > SAL_CALL OIndex::createDataDescriptor( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OColumns_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return this; +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OIndex::getColumns( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OColumns_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_pColumns) + refreshColumns(); + + return const_cast<OIndex*>(this)->m_pColumns; +} + diff --git a/connectivity/source/sdbcx/VIndexColumn.cxx b/connectivity/source/sdbcx/VIndexColumn.cxx new file mode 100644 index 000000000000..71067e4d9b2d --- /dev/null +++ b/connectivity/source/sdbcx/VIndexColumn.cxx @@ -0,0 +1,113 @@ +/************************************************************************* + * + * $RCSfile: VIndexColumn.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_SDBCX_INDEXCOLUMN_HXX_ +#include "connectivity/sdbcx/VIndexColumn.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::sdbcx; +using namespace ::com::sun::star::beans; +// ------------------------------------------------------------------------- +OIndexColumn::OIndexColumn(sal_Bool _bCase) : OColumn(_bCase) + , m_IsAscending(sal_True) +{ + construct(); +} +// ------------------------------------------------------------------------- +OIndexColumn::OIndexColumn( sal_Bool _IsAscending, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _TypeName, + const ::rtl::OUString& _DefaultValue, + sal_Int32 _IsNullable, + sal_Int32 _Precision, + sal_Int32 _Scale, + sal_Int32 _Type, + sal_Bool _IsAutoIncrement, + sal_Bool _IsRowVersion, + sal_Bool _IsCurrency, + sal_Bool _bCase + ) : OColumn(_Name, + _TypeName, + _DefaultValue, + _IsNullable, + _Precision, + _Scale, + _Type, + _IsAutoIncrement, + _IsRowVersion, + _IsCurrency, + _bCase) + , m_IsAscending(_IsAscending) +{ + construct(); +} +// ------------------------------------------------------------------------- +void OIndexColumn::construct() +{ + sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; + registerProperty(PROPERTY_ISASCENDING, PROPERTY_ID_ISASCENDING, nAttrib,&m_IsAscending, ::getBooleanCppuType()); +} + + diff --git a/connectivity/source/sdbcx/VKey.cxx b/connectivity/source/sdbcx/VKey.cxx new file mode 100644 index 000000000000..999d4a4c6c46 --- /dev/null +++ b/connectivity/source/sdbcx/VKey.cxx @@ -0,0 +1,187 @@ +/************************************************************************* + * + * $RCSfile: VKey.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_SDBCX_KEY_HXX_ +#include "connectivity/sdbcx/VKey.hxx" +#endif + +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +// ------------------------------------------------------------------------- +using namespace connectivity; +using namespace connectivity::sdbcx; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +IMPLEMENT_SERVICE_INFO(OKey,"com.sun.star.sdbcx.VKey","com.sun.star.sdbcx.Key"); +// ------------------------------------------------------------------------- +OKey::OKey(sal_Bool _bCase) : OColumns_BASE(m_aMutex) + , ODescriptor(OColumns_BASE::rBHelper,_bCase,sal_True) + , m_pColumns(NULL) +{ +} +// ------------------------------------------------------------------------- +OKey::OKey( const ::rtl::OUString& _Name, + const ::rtl::OUString& _ReferencedTable, + sal_Int32 _Type, + sal_Int32 _UpdateRule, + sal_Int32 _DeleteRule, + sal_Bool _bCase) : OColumns_BASE(m_aMutex) + ,ODescriptor(OColumns_BASE::rBHelper,_bCase) + ,m_pColumns(NULL) + ,m_ReferencedTable(_ReferencedTable) + ,m_Type(_Type) + ,m_UpdateRule(_UpdateRule) + ,m_DeleteRule(_DeleteRule) +{ + m_Name = _Name; +} +// ------------------------------------------------------------------------- +Any SAL_CALL OKey::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ODescriptor::queryInterface( rType); + if(aRet.hasValue()) + return aRet; + return OColumns_BASE::queryInterface( rType); +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OKey::getTypes( ) throw(RuntimeException) +{ + return ::utl::concatSequences(ODescriptor::getTypes(),OColumns_BASE::getTypes()); +} +// ------------------------------------------------------------------------- +void OKey::construct() +{ + ODescriptor::construct(); + + sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; + + registerProperty(PROPERTY_REFERENCEDTABLE, PROPERTY_ID_REFERENCEDTABLE, nAttrib,&m_ReferencedTable, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(PROPERTY_TYPE, PROPERTY_ID_TYPE, nAttrib,&m_Type, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(PROPERTY_UPDATERULE, PROPERTY_ID_UPDATERULE, nAttrib,&m_UpdateRule, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(PROPERTY_DELETERULE, PROPERTY_ID_DELETERULE, nAttrib,&m_DeleteRule, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); +} +// ------------------------------------------------------------------------- +void OKey::disposing(void) +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + + if(m_pColumns) + m_pColumns->disposing(); + + OColumns_BASE::disposing(); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OKey::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & OKey::getInfoHelper() +{ + return *const_cast<OKey*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > SAL_CALL OKey::createDataDescriptor( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OColumns_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return this; +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OKey::getColumns( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OColumns_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_pColumns) + refreshColumns(); + + return const_cast<OKey*>(this)->m_pColumns; +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/sdbcx/VKeyColumn.cxx b/connectivity/source/sdbcx/VKeyColumn.cxx new file mode 100644 index 000000000000..25fab0a9c2c0 --- /dev/null +++ b/connectivity/source/sdbcx/VKeyColumn.cxx @@ -0,0 +1,111 @@ +/************************************************************************* + * + * $RCSfile: VKeyColumn.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14: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_SDBCX_KEYCOLUMN_HXX_ +#include "connectivity/sdbcx/VKeyColumn.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::sdbcx; +using namespace ::com::sun::star::beans; + +// ------------------------------------------------------------------------- +OKeyColumn::OKeyColumn(sal_Bool _bCase) : OColumn(_bCase) +{ + construct(); +} +// ------------------------------------------------------------------------- +OKeyColumn::OKeyColumn( const ::rtl::OUString& _ReferencedColumn, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _TypeName, + const ::rtl::OUString& _DefaultValue, + sal_Int32 _IsNullable, + sal_Int32 _Precision, + sal_Int32 _Scale, + sal_Int32 _Type, + sal_Bool _IsAutoIncrement, + sal_Bool _IsRowVersion, + sal_Bool _IsCurrency, + sal_Bool _bCase + ) : OColumn(_Name, + _TypeName, + _DefaultValue, + _IsNullable, + _Precision, + _Scale, + _Type, + _IsAutoIncrement, + _IsRowVersion, + _IsCurrency, + _bCase) + , m_ReferencedColumn(_ReferencedColumn) +{ + construct(); +} +// ------------------------------------------------------------------------- +void OKeyColumn::construct() +{ + sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; + registerProperty(PROPERTY_REFERENCEDCOLUMN, PROPERTY_ID_REFERENCEDCOLUMN, nAttrib,&m_ReferencedColumn, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); +} + diff --git a/connectivity/source/sdbcx/VTable.cxx b/connectivity/source/sdbcx/VTable.cxx new file mode 100644 index 000000000000..d833b5c756f7 --- /dev/null +++ b/connectivity/source/sdbcx/VTable.cxx @@ -0,0 +1,247 @@ +/************************************************************************* + * + * $RCSfile: VTable.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:29 $ + * + * 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_SDBCX_TABLE_HXX_ +#include "connectivity/sdbcx/VTable.hxx" +#endif + +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_KEY_HXX_ +#include "connectivity/sdbcx/VKey.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_INDEX_HXX_ +#include "connectivity/sdbcx/VIndex.hxx" +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif + +// ------------------------------------------------------------------------- +using namespace connectivity; +using namespace connectivity::sdbcx; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +IMPLEMENT_SERVICE_INFO(OTable,"com.sun.star.sdbcx.VTable","com.sun.star.sdbcx.Table"); +// ------------------------------------------------------------------------- +OTable::OTable(sal_Bool _bCase) : OTable_BASE(m_aMutex) + ,ODescriptor(OTable_BASE::rBHelper,_bCase,sal_True) + ,m_pIndexes(NULL) + ,m_pKeys(NULL) + ,m_pColumns(NULL) +{ +} +// -------------------------------------------------------------------------- +OTable::OTable( sal_Bool _bCase, + const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description,const ::rtl::OUString& _SchemaName, + const ::rtl::OUString& _CatalogName) : OTable_BASE(m_aMutex) + ,ODescriptor(OTable_BASE::rBHelper,_bCase) + ,m_pIndexes(NULL) + ,m_pKeys(NULL) + ,m_pColumns(NULL) + ,m_CatalogName(_CatalogName) + ,m_SchemaName(_SchemaName) + ,m_Description(_Description) + ,m_Type(_Type) +{ + m_Name = _Name; +} +// ------------------------------------------------------------------------- +Any SAL_CALL OTable::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ODescriptor::queryInterface( rType); + if(aRet.hasValue()) + return aRet; + return OTable_BASE::queryInterface( rType); +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OTable::getTypes( ) throw(RuntimeException) +{ + return ::utl::concatSequences(ODescriptor::getTypes(),OTable_BASE::getTypes()); +} +// ------------------------------------------------------------------------- +void OTable::construct() +{ + ODescriptor::construct(); + + sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; + + registerProperty(PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME,nAttrib,&m_CatalogName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, nAttrib,&m_SchemaName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION,nAttrib,&m_Description, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(PROPERTY_TYPE, PROPERTY_ID_TYPE, nAttrib,&m_Type, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); +} +// ------------------------------------------------------------------------- +void SAL_CALL OTable::disposing(void) +{ + ODescriptor::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + + if(m_pIndexes) + m_pIndexes->disposing(); + if(m_pKeys) + m_pKeys->disposing(); + if(m_pColumns) + m_pColumns->disposing(); + +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OTable::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & OTable::getInfoHelper() +{ + return *const_cast<OTable*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > SAL_CALL OTable::createDataDescriptor( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OTable_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return this; +} +// XColumnsSupplier +Reference< XNameAccess > SAL_CALL OTable::getColumns( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OTable_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_pColumns) + refreshColumns(); + + return const_cast<OTable*>(this)->m_pColumns; +} +// ------------------------------------------------------------------------- +// XIndexesSupplier +Reference< XNameAccess > SAL_CALL OTable::getIndexes( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OTable_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_pIndexes) + refreshIndexes(); + + return const_cast<OTable*>(this)->m_pIndexes; +} +// ------------------------------------------------------------------------- +// XKeysSupplier +Reference< XIndexAccess > SAL_CALL OTable::getKeys( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OTable_BASE::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_pKeys) + refreshKeys(); + + return const_cast<OTable*>(this)->m_pKeys; +} +// ------------------------------------------------------------------------- +// XRename +void SAL_CALL OTable::rename( const ::rtl::OUString& newName ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OTable_BASE::rBHelper.bDisposed) + throw DisposedException(); + +} +// ------------------------------------------------------------------------- +// XAlterTable +void SAL_CALL OTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OTable_BASE::rBHelper.bDisposed) + throw DisposedException(); + +} +// ------------------------------------------------------------------------- +void SAL_CALL OTable::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OTable_BASE::rBHelper.bDisposed) + throw DisposedException(); + +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/sdbcx/VUser.cxx b/connectivity/source/sdbcx/VUser.cxx new file mode 100644 index 000000000000..5a2ba05efa9d --- /dev/null +++ b/connectivity/source/sdbcx/VUser.cxx @@ -0,0 +1,194 @@ +/************************************************************************* + * + * $RCSfile: VUser.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:29 $ + * + * 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_SDBCX_USER_HXX_ +#include "connectivity/sdbcx/VUser.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#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 _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ +#include "connectivity/sdbcx/VCollection.hxx" +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif + +// ------------------------------------------------------------------------- +using namespace connectivity; +using namespace connectivity::sdbcx; +namespace starsdbc = ::com::sun::star::sdbc; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +IMPLEMENT_SERVICE_INFO(OUser,"com.sun.star.sdbcx.VUser","com.sun.star.sdbcx.User"); +// ------------------------------------------------------------------------- +OUser::OUser(sal_Bool _bCase) : OUser_BASE(m_aMutex) + , ODescriptor(OUser_BASE::rBHelper,_bCase,sal_True) + , m_pGroups(NULL) +{ +} +// ------------------------------------------------------------------------- +OUser::OUser(const ::rtl::OUString& _Name,sal_Bool _bCase) : OUser_BASE(m_aMutex) + ,ODescriptor(OUser_BASE::rBHelper,_bCase) + ,m_pGroups(NULL) +{ + m_Name = _Name; +} +// ------------------------------------------------------------------------- +void OUser::disposing(void) +{ + OPropertySetHelper::disposing(); + ::osl::MutexGuard aGuard(m_aMutex); + if(m_pGroups) + m_pGroups->disposing(); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OUser::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ODescriptor::queryInterface( rType); + if(aRet.hasValue()) + return aRet; + return OUser_BASE::queryInterface( rType); +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OUser::getTypes( ) throw(RuntimeException) +{ + return ::utl::concatSequences(ODescriptor::getTypes(),OUser_BASE::getTypes()); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OUser::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); + +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & OUser::getInfoHelper() +{ + return *const_cast<OUser*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +// XUser +void SAL_CALL OUser::changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OUser_BASE::rBHelper.bDisposed) + throw DisposedException(); + + +} +// ------------------------------------------------------------------------- +// XGroupsSupplier +Reference< XNameAccess > SAL_CALL OUser::getGroups( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OUser_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return const_cast<OUser*>(this)->m_pGroups; +} +// ------------------------------------------------------------------------- +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OUser::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OUser_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OUser::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OUser_BASE::rBHelper.bDisposed) + throw DisposedException(); + + return 0; +} +// ------------------------------------------------------------------------- +void SAL_CALL OUser::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OUser_BASE::rBHelper.bDisposed) + throw DisposedException(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OUser::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (OUser_BASE::rBHelper.bDisposed) + throw DisposedException(); +} + diff --git a/connectivity/source/sdbcx/VView.cxx b/connectivity/source/sdbcx/VView.cxx new file mode 100644 index 000000000000..c96fb19dd707 --- /dev/null +++ b/connectivity/source/sdbcx/VView.cxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * $RCSfile: VView.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:29 $ + * + * 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_SDBCX_VIEW_HXX_ +#include "connectivity/sdbcx/VView.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +// ------------------------------------------------------------------------- +using namespace connectivity; +using namespace connectivity::sdbcx; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +IMPLEMENT_SERVICE_INFO(OView,"com.sun.star.sdbcx.VView","com.sun.star.sdbcx.View"); +// ------------------------------------------------------------------------- +OView::OView(sal_Bool _bCase, + const ::rtl::OUString& _Name, + sal_Int32 _CheckOption, + const ::rtl::OUString& _Command, + const ::rtl::OUString& _SchemaName, + const ::rtl::OUString& _CatalogName) : ODescriptor(OViewHelper::rBHelper,_bCase) + ,m_CatalogName(_CatalogName) + ,m_SchemaName(_SchemaName) + ,m_Command(_Command) + ,m_CheckOption(_CheckOption) + +{ + m_Name = _Name; +} +// ------------------------------------------------------------------------- +OView::OView(sal_Bool _bCase): ODescriptor(OViewHelper::rBHelper,_bCase,sal_True) +{ +} +// ------------------------------------------------------------------------- +void OView::construct() +{ + ODescriptor::construct(); + + sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; + + registerProperty(PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME,nAttrib,&m_CatalogName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, nAttrib,&m_SchemaName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, nAttrib,&m_Command, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(PROPERTY_CHECKOPTION, PROPERTY_ID_CHECKOPTION,nAttrib,&m_CheckOption, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL))); +} +// ------------------------------------------------------------------------- +void OView::disposing(void) +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OView::getTypes( ) throw(RuntimeException) +{ + Sequence< Type > aTypes(2); + aTypes.getArray()[0] = ::getCppuType(static_cast< Reference< ::com::sun::star::container::XNamed> *> (NULL)); + aTypes.getArray()[1] = ::getCppuType(static_cast< Reference< XServiceInfo> *> (NULL)); + + return ::utl::concatSequences(ODescriptor::getTypes(),aTypes); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OView::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::container::XNamed*> (this), + static_cast< XServiceInfo*> (this)); + if(aRet.hasValue()) + return aRet; + return ODescriptor::queryInterface( rType);; +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OView::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); + +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & OView::getInfoHelper() +{ + return *const_cast<OView*>(this)->getArrayHelper(); +} + diff --git a/connectivity/source/sdbcx/makefile.mk b/connectivity/source/sdbcx/makefile.mk new file mode 100644 index 000000000000..ba058294ae32 --- /dev/null +++ b/connectivity/source/sdbcx/makefile.mk @@ -0,0 +1,161 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:14:29 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. +PRJINC=.. +PRJNAME=connectivity +TARGET=sdbcx + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : settings.mk + +# --- Types ------------------------------------- + + +UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb + +UNOUCROUT=$(OUT)$/inc +INCPRE+=$(UNOUCROUT) + +# --- Types ------------------------------------- + +UNOTYPES+= \ + com.sun.star.util.XCancellable \ + com.sun.star.util.XNumberFormatter \ + com.sun.star.util.XRefreshable \ + com.sun.star.container.XNamed \ + com.sun.star.container.XEnumerationAccess \ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XWeak \ + com.sun.star.uno.XAggregation \ + com.sun.star.beans.XPropertyState \ + com.sun.star.beans.XPropertySet \ + com.sun.star.beans.PropertyValue \ + com.sun.star.beans.XMultiPropertySet \ + com.sun.star.beans.XFastPropertySet \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.EventObject \ + com.sun.star.lang.XComponent \ + com.sun.star.lang.IllegalArgumentException \ + com.sun.star.lang.DisposedException \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.java.XJavaThreadRegister_11 \ + com.sun.star.java.XJavaVM \ + com.sun.star.sdbc.XConnection \ + com.sun.star.sdbc.XStatement \ + com.sun.star.sdbc.XResultSet \ + com.sun.star.sdbc.XResultSetMetaDataSupplier \ + com.sun.star.sdbc.XColumnLocate \ + com.sun.star.sdbc.XResultSetUpdate \ + com.sun.star.sdbc.XWarningsSupplier \ + com.sun.star.sdbc.XRowUpdate \ + com.sun.star.sdbc.XMultipleResults \ + com.sun.star.sdbc.XBatchExecution \ + com.sun.star.sdbc.XPreparedBatchExecution \ + com.sun.star.sdbc.XParameters \ + com.sun.star.sdbc.XOutParameters \ + com.sun.star.sdbc.DriverPropertyInfo \ + com.sun.star.sdbc.XDriver \ + com.sun.star.sdbc.XRow \ + com.sun.star.sdbc.SQLWarning \ + com.sun.star.sdbc.ColumnSearch \ + com.sun.star.sdbc.DataType \ + com.sun.star.sdbc.ResultSetConcurrency \ + com.sun.star.sdbc.ResultSetType \ + com.sun.star.sdbc.ColumnValue \ + com.sun.star.sdbcx.XAppend \ + com.sun.star.sdbcx.XDrop \ + com.sun.star.sdb.XColumnUpdate \ + com.sun.star.sdb.XColumn \ + + + +# --- Files ------------------------------------- + +SLOFILES=\ + $(SLO)$/VCollection.obj \ + $(SLO)$/VColumn.obj \ + $(SLO)$/VIndexColumn.obj \ + $(SLO)$/VKeyColumn.obj \ + $(SLO)$/VCatalog.obj \ + $(SLO)$/VUser.obj \ + $(SLO)$/VGroup.obj \ + $(SLO)$/VTable.obj \ + $(SLO)$/VKey.obj \ + $(SLO)$/VIndex.obj \ + $(SLO)$/VView.obj + + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + + |