diff options
Diffstat (limited to 'connectivity/source/drivers/evoab2')
24 files changed, 313 insertions, 564 deletions
diff --git a/connectivity/source/drivers/evoab2/EApi.cxx b/connectivity/source/drivers/evoab2/EApi.cxx index 56a957fabb63..9ec8e0d44e32 100644 --- a/connectivity/source/drivers/evoab2/EApi.cxx +++ b/connectivity/source/drivers/evoab2/EApi.cxx @@ -21,24 +21,14 @@ #define DECLARE_FN_POINTERS 1 #include "EApi.h" static const char *eBookLibNames[] = { + "libebook-1.2.so.21", // evolution-data-server 3.45.2+ "libebook-1.2.so.20", // evolution-data-server 3.33.2+ "libebook-1.2.so.19", // evolution-data-server 3.24+ - "libebook-1.2.so.16", - "libebook-1.2.so.15", - "libebook-1.2.so.14", // bumped again (evolution-3.6) - "libebook-1.2.so.13", // bumped again (evolution-3.4) - "libebook-1.2.so.12", // bumped again - "libebook-1.2.so.10", // bumped again - "libebook-1.2.so.9", // evolution-2.8 - "libebook-1.2.so.5", // evolution-2.4 and 2.6+ - "libebook-1.2.so.3", // evolution-2.2 - "libebook.so.8" // evolution-2.0 + "libebook-1.2.so.16" }; typedef void (*SymbolFunc) (); -#define SYM_MAP(a) { #a, reinterpret_cast<SymbolFunc *>(&a) } - namespace { struct ApiMap @@ -51,70 +41,48 @@ struct ApiMap const ApiMap aCommonApiMap[] = { - SYM_MAP( eds_check_version ), - SYM_MAP( e_contact_field_name ), - SYM_MAP( e_contact_get ), - SYM_MAP( e_contact_get_type ), - SYM_MAP( e_contact_field_id ), - SYM_MAP( e_book_new ), - SYM_MAP( e_book_open ), - SYM_MAP( e_book_get_source ), - SYM_MAP( e_book_get_contacts ), - SYM_MAP( e_book_query_field_test ), - SYM_MAP( e_book_query_and ), - SYM_MAP( e_book_query_or ), - SYM_MAP( e_book_query_not ), - SYM_MAP( e_book_query_ref ), - SYM_MAP( e_book_query_unref ), - SYM_MAP( e_book_query_from_string ), - SYM_MAP( e_book_query_to_string ), - SYM_MAP( e_book_query_field_exists ) -}; - -//< 3.6 api -const ApiMap aOldApiMap[] = -{ - SYM_MAP( e_book_get_addressbooks ), - SYM_MAP( e_book_get_uri ), - SYM_MAP( e_book_authenticate_user ), - SYM_MAP( e_source_group_peek_base_uri), - SYM_MAP( e_source_peek_name ), - SYM_MAP( e_source_get_property ), - SYM_MAP( e_source_list_peek_groups ), - SYM_MAP( e_source_group_peek_sources ) + { "eds_check_version", reinterpret_cast<SymbolFunc *>(&eds_check_version) }, + { "e_contact_field_name", reinterpret_cast<SymbolFunc *>(&e_contact_field_name) }, + { "e_contact_get", reinterpret_cast<SymbolFunc *>(&e_contact_get) }, + { "e_contact_get_type", reinterpret_cast<SymbolFunc *>(&e_contact_get_type) }, + { "e_contact_field_id", reinterpret_cast<SymbolFunc *>(&e_contact_field_id) }, + { "e_book_new", reinterpret_cast<SymbolFunc *>(&e_book_new) }, + { "e_book_open", reinterpret_cast<SymbolFunc *>(&e_book_open) }, + { "e_book_get_source", reinterpret_cast<SymbolFunc *>(&e_book_get_source) }, + { "e_book_get_contacts", reinterpret_cast<SymbolFunc *>(&e_book_get_contacts) }, + { "e_book_query_field_test", reinterpret_cast<SymbolFunc *>(&e_book_query_field_test) }, + { "e_book_query_and", reinterpret_cast<SymbolFunc *>(&e_book_query_and) }, + { "e_book_query_or", reinterpret_cast<SymbolFunc *>(&e_book_query_or) }, + { "e_book_query_not", reinterpret_cast<SymbolFunc *>(&e_book_query_not) }, + { "e_book_query_ref", reinterpret_cast<SymbolFunc *>(&e_book_query_ref) }, + { "e_book_query_unref", reinterpret_cast<SymbolFunc *>(&e_book_query_unref) }, + { "e_book_query_from_string", reinterpret_cast<SymbolFunc *>(&e_book_query_from_string) }, + { "e_book_query_to_string", reinterpret_cast<SymbolFunc *>(&e_book_query_to_string) }, + { "e_book_query_field_exists", reinterpret_cast<SymbolFunc *>(&e_book_query_field_exists) } }; -//>= 3.6 api const ApiMap aNewApiMap[] = { - SYM_MAP( e_source_registry_list_sources ), - SYM_MAP( e_source_registry_new_sync ), - SYM_MAP( e_source_has_extension ), - SYM_MAP( e_source_get_extension ), - SYM_MAP( e_source_backend_get_backend_name ), - SYM_MAP( e_source_get_display_name ), - SYM_MAP( e_source_get_uid ), - SYM_MAP( e_source_registry_ref_source), - SYM_MAP( e_client_open_sync ), - SYM_MAP( e_client_get_source ), - SYM_MAP( e_book_client_get_contacts_sync ), - SYM_MAP( e_client_util_free_object_slist ) -}; - -//== indirect read access (3.6 only) -const ApiMap aClientApiMap36[] = -{ - SYM_MAP( e_book_client_new ) + { "e_source_registry_list_sources", reinterpret_cast<SymbolFunc *>(&e_source_registry_list_sources) }, + { "e_source_registry_new_sync", reinterpret_cast<SymbolFunc *>(&e_source_registry_new_sync) }, + { "e_source_has_extension", reinterpret_cast<SymbolFunc *>(&e_source_has_extension) }, + { "e_source_get_extension", reinterpret_cast<SymbolFunc *>(&e_source_get_extension) }, + { "e_source_backend_get_backend_name", reinterpret_cast<SymbolFunc *>(&e_source_backend_get_backend_name) }, + { "e_source_get_display_name", reinterpret_cast<SymbolFunc *>(&e_source_get_display_name) }, + { "e_source_get_uid", reinterpret_cast<SymbolFunc *>(&e_source_get_uid) }, + { "e_source_registry_ref_source", reinterpret_cast<SymbolFunc *>(&e_source_registry_ref_source) }, + { "e_client_open_sync", reinterpret_cast<SymbolFunc *>(&e_client_open_sync) }, + { "e_client_get_source", reinterpret_cast<SymbolFunc *>(&e_client_get_source) }, + { "e_book_client_get_contacts_sync", reinterpret_cast<SymbolFunc *>(&e_book_client_get_contacts_sync) }, + { "e_client_util_free_object_slist", reinterpret_cast<SymbolFunc *>(&e_client_util_free_object_slist) } }; //>= direct read access API (>= 3.8) const ApiMap aClientApiMap38[] = { - SYM_MAP( e_book_client_connect_direct_sync ) + { "e_book_client_connect_direct_sync", reinterpret_cast<SymbolFunc *>(&e_book_client_connect_direct_sync) } }; -#undef SYM_MAP - template<size_t N> static bool tryLink( osl::Module &rModule, const char *pName, const ApiMap (&pMap)[N]) { @@ -144,33 +112,14 @@ bool EApiInit() if (tryLink( aModule, eBookLibNames[ j ], aCommonApiMap)) { - if (eds_check_version( 3, 6, 0 ) != nullptr) + if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap)) { - if (tryLink( aModule, eBookLibNames[ j ], aOldApiMap)) + if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap38)) { aModule.release(); return true; } } - else if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap)) - { - if (eds_check_version( 3, 7, 6 ) != nullptr) - { - if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap36)) - { - aModule.release(); - return true; - } - } - else - { - if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap38)) - { - aModule.release(); - return true; - } - } - } } } fprintf( stderr, "Can find no compliant libebook client libraries\n" ); diff --git a/connectivity/source/drivers/evoab2/EApi.h b/connectivity/source/drivers/evoab2/EApi.h index 8c05f95fa2ce..a33bf9721de6 100644 --- a/connectivity/source/drivers/evoab2/EApi.h +++ b/connectivity/source/drivers/evoab2/EApi.h @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_EAPI_H -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_EAPI_H +#pragma once #include <glib-object.h> // Initializes the API below, returns false if not available @@ -147,7 +146,7 @@ EAPI_EXTERN const gchar* (*eds_check_version) (guint required_major, guint requi EAPI_EXTERN const gchar* (*e_source_get_uid) (ESource *source); EAPI_EXTERN ESource* (*e_source_registry_ref_source) (ESourceRegistry *registry, const gchar *uid); EAPI_EXTERN EBookClient* (*e_book_client_new) (ESource *source, GError **error); -EAPI_EXTERN EBookClient* (*e_book_client_connect_direct_sync) (ESourceRegistry *registry, ESource *source, GCancellable *cancellable, GError **error); +EAPI_EXTERN EBookClient* (*e_book_client_connect_direct_sync) (ESourceRegistry *registry, ESource *source, guint32 wait_for_connected_seconds, GCancellable *cancellable, GError **error); EAPI_EXTERN gboolean (*e_client_open_sync) (EClient *client, gboolean only_if_exists, GCancellable *cancellable, GError **error); EAPI_EXTERN ESource* (*e_client_get_source) (EClient *client); EAPI_EXTERN gboolean (*e_book_client_get_contacts_sync) (EBookClient *client, const gchar *sexp, GSList **contacts, GCancellable *cancellable, GError **error); @@ -157,6 +156,7 @@ ESourceRegistry *get_e_source_registry(); bool isSourceBackend(ESource *pSource, const char *backendname); G_END_DECLS -#endif + +inline void object_unref(gpointer data, gpointer) { g_object_unref(data); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NCatalog.cxx b/connectivity/source/drivers/evoab2/NCatalog.cxx index fb010b8dce5d..d16a6377d1d1 100644 --- a/connectivity/source/drivers/evoab2/NCatalog.cxx +++ b/connectivity/source/drivers/evoab2/NCatalog.cxx @@ -26,11 +26,8 @@ using namespace connectivity::evoab; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; OEvoabCatalog::OEvoabCatalog(OEvoabConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon) @@ -67,9 +64,8 @@ Reference< XNameAccess > SAL_CALL OEvoabCatalog::getTables( ) try { - if (!m_pTables) { - refreshTables(); - } + if (!m_pTables) + refreshTables(); } catch( const RuntimeException& ) { diff --git a/connectivity/source/drivers/evoab2/NCatalog.hxx b/connectivity/source/drivers/evoab2/NCatalog.hxx index d54ad68a2a9a..b2bd8084474c 100644 --- a/connectivity/source/drivers/evoab2/NCatalog.hxx +++ b/connectivity/source/drivers/evoab2/NCatalog.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NCATALOG_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NCATALOG_HXX +#pragma once #include <sdbcx/VCatalog.hxx> @@ -41,6 +40,4 @@ namespace connectivity::evoab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NCATALOG_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NColumns.cxx b/connectivity/source/drivers/evoab2/NColumns.cxx index 378e2af77634..99fce8f3bf46 100644 --- a/connectivity/source/drivers/evoab2/NColumns.cxx +++ b/connectivity/source/drivers/evoab2/NColumns.cxx @@ -25,12 +25,8 @@ using namespace connectivity::sdbcx; using namespace connectivity; -using namespace ::comphelper; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; using namespace connectivity::evoab; @@ -55,7 +51,7 @@ sdbcx::ObjectType OEvoabColumns::createObject(const OUString& _rName) { if (xRow->getString(4) == _rName) { - OColumn* pRet = new OColumn( + xRet = new OColumn( _rName, xRow->getString(6), xRow->getString(13), @@ -71,7 +67,6 @@ sdbcx::ObjectType OEvoabColumns::createObject(const OUString& _rName) sCatalogName, sSchemaName, sTableName); - xRet = pRet; break; } } diff --git a/connectivity/source/drivers/evoab2/NColumns.hxx b/connectivity/source/drivers/evoab2/NColumns.hxx index be5996c6ebec..f768c51bb046 100644 --- a/connectivity/source/drivers/evoab2/NColumns.hxx +++ b/connectivity/source/drivers/evoab2/NColumns.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NCOLUMNS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NCOLUMNS_HXX +#pragma once #include "NTable.hxx" #include <connectivity/sdbcx/VCollection.hxx> @@ -42,6 +41,4 @@ namespace connectivity::evoab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NCOLUMNS_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NConnection.cxx b/connectivity/source/drivers/evoab2/NConnection.cxx index d586d6ba2df1..66fc7ecb6511 100644 --- a/connectivity/source/drivers/evoab2/NConnection.cxx +++ b/connectivity/source/drivers/evoab2/NConnection.cxx @@ -24,6 +24,7 @@ #include "NPreparedStatement.hxx" #include "NStatement.hxx" #include <connectivity/dbexception.hxx> +#include <rtl/ref.hxx> #include <rtl/ustring.hxx> #include <sal/log.hxx> @@ -35,7 +36,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::lang; OEvoabConnection::OEvoabConnection(OEvoabDriver const & _rDriver) : m_rDriver(_rDriver) @@ -117,8 +117,7 @@ css::uno::Reference< XTablesSupplier > OEvoabConnection::createCatalog() Reference< XTablesSupplier > xTab = m_xCatalog; if(!xTab.is()) { - OEvoabCatalog *pCat = new OEvoabCatalog(this); - xTab = pCat; + xTab = new OEvoabCatalog(this); m_xCatalog = xTab; } return xTab; @@ -129,10 +128,8 @@ Reference< XStatement > SAL_CALL OEvoabConnection::createStatement( ) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OConnection_BASE::rBHelper.bDisposed); - OStatement* pStmt = new OStatement(this); - - Reference< XStatement > xStmt = pStmt; - m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + Reference< XStatement > xStmt = new OStatement(this); + m_aStatements.push_back(WeakReferenceHelper(xStmt)); return xStmt; } @@ -141,12 +138,11 @@ Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareStatement( con ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OConnection_BASE::rBHelper.bDisposed); - OEvoabPreparedStatement* pStmt = new OEvoabPreparedStatement( this ); - Reference< XPreparedStatement > xStmt = pStmt; + rtl::Reference<OEvoabPreparedStatement> pStmt = new OEvoabPreparedStatement( this ); pStmt->construct( sql ); m_aStatements.push_back(WeakReferenceHelper(*pStmt)); - return xStmt; + return pStmt; } Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareCall( const OUString& /*sql*/ ) diff --git a/connectivity/source/drivers/evoab2/NConnection.hxx b/connectivity/source/drivers/evoab2/NConnection.hxx index ccd9fa7bc04c..8dd8714bc2fe 100644 --- a/connectivity/source/drivers/evoab2/NConnection.hxx +++ b/connectivity/source/drivers/evoab2/NConnection.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NCONNECTION_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NCONNECTION_HXX +#pragma once #include "NDriver.hxx" #include <com/sun/star/sdbc/SQLWarning.hpp> @@ -61,7 +60,6 @@ namespace connectivity::evoab { /// @throws css::sdbc::SQLException void construct(const OUString& _rUrl,const css::uno::Sequence< css::beans::PropertyValue >& _rInfo ); - OString const & getPassword() const { return m_aPassword; } void setPassword( OString const & aStr ) { m_aPassword = aStr; } // own methods const OEvoabDriver& getDriver() const { return m_rDriver; } @@ -104,6 +102,4 @@ namespace connectivity::evoab { }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NCONNECTION_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx index 5e84a27e13fb..110d01feb213 100644 --- a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx @@ -23,6 +23,7 @@ #include <connectivity/dbexception.hxx> #include <connectivity/FValue.hxx> #include <com/sun/star/sdbc/ColumnSearch.hpp> +#include <rtl/ref.hxx> #include <cstddef> #include <string.h> @@ -33,10 +34,7 @@ using namespace connectivity::evoab; using namespace connectivity; using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdbcx; namespace { @@ -252,8 +250,14 @@ OEvoabDatabaseMetaData::~OEvoabDatabaseMetaData() } -ODatabaseMetaDataResultSet::ORows OEvoabDatabaseMetaData::getColumnRows( const OUString& columnNamePattern ) +Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns( + const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& /*tableNamePattern*/, + const OUString& columnNamePattern ) { + // this returns an empty resultset where the column-names are already set + // in special the metadata of the resultset already returns the right columns + rtl::Reference<ODatabaseMetaDataResultSet> pResultSet = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumns ); + ODatabaseMetaDataResultSet::ORows aRows; ODatabaseMetaDataResultSet::ORow aRow(19); @@ -293,7 +297,7 @@ ODatabaseMetaDataResultSet::ORows OEvoabDatabaseMetaData::getColumnRows( const O ::osl::MutexGuard aGuard( m_aMutex ); initFields(); - for (sal_Int32 i = 0; i < static_cast<sal_Int32>(nFields); i++) + for (guint i = 0; i < nFields; i++) { if( match( columnNamePattern, getFieldName( i ), '\0' ) ) { @@ -303,12 +307,14 @@ ODatabaseMetaDataResultSet::ORows OEvoabDatabaseMetaData::getColumnRows( const O // COLUMN_NAME aRow[4] = new ORowSetValueDecorator( getFieldName( i ) ); // ORDINAL_POSITION - aRow[17] = new ORowSetValueDecorator( i ); + aRow[17] = new ORowSetValueDecorator( sal_Int32(i) ); aRows.push_back( aRow ); } } - return aRows ; + pResultSet->setRows(std::move(aRows)); + + return pResultSet; } OUString OEvoabDatabaseMetaData::impl_getCatalogSeparator_throw( ) @@ -984,23 +990,19 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTableTypes( ) { u"TABLE" // Currently we only support a 'TABLE' nothing more complex }; - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes); - Reference< XResultSet > xRef = pResult; + rtl::Reference<::connectivity::ODatabaseMetaDataResultSet> pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes); // here we fill the rows which should be visible when ask for data from the resultset returned here + auto nNbTypes = std::size(sTableTypes); ODatabaseMetaDataResultSet::ORows aRows; - for(std::size_t i=0;i < SAL_N_ELEMENTS(sTableTypes);++i) + for(std::size_t i=0;i < nNbTypes;++i) { - ODatabaseMetaDataResultSet::ORow aRow; - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator(OUString(sTableTypes[i]))); - // bound row - aRows.push_back(aRow); + aRows.push_back( { ODatabaseMetaDataResultSet::getEmptyValue(), new ORowSetValueDecorator(OUString(sTableTypes[i])) }); } // here we set the rows at the resultset - pResult->setRows(aRows); - return xRef; + pResult->setRows(std::move(aRows)); + return pResult; } Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( ) @@ -1009,34 +1011,33 @@ Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( ) * Return the proper type information required by evo driver */ - ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo); + rtl::Reference<ODatabaseMetaDataResultSet> pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo); - Reference< XResultSet > xResultSet = pResultSet; static ODatabaseMetaDataResultSet::ORows aRows = []() { ODatabaseMetaDataResultSet::ORows tmp; - ODatabaseMetaDataResultSet::ORow aRow; - aRow.reserve(19); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator(OUString("VARCHAR"))); - aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR)); - aRow.push_back(new ORowSetValueDecorator(sal_Int32(s_nCHAR_OCTET_LENGTH))); - aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); - aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); - aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(new ORowSetValueDecorator(sal_Int32(ColumnSearch::FULL))); - aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator(sal_Int32(10))); + ODatabaseMetaDataResultSet::ORow aRow + { + ODatabaseMetaDataResultSet::getEmptyValue() , + new ORowSetValueDecorator(OUString("VARCHAR")) , + new ORowSetValueDecorator(DataType::VARCHAR) , + new ORowSetValueDecorator(sal_Int32(s_nCHAR_OCTET_LENGTH)) , + ODatabaseMetaDataResultSet::getQuoteValue() , + ODatabaseMetaDataResultSet::getQuoteValue() , + ODatabaseMetaDataResultSet::getEmptyValue() , + ODatabaseMetaDataResultSet::get1Value() , + ODatabaseMetaDataResultSet::get1Value() , + new ORowSetValueDecorator(sal_Int32(ColumnSearch::FULL)) , + ODatabaseMetaDataResultSet::get1Value() , + ODatabaseMetaDataResultSet::get0Value() , + ODatabaseMetaDataResultSet::get0Value() , + ODatabaseMetaDataResultSet::getEmptyValue() , + ODatabaseMetaDataResultSet::get0Value() , + ODatabaseMetaDataResultSet::get0Value() , + ODatabaseMetaDataResultSet::getEmptyValue() , + ODatabaseMetaDataResultSet::getEmptyValue() , + new ORowSetValueDecorator(sal_Int32(10)) + }; tmp.push_back(aRow); @@ -1046,23 +1047,10 @@ Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( ) tmp.push_back(aRow); return tmp; }(); - pResultSet->setRows(aRows); - return xResultSet; -} - -Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns( - const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& /*tableNamePattern*/, - const OUString& columnNamePattern ) -{ - // this returns an empty resultset where the column-names are already set - // in special the metadata of the resultset already returns the right columns - ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumns ); - Reference< XResultSet > xResultSet = pResultSet; - pResultSet->setRows( getColumnRows( columnNamePattern ) ); - return xResultSet; + pResultSet->setRows(std::move(aRows)); + return pResultSet; } - bool isSourceBackend(ESource *pSource, const char *backendname) { if (!pSource || !e_source_has_extension (pSource, E_SOURCE_EXTENSION_ADDRESS_BOOK)) @@ -1078,136 +1066,82 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables( { ::osl::MutexGuard aGuard( m_aMutex ); - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes); - Reference< XResultSet > xRef = pResult; + rtl::Reference<ODatabaseMetaDataResultSet> pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables); // check if any type is given // when no types are given then we have to return all tables e.g. TABLE - const OUString aTable("TABLE"); + static constexpr OUString aTable(u"TABLE"_ustr); bool bTableFound = true; sal_Int32 nLength = types.getLength(); if(nLength) - { - bTableFound = false; - - const OUString* pBegin = types.getConstArray(); - const OUString* pEnd = pBegin + nLength; - for(;pBegin != pEnd;++pBegin) - { - if(*pBegin == aTable) - { - bTableFound = true; - break; - } - } - } - if(!bTableFound) - return xRef; - - ODatabaseMetaDataResultSet::ORows aRows; - - if (eds_check_version(3, 6, 0) == nullptr) { - GList *pSources = e_source_registry_list_sources(get_e_source_registry(), E_SOURCE_EXTENSION_ADDRESS_BOOK); + bTableFound = false; - for (GList* liter = pSources; liter; liter = liter->next) + const OUString* pBegin = types.getConstArray(); + const OUString* pEnd = pBegin + nLength; + for(;pBegin != pEnd;++pBegin) { - ESource *pSource = E_SOURCE (liter->data); - bool can = false; - switch (m_pConnection->getSDBCAddressType()) + if(*pBegin == aTable) { - case SDBCAddress::EVO_GWISE: - can = isSourceBackend( pSource, "groupwise"); // not supported in evo/eds 3.6.x+, somehow - break; - case SDBCAddress::EVO_LOCAL: - can = isSourceBackend( pSource, "local"); - break; - case SDBCAddress::EVO_LDAP: - can = isSourceBackend( pSource, "ldap"); - break; - case SDBCAddress::Unknown: - can = true; - break; + bTableFound = true; + break; } - if (!can) - continue; - - OUString aHumanName = OStringToOUString( e_source_get_display_name( pSource ), - RTL_TEXTENCODING_UTF8 ); - OUString aUID = OStringToOUString( e_source_get_uid( pSource ), - RTL_TEXTENCODING_UTF8 ); - ODatabaseMetaDataResultSet::ORow aRow{ - ORowSetValueDecoratorRef(), - ORowSetValueDecoratorRef(), - ORowSetValueDecoratorRef(), - new ORowSetValueDecorator(aHumanName), //tablename - new ORowSetValueDecorator(aTable), - new ORowSetValueDecorator(aUID)}; //comment - //I'd prefer to swap the comment and the human name and - //just use e_source_registry_ref_source(get_e_source_registry(), aUID); - //in open book rather than search for the name again - aRows.push_back(aRow); } - - g_list_foreach (pSources, reinterpret_cast<GFunc>(g_object_unref), nullptr); - g_list_free (pSources); } - else - { - ESourceList *pSourceList; - if( !e_book_get_addressbooks (&pSourceList, nullptr) ) - pSourceList = nullptr; + if(!bTableFound) + return pResult; - GSList *g; - for( g = e_source_list_peek_groups( pSourceList ); g; g = g->next) - { - GSList *s; - const char *p = e_source_group_peek_base_uri(E_SOURCE_GROUP(g->data)); + ODatabaseMetaDataResultSet::ORows aRows; - switch (m_pConnection->getSDBCAddressType()) { + GList *pSources = e_source_registry_list_sources(get_e_source_registry(), E_SOURCE_EXTENSION_ADDRESS_BOOK); + + for (GList* liter = pSources; liter; liter = liter->next) + { + ESource *pSource = E_SOURCE (liter->data); + bool can = false; + switch (m_pConnection->getSDBCAddressType()) + { case SDBCAddress::EVO_GWISE: - if ( !strncmp( "groupwise://", p, 11 )) - break; - else - continue; + can = isSourceBackend( pSource, "groupwise"); // not supported in evo/eds 3.6.x+, somehow + break; case SDBCAddress::EVO_LOCAL: - if ( !strncmp( "file://", p, 6 ) || - !strncmp( "local://", p, 6 ) ) - break; - else - continue; + can = isSourceBackend( pSource, "local"); + break; case SDBCAddress::EVO_LDAP: - if ( !strncmp( "ldap://", p, 6 )) - break; - else - continue; + can = isSourceBackend( pSource, "ldap"); + break; case SDBCAddress::Unknown: + can = true; break; - } - for (s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next) - { - ESource *pSource = E_SOURCE (s->data); - - OUString aName = OStringToOUString( e_source_peek_name( pSource ), - RTL_TEXTENCODING_UTF8 ); - - ODatabaseMetaDataResultSet::ORow aRow{ - ORowSetValueDecoratorRef(), - ORowSetValueDecoratorRef(), - ORowSetValueDecoratorRef(), - new ORowSetValueDecorator(aName), - new ORowSetValueDecorator(aTable), - ODatabaseMetaDataResultSet::getEmptyValue()}; - aRows.push_back(aRow); - } } + if (!can) + continue; + + OUString aHumanName = OStringToOUString( e_source_get_display_name( pSource ), + RTL_TEXTENCODING_UTF8 ); + OUString aUID = OStringToOUString( e_source_get_uid( pSource ), + RTL_TEXTENCODING_UTF8 ); + ODatabaseMetaDataResultSet::ORow aRow{ + ORowSetValueDecoratorRef(), + ORowSetValueDecoratorRef(), + ORowSetValueDecoratorRef(), + new ORowSetValueDecorator(aHumanName), //tablename + new ORowSetValueDecorator(ORowSetValue(aTable)), + new ORowSetValueDecorator(aUID)}; //comment + //I'd prefer to swap the comment and the human name and + //just use e_source_registry_ref_source(get_e_source_registry(), aUID); + //in open book rather than search for the name again + aRows.push_back(aRow); } - pResult->setRows(aRows); + g_list_foreach (pSources, object_unref, nullptr); + g_list_free (pSources); + + pResult->setRows(std::move(aRows)); - return xRef; + return pResult; } Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getUDTs( const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx index cbfed176fabc..a64c234e6a52 100644 --- a/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx +++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NDATABASEMETADATA_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NDATABASEMETADATA_HXX +#pragma once #include <sal/config.h> @@ -66,8 +65,6 @@ namespace connectivity::evoab { OEvoabConnection* m_pConnection; - ODatabaseMetaDataResultSet::ORows getColumnRows( const OUString& columnNamePattern ); - protected: virtual css::uno::Reference< css::sdbc::XResultSet > impl_getTypeInfo_throw() override; // cached database information @@ -218,6 +215,4 @@ namespace connectivity::evoab } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NDATABASEMETADATA_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NDriver.cxx b/connectivity/source/drivers/evoab2/NDriver.cxx index b8e3c4d4ff88..c72d9b1a189f 100644 --- a/connectivity/source/drivers/evoab2/NDriver.cxx +++ b/connectivity/source/drivers/evoab2/NDriver.cxx @@ -23,6 +23,7 @@ #include <connectivity/dbexception.hxx> #include <cppuhelper/supportsservice.hxx> #include <com/sun/star/ucb/XContentAccess.hpp> +#include <rtl/ref.hxx> #include <strings.hrc> #include <resource/sharedresources.hxx> @@ -30,10 +31,8 @@ using namespace osl; using namespace connectivity::evoab; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::ucb; OEvoabDriver::OEvoabDriver(const Reference< XComponentContext >& _rxContext) : @@ -103,12 +102,11 @@ Reference< XConnection > SAL_CALL OEvoabDriver::connect( const OUString& url, co if ( ! acceptsURL(url) ) return nullptr; - OEvoabConnection* pCon = new OEvoabConnection( *this ); + rtl::Reference<OEvoabConnection> pCon = new OEvoabConnection( *this ); pCon->construct(url,info); - Reference< XConnection > xCon = pCon; m_xConnections.push_back(WeakReferenceHelper(*pCon)); - return xCon; + return pCon; } sal_Bool SAL_CALL OEvoabDriver::acceptsURL( const OUString& url ) diff --git a/connectivity/source/drivers/evoab2/NDriver.hxx b/connectivity/source/drivers/evoab2/NDriver.hxx index 2780a05ec34d..b505bb9db5fd 100644 --- a/connectivity/source/drivers/evoab2/NDriver.hxx +++ b/connectivity/source/drivers/evoab2/NDriver.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NDRIVER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NDRIVER_HXX +#pragma once #include <sal/config.h> @@ -29,7 +28,7 @@ #include <cppuhelper/compbase.hxx> #include <connectivity/CommonTools.hxx> -#define EVOAB_DRIVER_IMPL_NAME "com.sun.star.comp.sdbc.evoab.OEvoabDriver" +inline constexpr OUString EVOAB_DRIVER_IMPL_NAME = u"com.sun.star.comp.sdbc.evoab.OEvoabDriver"_ustr; namespace connectivity::evoab { @@ -64,7 +63,7 @@ namespace connectivity::evoab virtual sal_Int32 SAL_CALL getMinorVersion( ) override; public: - css::uno::Reference< css::uno::XComponentContext > getComponentContext( ) const { return m_xContext; } + const css::uno::Reference< css::uno::XComponentContext >& getComponentContext( ) const { return m_xContext; } // static methods static bool acceptsURL_Stat( std::u16string_view url ); @@ -72,6 +71,4 @@ namespace connectivity::evoab } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NDRIVER_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NPreparedStatement.cxx b/connectivity/source/drivers/evoab2/NPreparedStatement.cxx index 57981e95e82d..2ed8b0f166b9 100644 --- a/connectivity/source/drivers/evoab2/NPreparedStatement.cxx +++ b/connectivity/source/drivers/evoab2/NPreparedStatement.cxx @@ -21,14 +21,14 @@ #include "NPreparedStatement.hxx" #include <connectivity/dbexception.hxx> #include <connectivity/dbtools.hxx> -#include <tools/diagnose_ex.h> +#include <rtl/ref.hxx> +#include <comphelper/diagnose_ex.hxx> #include <strings.hrc> using namespace connectivity::evoab; using namespace com::sun::star::uno; using namespace com::sun::star::lang; -using namespace com::sun::star::beans; using namespace com::sun::star::sdbc; using namespace com::sun::star::container; using namespace com::sun::star::io; @@ -39,8 +39,6 @@ IMPLEMENT_SERVICE_INFO(OEvoabPreparedStatement,"com.sun.star.sdbcx.evoab.Prepare OEvoabPreparedStatement::OEvoabPreparedStatement( OEvoabConnection* _pConnection ) :OCommonStatement(_pConnection) - ,m_sSqlStatement() - ,m_xMetaData() { } @@ -54,7 +52,8 @@ void OEvoabPreparedStatement::construct( const OUString& _sql ) ENSURE_OR_THROW( m_aQueryData.xSelectColumns.is(), "no SelectColumn" ); // create our meta data - OEvoabResultSetMetaData* pMeta = new OEvoabResultSetMetaData( m_aQueryData.sTable ); + rtl::Reference<OEvoabResultSetMetaData> pMeta + = new OEvoabResultSetMetaData( m_aQueryData.sTable ); m_xMetaData = pMeta; pMeta->setEvoabFields( m_aQueryData.xSelectColumns ); } @@ -65,13 +64,13 @@ OEvoabPreparedStatement::~OEvoabPreparedStatement() } -void SAL_CALL OEvoabPreparedStatement::acquire() throw() +void SAL_CALL OEvoabPreparedStatement::acquire() noexcept { OCommonStatement::acquire(); } -void SAL_CALL OEvoabPreparedStatement::release() throw() +void SAL_CALL OEvoabPreparedStatement::release() noexcept { OCommonStatement::release(); } diff --git a/connectivity/source/drivers/evoab2/NPreparedStatement.hxx b/connectivity/source/drivers/evoab2/NPreparedStatement.hxx index 62e79cb335f4..cd42d42d505b 100644 --- a/connectivity/source/drivers/evoab2/NPreparedStatement.hxx +++ b/connectivity/source/drivers/evoab2/NPreparedStatement.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NPREPAREDSTATEMENT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NPREPAREDSTATEMENT_HXX +#pragma once #include "NStatement.hxx" #include "NConnection.hxx" @@ -57,12 +56,11 @@ namespace connectivity::evoab void construct( const OUString& _sql ); - private: DECLARE_SERVICE_INFO(); //XInterface virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - virtual void SAL_CALL acquire() throw() override; - virtual void SAL_CALL release() throw() override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; //XTypeProvider virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; @@ -107,6 +105,4 @@ namespace connectivity::evoab } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NPREPAREDSTATEMENT_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NResultSet.cxx b/connectivity/source/drivers/evoab2/NResultSet.cxx index a9c73a65b740..bc9656337097 100644 --- a/connectivity/source/drivers/evoab2/NResultSet.cxx +++ b/connectivity/source/drivers/evoab2/NResultSet.cxx @@ -36,7 +36,7 @@ #include <connectivity/sqlerror.hxx> #include <rtl/string.hxx> #include <sal/log.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <unotools/syslocale.hxx> #include <unotools/intlwrapper.hxx> #include <unotools/collatorwrapper.hxx> @@ -51,7 +51,6 @@ using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::beans; using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdbcx; using namespace com::sun::star::container; using namespace com::sun::star::io; namespace ErrorCondition = ::com::sun::star::sdb::ErrorCondition; @@ -88,7 +87,7 @@ static OUString valueToOUString( GValue& _rValue ) { const char *pStr = g_value_get_string( &_rValue ); - OString aStr( pStr ? pStr : "" ); + std::string_view aStr( pStr ? pStr : "" ); OUString sResult( OStringToOUString( aStr, RTL_TEXTENCODING_UTF8 ) ); g_value_unset( &_rValue ); return sResult; @@ -308,6 +307,10 @@ static int CompareContacts( gconstpointer _lhs, gconstpointer _rhs, gpointer _us for ( const auto& sortCol : rCompData.rSortOrder ) { sal_Int32 nField = sortCol.nField; + int nOrder = 1; + // if descending sort, reverse order + if (!sortCol.bAscending) + nOrder = -1; GType eFieldType = evoab::getGFieldType( nField ); bool success = getValue( lhs, nField, eFieldType, &aLhsValue, bLhsNull ) @@ -317,9 +320,9 @@ static int CompareContacts( gconstpointer _lhs, gconstpointer _rhs, gpointer _us return 0; if ( bLhsNull && !bRhsNull ) - return -1; + return -1 * nOrder; if ( !bLhsNull && bRhsNull ) - return 1; + return 1 * nOrder; if ( bLhsNull && bRhsNull ) continue; @@ -329,16 +332,16 @@ static int CompareContacts( gconstpointer _lhs, gconstpointer _rhs, gpointer _us sRhs = valueToOUString( aRhsValue ); sal_Int32 nCompResult = rCompData.aIntlWrapper.getCaseCollator()->compareString( sLhs, sRhs ); if ( nCompResult != 0 ) - return nCompResult; + return nCompResult * nOrder; continue; } bLhs = valueToBool( aLhsValue ); bRhs = valueToBool( aRhsValue ); if ( bLhs && !bRhs ) - return -1; + return -1 * nOrder; if ( !bLhs && bRhs ) - return 1; + return 1 * nOrder; continue; } @@ -398,7 +401,7 @@ public: break; } } - g_list_foreach (pSources, reinterpret_cast<GFunc>(g_object_unref), nullptr); + g_list_foreach (pSources, object_unref, nullptr); g_list_free (pSources); if (!id) return nullptr; @@ -431,7 +434,7 @@ public: m_pContacts = nullptr; } - virtual void executeQuery (EBook* pBook, EBookQuery* pQuery, OString &/*rPassword*/) override + virtual void executeQuery (EBook* pBook, EBookQuery* pQuery) override { freeContacts(); char *sexp = e_book_query_to_string( pQuery ); @@ -476,123 +479,7 @@ class OEvoabVersion38Helper : public OEvoabVersion36Helper protected: virtual EBookClient * createClient( ESource *pSource ) override { - return e_book_client_connect_direct_sync (get_e_source_registry (), pSource, nullptr, nullptr); - } -}; - -ESource * findSource( const char *id ) -{ - ESourceList *pSourceList = nullptr; - - g_return_val_if_fail (id != nullptr, nullptr); - - if (!e_book_get_addressbooks (&pSourceList, nullptr)) - pSourceList = nullptr; - - for ( GSList *g = e_source_list_peek_groups (pSourceList); g; g = g->next) - { - for (GSList *s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next) - { - ESource *pSource = E_SOURCE (s->data); - if (!strcmp (e_source_peek_name (pSource), id)) - return pSource; - } - } - return nullptr; -} - -bool isAuthRequired( EBook *pBook ) -{ - return e_source_get_property( e_book_get_source( pBook ), - "auth" ) != nullptr; -} - -class OEvoabVersion35Helper : public OEvoabVersionHelper -{ -private: - GList *m_pContacts; - -public: - OEvoabVersion35Helper() - : m_pContacts(nullptr) - { - } - - virtual ~OEvoabVersion35Helper() override - { - freeContacts(); - } - - virtual EBook* openBook(const char *abname) override - { - ESource *pSource = findSource (abname); - EBook *pBook = pSource ? e_book_new (pSource, nullptr) : nullptr; - if (pBook && !e_book_open (pBook, true, nullptr)) - { - g_object_unref (G_OBJECT (pBook)); - pBook = nullptr; - } - return pBook; - } - - virtual bool isLDAP( EBook *pBook ) override - { - return pBook && !strncmp( "ldap://", e_book_get_uri( pBook ), 6 ); - } - - virtual bool isLocal( EBook *pBook ) override - { - return pBook && ( !strncmp( "file://", e_book_get_uri( pBook ), 6 ) || - !strncmp( "local:", e_book_get_uri( pBook ), 6 ) ); - } - - virtual void freeContacts() override final - { - g_list_free(m_pContacts); - m_pContacts = nullptr; - } - - virtual void executeQuery (EBook* pBook, EBookQuery* pQuery, OString &rPassword) override - { - freeContacts(); - - ESource *pSource = e_book_get_source( pBook ); - bool bAuthSuccess = true; - - if( isAuthRequired( pBook ) ) - { - OString aUser( getUserName( pBook ) ); - const char *pAuth = e_source_get_property( pSource, "auth" ); - bAuthSuccess = e_book_authenticate_user( pBook, aUser.getStr(), rPassword.getStr(), pAuth, nullptr ); - } - - if (bAuthSuccess) - e_book_get_contacts( pBook, pQuery, &m_pContacts, nullptr ); - } - - virtual EContact *getContact(sal_Int32 nIndex) override - { - gpointer pData = g_list_nth_data (m_pContacts, nIndex); - return pData ? E_CONTACT (pData) : nullptr; - } - - virtual sal_Int32 getNumContacts() override - { - return g_list_length( m_pContacts ); - } - - virtual bool hasContacts() override - { - return m_pContacts != nullptr; - } - - virtual void sortContacts( const ComparisonData& _rCompData ) override - { - OSL_ENSURE( !_rCompData.rSortOrder.empty(), "sortContacts: no need to call this without any sort order!" ); - ENSURE_OR_THROW( _rCompData.aIntlWrapper.getCaseCollator(), "no collator for comparing strings" ); - - m_pContacts = g_list_sort_with_data( m_pContacts, &CompareContacts, - const_cast< gpointer >( static_cast< gconstpointer >( &_rCompData ) ) ); + return e_book_client_connect_direct_sync (get_e_source_registry (), pSource, 10, nullptr, nullptr); } }; @@ -611,26 +498,36 @@ OEvoabResultSet::OEvoabResultSet( OCommonStatement* pStmt, OEvoabConnection *pCo ,m_nIndex(-1) ,m_nLength(0) { - if (eds_check_version( 3, 7, 6 ) == nullptr) - m_pVersionHelper = std::make_unique<OEvoabVersion38Helper>(); - else if (eds_check_version( 3, 6, 0 ) == nullptr) - m_pVersionHelper = std::make_unique<OEvoabVersion36Helper>(); - else - m_pVersionHelper = std::make_unique<OEvoabVersion35Helper>(); + m_pVersionHelper = std::make_unique<OEvoabVersion38Helper>(); - #define REGISTER_PROP( id, member ) \ - registerProperty( \ - OMetaConnection::getPropMap().getNameByIndex( id ), \ - id, \ - PropertyAttribute::READONLY, \ - &member, \ - cppu::UnoType<decltype(member)>::get() \ - ); - - REGISTER_PROP( PROPERTY_ID_FETCHSIZE, m_nFetchSize ); - REGISTER_PROP( PROPERTY_ID_RESULTSETTYPE, m_nResultSetType ); - REGISTER_PROP( PROPERTY_ID_FETCHDIRECTION, m_nFetchDirection ); - REGISTER_PROP( PROPERTY_ID_RESULTSETCONCURRENCY, m_nResultSetConcurrency ); + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), + PROPERTY_ID_FETCHSIZE, + PropertyAttribute::READONLY, + &m_nFetchSize, + cppu::UnoType<decltype(m_nFetchSize)>::get() + ); + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), + PROPERTY_ID_RESULTSETTYPE, + PropertyAttribute::READONLY, + &m_nResultSetType, + cppu::UnoType<decltype(m_nResultSetType)>::get() + ); + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), + PROPERTY_ID_FETCHDIRECTION, + PropertyAttribute::READONLY, + &m_nFetchDirection, + cppu::UnoType<decltype(m_nFetchDirection)>::get() + ); + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), + PROPERTY_ID_RESULTSETCONCURRENCY, + PropertyAttribute::READONLY, + &m_nResultSetConcurrency, + cppu::UnoType<decltype(m_nResultSetConcurrency)>::get() + ); } OEvoabResultSet::~OEvoabResultSet() @@ -672,9 +569,7 @@ void OEvoabResultSet::construct( const QueryData& _rData ) } if ( bExecuteQuery ) { - OString aPassword = m_pConnection->getPassword(); - m_pVersionHelper->executeQuery(pBook, _rData.getQuery(), aPassword); - m_pConnection->setPassword( aPassword ); + m_pVersionHelper->executeQuery(pBook, _rData.getQuery()); if ( m_pVersionHelper->hasContacts() && !_rData.aSortOrder.empty() ) { @@ -872,7 +767,7 @@ Reference< XResultSetMetaData > SAL_CALL OEvoabResultSet::getMetaData( ) // the meta data should have been created at construction time ENSURE_OR_THROW( m_xMetaData.is(), "internal error: no meta data" ); - return m_xMetaData.get(); + return m_xMetaData; } // XResultSetMetaDataSupplier Interface Ends @@ -1016,8 +911,7 @@ Reference< XInterface > SAL_CALL OEvoabResultSet::getStatement( ) { ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - css::uno::WeakReferenceHelper aStatement(static_cast<OWeakObject*>(m_pStatement)); - return aStatement.get(); + return cppu::getXWeak(m_pStatement); } @@ -1119,12 +1013,12 @@ sal_Int32 SAL_CALL OEvoabResultSet::findColumn( const OUString& columnName ) return *getArrayHelper(); } -void SAL_CALL OEvoabResultSet::acquire() throw() +void SAL_CALL OEvoabResultSet::acquire() noexcept { OResultSet_BASE::acquire(); } -void SAL_CALL OEvoabResultSet::release() throw() +void SAL_CALL OEvoabResultSet::release() noexcept { OResultSet_BASE::release(); } diff --git a/connectivity/source/drivers/evoab2/NResultSet.hxx b/connectivity/source/drivers/evoab2/NResultSet.hxx index 034dcc439de0..3eeeab244ab3 100644 --- a/connectivity/source/drivers/evoab2/NResultSet.hxx +++ b/connectivity/source/drivers/evoab2/NResultSet.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NRESULTSET_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NRESULTSET_HXX +#pragma once #include <memory> @@ -50,7 +49,7 @@ namespace connectivity::evoab { public: virtual EBook* openBook(const char *abname) = 0; - virtual void executeQuery (EBook* pBook, EBookQuery* pQuery, OString &rPassword) = 0; + virtual void executeQuery (EBook* pBook, EBookQuery* pQuery) = 0; virtual void freeContacts() = 0; virtual bool isLDAP( EBook *pBook ) = 0; virtual bool isLocal( EBook *pBook ) = 0; @@ -119,8 +118,8 @@ namespace connectivity::evoab virtual void SAL_CALL disposing() override; // XInterface virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - virtual void SAL_CALL acquire() throw() override; - virtual void SAL_CALL release() throw() override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; //XTypeProvider virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; // XPropertySet @@ -180,6 +179,4 @@ namespace connectivity::evoab } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NRESULTSET_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx b/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx index 7f196bed35e7..a828b127fe68 100644 --- a/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx @@ -21,15 +21,14 @@ #include "NDatabaseMetaData.hxx" #include <connectivity/dbexception.hxx> #include <strings.hrc> +#include <utility> using namespace connectivity::evoab; using namespace com::sun::star::uno; -using namespace com::sun::star::lang; using namespace com::sun::star::sdbc; -OEvoabResultSetMetaData::OEvoabResultSetMetaData(const OUString& _aTableName) - : m_aTableName(_aTableName), - m_aEvoabFields() +OEvoabResultSetMetaData::OEvoabResultSetMetaData(OUString _aTableName) + : m_aTableName(std::move(_aTableName)) { } @@ -102,15 +101,7 @@ OUString SAL_CALL OEvoabResultSetMetaData::getColumnTypeName( sal_Int32 nColumnN OUString SAL_CALL OEvoabResultSetMetaData::getColumnLabel( sal_Int32 nColumnNum ) { - sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1]; - const ColumnProperty *pSpecs = getField(nField); - GParamSpec *pSpec = pSpecs->pField; - OUString aLabel; - - if( pSpec ) - aLabel = OStringToOUString( g_param_spec_get_nick( pSpec ), - RTL_TEXTENCODING_UTF8 ); - return aLabel; + return getColumnName(nColumnNum); } OUString SAL_CALL OEvoabResultSetMetaData::getColumnServiceName( sal_Int32 /*nColumnNum*/ ) diff --git a/connectivity/source/drivers/evoab2/NResultSetMetaData.hxx b/connectivity/source/drivers/evoab2/NResultSetMetaData.hxx index 9d8dc6db3e23..e79d347b1c4d 100644 --- a/connectivity/source/drivers/evoab2/NResultSetMetaData.hxx +++ b/connectivity/source/drivers/evoab2/NResultSetMetaData.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NRESULTSETMETADATA_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NRESULTSETMETADATA_HXX +#pragma once #include <com/sun/star/sdbc/XResultSetMetaData.hpp> #include <cppuhelper/implbase.hxx> @@ -41,13 +40,13 @@ namespace connectivity::evoab protected: virtual ~OEvoabResultSetMetaData() override; public: - explicit OEvoabResultSetMetaData(const OUString& _aTableName); + explicit OEvoabResultSetMetaData(OUString _aTableName); /// @throws css::sdbc::SQLException void setEvoabFields(const ::rtl::Reference<connectivity::OSQLColumns> &xColumns); sal_uInt32 fieldAtColumn(sal_Int32 columnIndex) const { return m_aEvoabFields[columnIndex - 1]; } /// Avoid ambiguous cast error from the compiler. - operator css::uno::Reference< css::sdbc::XResultSetMetaData > () throw() + operator css::uno::Reference< css::sdbc::XResultSetMetaData > () noexcept { return this; } virtual sal_Int32 SAL_CALL getColumnCount( ) override; @@ -75,6 +74,4 @@ namespace connectivity::evoab } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NRESULTSETMETADATA_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NStatement.cxx b/connectivity/source/drivers/evoab2/NStatement.cxx index 80b02d82f0a5..91ebdda56c70 100644 --- a/connectivity/source/drivers/evoab2/NStatement.cxx +++ b/connectivity/source/drivers/evoab2/NStatement.cxx @@ -22,6 +22,7 @@ #include <string_view> #include <osl/diagnose.h> +#include <rtl/ref.hxx> #include <rtl/ustring.hxx> #include <sal/log.hxx> #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> @@ -37,7 +38,7 @@ #include <sqlbison.hxx> #include <strings.hrc> #include <connectivity/dbexception.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace connectivity::evoab { @@ -48,7 +49,6 @@ using namespace com::sun::star::beans; using namespace com::sun::star::sdbc; using namespace com::sun::star::sdbcx; using namespace com::sun::star::container; -using namespace com::sun::star::io; using namespace com::sun::star::util; namespace { @@ -88,24 +88,69 @@ OCommonStatement::OCommonStatement(OEvoabConnection* _pConnection) , m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE) , m_bEscapeProcessing(true) { -#define REGISTER_PROP( id, member ) \ - registerProperty( \ - OMetaConnection::getPropMap().getNameByIndex( id ), \ - id, \ - 0, \ - &member, \ - cppu::UnoType<decltype(member)>::get() \ + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME), + PROPERTY_ID_CURSORNAME, + 0, + &m_aCursorName, + cppu::UnoType<decltype(m_aCursorName)>::get() + ); + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE), + PROPERTY_ID_MAXFIELDSIZE, + 0, + &m_nMaxFieldSize, + cppu::UnoType<decltype(m_nMaxFieldSize)>::get() + ); + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXROWS), + PROPERTY_ID_MAXROWS, + 0, + &m_nMaxRows, + cppu::UnoType<decltype(m_nMaxRows)>::get() + ); + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT), + PROPERTY_ID_QUERYTIMEOUT, + 0, + &m_nQueryTimeOut, + cppu::UnoType<decltype(m_nQueryTimeOut)>::get() + ); + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), + PROPERTY_ID_FETCHSIZE, + 0, + &m_nFetchSize, + cppu::UnoType<decltype(m_nFetchSize)>::get() + ); + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), + PROPERTY_ID_RESULTSETTYPE, + 0, + &m_nResultSetType, + cppu::UnoType<decltype(m_nResultSetType)>::get() + ); + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), + PROPERTY_ID_FETCHDIRECTION, + 0, + &m_nFetchDirection, + cppu::UnoType<decltype(m_nFetchDirection)>::get() + ); + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING), + PROPERTY_ID_ESCAPEPROCESSING, + 0, + &m_bEscapeProcessing, + cppu::UnoType<decltype(m_bEscapeProcessing)>::get() + ); + registerProperty( + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), + PROPERTY_ID_RESULTSETCONCURRENCY, + 0, + &m_nResultSetConcurrency, + cppu::UnoType<decltype(m_nResultSetConcurrency)>::get() ); - - REGISTER_PROP( PROPERTY_ID_CURSORNAME, m_aCursorName ); - REGISTER_PROP( PROPERTY_ID_MAXFIELDSIZE, m_nMaxFieldSize ); - REGISTER_PROP( PROPERTY_ID_MAXROWS, m_nMaxRows ); - REGISTER_PROP( PROPERTY_ID_QUERYTIMEOUT, m_nQueryTimeOut ); - REGISTER_PROP( PROPERTY_ID_FETCHSIZE, m_nFetchSize ); - REGISTER_PROP( PROPERTY_ID_RESULTSETTYPE, m_nResultSetType ); - REGISTER_PROP( PROPERTY_ID_FETCHDIRECTION, m_nFetchDirection ); - REGISTER_PROP( PROPERTY_ID_ESCAPEPROCESSING, m_bEscapeProcessing ); - REGISTER_PROP( PROPERTY_ID_RESULTSETCONCURRENCY, m_nResultSetConcurrency ); } OCommonStatement::~OCommonStatement() @@ -222,8 +267,11 @@ void OCommonStatement::orderByAnalysis( const OSQLParseNode* _pOrderByClause, So ENSURE_OR_THROW( ( pColumnRef != nullptr ) && ( pAscDesc != nullptr ) - && SQL_ISRULE( pAscDesc, opt_asc_desc ) - && ( pAscDesc->count() < 2 ), + && ( pAscDesc->isLeaf() ) + && ( SQL_ISRULE( pAscDesc, opt_asc_desc ) + || SQL_ISTOKEN(pAscDesc, ASC) + || SQL_ISTOKEN(pAscDesc, DESC) + ), "ordering_spec structure error" ); // column name -> column field @@ -232,11 +280,7 @@ void OCommonStatement::orderByAnalysis( const OSQLParseNode* _pOrderByClause, So const OUString sColumnName( impl_getColumnRefColumnName_throw( *pColumnRef ) ); guint nField = evoab::findEvoabField( sColumnName ); // ascending/descending? - bool bAscending = true; - if ( ( pAscDesc->count() == 1 ) - && SQL_ISTOKEN( pAscDesc->getChild( 0 ), DESC ) - ) - bAscending = false; + bool bAscending = !SQL_ISTOKEN(pAscDesc, DESC); _out_rSort.push_back( FieldSort( nField, bAscending ) ); } @@ -460,6 +504,7 @@ void OCommonStatement::parseSql( const OUString& sql, QueryData& _out_rQueryData pOrderByClause->showParseTree( sTreeDebug ); SAL_INFO( "connectivity.evoab2", "found order-by tree:\n" << sTreeDebug ); #endif + orderByAnalysis( pOrderByClause, _out_rQueryData.aSortOrder ); } @@ -503,7 +548,7 @@ Any SAL_CALL OCommonStatement::getWarnings( ) checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); - return makeAny(SQLWarning()); + return Any(SQLWarning()); } @@ -527,12 +572,12 @@ void SAL_CALL OCommonStatement::clearWarnings( ) } -void SAL_CALL OCommonStatement::acquire() throw() +void SAL_CALL OCommonStatement::acquire() noexcept { OCommonStatement_IBase::acquire(); } -void SAL_CALL OCommonStatement::release() throw() +void SAL_CALL OCommonStatement::release() noexcept { OCommonStatement_IBase::release(); } @@ -564,13 +609,12 @@ QueryData OCommonStatement::impl_getEBookQuery_throw( const OUString& _rSql ) Reference< XResultSet > OCommonStatement::impl_executeQuery_throw( const QueryData& _rQueryData ) { // create result set - OEvoabResultSet* pResult = new OEvoabResultSet( this, m_xConnection.get() ); - Reference< XResultSet > xRS = pResult; + rtl::Reference<OEvoabResultSet> pResult = new OEvoabResultSet( this, m_xConnection.get() ); pResult->construct( _rQueryData ); // done - m_xResultSet = xRS; - return xRS; + m_xResultSet = Reference<XWeak>(pResult); + return pResult; } diff --git a/connectivity/source/drivers/evoab2/NStatement.hxx b/connectivity/source/drivers/evoab2/NStatement.hxx index a5d739eb14a1..a348c5335d56 100644 --- a/connectivity/source/drivers/evoab2/NStatement.hxx +++ b/connectivity/source/drivers/evoab2/NStatement.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NSTATEMENT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NSTATEMENT_HXX +#pragma once #include <com/sun/star/sdbc/XStatement.hpp> #include <com/sun/star/sdbc/XWarningsSupplier.hpp> @@ -198,8 +197,8 @@ namespace connectivity::evoab // OComponentHelper virtual void SAL_CALL disposing() override; // XInterface - virtual void SAL_CALL release() throw() override; - virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() noexcept override; + virtual void SAL_CALL acquire() noexcept override; // XInterface virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; //XTypeProvider @@ -230,7 +229,7 @@ namespace connectivity::evoab impl_executeQuery_throw( const QueryData& _rData ); css::uno::Reference< css::sdbc::XConnection > - impl_getConnection() { return css::uno::Reference< css::sdbc::XConnection >( m_xConnection.get() ); } + impl_getConnection() { return css::uno::Reference< css::sdbc::XConnection >( m_xConnection ); } OUString impl_getColumnRefColumnName_throw( const ::connectivity::OSQLParseNode& _rColumnRef ); @@ -253,8 +252,8 @@ namespace connectivity::evoab // XInterface virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - virtual void SAL_CALL acquire() throw() override; - virtual void SAL_CALL release() throw() override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; // XTypeProvider DECLARE_XTYPEPROVIDER() @@ -271,6 +270,4 @@ namespace connectivity::evoab } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NSTATEMENT_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NTable.cxx b/connectivity/source/drivers/evoab2/NTable.cxx index b5c652a8ff67..631c27db244d 100644 --- a/connectivity/source/drivers/evoab2/NTable.cxx +++ b/connectivity/source/drivers/evoab2/NTable.cxx @@ -24,13 +24,8 @@ #include <com/sun/star/sdbc/XRow.hpp> using namespace connectivity; -using namespace ::comphelper; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; using namespace connectivity::evoab; OEvoabTable::OEvoabTable( sdbcx::OCollection* _pTables, @@ -62,15 +57,15 @@ void OEvoabTable::refreshColumns() if (xResult.is()) { - Reference< XRow > xRow(xResult, UNO_QUERY); - while (xResult->next()) - aVector.push_back(xRow->getString(4)); + Reference< XRow > xRow(xResult, UNO_QUERY); + while (xResult->next()) + aVector.push_back(xRow->getString(4)); } } if (m_xColumns) m_xColumns->reFill(aVector); else - m_xColumns = new OEvoabColumns(this,m_aMutex,aVector); + m_xColumns.reset(new OEvoabColumns(this,m_aMutex,aVector)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NTable.hxx b/connectivity/source/drivers/evoab2/NTable.hxx index 2b38171b398f..0aa30815b9b5 100644 --- a/connectivity/source/drivers/evoab2/NTable.hxx +++ b/connectivity/source/drivers/evoab2/NTable.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NTABLE_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NTABLE_HXX +#pragma once #include "NConnection.hxx" #include <connectivity/sdbcx/VTable.hxx> @@ -51,6 +50,4 @@ namespace connectivity::evoab } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NTABLE_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/evoab2/NTables.cxx b/connectivity/source/drivers/evoab2/NTables.cxx index b7a844fac15d..3be63e1e1049 100644 --- a/connectivity/source/drivers/evoab2/NTables.cxx +++ b/connectivity/source/drivers/evoab2/NTables.cxx @@ -29,12 +29,7 @@ using namespace ::cppu; using namespace connectivity::evoab; using namespace connectivity::sdbcx; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; -using namespace dbtools; ObjectType OEvoabTables::createObject(const OUString& aName) { @@ -48,7 +43,7 @@ ObjectType OEvoabTables::createObject(const OUString& aName) Reference< XRow > xRow(xResult,UNO_QUERY); if(xResult->next()) // there can be only one table with this name { - OEvoabTable* pRet = new OEvoabTable( + xRet = new OEvoabTable( this, static_cast<OEvoabCatalog&>(m_rParent).getConnection(), aName, @@ -56,7 +51,6 @@ ObjectType OEvoabTables::createObject(const OUString& aName) xRow->getString(5), "", ""); - xRet = pRet; } } diff --git a/connectivity/source/drivers/evoab2/NTables.hxx b/connectivity/source/drivers/evoab2/NTables.hxx index 593367c73a86..e5d454729431 100644 --- a/connectivity/source/drivers/evoab2/NTables.hxx +++ b/connectivity/source/drivers/evoab2/NTables.hxx @@ -16,11 +16,11 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NTABLES_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NTABLES_HXX +#pragma once #include <connectivity/sdbcx/VCollection.hxx> #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#include <utility> namespace connectivity::evoab { @@ -31,16 +31,14 @@ namespace connectivity::evoab virtual sdbcx::ObjectType createObject(const OUString& _rName) override; virtual void impl_refresh() override; public: - OEvoabTables(const css::uno::Reference< css::sdbc::XDatabaseMetaData >& _rMetaData, + OEvoabTables(css::uno::Reference< css::sdbc::XDatabaseMetaData > _xMetaData, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, const ::std::vector< OUString> &_rVector) : sdbcx::OCollection(_rParent,true,_rMutex,_rVector), - m_xMetaData(_rMetaData) + m_xMetaData(std::move(_xMetaData)) {} virtual void disposing() override; }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_EVOAB2_NTABLES_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |