LibreOffice Module connectivity (master) 1
NResultSet.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
21#include "NDatabaseMetaData.hxx"
22#include "NConnection.hxx"
23#include "NResultSet.hxx"
24#include <propertyids.hxx>
25#include <strings.hrc>
26
27#include <com/sun/star/beans/PropertyAttribute.hpp>
28#include <com/sun/star/sdb/ErrorCondition.hpp>
29#include <com/sun/star/sdbc/FetchDirection.hpp>
30#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
31#include <com/sun/star/sdbc/ResultSetType.hpp>
32
37#include <rtl/string.hxx>
38#include <sal/log.hxx>
43
44#include <cstring>
45
46namespace connectivity::evoab {
47
48using namespace ::comphelper;
49using namespace com::sun::star;
50using namespace com::sun::star::uno;
51using namespace com::sun::star::lang;
52using namespace com::sun::star::beans;
53using namespace com::sun::star::sdbc;
54using namespace com::sun::star::sdbcx;
55using namespace com::sun::star::container;
56using namespace com::sun::star::io;
58
59
60OUString SAL_CALL OEvoabResultSet::getImplementationName( )
61{
62 return "com.sun.star.sdbcx.evoab.ResultSet";
63}
64
65 Sequence< OUString > SAL_CALL OEvoabResultSet::getSupportedServiceNames( )
66{
67 return { "com.sun.star.sdbc.ResultSet" };
68}
69
70sal_Bool SAL_CALL OEvoabResultSet::supportsService( const OUString& _rServiceName )
71{
72 return cppu::supportsService(this, _rServiceName);
73}
74
76{
79
80 ComparisonData(const SortDescriptor& _rSortOrder)
81 : rSortOrder(_rSortOrder)
82 , aIntlWrapper(SvtSysLocale().GetUILanguageTag())
83 {
84 }
85};
86
87static OUString
88valueToOUString( GValue& _rValue )
89{
90 const char *pStr = g_value_get_string( &_rValue );
91 std::string_view aStr( pStr ? pStr : "" );
92 OUString sResult( OStringToOUString( aStr, RTL_TEXTENCODING_UTF8 ) );
93 g_value_unset( &_rValue );
94 return sResult;
95}
96
97static bool
98valueToBool( GValue& _rValue )
99{
100 bool bResult = g_value_get_boolean( &_rValue );
101 g_value_unset( &_rValue );
102 return bResult;
103}
104
105static int
106whichAddress(int value)
107{
108 int fieldEnum;
109 switch (value)
110 {
111 case HOME_ADDR_LINE1:
112 case HOME_ADDR_LINE2:
113 case HOME_CITY:
114 case HOME_STATE:
115 case HOME_COUNTRY:
116 case HOME_ZIP:
117 fieldEnum = e_contact_field_id("address_home");
118 break;
119
120 case WORK_ADDR_LINE1:
121 case WORK_ADDR_LINE2:
122 case WORK_CITY:
123 case WORK_STATE:
124 case WORK_COUNTRY:
125 case WORK_ZIP:
126 fieldEnum = e_contact_field_id("address_work");
127 break;
128
129 case OTHER_ADDR_LINE1:
130 case OTHER_ADDR_LINE2:
131 case OTHER_CITY:
132 case OTHER_STATE:
133 case OTHER_COUNTRY:
134 case OTHER_ZIP:
135 fieldEnum = e_contact_field_id("address_other");
136 break;
137
138 default: fieldEnum = e_contact_field_id("address_home");
139 }
140 return fieldEnum;
141}
142
143/*
144* This function decides the default column values based on the first field of EContactAddress.
145* The search order is Work->Home->other(defaults).
146*/
147static EContactAddress *
148getDefaultContactAddress( EContact *pContact,int *value )
149{
151 if ( ec && (ec->street[0]!='\0') )
152 {
154 return ec;
155 }
156 else
157 {
158 ec = static_cast<EContactAddress *>(e_contact_get(pContact,whichAddress(HOME_ADDR_LINE1)));
159 if ( ec && (ec->street[0]!='\0') )
160 {
162 return ec;
163 }
164 }
165
167 return static_cast<EContactAddress *>(e_contact_get(pContact,whichAddress(OTHER_ADDR_LINE1)));
168}
169
170static EContactAddress*
171getContactAddress( EContact *pContact, int * address_enum )
172{
173 EContactAddress *ec = nullptr;
174 switch (*address_enum) {
175
178 case DEFAULT_CITY:
179 case DEFAULT_STATE:
180 case DEFAULT_COUNTRY:
181 case DEFAULT_ZIP:
182 ec = getDefaultContactAddress(pContact,address_enum);break;
183 default:
184 ec = static_cast<EContactAddress *>(e_contact_get(pContact,whichAddress(*address_enum)));
185 }
186 return ec;
187}
188
189static bool
190handleSplitAddress( EContact *pContact,GValue *pStackValue, int value )
191{
192 EContactAddress *ec = getContactAddress(pContact,&value) ;
193
194 if (ec==nullptr)
195 return true;
196
197 switch (value) {
198 case WORK_ADDR_LINE1:
199 g_value_set_string(pStackValue,ec->street ); break;
200 case WORK_ADDR_LINE2:
201 g_value_set_string(pStackValue,ec->po ); break;
202 case WORK_CITY:
203 g_value_set_string(pStackValue,ec->locality ); break;
204 case WORK_STATE:
205 g_value_set_string(pStackValue,ec->region ); break;
206 case WORK_COUNTRY:
207 g_value_set_string(pStackValue,ec->country ); break;
208 case WORK_ZIP:
209 g_value_set_string(pStackValue,ec->code ); break;
210
211 case HOME_ADDR_LINE1:
212 g_value_set_string(pStackValue,ec->street ); break;
213 case HOME_ADDR_LINE2:
214 g_value_set_string(pStackValue,ec->po ); break;
215 case HOME_CITY:
216 g_value_set_string(pStackValue,ec->locality ); break;
217 case HOME_STATE:
218 g_value_set_string(pStackValue,ec->region ); break;
219 case HOME_COUNTRY:
220 g_value_set_string(pStackValue,ec->country ); break;
221 case HOME_ZIP:
222 g_value_set_string(pStackValue,ec->code ); break;
223
224 case OTHER_ADDR_LINE1:
225 g_value_set_string(pStackValue,ec->street ); break;
226 case OTHER_ADDR_LINE2:
227 g_value_set_string(pStackValue,ec->po ); break;
228 case OTHER_CITY:
229 g_value_set_string(pStackValue,ec->locality ); break;
230 case OTHER_STATE:
231 g_value_set_string(pStackValue,ec->region ); break;
232 case OTHER_COUNTRY:
233 g_value_set_string(pStackValue,ec->country ); break;
234 case OTHER_ZIP:
235 g_value_set_string(pStackValue,ec->code ); break;
236
237 }
238
239 return false;
240}
241
242static bool
243getValue( EContact* pContact, sal_Int32 nColumnNum, GType nType, GValue* pStackValue, bool& _out_rWasNull )
244{
245 const ColumnProperty * pSpecs = evoab::getField( nColumnNum );
246 if ( !pSpecs )
247 return false;
248
249 GParamSpec* pSpec = pSpecs->pField;
250 bool bIsSplittedColumn = pSpecs->bIsSplittedValue;
251
252 _out_rWasNull = true;
253 if ( !pSpec || !pContact)
254 return false;
255
256 if ( G_PARAM_SPEC_VALUE_TYPE (pSpec) != nType )
257 {
258 SAL_WARN("connectivity.evoab2", "Wrong type (0x" << std::hex << static_cast<int>(G_PARAM_SPEC_VALUE_TYPE(pSpec)) << ") (0x"
259 << std::hex << static_cast<int>(nType) << ") " << (pSpec->name ? pSpec->name : "<noname>"));
260 return false;
261 }
262
263 g_value_init( pStackValue, nType );
264 if ( bIsSplittedColumn )
265 {
266 const SplitEvoColumns* evo_addr( get_evo_addr() );
267 for (int i=0;i<OTHER_ZIP;i++)
268 {
269 if (0 == strcmp (g_param_spec_get_name (pSpec), evo_addr[i].pColumnName))
270 {
271 _out_rWasNull = handleSplitAddress( pContact, pStackValue, evo_addr[i].value );
272 return true;
273 }
274 }
275 }
276 else
277 {
278 g_object_get_property( G_OBJECT (pContact),
279 g_param_spec_get_name (pSpec),
280 pStackValue );
281 if ( G_VALUE_TYPE( pStackValue ) != nType )
282 {
283 SAL_WARN("connectivity.evoab2", "Fetched type mismatch" );
284 g_value_unset( pStackValue );
285 return false;
286 }
287 }
288 _out_rWasNull = false;
289 return true;
290}
291
292extern "C" {
293
294static int CompareContacts( gconstpointer _lhs, gconstpointer _rhs, gpointer _userData )
295{
296 EContact* lhs = const_cast< gpointer >( _lhs );
297 EContact* rhs = const_cast< gpointer >( _rhs );
298
299 GValue aLhsValue = { 0, { { 0 } } };
300 GValue aRhsValue = { 0, { { 0 } } };
301 bool bLhsNull = true;
302 bool bRhsNull = true;
303
304 OUString sLhs, sRhs;
305 bool bLhs(false), bRhs(false);
306
307 const ComparisonData& rCompData = *static_cast< const ComparisonData* >( _userData );
308 for ( const auto& sortCol : rCompData.rSortOrder )
309 {
310 sal_Int32 nField = sortCol.nField;
311 int nOrder = 1;
312 // if descending sort, reverse order
313 if (!sortCol.bAscending)
314 nOrder = -1;
315 GType eFieldType = evoab::getGFieldType( nField );
316
317 bool success = getValue( lhs, nField, eFieldType, &aLhsValue, bLhsNull )
318 && getValue( rhs, nField, eFieldType, &aRhsValue, bRhsNull );
319 OSL_ENSURE( success, "CompareContacts: could not retrieve both values!" );
320 if ( !success )
321 return 0;
322
323 if ( bLhsNull && !bRhsNull )
324 return -1 * nOrder;
325 if ( !bLhsNull && bRhsNull )
326 return 1 * nOrder;
327 if ( bLhsNull && bRhsNull )
328 continue;
329
330 if ( eFieldType == G_TYPE_STRING )
331 {
332 sLhs = valueToOUString( aLhsValue );
333 sRhs = valueToOUString( aRhsValue );
334 sal_Int32 nCompResult = rCompData.aIntlWrapper.getCaseCollator()->compareString( sLhs, sRhs );
335 if ( nCompResult != 0 )
336 return nCompResult * nOrder;
337 continue;
338 }
339
340 bLhs = valueToBool( aLhsValue );
341 bRhs = valueToBool( aRhsValue );
342 if ( bLhs && !bRhs )
343 return -1 * nOrder;
344 if ( !bLhs && bRhs )
345 return 1 * nOrder;
346 continue;
347 }
348
349 return 0;
350}
351
352}
353
355{
356 OString aName;
357 if( isLDAP( pBook ) )
358 aName = e_source_get_property( e_book_get_source( pBook ), "binddn" );
359 else
360 aName = e_source_get_property( e_book_get_source( pBook ), "user" );
361 return aName;
362}
363
364namespace {
365
366bool isBookBackend( EBookClient *pBook, const char *backendname)
367{
368 if (!pBook)
369 return false;
370 ESource *pSource = e_client_get_source (reinterpret_cast<EClient *>(pBook));
371 return isSourceBackend(pSource, backendname);
372}
373
374class OEvoabVersion36Helper : public OEvoabVersionHelper
375{
376private:
377 GSList *m_pContacts;
378public:
379 OEvoabVersion36Helper()
380 : m_pContacts(nullptr)
381 {
382 }
383
384 virtual ~OEvoabVersion36Helper() override
385 {
386 freeContacts();
387 }
388
389 virtual EBook* openBook(const char *abname) override
390 {
391 //It would be better if here we had id to begin with, see
392 //NDatabaseMetaData.cxx
393 const char *id = nullptr;
395 for (GList* liter = pSources; liter; liter = liter->next)
396 {
397 ESource *pSource = E_SOURCE (liter->data);
398
399 if (strcmp(abname, e_source_get_display_name( pSource )) == 0)
400 {
401 id = e_source_get_uid( pSource );
402 break;
403 }
404 }
405 g_list_foreach (pSources, reinterpret_cast<GFunc>(g_object_unref), nullptr);
406 g_list_free (pSources);
407 if (!id)
408 return nullptr;
409
411 EBookClient *pBook = pSource ? createClient (pSource) : nullptr;
412 if (pBook && !e_client_open_sync (pBook, true, nullptr, nullptr))
413 {
414 g_object_unref (G_OBJECT (pBook));
415 pBook = nullptr;
416 }
417 if (pSource)
418 g_object_unref (pSource);
419 return pBook;
420 }
421
422 virtual bool isLDAP( EBook *pBook ) override
423 {
424 return isBookBackend(pBook, "ldap");
425 }
426
427 virtual bool isLocal( EBook *pBook ) override
428 {
429 return isBookBackend(pBook, "local");
430 }
431
432 virtual void freeContacts() override final
433 {
435 m_pContacts = nullptr;
436 }
437
438 virtual void executeQuery (EBook* pBook, EBookQuery* pQuery) override
439 {
440 freeContacts();
441 char *sexp = e_book_query_to_string( pQuery );
442 e_book_client_get_contacts_sync( pBook, sexp, &m_pContacts, nullptr, nullptr );
443 g_free (sexp);
444 }
445
446 virtual EContact *getContact(sal_Int32 nIndex) override
447 {
448 gpointer pData = g_slist_nth_data (m_pContacts, nIndex);
449 return pData ? E_CONTACT (pData) : nullptr;
450 }
451
452 virtual sal_Int32 getNumContacts() override
453 {
454 return g_slist_length( m_pContacts );
455 }
456
457 virtual bool hasContacts() override
458 {
459 return m_pContacts != nullptr;
460 }
461
462 virtual void sortContacts( const ComparisonData& _rCompData ) override
463 {
464 OSL_ENSURE( !_rCompData.rSortOrder.empty(), "sortContacts: no need to call this without any sort order!" );
465 ENSURE_OR_THROW( _rCompData.aIntlWrapper.getCaseCollator(), "no collator for comparing strings" );
466
467 m_pContacts = g_slist_sort_with_data( m_pContacts, &CompareContacts,
468 const_cast< gpointer >( static_cast< gconstpointer >( &_rCompData ) ) );
469 }
470
471protected:
472 virtual EBookClient * createClient( ESource *pSource )
473 {
474 return e_book_client_new (pSource, nullptr);
475 }
476};
477
478class OEvoabVersion38Helper : public OEvoabVersion36Helper
479{
480protected:
481 virtual EBookClient * createClient( ESource *pSource ) override
482 {
483 return e_book_client_connect_direct_sync (get_e_source_registry (), pSource, 10, nullptr, nullptr);
484 }
485};
486
487}
488
492 ,m_pStatement(pStmt)
493 ,m_pConnection(pConnection)
494 ,m_bWasNull(true)
495 ,m_nFetchSize(0)
496 ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE)
497 ,m_nFetchDirection(FetchDirection::FORWARD)
498 ,m_nResultSetConcurrency(ResultSetConcurrency::READ_ONLY)
499 ,m_nIndex(-1)
500 ,m_nLength(0)
501{
502 m_pVersionHelper = std::make_unique<OEvoabVersion38Helper>();
503
507 PropertyAttribute::READONLY,
509 cppu::UnoType<decltype(m_nFetchSize)>::get()
510 );
514 PropertyAttribute::READONLY,
516 cppu::UnoType<decltype(m_nResultSetType)>::get()
517 );
521 PropertyAttribute::READONLY,
523 cppu::UnoType<decltype(m_nFetchDirection)>::get()
524 );
528 PropertyAttribute::READONLY,
530 cppu::UnoType<decltype(m_nResultSetConcurrency)>::get()
531 );
532}
533
535{}
536
538{
539 ENSURE_OR_THROW( _rData.getQuery(), "internal error: no EBookQuery" );
540
541 EBook *pBook = m_pVersionHelper->openBook(OUStringToOString(_rData.sTable, RTL_TEXTENCODING_UTF8).getStr());
542 if ( !pBook )
543 m_pConnection->throwGenericSQLException( STR_CANNOT_OPEN_BOOK, *this );
544
545 m_pVersionHelper->freeContacts();
546 bool bExecuteQuery = true;
547 switch ( _rData.eFilterType )
548 {
549 case eFilterNone:
550 if ( !m_pVersionHelper->isLocal( pBook ) )
551 {
552 SQLError aErrorFactory;
553 SQLException aAsException = aErrorFactory.getSQLException( ErrorCondition::DATA_CANNOT_SELECT_UNFILTERED, *this );
554 m_aWarnings.appendWarning( SQLWarning(
555 aAsException.Message,
556 aAsException.Context,
557 aAsException.SQLState,
558 aAsException.ErrorCode,
559 aAsException.NextException
560 ) );
561 bExecuteQuery = false;
562 }
563 break;
565 bExecuteQuery = false;
566 break;
567 case eFilterOther:
568 bExecuteQuery = true;
569 break;
570 }
571 if ( bExecuteQuery )
572 {
573 m_pVersionHelper->executeQuery(pBook, _rData.getQuery());
574
575 if ( m_pVersionHelper->hasContacts() && !_rData.aSortOrder.empty() )
576 {
577 ComparisonData aCompData(_rData.aSortOrder);
578 m_pVersionHelper->sortContacts(aCompData);
579 }
580 }
581 m_nLength = m_pVersionHelper->getNumContacts();
582 SAL_INFO("connectivity.evoab2", "Query return " << m_nLength << " records");
583 m_nIndex = -1;
584
585 // create our meta data (need the EBookQuery for this)
587
588 m_xMetaData->setEvoabFields( _rData.xSelectColumns );
589}
590
591
593{
594 ::comphelper::OPropertyContainer::disposing();
595
596 ::osl::MutexGuard aGuard(m_aMutex);
597 m_pVersionHelper.reset();
598 m_pStatement = nullptr;
599 m_xMetaData.clear();
600}
601
602Any SAL_CALL OEvoabResultSet::queryInterface( const Type & rType )
603{
604 Any aRet = ::comphelper::OPropertyContainer::queryInterface(rType);
605 if(!aRet.hasValue())
606 aRet = OResultSet_BASE::queryInterface(rType);
607 return aRet;
608}
609
611{
612 return ::comphelper::concatSequences(
613 OResultSet_BASE::getTypes(),
615 );
616}
617
618
619// XRow Interface
620
628OUString SAL_CALL OEvoabResultSet::getString( sal_Int32 nColumnNum )
629{
630 ::osl::MutexGuard aGuard( m_aMutex );
631 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
632 OUString aResult;
633 if ( m_xMetaData.is())
634 {
635 sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(nColumnNum);
636 GValue aValue = { 0, { { 0 } } };
637 if ( getValue( getCur(), nFieldNumber, G_TYPE_STRING, &aValue, m_bWasNull ) )
638 aResult = valueToOUString( aValue );
639 }
640 return aResult;
641}
642
643sal_Bool SAL_CALL OEvoabResultSet::getBoolean( sal_Int32 nColumnNum )
644{
645 ::osl::MutexGuard aGuard( m_aMutex );
646 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
647 bool bResult = false;
648
649 if ( m_xMetaData.is())
650 {
651 sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(nColumnNum);
652 GValue aValue = { 0, { { 0 } } };
653 if ( getValue( getCur(), nFieldNumber, G_TYPE_BOOLEAN, &aValue, m_bWasNull ) )
654 bResult = valueToBool( aValue );
655 }
656 return bResult;
657}
658
659sal_Int64 SAL_CALL OEvoabResultSet::getLong( sal_Int32 /*nColumnNum*/ )
660{
661 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getLong", *this );
662 return sal_Int64();
663}
664
665Reference< XArray > SAL_CALL OEvoabResultSet::getArray( sal_Int32 /*nColumnNum*/ )
666{
667 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getArray", *this );
668 return nullptr;
669}
670
671Reference< XClob > SAL_CALL OEvoabResultSet::getClob( sal_Int32 /*nColumnNum*/ )
672{
673 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getClob", *this );
674 return nullptr;
675}
676
677Reference< XBlob > SAL_CALL OEvoabResultSet::getBlob( sal_Int32 /*nColumnNum*/ )
678{
679 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getBlob", *this );
680 return nullptr;
681}
682
683Reference< XRef > SAL_CALL OEvoabResultSet::getRef( sal_Int32 /*nColumnNum*/ )
684{
686 return nullptr;
687}
688
689Any SAL_CALL OEvoabResultSet::getObject( sal_Int32 /*nColumnNum*/, const Reference< css::container::XNameAccess >& /*typeMap*/ )
690{
691 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getObject", *this );
692 return Any();
693}
694
695sal_Int16 SAL_CALL OEvoabResultSet::getShort( sal_Int32 /*nColumnNum*/ )
696{
697 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getShort", *this );
698 return 0;
699}
700
701css::util::Time SAL_CALL OEvoabResultSet::getTime( sal_Int32 /*nColumnNum*/ )
702{
703 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getTime", *this );
704 return css::util::Time();
705}
706
707util::DateTime SAL_CALL OEvoabResultSet::getTimestamp( sal_Int32 /*nColumnNum*/ )
708{
709 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getTimestamp", *this );
710 return css::util::DateTime();
711}
712
714{
715 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getBinaryStream", *this );
716 return nullptr;
717}
718
720{
721 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getCharacterStream", *this );
722 return nullptr;
723}
724
725sal_Int8 SAL_CALL OEvoabResultSet::getByte( sal_Int32 /*nColumnNum*/ )
726{
727 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getByte", *this );
728 return 0;
729}
730
731Sequence< sal_Int8 > SAL_CALL OEvoabResultSet::getBytes( sal_Int32 /*nColumnNum*/ )
732{
733 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getBytes", *this );
734 return Sequence< sal_Int8 >();
735}
736
737css::util::Date SAL_CALL OEvoabResultSet::getDate( sal_Int32 /*nColumnNum*/ )
738{
739 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getDate", *this );
740 return css::util::Date();
741}
742
743double SAL_CALL OEvoabResultSet::getDouble( sal_Int32 /*nColumnNum*/ )
744{
745 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getDouble", *this );
746 return 0;
747}
748
749float SAL_CALL OEvoabResultSet::getFloat( sal_Int32 /*nColumnNum*/ )
750{
751 ::dbtools::throwFunctionNotSupportedSQLException( "XRow::getFloat", *this );
752 return 0;
753}
754
755sal_Int32 SAL_CALL OEvoabResultSet::getInt( sal_Int32 /*nColumnNum*/ )
756{
758 return 0;
759}
760// XRow Interface Ends
761
762
763// XResultSetMetaDataSupplier Interface
765{
766 ::osl::MutexGuard aGuard( m_aMutex );
767 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
768
769 // the meta data should have been created at construction time
770 ENSURE_OR_THROW( m_xMetaData.is(), "internal error: no meta data" );
771 return m_xMetaData;
772}
773// XResultSetMetaDataSupplier Interface Ends
774
775
776// XResultSet Interface
778{
779 ::osl::MutexGuard aGuard( m_aMutex );
780 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
781 if (m_nIndex+1 < m_nLength) {
782 ++m_nIndex ;
783 return true;
784 }
785 else
786 return false;
787}
788
790{
791 ::osl::MutexGuard aGuard( m_aMutex );
792 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
793
794 return m_bWasNull;
795}
796
798{
799 ::osl::MutexGuard aGuard( m_aMutex );
800 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
801
802 return m_nIndex < 0;
803}
804
805sal_Int32 SAL_CALL OEvoabResultSet::getRow( )
806{
807 ::osl::MutexGuard aGuard( m_aMutex );
808 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
809
810 return m_nIndex;
811}
812
814{
815 ::osl::MutexGuard aGuard( m_aMutex );
816 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
817
818 return m_nIndex >= m_nLength;
819}
820
822{
823 ::osl::MutexGuard aGuard( m_aMutex );
824 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
825
826 return m_nIndex == 0;
827}
828
830{
831 ::osl::MutexGuard aGuard( m_aMutex );
832 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
833
834 return m_nIndex == m_nLength - 1;
835}
836
838{
839 ::osl::MutexGuard aGuard( m_aMutex );
840 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
841
842 m_nIndex = -1;
843}
844
846{
847 ::osl::MutexGuard aGuard( m_aMutex );
848 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
849
851}
852
853
855{
856 ::osl::MutexGuard aGuard( m_aMutex );
857 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
858
859 m_nIndex = 0;
860 return true;
861}
862
863
865{
866 ::osl::MutexGuard aGuard( m_aMutex );
867 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
868
869 m_nIndex = m_nLength - 1;
870 return true;
871}
872
873sal_Bool SAL_CALL OEvoabResultSet::absolute( sal_Int32 row )
874{
875 ::osl::MutexGuard aGuard( m_aMutex );
876 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
877 if (row < m_nLength) {
878 m_nIndex = row;
879 return true;
880 }
881 else
882 return false;
883}
884
885sal_Bool SAL_CALL OEvoabResultSet::relative( sal_Int32 row )
886{
887 ::osl::MutexGuard aGuard( m_aMutex );
888 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
889
890 if ((m_nIndex+row) < m_nLength) {
891 m_nIndex += row;
892 return true;
893 }
894 else
895 return false;
896}
897
899{
900 ::osl::MutexGuard aGuard( m_aMutex );
901 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
902
903 if(m_nIndex > 0) {
904 m_nIndex--;
905 return true;
906 }
907 else
908 return false;
909}
910
912{
913 ::osl::MutexGuard aGuard( m_aMutex );
914 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
915 return cppu::getXWeak(m_pStatement);
916}
917
918
920{
921 ::osl::MutexGuard aGuard( m_aMutex );
922 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
923
924 return false;
925}
926
928{
929 ::osl::MutexGuard aGuard( m_aMutex );
930 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
931
932 return false;
933}
934
936{
937 ::osl::MutexGuard aGuard( m_aMutex );
938 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
939
940 return false;
941}
942
944{
945 ::osl::MutexGuard aGuard( m_aMutex );
946 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
947}
948//XResult Interface ends
949
950// XCancellable
951
953{
954 ::osl::MutexGuard aGuard( m_aMutex );
955 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
956}
957
958//XCloseable
960{
961 {
962 ::osl::MutexGuard aGuard( m_aMutex );
963 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
964 }
965 dispose();
966}
967
968// XWarningsSupplier
969
971{
973}
974
976{
977 return m_aWarnings.getWarnings();
978}
979
980//XColumnLocate Interface
981sal_Int32 SAL_CALL OEvoabResultSet::findColumn( const OUString& columnName )
982{
983 ::osl::MutexGuard aGuard( m_aMutex );
984 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
985
986 // find the first column with the name columnName
988 sal_Int32 nLen = xMeta->getColumnCount();
989 sal_Int32 i = 1;
990 for(;i<=nLen;++i)
991 {
992 if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
993 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
994 return i;
995 }
996
998 assert(false);
999 return 0; // Never reached
1000}
1001
1002//XColumnLocate interface ends
1003
1004
1006{
1007 Sequence< Property > aProps;
1008 describeProperties( aProps );
1009 return new ::cppu::OPropertyArrayHelper( aProps );
1010}
1011
1013{
1014 return *getArrayHelper();
1015}
1016
1017void SAL_CALL OEvoabResultSet::acquire() noexcept
1018{
1019 OResultSet_BASE::acquire();
1020}
1021
1022void SAL_CALL OEvoabResultSet::release() noexcept
1023{
1024 OResultSet_BASE::release();
1025}
1026
1027css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
1029{
1030 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
1031}
1032
1033
1034} // connectivity::evoab
1035
1036/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ESourceRegistry * get_e_source_registry()
Definition: EApi.cxx:129
EAPI_EXTERN void(* e_client_util_free_object_slist)(GSList *objects)
Definition: EApi.h:153
EAPI_EXTERN ESource *(* e_client_get_source)(EClient *client)
Definition: EApi.h:151
#define E_CONTACT(a)
Definition: EApi.h:45
EAPI_EXTERN EContactField(* e_contact_field_id)(const char *field_name)
Definition: EApi.h:60
EAPI_EXTERN EBookClient *(* e_book_client_connect_direct_sync)(ESourceRegistry *registry, ESource *source, guint32 wait_for_connected_seconds, GCancellable *cancellable, GError **error)
Definition: EApi.h:149
EAPI_EXTERN const gchar *(* e_source_get_display_name)(ESource *source)
Definition: EApi.h:144
void EClient
Definition: EApi.h:137
EAPI_EXTERN gpointer(* e_contact_get)(EContact *contact, EContactField field_id)
Definition: EApi.h:50
EClient EBookClient
Definition: EApi.h:138
void ESource
Definition: EApi.h:53
EAPI_EXTERN ESource *(* e_source_registry_ref_source)(ESourceRegistry *registry, const gchar *uid)
Definition: EApi.h:147
EAPI_EXTERN ESource *(* e_book_get_source)(EBook *book)
Definition: EApi.h:91
void EContact
Definition: EApi.h:44
bool isSourceBackend(ESource *pSource, const char *backendname)
#define E_SOURCE(a)
Definition: EApi.h:54
EAPI_EXTERN char *(* e_book_query_to_string)(EBookQuery *q)
Definition: EApi.h:117
void EBookQuery
Definition: EApi.h:81
EAPI_EXTERN gboolean(* e_book_client_get_contacts_sync)(EBookClient *client, const gchar *sexp, GSList **contacts, GCancellable *cancellable, GError **error)
Definition: EApi.h:152
EAPI_EXTERN const gchar *(* e_source_get_property)(ESource *source, const gchar *property)
Definition: EApi.h:56
EAPI_EXTERN const gchar *(* e_source_get_uid)(ESource *source)
Definition: EApi.h:146
void EBook
Definition: EApi.h:80
EAPI_EXTERN GList *(* e_source_registry_list_sources)(ESourceRegistry *registry, const gchar *extension_name)
Definition: EApi.h:140
EAPI_EXTERN EBookClient *(* e_book_client_new)(ESource *source, GError **error)
Definition: EApi.h:148
EAPI_EXTERN gboolean(* e_client_open_sync)(EClient *client, gboolean only_if_exists, GCancellable *cancellable, GError **error)
Definition: EApi.h:150
#define E_SOURCE_EXTENSION_ADDRESS_BOOK
Definition: EApi.h:133
const sal_Int32 m_nLength
GSList * m_pContacts
Definition: NResultSet.cxx:377
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
const CollatorWrapper * getCaseCollator() const
void describeProperties(css::uno::Sequence< css::beans::Property > &_rProps) const
void registerProperty(const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void *_pPointerToMember, const css::uno::Type &_rMemberType)
static css::uno::Sequence< css::uno::Type > getBaseTypes()
::dbtools::OPropertyMap & getPropMap()
Definition: TConnection.cxx:68
void throwGenericSQLException(TranslateId pErrorResourceId, const css::uno::Reference< css::uno::XInterface > &_xContext)
Definition: TConnection.cxx:74
a class which provides helpers for working with SQLErrors
Definition: sqlerror.hxx:59
css::sdbc::SQLException getSQLException(const ErrorCondition _eCondition, const css::uno::Reference< css::uno::XInterface > &_rxContext, const std::optional< OUString > &_rParamValue1=std::nullopt, const std::optional< OUString > &_rParamValue2=std::nullopt, const std::optional< OUString > &_rParamValue3=std::nullopt) const
retrieves an SQLException object which contains information about the given error condition
Definition: sqlerror.cxx:285
virtual void SAL_CALL disposing() override
Definition: NResultSet.cxx:592
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:719
virtual void SAL_CALL acquire() noexcept override
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:665
virtual sal_Bool SAL_CALL rowDeleted() override
Definition: NResultSet.cxx:919
std::unique_ptr< OEvoabVersionHelper > m_pVersionHelper
Definition: NResultSet.hxx:81
virtual sal_Bool SAL_CALL next() override
Definition: NResultSet.cxx:777
virtual sal_Bool SAL_CALL isBeforeFirst() override
Definition: NResultSet.cxx:797
virtual void SAL_CALL refreshRow() override
Definition: NResultSet.cxx:943
virtual void SAL_CALL beforeFirst() override
Definition: NResultSet.cxx:837
virtual sal_Bool SAL_CALL rowInserted() override
Definition: NResultSet.cxx:927
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
Definition: NResultSet.cxx:873
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:737
virtual sal_Bool SAL_CALL first() override
Definition: NResultSet.cxx:854
OEvoabResultSet(OCommonStatement *pStmt, OEvoabConnection *pConnection)
Definition: NResultSet.cxx:489
virtual css::uno::Any SAL_CALL getWarnings() override
Definition: NResultSet.cxx:975
virtual sal_Bool SAL_CALL isAfterLast() override
Definition: NResultSet.cxx:813
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
Definition: NResultSet.cxx:885
virtual sal_Int32 SAL_CALL findColumn(const OUString &columnName) override
Definition: NResultSet.cxx:981
virtual void SAL_CALL cancel() override
Definition: NResultSet.cxx:952
virtual sal_Bool SAL_CALL last() override
Definition: NResultSet.cxx:864
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:755
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:743
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:749
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:671
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: NResultSet.cxx:602
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:643
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
Definition: NResultSet.cxx:911
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
rtl::Reference< OEvoabResultSetMetaData > m_xMetaData
Definition: NResultSet.hxx:85
virtual sal_Bool SAL_CALL isLast() override
Definition: NResultSet.cxx:829
virtual void SAL_CALL afterLast() override
Definition: NResultSet.cxx:845
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: NResultSet.cxx:610
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:695
virtual sal_Int32 SAL_CALL getRow() override
Definition: NResultSet.cxx:805
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
Definition: NResultSet.cxx:689
virtual sal_Bool SAL_CALL wasNull() override
Definition: NResultSet.cxx:789
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:677
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:713
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
Definition: NResultSet.cxx:764
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:683
virtual void SAL_CALL release() noexcept override
virtual sal_Bool SAL_CALL rowUpdated() override
Definition: NResultSet.cxx:935
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:731
virtual sal_Bool SAL_CALL isFirst() override
Definition: NResultSet.cxx:821
virtual void SAL_CALL clearWarnings() override
Definition: NResultSet.cxx:970
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:707
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
getString: @nColumnNum: The column index from the table.
Definition: NResultSet.cxx:628
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:701
::dbtools::WarningsContainer m_aWarnings
Definition: NResultSet.hxx:86
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:725
virtual sal_Bool SAL_CALL previous() override
Definition: NResultSet.cxx:898
virtual void SAL_CALL close() override
Definition: NResultSet.cxx:959
void construct(const QueryData &_rData)
Definition: NResultSet.cxx:537
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
Definition: NResultSet.cxx:659
virtual bool isLDAP(EBook *pBook)=0
mutable::osl::Mutex m_aMutex
void appendWarning(const OUString &_rWarning, const char *_pAsciiSQLState, const css::uno::Reference< css::uno::XInterface > &_rxContext)
appends an SQLWarning instance to the chain
css::uno::Any getWarnings() const
Any value
#define ENSURE_OR_THROW(c, m)
std::mutex m_aMutex
OUString aName
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
aStr
std::unique_ptr< sal_Int32[]> pData
Type
static bool valueToBool(GValue &_rValue)
Definition: NResultSet.cxx:98
const ColumnProperty * getField(guint n)
static OUString valueToOUString(GValue &_rValue)
Definition: NResultSet.cxx:88
static int whichAddress(int value)
Definition: NResultSet.cxx:106
static EContactAddress * getDefaultContactAddress(EContact *pContact, int *value)
Definition: NResultSet.cxx:148
const SplitEvoColumns * get_evo_addr()
GType getGFieldType(guint nCol)
static EContactAddress * getContactAddress(EContact *pContact, int *address_enum)
Definition: NResultSet.cxx:171
std::vector< FieldSort > SortDescriptor
Definition: NStatement.hxx:58
static bool handleSplitAddress(EContact *pContact, GValue *pStackValue, int value)
Definition: NResultSet.cxx:190
static bool getValue(EContact *pContact, sal_Int32 nColumnNum, GType nType, GValue *pStackValue, bool &_out_rWasNull)
Definition: NResultSet.cxx:243
::cppu::WeakComponentImplHelper< css::sdbc::XResultSet, css::sdbc::XRow, css::sdbc::XResultSetMetaDataSupplier, css::util::XCancellable, css::sdbc::XWarningsSupplier, css::sdbc::XCloseable, css::sdbc::XColumnLocate, css::lang::XServiceInfo > OResultSet_BASE
Definition: NResultSet.hxx:72
static int CompareContacts(gconstpointer _lhs, gconstpointer _rhs, gpointer _userData)
Definition: NResultSet.cxx:294
::sal_Int32 ErrorCondition
error condition values as defined in css::sdb::ErrorCondition
Definition: sqlerror.hxx:42
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
void throwFunctionNotSupportedSQLException(const OUString &_rFunctionName, const css::uno::Reference< css::uno::XInterface > &_rxContext)
throws an exception with SQL state IM001, saying that a certain function is not supported
void throwInvalidColumnException(const OUString &_rColumnName, const Reference< XInterface > &_rxContext)
int i
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
Definition: pq_tools.cxx:100
void dispose()
const char * columnName
Definition: pq_statics.cxx:56
#define PROPERTY_ID_RESULTSETTYPE
Definition: propertyids.hxx:44
#define PROPERTY_ID_RESULTSETCONCURRENCY
Definition: propertyids.hxx:43
#define PROPERTY_ID_FETCHSIZE
Definition: propertyids.hxx:46
#define PROPERTY_ID_FETCHDIRECTION
Definition: propertyids.hxx:45
QPRO_FUNC_TYPE nType
char * locality
Definition: EApi.h:127
char * po
Definition: EApi.h:124
char * country
Definition: EApi.h:130
char * code
Definition: EApi.h:129
char * region
Definition: EApi.h:128
char * street
Definition: EApi.h:126
const SortDescriptor & rSortOrder
Definition: NResultSet.cxx:77
ComparisonData(const SortDescriptor &_rSortOrder)
Definition: NResultSet.cxx:80
rtl::Reference< connectivity::OSQLColumns > xSelectColumns
Definition: NStatement.hxx:128
EBookQuery * getQuery() const
Definition: NStatement.hxx:139
unsigned char sal_Bool
signed char sal_Int8