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>
37#include <rtl/string.hxx>
60OUString SAL_CALL OEvoabResultSet::getImplementationName( )
62 return "com.sun.star.sdbcx.evoab.ResultSet";
67 return {
"com.sun.star.sdbc.ResultSet" };
70sal_Bool SAL_CALL OEvoabResultSet::supportsService(
const OUString& _rServiceName )
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 );
100 bool bResult = g_value_get_boolean( &_rValue );
101 g_value_unset( &_rValue );
151 if ( ec && (ec->
street[0]!=
'\0') )
159 if ( ec && (ec->
street[0]!=
'\0') )
174 switch (*address_enum) {
199 g_value_set_string(pStackValue,ec->
street );
break;
201 g_value_set_string(pStackValue,ec->
po );
break;
203 g_value_set_string(pStackValue,ec->
locality );
break;
205 g_value_set_string(pStackValue,ec->
region );
break;
207 g_value_set_string(pStackValue,ec->
country );
break;
209 g_value_set_string(pStackValue,ec->
code );
break;
212 g_value_set_string(pStackValue,ec->
street );
break;
214 g_value_set_string(pStackValue,ec->
po );
break;
216 g_value_set_string(pStackValue,ec->
locality );
break;
218 g_value_set_string(pStackValue,ec->
region );
break;
220 g_value_set_string(pStackValue,ec->
country );
break;
222 g_value_set_string(pStackValue,ec->
code );
break;
225 g_value_set_string(pStackValue,ec->
street );
break;
227 g_value_set_string(pStackValue,ec->
po );
break;
229 g_value_set_string(pStackValue,ec->
locality );
break;
231 g_value_set_string(pStackValue,ec->
region );
break;
233 g_value_set_string(pStackValue,ec->
country );
break;
235 g_value_set_string(pStackValue,ec->
code );
break;
243getValue(
EContact* pContact, sal_Int32 nColumnNum, GType nType, GValue* pStackValue,
bool& _out_rWasNull )
249 GParamSpec* pSpec = pSpecs->
pField;
252 _out_rWasNull =
true;
253 if ( !pSpec || !pContact)
256 if ( G_PARAM_SPEC_VALUE_TYPE (pSpec) !=
nType )
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>"));
263 g_value_init( pStackValue,
nType );
264 if ( bIsSplittedColumn )
269 if (0 == strcmp (g_param_spec_get_name (pSpec), evo_addr[
i].pColumnName))
278 g_object_get_property( G_OBJECT (pContact),
279 g_param_spec_get_name (pSpec),
281 if ( G_VALUE_TYPE( pStackValue ) !=
nType )
283 SAL_WARN(
"connectivity.evoab2",
"Fetched type mismatch" );
284 g_value_unset( pStackValue );
288 _out_rWasNull =
false;
294static int CompareContacts( gconstpointer _lhs, gconstpointer _rhs, gpointer _userData )
296 EContact* lhs =
const_cast< gpointer
>( _lhs );
297 EContact* rhs =
const_cast< gpointer
>( _rhs );
299 GValue aLhsValue = { 0, { { 0 } } };
300 GValue aRhsValue = { 0, { { 0 } } };
301 bool bLhsNull =
true;
302 bool bRhsNull =
true;
305 bool bLhs(
false), bRhs(
false);
308 for (
const auto& sortCol : rCompData.
rSortOrder )
310 sal_Int32 nField = sortCol.nField;
313 if (!sortCol.bAscending)
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!" );
323 if ( bLhsNull && !bRhsNull )
325 if ( !bLhsNull && bRhsNull )
327 if ( bLhsNull && bRhsNull )
330 if ( eFieldType == G_TYPE_STRING )
335 if ( nCompResult != 0 )
336 return nCompResult * nOrder;
366bool isBookBackend(
EBookClient *pBook,
const char *backendname)
374class OEvoabVersion36Helper :
public OEvoabVersionHelper
379 OEvoabVersion36Helper()
384 virtual ~OEvoabVersion36Helper()
override
389 virtual EBook* openBook(
const char *abname)
override
393 const char *
id =
nullptr;
395 for (GList* liter = pSources; liter; liter = liter->next)
405 g_list_foreach (pSources,
reinterpret_cast<GFunc
>(g_object_unref),
nullptr);
406 g_list_free (pSources);
411 EBookClient *pBook = pSource ? createClient (pSource) : nullptr;
414 g_object_unref (G_OBJECT (pBook));
418 g_object_unref (pSource);
422 virtual bool isLDAP(
EBook *pBook )
override
424 return isBookBackend(pBook,
"ldap");
427 virtual bool isLocal(
EBook *pBook )
override
429 return isBookBackend(pBook,
"local");
432 virtual void freeContacts() override final
446 virtual EContact *getContact(sal_Int32 nIndex)
override
452 virtual sal_Int32 getNumContacts()
override
457 virtual bool hasContacts()
override
462 virtual void sortContacts(
const ComparisonData& _rCompData )
override
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" );
468 const_cast< gpointer
>(
static_cast< gconstpointer
>( &_rCompData ) ) );
478class OEvoabVersion38Helper :
public OEvoabVersion36Helper
493 ,m_pConnection(pConnection)
496 ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE)
497 ,m_nFetchDirection(FetchDirection::FORWARD)
498 ,m_nResultSetConcurrency(ResultSetConcurrency::READ_ONLY)
507 PropertyAttribute::READONLY,
514 PropertyAttribute::READONLY,
521 PropertyAttribute::READONLY,
528 PropertyAttribute::READONLY,
546 bool bExecuteQuery =
true;
553 SQLException aAsException = aErrorFactory.
getSQLException( ErrorCondition::DATA_CANNOT_SELECT_UNFILTERED, *
this );
555 aAsException.Message,
556 aAsException.Context,
557 aAsException.SQLState,
558 aAsException.ErrorCode,
559 aAsException.NextException
561 bExecuteQuery =
false;
565 bExecuteQuery =
false;
568 bExecuteQuery =
true;
594 ::comphelper::OPropertyContainer::disposing();
604 Any aRet = ::comphelper::OPropertyContainer::queryInterface(rType);
606 aRet = OResultSet_BASE::queryInterface(rType);
612 return ::comphelper::concatSequences(
613 OResultSet_BASE::getTypes(),
630 ::osl::MutexGuard aGuard(
m_aMutex );
635 sal_Int32 nFieldNumber =
m_xMetaData->fieldAtColumn(nColumnNum);
636 GValue aValue = { 0, { { 0 } } };
645 ::osl::MutexGuard aGuard(
m_aMutex );
647 bool bResult =
false;
651 sal_Int32 nFieldNumber =
m_xMetaData->fieldAtColumn(nColumnNum);
652 GValue aValue = { 0, { { 0 } } };
704 return css::util::Time();
710 return css::util::DateTime();
740 return css::util::Date();
766 ::osl::MutexGuard aGuard(
m_aMutex );
779 ::osl::MutexGuard aGuard(
m_aMutex );
791 ::osl::MutexGuard aGuard(
m_aMutex );
799 ::osl::MutexGuard aGuard(
m_aMutex );
807 ::osl::MutexGuard aGuard(
m_aMutex );
815 ::osl::MutexGuard aGuard(
m_aMutex );
823 ::osl::MutexGuard aGuard(
m_aMutex );
831 ::osl::MutexGuard aGuard(
m_aMutex );
839 ::osl::MutexGuard aGuard(
m_aMutex );
847 ::osl::MutexGuard aGuard(
m_aMutex );
856 ::osl::MutexGuard aGuard(
m_aMutex );
866 ::osl::MutexGuard aGuard(
m_aMutex );
875 ::osl::MutexGuard aGuard(
m_aMutex );
887 ::osl::MutexGuard aGuard(
m_aMutex );
900 ::osl::MutexGuard aGuard(
m_aMutex );
913 ::osl::MutexGuard aGuard(
m_aMutex );
921 ::osl::MutexGuard aGuard(
m_aMutex );
929 ::osl::MutexGuard aGuard(
m_aMutex );
937 ::osl::MutexGuard aGuard(
m_aMutex );
945 ::osl::MutexGuard aGuard(
m_aMutex );
954 ::osl::MutexGuard aGuard(
m_aMutex );
962 ::osl::MutexGuard aGuard(
m_aMutex );
983 ::osl::MutexGuard aGuard(
m_aMutex );
988 sal_Int32 nLen = xMeta->getColumnCount();
992 if(xMeta->isCaseSensitive(
i) ?
columnName == xMeta->getColumnName(
i) :
993 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(
i)))
1009 return new ::cppu::OPropertyArrayHelper( aProps );
1019 OResultSet_BASE::acquire();
1024 OResultSet_BASE::release();
1027css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
1030 return ::cppu::OPropertySetHelper::createPropertySetInfo(
getInfoHelper());
ESourceRegistry * get_e_source_registry()
EAPI_EXTERN void(* e_client_util_free_object_slist)(GSList *objects)
EAPI_EXTERN ESource *(* e_client_get_source)(EClient *client)
EAPI_EXTERN EContactField(* e_contact_field_id)(const char *field_name)
EAPI_EXTERN EBookClient *(* e_book_client_connect_direct_sync)(ESourceRegistry *registry, ESource *source, guint32 wait_for_connected_seconds, GCancellable *cancellable, GError **error)
EAPI_EXTERN const gchar *(* e_source_get_display_name)(ESource *source)
EAPI_EXTERN gpointer(* e_contact_get)(EContact *contact, EContactField field_id)
EAPI_EXTERN ESource *(* e_source_registry_ref_source)(ESourceRegistry *registry, const gchar *uid)
EAPI_EXTERN ESource *(* e_book_get_source)(EBook *book)
bool isSourceBackend(ESource *pSource, const char *backendname)
EAPI_EXTERN char *(* e_book_query_to_string)(EBookQuery *q)
EAPI_EXTERN gboolean(* e_book_client_get_contacts_sync)(EBookClient *client, const gchar *sexp, GSList **contacts, GCancellable *cancellable, GError **error)
EAPI_EXTERN const gchar *(* e_source_get_property)(ESource *source, const gchar *property)
EAPI_EXTERN const gchar *(* e_source_get_uid)(ESource *source)
EAPI_EXTERN GList *(* e_source_registry_list_sources)(ESourceRegistry *registry, const gchar *extension_name)
EAPI_EXTERN EBookClient *(* e_book_client_new)(ESource *source, GError **error)
EAPI_EXTERN gboolean(* e_client_open_sync)(EClient *client, gboolean only_if_exists, GCancellable *cancellable, GError **error)
#define E_SOURCE_EXTENSION_ADDRESS_BOOK
const sal_Int32 m_nLength
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
const CollatorWrapper * getCaseCollator() const
::cppu::IPropertyArrayHelper * getArrayHelper()
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()
a class which provides helpers for working with SQLErrors
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
virtual void SAL_CALL disposing() override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) override
virtual void SAL_CALL acquire() noexcept override
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL rowDeleted() override
std::unique_ptr< OEvoabVersionHelper > m_pVersionHelper
virtual sal_Bool SAL_CALL next() override
virtual sal_Bool SAL_CALL isBeforeFirst() override
virtual void SAL_CALL refreshRow() override
virtual void SAL_CALL beforeFirst() override
virtual sal_Bool SAL_CALL rowInserted() override
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL first() override
OEvoabResultSet(OCommonStatement *pStmt, OEvoabConnection *pConnection)
virtual css::uno::Any SAL_CALL getWarnings() override
virtual sal_Bool SAL_CALL isAfterLast() override
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
virtual sal_Int32 SAL_CALL findColumn(const OUString &columnName) override
virtual void SAL_CALL cancel() override
virtual sal_Bool SAL_CALL last() override
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
rtl::Reference< OEvoabResultSetMetaData > m_xMetaData
virtual sal_Bool SAL_CALL isLast() override
virtual void SAL_CALL afterLast() override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
virtual sal_Int32 SAL_CALL getRow() override
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
OEvoabConnection * m_pConnection
virtual sal_Bool SAL_CALL wasNull() override
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
sal_Int32 m_nResultSetConcurrency
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
virtual void SAL_CALL release() noexcept override
virtual sal_Bool SAL_CALL rowUpdated() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL isFirst() override
virtual void SAL_CALL clearWarnings() override
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
getString: @nColumnNum: The column index from the table.
OCommonStatement * m_pStatement
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
::dbtools::WarningsContainer m_aWarnings
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
sal_Int32 m_nResultSetType
virtual sal_Bool SAL_CALL previous() override
virtual void SAL_CALL close() override
void construct(const QueryData &_rData)
sal_Int32 m_nFetchDirection
virtual ~OEvoabResultSet() override
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
virtual bool isLDAP(EBook *pBook)=0
OString getUserName(EBook *pBook)
mutable::osl::Mutex m_aMutex
#define ENSURE_OR_THROW(c, m)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::unique_ptr< sal_Int32[]> pData
static bool valueToBool(GValue &_rValue)
const ColumnProperty * getField(guint n)
static OUString valueToOUString(GValue &_rValue)
static int whichAddress(int value)
static EContactAddress * getDefaultContactAddress(EContact *pContact, int *value)
const SplitEvoColumns * get_evo_addr()
GType getGFieldType(guint nCol)
static EContactAddress * getContactAddress(EContact *pContact, int *address_enum)
std::vector< FieldSort > SortDescriptor
static bool handleSplitAddress(EContact *pContact, GValue *pStackValue, int value)
static bool getValue(EContact *pContact, sal_Int32 nColumnNum, GType nType, GValue *pStackValue, bool &_out_rWasNull)
::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
static int CompareContacts(gconstpointer _lhs, gconstpointer _rhs, gpointer _userData)
::sal_Int32 ErrorCondition
error condition values as defined in css::sdb::ErrorCondition
void checkDisposed(bool _bThrow)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
#define PROPERTY_ID_RESULTSETTYPE
#define PROPERTY_ID_RESULTSETCONCURRENCY
#define PROPERTY_ID_FETCHSIZE
#define PROPERTY_ID_FETCHDIRECTION
gboolean bIsSplittedValue
const SortDescriptor & rSortOrder
ComparisonData(const SortDescriptor &_rSortOrder)
rtl::Reference< connectivity::OSQLColumns > xSelectColumns
SortDescriptor aSortOrder
QueryFilterType eFilterType
EBookQuery * getQuery() const