connectivity/source/drivers/firebird/Connection.cxx | 15 +++++++++++++++ connectivity/source/drivers/firebird/Connection.hxx | 5 +++++ connectivity/source/drivers/firebird/Driver.cxx | 6 ++++-- 3 files changed, 24 insertions(+), 2 deletions(-)
New commits: commit 19ac6869e129bf03737087eb32198026f9663894 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Sep 11 19:21:19 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Sep 14 10:25:54 2021 +0200 tdf#117842: use XUnoTunnel to get wrapped connection reliably XDataDefinitionSupplier::getDataDefinitionByConnection may take not only direct reference to expected connection type, but also connectivity::OConnectionWeakWrapper wrapping it. Change-Id: I88925f9403b51f0cf13f02b5f00d3765a242230e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121890 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit ccc6c846eb7f6d334d0ab2e6b50c188c434caa19) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121986 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index 04f8d0a8185c..5e61aa5a0f0a 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -44,8 +44,10 @@ #include <resource/sharedresources.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/servicehelper.hxx> #include <comphelper/storagehelper.hxx> #include <cppuhelper/exc_hlp.hxx> +#include <cppuhelper/typeprovider.hxx> #include <unotools/tempfile.hxx> #include <unotools/localfilehelper.hxx> @@ -361,6 +363,19 @@ Reference< XClob> Connection::createClob(ISC_QUAD const * pBlobId) return xReturn; } +//----- XUnoTunnel ---------------------------------------------------------- +// virtual +sal_Int64 SAL_CALL Connection::getSomething(const css::uno::Sequence<sal_Int8>& rId) +{ + return (isUnoTunnelId<Connection>(rId)) ? reinterpret_cast<sal_Int64>(this) : sal_Int64(0); +} + +// static +css::uno::Sequence<sal_Int8> Connection::getUnoTunnelId() +{ + static const cppu::OImplementationId implId; + return implId.getImplementationId(); +} //----- XConnection ---------------------------------------------------------- Reference< XStatement > SAL_CALL Connection::createStatement( ) diff --git a/connectivity/source/drivers/firebird/Connection.hxx b/connectivity/source/drivers/firebird/Connection.hxx index eba3b9710952..caf091146ae6 100644 --- a/connectivity/source/drivers/firebird/Connection.hxx +++ b/connectivity/source/drivers/firebird/Connection.hxx @@ -33,6 +33,7 @@ #include <com/sun/star/document/XDocumentEventListener.hpp> #include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/sdbc/XBlob.hpp> #include <com/sun/star/sdbc/XClob.hpp> #include <com/sun/star/sdbc/XConnection.hpp> @@ -45,6 +46,7 @@ namespace connectivity::firebird typedef ::cppu::WeakComponentImplHelper< css::document::XDocumentEventListener, css::lang::XServiceInfo, + css::lang::XUnoTunnel, css::sdbc::XConnection, css::sdbc::XWarningsSupplier > Connection_BASE; @@ -206,6 +208,9 @@ namespace connectivity::firebird // XServiceInfo DECLARE_SERVICE_INFO(); + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence<sal_Int8>& rId) override; + static css::uno::Sequence<sal_Int8> getUnoTunnelId(); // XConnection virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement( ) override; virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) override; diff --git a/connectivity/source/drivers/firebird/Driver.cxx b/connectivity/source/drivers/firebird/Driver.cxx index 1d452eb1c593..4a12953ae5f9 100644 --- a/connectivity/source/drivers/firebird/Driver.cxx +++ b/connectivity/source/drivers/firebird/Driver.cxx @@ -25,6 +25,7 @@ #include <strings.hrc> #include <resource/sharedresources.hxx> +#include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> #include <osl/file.hxx> #include <osl/process.h> @@ -192,8 +193,9 @@ sal_Int32 SAL_CALL FirebirdDriver::getMinorVersion( ) uno::Reference< XTablesSupplier > SAL_CALL FirebirdDriver::getDataDefinitionByConnection( const uno::Reference< XConnection >& rConnection) { - Connection* pConnection = static_cast< Connection* >(rConnection.get()); - return pConnection->createCatalog(); + if (Connection* pConnection = comphelper::getUnoTunnelImplementation<Connection>(rConnection)) + return pConnection->createCatalog(); + return {}; } uno::Reference< XTablesSupplier > SAL_CALL FirebirdDriver::getDataDefinitionByURL(