diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-11 19:21:19 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-12 08:02:36 +0200 |
commit | ccc6c846eb7f6d334d0ab2e6b50c188c434caa19 (patch) | |
tree | 031877d217cac21663f960dac034733429cc142e /connectivity/source | |
parent | 380550fb478b20deca980e5eefd7a8ce7703263d (diff) |
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.kaganski@collabora.com>
Diffstat (limited to 'connectivity/source')
-rw-r--r-- | connectivity/source/drivers/firebird/Connection.cxx | 15 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Connection.hxx | 5 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Driver.cxx | 6 |
3 files changed, 24 insertions, 2 deletions
diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index 6d38af079d1e..040770fe0e6d 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> @@ -376,6 +378,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 857352583c39..fbf29293a31c 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> @@ -190,8 +191,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( |