1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "NDatabaseMetaData.hxx" 32*cdf0e10cSrcweir #include "NConnection.hxx" 33*cdf0e10cSrcweir #include "NResultSet.hxx" 34*cdf0e10cSrcweir #include "propertyids.hxx" 35*cdf0e10cSrcweir #include "resource/evoab2_res.hrc" 36*cdf0e10cSrcweir #include "TSortIndex.hxx" 37*cdf0e10cSrcweir #include <algorithm> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/sdb/ErrorCondition.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/sdbc/FetchDirection.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetType.hpp> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 48*cdf0e10cSrcweir #include <comphelper/extract.hxx> 49*cdf0e10cSrcweir #include <comphelper/property.hxx> 50*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 51*cdf0e10cSrcweir #include <comphelper/types.hxx> 52*cdf0e10cSrcweir #include <connectivity/dbexception.hxx> 53*cdf0e10cSrcweir #include <connectivity/sqlerror.hxx> 54*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 55*cdf0e10cSrcweir #include <rtl/string.hxx> 56*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 57*cdf0e10cSrcweir #include <unotools/syslocale.hxx> 58*cdf0e10cSrcweir #include <unotools/intlwrapper.hxx> 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir #include <cstring> 61*cdf0e10cSrcweir #include <vector> 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir namespace connectivity { namespace evoab { 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir using namespace ::comphelper; 66*cdf0e10cSrcweir using namespace com::sun::star; 67*cdf0e10cSrcweir using namespace com::sun::star::uno; 68*cdf0e10cSrcweir using namespace com::sun::star::lang; 69*cdf0e10cSrcweir using namespace com::sun::star::beans; 70*cdf0e10cSrcweir using namespace com::sun::star::sdbc; 71*cdf0e10cSrcweir using namespace com::sun::star::sdbcx; 72*cdf0e10cSrcweir using namespace com::sun::star::container; 73*cdf0e10cSrcweir using namespace com::sun::star::io; 74*cdf0e10cSrcweir namespace ErrorCondition = ::com::sun::star::sdb::ErrorCondition; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir //------------------------------------------------------------------------------ 77*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OEvoabResultSet::getImplementationName( ) throw ( RuntimeException) \ 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.evoab.ResultSet"); 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir // ------------------------------------------------------------------------- 82*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL OEvoabResultSet::getSupportedServiceNames( ) throw( RuntimeException) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported(1); 85*cdf0e10cSrcweir aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet"); 86*cdf0e10cSrcweir return aSupported; 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir // ------------------------------------------------------------------------- 89*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); 92*cdf0e10cSrcweir const ::rtl::OUString* pSupported = aSupported.getConstArray(); 93*cdf0e10cSrcweir const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 94*cdf0e10cSrcweir for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) 95*cdf0e10cSrcweir ; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir return pSupported != pEnd; 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir // ------------------------------------------------------------------------- 101*cdf0e10cSrcweir OEvoabResultSet::OEvoabResultSet( OCommonStatement* pStmt, OEvoabConnection *pConnection ) 102*cdf0e10cSrcweir :OResultSet_BASE(m_aMutex) 103*cdf0e10cSrcweir ,::comphelper::OPropertyContainer( OResultSet_BASE::rBHelper ) 104*cdf0e10cSrcweir ,m_pStatement(pStmt) 105*cdf0e10cSrcweir ,m_pConnection(pConnection) 106*cdf0e10cSrcweir ,m_xMetaData(NULL) 107*cdf0e10cSrcweir ,m_bWasNull(sal_True) 108*cdf0e10cSrcweir ,m_nFetchSize(0) 109*cdf0e10cSrcweir ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE) 110*cdf0e10cSrcweir ,m_nFetchDirection(FetchDirection::FORWARD) 111*cdf0e10cSrcweir ,m_nResultSetConcurrency(ResultSetConcurrency::READ_ONLY) 112*cdf0e10cSrcweir ,m_pContacts(NULL) 113*cdf0e10cSrcweir ,m_nIndex(-1) 114*cdf0e10cSrcweir ,m_nLength(0) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir #define REGISTER_PROP( id, member ) \ 117*cdf0e10cSrcweir registerProperty( \ 118*cdf0e10cSrcweir OMetaConnection::getPropMap().getNameByIndex( id ), \ 119*cdf0e10cSrcweir id, \ 120*cdf0e10cSrcweir PropertyAttribute::READONLY, \ 121*cdf0e10cSrcweir &member, \ 122*cdf0e10cSrcweir ::getCppuType( &member ) \ 123*cdf0e10cSrcweir ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir REGISTER_PROP( PROPERTY_ID_FETCHSIZE, m_nFetchSize ); 126*cdf0e10cSrcweir REGISTER_PROP( PROPERTY_ID_RESULTSETTYPE, m_nResultSetType ); 127*cdf0e10cSrcweir REGISTER_PROP( PROPERTY_ID_FETCHDIRECTION, m_nFetchDirection ); 128*cdf0e10cSrcweir REGISTER_PROP( PROPERTY_ID_RESULTSETCONCURRENCY, m_nResultSetConcurrency ); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir // ------------------------------------------------------------------------- 132*cdf0e10cSrcweir OEvoabResultSet::~OEvoabResultSet() 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir // ------------------------------------------------------------------------- 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir static ESource * 139*cdf0e10cSrcweir findSource( const char *name ) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir ESourceList *pSourceList = NULL; 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir g_return_val_if_fail (name != NULL, NULL); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir if (!e_book_get_addressbooks (&pSourceList, NULL)) 146*cdf0e10cSrcweir pSourceList = NULL; 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir for ( GSList *g = e_source_list_peek_groups (pSourceList); g; g = g->next) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir for (GSList *s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir ESource *pSource = E_SOURCE (s->data); 153*cdf0e10cSrcweir if (!strcmp (e_source_peek_name (pSource), name)) 154*cdf0e10cSrcweir return pSource; 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir return NULL; 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir static EBook * 161*cdf0e10cSrcweir openBook( const char *abname ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir ESource *pSource = findSource (abname); 164*cdf0e10cSrcweir EBook *pBook = NULL; 165*cdf0e10cSrcweir if (pSource) 166*cdf0e10cSrcweir pBook = e_book_new (pSource, NULL); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir if (pBook && !e_book_open (pBook, TRUE, NULL)) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir g_object_unref (G_OBJECT (pBook)); 171*cdf0e10cSrcweir pBook = NULL; 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir return pBook; 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir static bool isLDAP( EBook *pBook ) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir return pBook && !strncmp( "ldap://", e_book_get_uri( pBook ), 6 ); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir static bool isLocal( EBook *pBook ) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir return pBook && !strncmp( "file://", e_book_get_uri( pBook ), 6 ); 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir static bool isAuthRequired( EBook *pBook ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir return e_source_get_property( e_book_get_source( pBook ), 190*cdf0e10cSrcweir "auth" ) != NULL; 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir static rtl::OString getUserName( EBook *pBook ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir rtl::OString aName; 196*cdf0e10cSrcweir if( isLDAP( pBook ) ) 197*cdf0e10cSrcweir aName = e_source_get_property( e_book_get_source( pBook ), "binddn" ); 198*cdf0e10cSrcweir else 199*cdf0e10cSrcweir aName = e_source_get_property( e_book_get_source( pBook ), "user" ); 200*cdf0e10cSrcweir return aName; 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir static ::rtl::OUString 204*cdf0e10cSrcweir valueToOUString( GValue& _rValue ) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir const char *pStr = g_value_get_string( &_rValue ); 207*cdf0e10cSrcweir rtl::OString aStr( pStr ? pStr : "" ); 208*cdf0e10cSrcweir ::rtl::OUString sResult( ::rtl::OStringToOUString( aStr, RTL_TEXTENCODING_UTF8 ) ); 209*cdf0e10cSrcweir g_value_unset( &_rValue ); 210*cdf0e10cSrcweir return sResult; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir static bool 214*cdf0e10cSrcweir valueToBool( GValue& _rValue ) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir bool bResult = g_value_get_boolean( &_rValue ); 217*cdf0e10cSrcweir g_value_unset( &_rValue ); 218*cdf0e10cSrcweir return bResult; 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir static bool 222*cdf0e10cSrcweir executeQuery (EBook* pBook, EBookQuery* pQuery, GList **ppList, 223*cdf0e10cSrcweir rtl::OString &rPassword, GError **pError) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir ESource *pSource = e_book_get_source( pBook ); 226*cdf0e10cSrcweir bool bSuccess = false; 227*cdf0e10cSrcweir bool bAuthSuccess = true; 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir *ppList = NULL; 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir if( isAuthRequired( pBook ) ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir rtl::OString aUser( getUserName( pBook ) ); 234*cdf0e10cSrcweir const char *pAuth = e_source_get_property( pSource, "auth" ); 235*cdf0e10cSrcweir bAuthSuccess = e_book_authenticate_user( pBook, aUser, rPassword, pAuth, pError ); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir if (bAuthSuccess) 239*cdf0e10cSrcweir bSuccess = e_book_get_contacts( pBook, pQuery, ppList, pError ); 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir return bSuccess; 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir static int 245*cdf0e10cSrcweir whichAddress(int value) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir int fieldEnum; 248*cdf0e10cSrcweir switch (value) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir case HOME_ADDR_LINE1: 251*cdf0e10cSrcweir case HOME_ADDR_LINE2: 252*cdf0e10cSrcweir case HOME_CITY: 253*cdf0e10cSrcweir case HOME_STATE: 254*cdf0e10cSrcweir case HOME_COUNTRY: 255*cdf0e10cSrcweir case HOME_ZIP: 256*cdf0e10cSrcweir fieldEnum = e_contact_field_id("address_home"); 257*cdf0e10cSrcweir break; 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir case WORK_ADDR_LINE1: 260*cdf0e10cSrcweir case WORK_ADDR_LINE2: 261*cdf0e10cSrcweir case WORK_CITY: 262*cdf0e10cSrcweir case WORK_STATE: 263*cdf0e10cSrcweir case WORK_COUNTRY: 264*cdf0e10cSrcweir case WORK_ZIP: 265*cdf0e10cSrcweir fieldEnum = e_contact_field_id("address_work"); 266*cdf0e10cSrcweir break; 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir case OTHER_ADDR_LINE1: 269*cdf0e10cSrcweir case OTHER_ADDR_LINE2: 270*cdf0e10cSrcweir case OTHER_CITY: 271*cdf0e10cSrcweir case OTHER_STATE: 272*cdf0e10cSrcweir case OTHER_COUNTRY: 273*cdf0e10cSrcweir case OTHER_ZIP: 274*cdf0e10cSrcweir fieldEnum = e_contact_field_id("address_other"); 275*cdf0e10cSrcweir break; 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir default: fieldEnum = e_contact_field_id("address_home"); 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir return fieldEnum; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir /* 283*cdf0e10cSrcweir * This function decides the default column values based on the first field of EContactAddress. 284*cdf0e10cSrcweir * The search order is Work->Home->other(defaults). 285*cdf0e10cSrcweir */ 286*cdf0e10cSrcweir static EContactAddress * 287*cdf0e10cSrcweir getDefaultContactAddress( EContact *pContact,int *value ) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir EContactAddress *ec = (EContactAddress *)e_contact_get(pContact,whichAddress(WORK_ADDR_LINE1)); 290*cdf0e10cSrcweir if ( ec && (strlen(ec->street)>0) ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir *value= *value +WORK_ADDR_LINE1 -1; 293*cdf0e10cSrcweir return ec; 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir else 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir ec = (EContactAddress *)e_contact_get(pContact,whichAddress(HOME_ADDR_LINE1)); 298*cdf0e10cSrcweir if ( ec && (strlen(ec->street)>0) ) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir *value=*value+HOME_ADDR_LINE1-1; 301*cdf0e10cSrcweir return ec; 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir *value=*value+OTHER_ADDR_LINE1-1; 306*cdf0e10cSrcweir return (EContactAddress *)e_contact_get(pContact,whichAddress(OTHER_ADDR_LINE1)); 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir static EContactAddress* 310*cdf0e10cSrcweir getContactAddress( EContact *pContact, int * address_enum ) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir EContactAddress *ec = NULL; 313*cdf0e10cSrcweir switch (*address_enum) { 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir case DEFAULT_ADDR_LINE1: 316*cdf0e10cSrcweir case DEFAULT_ADDR_LINE2: 317*cdf0e10cSrcweir case DEFAULT_CITY: 318*cdf0e10cSrcweir case DEFAULT_STATE: 319*cdf0e10cSrcweir case DEFAULT_COUNTRY: 320*cdf0e10cSrcweir case DEFAULT_ZIP: 321*cdf0e10cSrcweir ec = getDefaultContactAddress(pContact,address_enum);break; 322*cdf0e10cSrcweir default: 323*cdf0e10cSrcweir ec = (EContactAddress *)e_contact_get(pContact,whichAddress(*address_enum)); 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir return ec; 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir static bool 329*cdf0e10cSrcweir handleSplitAddress( EContact *pContact,GValue *pStackValue, int value ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir EContactAddress *ec = getContactAddress(pContact,&value) ; 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir if (ec==NULL) 334*cdf0e10cSrcweir return true; 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir switch (value) { 337*cdf0e10cSrcweir case WORK_ADDR_LINE1: 338*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->street ); break; 339*cdf0e10cSrcweir case WORK_ADDR_LINE2: 340*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->po ); break; 341*cdf0e10cSrcweir case WORK_CITY: 342*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->locality ); break; 343*cdf0e10cSrcweir case WORK_STATE: 344*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->region ); break; 345*cdf0e10cSrcweir case WORK_COUNTRY: 346*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->country ); break; 347*cdf0e10cSrcweir case WORK_ZIP: 348*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->code ); break; 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir case HOME_ADDR_LINE1: 351*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->street ); break; 352*cdf0e10cSrcweir case HOME_ADDR_LINE2: 353*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->po ); break; 354*cdf0e10cSrcweir case HOME_CITY: 355*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->locality ); break; 356*cdf0e10cSrcweir case HOME_STATE: 357*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->region ); break; 358*cdf0e10cSrcweir case HOME_COUNTRY: 359*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->country ); break; 360*cdf0e10cSrcweir case HOME_ZIP: 361*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->code ); break; 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir case OTHER_ADDR_LINE1: 364*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->street ); break; 365*cdf0e10cSrcweir case OTHER_ADDR_LINE2: 366*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->po ); break; 367*cdf0e10cSrcweir case OTHER_CITY: 368*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->locality ); break; 369*cdf0e10cSrcweir case OTHER_STATE: 370*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->region ); break; 371*cdf0e10cSrcweir case OTHER_COUNTRY: 372*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->country ); break; 373*cdf0e10cSrcweir case OTHER_ZIP: 374*cdf0e10cSrcweir g_value_set_string(pStackValue,ec->code ); break; 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir return false; 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir static bool 381*cdf0e10cSrcweir getValue( EContact* pContact, sal_Int32 nColumnNum, GType nType, GValue* pStackValue, bool& _out_rWasNull ) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir const ColumnProperty * pSpecs = evoab::getField( nColumnNum ); 384*cdf0e10cSrcweir if ( !pSpecs ) 385*cdf0e10cSrcweir return false; 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir GParamSpec* pSpec = pSpecs->pField; 388*cdf0e10cSrcweir gboolean bIsSplittedColumn = pSpecs->bIsSplittedValue; 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir _out_rWasNull = true; 391*cdf0e10cSrcweir if ( !pSpec || !pContact) 392*cdf0e10cSrcweir return false; 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir if ( G_PARAM_SPEC_VALUE_TYPE (pSpec) != nType ) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir OSL_TRACE( "Wrong type (0x%x) (0x%x) '%s'", 398*cdf0e10cSrcweir (int)G_PARAM_SPEC_VALUE_TYPE (pSpec), (int) nType, 399*cdf0e10cSrcweir pSpec->name ? pSpec->name : "<noname>"); 400*cdf0e10cSrcweir return false; 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir g_value_init( pStackValue, nType ); 404*cdf0e10cSrcweir if ( bIsSplittedColumn ) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir const SplitEvoColumns* evo_addr( get_evo_addr() ); 407*cdf0e10cSrcweir for (int i=0;i<OTHER_ZIP;i++) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir if (0 == strcmp (g_param_spec_get_name ((GParamSpec *)pSpec), evo_addr[i].pColumnName)) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir _out_rWasNull = handleSplitAddress( pContact, pStackValue, evo_addr[i].value ); 412*cdf0e10cSrcweir return true; 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir else 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir g_object_get_property( G_OBJECT (pContact), 419*cdf0e10cSrcweir g_param_spec_get_name ((GParamSpec *) pSpec), 420*cdf0e10cSrcweir pStackValue ); 421*cdf0e10cSrcweir if ( G_VALUE_TYPE( pStackValue ) != nType ) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir OSL_TRACE( "Fetched type mismatch" ); 424*cdf0e10cSrcweir g_value_unset( pStackValue ); 425*cdf0e10cSrcweir return false; 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir _out_rWasNull = false; 429*cdf0e10cSrcweir return true; 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir namespace 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir struct ComparisonData 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir const SortDescriptor& rSortOrder; 437*cdf0e10cSrcweir IntlWrapper aIntlWrapper; 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir ComparisonData( const SortDescriptor& _rSortOrder, const Reference< XMultiServiceFactory >& _rxFactory ) 440*cdf0e10cSrcweir :rSortOrder( _rSortOrder ) 441*cdf0e10cSrcweir ,aIntlWrapper( _rxFactory, SvtSysLocale().GetLocaleData().getLocale() ) 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir }; 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir extern "C" 448*cdf0e10cSrcweir int CompareContacts( gconstpointer _lhs, gconstpointer _rhs, gpointer _userData ) 449*cdf0e10cSrcweir { 450*cdf0e10cSrcweir EContact* lhs = static_cast< EContact* >( const_cast< gpointer >( _lhs ) ); 451*cdf0e10cSrcweir EContact* rhs = static_cast< EContact* >( const_cast< gpointer >( _rhs ) ); 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir GValue aLhsValue = { 0, { { 0 } } }; 454*cdf0e10cSrcweir GValue aRhsValue = { 0, { { 0 } } }; 455*cdf0e10cSrcweir bool bLhsNull = true; 456*cdf0e10cSrcweir bool bRhsNull = true; 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir ::rtl::OUString sLhs, sRhs; 459*cdf0e10cSrcweir bool bLhs(false), bRhs(false); 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir const ComparisonData& rCompData = *static_cast< const ComparisonData* >( _userData ); 462*cdf0e10cSrcweir for ( SortDescriptor::const_iterator sortCol = rCompData.rSortOrder.begin(); 463*cdf0e10cSrcweir sortCol != rCompData.rSortOrder.end(); 464*cdf0e10cSrcweir ++sortCol 465*cdf0e10cSrcweir ) 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir sal_Int32 nField = sortCol->nField; 468*cdf0e10cSrcweir GType eFieldType = evoab::getGFieldType( nField ); 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir bool success = getValue( lhs, nField, eFieldType, &aLhsValue, bLhsNull ) 471*cdf0e10cSrcweir && getValue( rhs, nField, eFieldType, &aRhsValue, bRhsNull ); 472*cdf0e10cSrcweir OSL_ENSURE( success, "CompareContacts: could not retrieve both values!" ); 473*cdf0e10cSrcweir if ( !success ) 474*cdf0e10cSrcweir return 0; 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir if ( bLhsNull && !bRhsNull ) 477*cdf0e10cSrcweir return -1; 478*cdf0e10cSrcweir if ( !bLhsNull && bRhsNull ) 479*cdf0e10cSrcweir return 1; 480*cdf0e10cSrcweir if ( bLhsNull && bRhsNull ) 481*cdf0e10cSrcweir continue; 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir if ( eFieldType == G_TYPE_STRING ) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir sLhs = valueToOUString( aLhsValue ); 486*cdf0e10cSrcweir sRhs = valueToOUString( aRhsValue ); 487*cdf0e10cSrcweir sal_Int32 nCompResult = rCompData.aIntlWrapper.getCaseCollator()->compareString( sLhs, sRhs ); 488*cdf0e10cSrcweir if ( nCompResult != 0 ) 489*cdf0e10cSrcweir return nCompResult; 490*cdf0e10cSrcweir continue; 491*cdf0e10cSrcweir } 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir bLhs = valueToBool( aLhsValue ); 494*cdf0e10cSrcweir bRhs = valueToBool( aRhsValue ); 495*cdf0e10cSrcweir if ( bLhs && !bRhs ) 496*cdf0e10cSrcweir return -1; 497*cdf0e10cSrcweir if ( !bLhs && bRhs ) 498*cdf0e10cSrcweir return 1; 499*cdf0e10cSrcweir continue; 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir return 0; 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir static GList* 506*cdf0e10cSrcweir sortContacts( GList* _pContactList, const ComparisonData& _rCompData ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir OSL_ENSURE( !_rCompData.rSortOrder.empty(), "sortContacts: no need to call this without any sort order!" ); 509*cdf0e10cSrcweir ENSURE_OR_THROW( _rCompData.aIntlWrapper.getCaseCollator(), "no collator for comparing strings" ); 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir return g_list_sort_with_data( _pContactList, &CompareContacts, const_cast< gpointer >( static_cast< gconstpointer >( &_rCompData ) ) ); 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir // ------------------------------------------------------------------------- 515*cdf0e10cSrcweir void OEvoabResultSet::construct( const QueryData& _rData ) 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir ENSURE_OR_THROW( _rData.getQuery(), "internal error: no EBookQuery" ); 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir EBook *pBook = openBook( ::rtl::OUStringToOString( _rData.sTable, RTL_TEXTENCODING_UTF8 ) ); 520*cdf0e10cSrcweir if ( !pBook ) 521*cdf0e10cSrcweir m_pConnection->throwGenericSQLException( STR_CANNOT_OPEN_BOOK, *this ); 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir g_list_free(m_pContacts); 524*cdf0e10cSrcweir m_pContacts = NULL; 525*cdf0e10cSrcweir bool bExecuteQuery = true; 526*cdf0e10cSrcweir switch ( _rData.eFilterType ) 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir case eFilterNone: 529*cdf0e10cSrcweir if ( !isLocal( pBook ) ) 530*cdf0e10cSrcweir { 531*cdf0e10cSrcweir SQLError aErrorFactory( m_pConnection->getDriver().getMSFactory() ); 532*cdf0e10cSrcweir SQLException aAsException = aErrorFactory.getSQLException( ErrorCondition::DATA_CANNOT_SELECT_UNFILTERED, *this ); 533*cdf0e10cSrcweir m_aWarnings.appendWarning( SQLWarning( 534*cdf0e10cSrcweir aAsException.Message, 535*cdf0e10cSrcweir aAsException.Context, 536*cdf0e10cSrcweir aAsException.SQLState, 537*cdf0e10cSrcweir aAsException.ErrorCode, 538*cdf0e10cSrcweir aAsException.NextException 539*cdf0e10cSrcweir ) ); 540*cdf0e10cSrcweir bExecuteQuery = false; 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir break; 543*cdf0e10cSrcweir case eFilterAlwaysFalse: 544*cdf0e10cSrcweir bExecuteQuery = false; 545*cdf0e10cSrcweir break; 546*cdf0e10cSrcweir case eFilterOther: 547*cdf0e10cSrcweir bExecuteQuery = true; 548*cdf0e10cSrcweir break; 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir if ( bExecuteQuery ) 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir rtl::OString aPassword = m_pConnection->getPassword(); 553*cdf0e10cSrcweir executeQuery( pBook, _rData.getQuery(), &m_pContacts, aPassword, NULL ); 554*cdf0e10cSrcweir m_pConnection->setPassword( aPassword ); 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir if ( m_pContacts && !_rData.aSortOrder.empty() ) 557*cdf0e10cSrcweir { 558*cdf0e10cSrcweir ComparisonData aCompData( _rData.aSortOrder, getConnection()->getDriver().getMSFactory() ); 559*cdf0e10cSrcweir m_pContacts = sortContacts( m_pContacts, aCompData ); 560*cdf0e10cSrcweir } 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir m_nLength = g_list_length( m_pContacts ); 563*cdf0e10cSrcweir OSL_TRACE( "Query return %d records", m_nLength ); 564*cdf0e10cSrcweir m_nIndex = -1; 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir // create our meta data (need the EBookQuery for this) 567*cdf0e10cSrcweir OEvoabResultSetMetaData* pMeta = new OEvoabResultSetMetaData( _rData.sTable ); 568*cdf0e10cSrcweir m_xMetaData = pMeta; 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir pMeta->setEvoabFields( _rData.xSelectColumns ); 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir // ------------------------------------------------------------------------- 574*cdf0e10cSrcweir void OEvoabResultSet::disposing(void) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir ::comphelper::OPropertyContainer::disposing(); 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 579*cdf0e10cSrcweir g_list_free(m_pContacts); 580*cdf0e10cSrcweir m_pContacts = NULL; 581*cdf0e10cSrcweir m_pStatement = NULL; 582*cdf0e10cSrcweir m_xMetaData.clear(); 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir // ------------------------------------------------------------------------- 585*cdf0e10cSrcweir Any SAL_CALL OEvoabResultSet::queryInterface( const Type & rType ) throw(RuntimeException) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir Any aRet = ::comphelper::OPropertyContainer::queryInterface(rType); 588*cdf0e10cSrcweir if(!aRet.hasValue()) 589*cdf0e10cSrcweir aRet = OResultSet_BASE::queryInterface(rType); 590*cdf0e10cSrcweir return aRet; 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir // ------------------------------------------------------------------------- 593*cdf0e10cSrcweir Sequence< Type > SAL_CALL OEvoabResultSet::getTypes( ) throw( RuntimeException) 594*cdf0e10cSrcweir { 595*cdf0e10cSrcweir return ::comphelper::concatSequences( 596*cdf0e10cSrcweir OResultSet_BASE::getTypes(), 597*cdf0e10cSrcweir ::comphelper::OPropertyContainer::getTypes() 598*cdf0e10cSrcweir ); 599*cdf0e10cSrcweir } 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir // ------------------------------------------------------------------------- 602*cdf0e10cSrcweir // XRow Interface 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir /** 605*cdf0e10cSrcweir * getString: 606*cdf0e10cSrcweir * @nColumnNum: The column index from the table. 607*cdf0e10cSrcweir * 608*cdf0e10cSrcweir * If the equivalent NResultSetMetaData.cxx marks the columntype of 609*cdf0e10cSrcweir * nColumnNum as DataType::VARCHAR this accessor is used. 610*cdf0e10cSrcweir */ 611*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OEvoabResultSet::getString( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException) 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 614*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 615*cdf0e10cSrcweir rtl::OUString aResult; 616*cdf0e10cSrcweir if ( m_xMetaData.is()) 617*cdf0e10cSrcweir { 618*cdf0e10cSrcweir OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) m_xMetaData.get(); 619*cdf0e10cSrcweir sal_Int32 nFieldNumber = pMeta->fieldAtColumn(nColumnNum); 620*cdf0e10cSrcweir GValue aValue = { 0, { { 0 } } }; 621*cdf0e10cSrcweir if ( getValue( getCur(), nFieldNumber, G_TYPE_STRING, &aValue, m_bWasNull ) ) 622*cdf0e10cSrcweir aResult = valueToOUString( aValue ); 623*cdf0e10cSrcweir } 624*cdf0e10cSrcweir return aResult; 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir // ------------------------------------------------------------------------- 627*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::getBoolean( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException) 628*cdf0e10cSrcweir { 629*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 630*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 631*cdf0e10cSrcweir sal_Bool bResult = sal_False; 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir if ( m_xMetaData.is()) 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) m_xMetaData.get(); 636*cdf0e10cSrcweir sal_Int32 nFieldNumber = pMeta->fieldAtColumn(nColumnNum); 637*cdf0e10cSrcweir GValue aValue = { 0, { { 0 } } }; 638*cdf0e10cSrcweir if ( getValue( getCur(), nFieldNumber, G_TYPE_BOOLEAN, &aValue, m_bWasNull ) ) 639*cdf0e10cSrcweir bResult = valueToBool( aValue ); 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir return bResult ? sal_True : sal_False; 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir // ------------------------------------------------------------------------- 644*cdf0e10cSrcweir sal_Int64 SAL_CALL OEvoabResultSet::getLong( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 645*cdf0e10cSrcweir { 646*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getLong", *this ); 647*cdf0e10cSrcweir return sal_Int64(); 648*cdf0e10cSrcweir } 649*cdf0e10cSrcweir // ------------------------------------------------------------------------- 650*cdf0e10cSrcweir Reference< XArray > SAL_CALL OEvoabResultSet::getArray( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 651*cdf0e10cSrcweir { 652*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getArray", *this ); 653*cdf0e10cSrcweir return NULL; 654*cdf0e10cSrcweir } 655*cdf0e10cSrcweir // ------------------------------------------------------------------------- 656*cdf0e10cSrcweir Reference< XClob > SAL_CALL OEvoabResultSet::getClob( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getClob", *this ); 659*cdf0e10cSrcweir return NULL; 660*cdf0e10cSrcweir } 661*cdf0e10cSrcweir // ------------------------------------------------------------------------- 662*cdf0e10cSrcweir Reference< XBlob > SAL_CALL OEvoabResultSet::getBlob( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 663*cdf0e10cSrcweir { 664*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getBlob", *this ); 665*cdf0e10cSrcweir return NULL; 666*cdf0e10cSrcweir } 667*cdf0e10cSrcweir // ------------------------------------------------------------------------- 668*cdf0e10cSrcweir Reference< XRef > SAL_CALL OEvoabResultSet::getRef( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 669*cdf0e10cSrcweir { 670*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getRef", *this ); 671*cdf0e10cSrcweir return NULL; 672*cdf0e10cSrcweir } 673*cdf0e10cSrcweir // ------------------------------------------------------------------------- 674*cdf0e10cSrcweir Any SAL_CALL OEvoabResultSet::getObject( sal_Int32 /*nColumnNum*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getObject", *this ); 677*cdf0e10cSrcweir return Any(); 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir // ------------------------------------------------------------------------- 680*cdf0e10cSrcweir sal_Int16 SAL_CALL OEvoabResultSet::getShort( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 681*cdf0e10cSrcweir { 682*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getShort", *this ); 683*cdf0e10cSrcweir return 0; 684*cdf0e10cSrcweir } 685*cdf0e10cSrcweir // ------------------------------------------------------------------------- 686*cdf0e10cSrcweir ::com::sun::star::util::Time SAL_CALL OEvoabResultSet::getTime( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getTime", *this ); 689*cdf0e10cSrcweir return ::com::sun::star::util::Time(); 690*cdf0e10cSrcweir } 691*cdf0e10cSrcweir // ------------------------------------------------------------------------- 692*cdf0e10cSrcweir util::DateTime SAL_CALL OEvoabResultSet::getTimestamp( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 693*cdf0e10cSrcweir { 694*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getTimestamp", *this ); 695*cdf0e10cSrcweir return ::com::sun::star::util::DateTime(); 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir // ------------------------------------------------------------------------- 698*cdf0e10cSrcweir Reference< XInputStream > SAL_CALL OEvoabResultSet::getBinaryStream( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 699*cdf0e10cSrcweir { 700*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getBinaryStream", *this ); 701*cdf0e10cSrcweir return NULL; 702*cdf0e10cSrcweir } 703*cdf0e10cSrcweir // ------------------------------------------------------------------------- 704*cdf0e10cSrcweir Reference< XInputStream > SAL_CALL OEvoabResultSet::getCharacterStream( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getCharacterStream", *this ); 707*cdf0e10cSrcweir return NULL; 708*cdf0e10cSrcweir } 709*cdf0e10cSrcweir // ------------------------------------------------------------------------- 710*cdf0e10cSrcweir sal_Int8 SAL_CALL OEvoabResultSet::getByte( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 711*cdf0e10cSrcweir { 712*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getByte", *this ); 713*cdf0e10cSrcweir return 0; 714*cdf0e10cSrcweir } 715*cdf0e10cSrcweir // ------------------------------------------------------------------------- 716*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL OEvoabResultSet::getBytes( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 717*cdf0e10cSrcweir { 718*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getBytes", *this ); 719*cdf0e10cSrcweir return Sequence< sal_Int8 >(); 720*cdf0e10cSrcweir } 721*cdf0e10cSrcweir // ------------------------------------------------------------------------- 722*cdf0e10cSrcweir ::com::sun::star::util::Date SAL_CALL OEvoabResultSet::getDate( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 723*cdf0e10cSrcweir { 724*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getDate", *this ); 725*cdf0e10cSrcweir return ::com::sun::star::util::Date(); 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir // ------------------------------------------------------------------------- 728*cdf0e10cSrcweir double SAL_CALL OEvoabResultSet::getDouble( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 729*cdf0e10cSrcweir { 730*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getDouble", *this ); 731*cdf0e10cSrcweir return 0; 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir // ------------------------------------------------------------------------- 734*cdf0e10cSrcweir float SAL_CALL OEvoabResultSet::getFloat( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 735*cdf0e10cSrcweir { 736*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getFloat", *this ); 737*cdf0e10cSrcweir return 0; 738*cdf0e10cSrcweir } 739*cdf0e10cSrcweir // ------------------------------------------------------------------------- 740*cdf0e10cSrcweir sal_Int32 SAL_CALL OEvoabResultSet::getInt( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 741*cdf0e10cSrcweir { 742*cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getInt", *this ); 743*cdf0e10cSrcweir return 0; 744*cdf0e10cSrcweir } 745*cdf0e10cSrcweir // XRow Interface Ends 746*cdf0e10cSrcweir // ------------------------------------------------------------------------- 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir // XResultSetMetaDataSupplier Interface 749*cdf0e10cSrcweir Reference< XResultSetMetaData > SAL_CALL OEvoabResultSet::getMetaData( ) throw(SQLException, RuntimeException) 750*cdf0e10cSrcweir { 751*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 752*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir // the meta data should have been created at construction time 755*cdf0e10cSrcweir ENSURE_OR_THROW( m_xMetaData.is(), "internal error: no meta data" ); 756*cdf0e10cSrcweir return m_xMetaData; 757*cdf0e10cSrcweir } 758*cdf0e10cSrcweir // XResultSetMetaDataSupplier Interface Ends 759*cdf0e10cSrcweir // ------------------------------------------------------------------------- 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir // XResultSet Interface 762*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::next( ) throw(SQLException, RuntimeException) 763*cdf0e10cSrcweir { 764*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 765*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 766*cdf0e10cSrcweir if (m_nIndex+1 < m_nLength) { 767*cdf0e10cSrcweir ++m_nIndex ; 768*cdf0e10cSrcweir return true; 769*cdf0e10cSrcweir } 770*cdf0e10cSrcweir else 771*cdf0e10cSrcweir return false; 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir // ------------------------------------------------------------------------- 774*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::wasNull( ) throw(SQLException, RuntimeException) 775*cdf0e10cSrcweir { 776*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 777*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir return m_bWasNull; 780*cdf0e10cSrcweir } 781*cdf0e10cSrcweir // ------------------------------------------------------------------------- 782*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) 783*cdf0e10cSrcweir { 784*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 785*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir return m_nIndex < 0; 788*cdf0e10cSrcweir } 789*cdf0e10cSrcweir // ------------------------------------------------------------------------- 790*cdf0e10cSrcweir sal_Int32 SAL_CALL OEvoabResultSet::getRow( ) throw(SQLException, RuntimeException) 791*cdf0e10cSrcweir { 792*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 793*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir return m_nIndex; 796*cdf0e10cSrcweir } 797*cdf0e10cSrcweir // ------------------------------------------------------------------------- 798*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::isAfterLast( ) throw(SQLException, RuntimeException) 799*cdf0e10cSrcweir { 800*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 801*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 802*cdf0e10cSrcweir 803*cdf0e10cSrcweir return m_nIndex >= m_nLength; 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir // ------------------------------------------------------------------------- 806*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::isFirst( ) throw(SQLException, RuntimeException) 807*cdf0e10cSrcweir { 808*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 809*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir return m_nIndex == 0; 812*cdf0e10cSrcweir } 813*cdf0e10cSrcweir // ------------------------------------------------------------------------- 814*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::isLast( ) throw(SQLException, RuntimeException) 815*cdf0e10cSrcweir { 816*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 817*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 818*cdf0e10cSrcweir 819*cdf0e10cSrcweir return m_nIndex == m_nLength - 1; 820*cdf0e10cSrcweir } 821*cdf0e10cSrcweir // ------------------------------------------------------------------------- 822*cdf0e10cSrcweir void SAL_CALL OEvoabResultSet::beforeFirst( ) throw(SQLException, RuntimeException) 823*cdf0e10cSrcweir { 824*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 825*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir m_nIndex = -1; 828*cdf0e10cSrcweir } 829*cdf0e10cSrcweir // ------------------------------------------------------------------------- 830*cdf0e10cSrcweir void SAL_CALL OEvoabResultSet::afterLast( ) throw(SQLException, RuntimeException) 831*cdf0e10cSrcweir { 832*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 833*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 834*cdf0e10cSrcweir 835*cdf0e10cSrcweir m_nIndex = m_nLength; 836*cdf0e10cSrcweir } 837*cdf0e10cSrcweir // ------------------------------------------------------------------------- 838*cdf0e10cSrcweir 839*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::first( ) throw(SQLException, RuntimeException) 840*cdf0e10cSrcweir { 841*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 842*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir m_nIndex = 0; 845*cdf0e10cSrcweir return true; 846*cdf0e10cSrcweir } 847*cdf0e10cSrcweir // ------------------------------------------------------------------------- 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::last( ) throw(SQLException, RuntimeException) 850*cdf0e10cSrcweir { 851*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 852*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir m_nIndex = m_nLength - 1; 855*cdf0e10cSrcweir return true; 856*cdf0e10cSrcweir } 857*cdf0e10cSrcweir // ------------------------------------------------------------------------- 858*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) 859*cdf0e10cSrcweir { 860*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 861*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 862*cdf0e10cSrcweir if (row < m_nLength) { 863*cdf0e10cSrcweir m_nIndex = row; 864*cdf0e10cSrcweir return true; 865*cdf0e10cSrcweir } 866*cdf0e10cSrcweir else 867*cdf0e10cSrcweir return false; 868*cdf0e10cSrcweir } 869*cdf0e10cSrcweir // ------------------------------------------------------------------------- 870*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) 871*cdf0e10cSrcweir { 872*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 873*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir if ((m_nIndex+row) < m_nLength) { 876*cdf0e10cSrcweir m_nIndex += row; 877*cdf0e10cSrcweir return true; 878*cdf0e10cSrcweir } 879*cdf0e10cSrcweir else 880*cdf0e10cSrcweir return false; 881*cdf0e10cSrcweir } 882*cdf0e10cSrcweir // ------------------------------------------------------------------------- 883*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::previous( ) throw(SQLException, RuntimeException) 884*cdf0e10cSrcweir { 885*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 886*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 887*cdf0e10cSrcweir 888*cdf0e10cSrcweir if(m_nIndex > 0) { 889*cdf0e10cSrcweir m_nIndex--; 890*cdf0e10cSrcweir return true; 891*cdf0e10cSrcweir } 892*cdf0e10cSrcweir else 893*cdf0e10cSrcweir return false; 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir // ------------------------------------------------------------------------- 896*cdf0e10cSrcweir Reference< XInterface > SAL_CALL OEvoabResultSet::getStatement( ) throw(SQLException, RuntimeException) 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 899*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 900*cdf0e10cSrcweir ::com::sun::star::uno::WeakReferenceHelper aStatement((OWeakObject*)m_pStatement); 901*cdf0e10cSrcweir return aStatement.get(); 902*cdf0e10cSrcweir } 903*cdf0e10cSrcweir // ------------------------------------------------------------------------- 904*cdf0e10cSrcweir 905*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::rowDeleted( ) throw(SQLException, RuntimeException) 906*cdf0e10cSrcweir { 907*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 908*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 909*cdf0e10cSrcweir 910*cdf0e10cSrcweir return sal_False; 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir // ------------------------------------------------------------------------- 913*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::rowInserted( ) throw(SQLException, RuntimeException) 914*cdf0e10cSrcweir { 915*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 916*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir return sal_False; 919*cdf0e10cSrcweir } 920*cdf0e10cSrcweir // ------------------------------------------------------------------------- 921*cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSet::rowUpdated( ) throw(SQLException, RuntimeException) 922*cdf0e10cSrcweir { 923*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 924*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir return sal_False; 927*cdf0e10cSrcweir } 928*cdf0e10cSrcweir // ------------------------------------------------------------------------- 929*cdf0e10cSrcweir void SAL_CALL OEvoabResultSet::refreshRow( ) throw(SQLException, RuntimeException) 930*cdf0e10cSrcweir { 931*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 932*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 933*cdf0e10cSrcweir } 934*cdf0e10cSrcweir //XResult Interface ends 935*cdf0e10cSrcweir // ------------------------------------------------------------------------- 936*cdf0e10cSrcweir // XCancellable 937*cdf0e10cSrcweir 938*cdf0e10cSrcweir void SAL_CALL OEvoabResultSet::cancel( ) throw(RuntimeException) 939*cdf0e10cSrcweir { 940*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 941*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 942*cdf0e10cSrcweir OSL_TRACE("In/Out: OEvoabResultSet::cancel" ); 943*cdf0e10cSrcweir 944*cdf0e10cSrcweir } 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir //XCloseable 947*cdf0e10cSrcweir void SAL_CALL OEvoabResultSet::close( ) throw(SQLException, RuntimeException) 948*cdf0e10cSrcweir { 949*cdf0e10cSrcweir { 950*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 951*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 952*cdf0e10cSrcweir } 953*cdf0e10cSrcweir OSL_TRACE("In/Out: OEvoabResultSet::close" ); 954*cdf0e10cSrcweir dispose(); 955*cdf0e10cSrcweir } 956*cdf0e10cSrcweir 957*cdf0e10cSrcweir // XWarningsSupplier 958*cdf0e10cSrcweir // ------------------------------------------------------------------------- 959*cdf0e10cSrcweir void SAL_CALL OEvoabResultSet::clearWarnings( ) throw(SQLException, RuntimeException) 960*cdf0e10cSrcweir { 961*cdf0e10cSrcweir OSL_TRACE("In/Out: OEvoabResultSet::clearWarnings" ); 962*cdf0e10cSrcweir m_aWarnings.clearWarnings(); 963*cdf0e10cSrcweir } 964*cdf0e10cSrcweir // ------------------------------------------------------------------------- 965*cdf0e10cSrcweir Any SAL_CALL OEvoabResultSet::getWarnings( ) throw(SQLException, RuntimeException) 966*cdf0e10cSrcweir { 967*cdf0e10cSrcweir OSL_TRACE("In/Out: OEvoabResultSet::getWarnings" ); 968*cdf0e10cSrcweir return m_aWarnings.getWarnings(); 969*cdf0e10cSrcweir } 970*cdf0e10cSrcweir // ------------------------------------------------------------------------- 971*cdf0e10cSrcweir //XColumnLocate Interface 972*cdf0e10cSrcweir sal_Int32 SAL_CALL OEvoabResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException) 973*cdf0e10cSrcweir { 974*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 975*cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 976*cdf0e10cSrcweir 977*cdf0e10cSrcweir // find the first column with the name columnName 978*cdf0e10cSrcweir Reference< XResultSetMetaData > xMeta = getMetaData(); 979*cdf0e10cSrcweir sal_Int32 nLen = xMeta->getColumnCount(); 980*cdf0e10cSrcweir sal_Int32 i = 1; 981*cdf0e10cSrcweir for(;i<=nLen;++i) 982*cdf0e10cSrcweir if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) : 983*cdf0e10cSrcweir columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))) 984*cdf0e10cSrcweir break; 985*cdf0e10cSrcweir return i; 986*cdf0e10cSrcweir } 987*cdf0e10cSrcweir // ------------------------------------------------------------------------- 988*cdf0e10cSrcweir //XColumnLocate interface ends 989*cdf0e10cSrcweir 990*cdf0e10cSrcweir // ------------------------------------------------------------------------- 991*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* OEvoabResultSet::createArrayHelper( ) const 992*cdf0e10cSrcweir { 993*cdf0e10cSrcweir Sequence< Property > aProps; 994*cdf0e10cSrcweir describeProperties( aProps ); 995*cdf0e10cSrcweir return new ::cppu::OPropertyArrayHelper( aProps ); 996*cdf0e10cSrcweir } 997*cdf0e10cSrcweir // ------------------------------------------------------------------------- 998*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper & OEvoabResultSet::getInfoHelper() 999*cdf0e10cSrcweir { 1000*cdf0e10cSrcweir return *const_cast<OEvoabResultSet*>(this)->getArrayHelper(); 1001*cdf0e10cSrcweir } 1002*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1003*cdf0e10cSrcweir void SAL_CALL OEvoabResultSet::acquire() throw() 1004*cdf0e10cSrcweir { 1005*cdf0e10cSrcweir OResultSet_BASE::acquire(); 1006*cdf0e10cSrcweir } 1007*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1008*cdf0e10cSrcweir void SAL_CALL OEvoabResultSet::release() throw() 1009*cdf0e10cSrcweir { 1010*cdf0e10cSrcweir OResultSet_BASE::release(); 1011*cdf0e10cSrcweir } 1012*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1013*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL 1014*cdf0e10cSrcweir OEvoabResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) 1015*cdf0e10cSrcweir { 1016*cdf0e10cSrcweir return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); 1017*cdf0e10cSrcweir } 1018*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1019*cdf0e10cSrcweir 1020*cdf0e10cSrcweir } } // connectivity::evoab 1021