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