summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-01-12 11:49:29 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-01-13 06:15:21 +0000
commit14df26ac57696c11fd344bb16ec22738e42377fc (patch)
tree38d06a93a5f01e014be6b93cbc420d016bd4405e
parent20adf4683c7d38ad41edac586b897757393c8029 (diff)
XUnoTunnel->dynamic_cast in comphelper::ByteReader and comphelper::ByteWriter
Change-Id: I1f8c864a939dff1252ba15f517f63b62d1a1e1fc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145393 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--comphelper/source/misc/storagehelper.cxx11
-rw-r--r--comphelper/source/streaming/basicio.cxx13
-rw-r--r--comphelper/source/streaming/memorystream.cxx12
-rw-r--r--comphelper/source/streaming/seqstream.cxx7
-rw-r--r--include/comphelper/bytereader.hxx9
-rw-r--r--include/comphelper/seqstream.hxx5
-rw-r--r--include/unotools/streamwrap.hxx5
-rw-r--r--package/source/xstor/owriteablestream.cxx19
-rw-r--r--package/source/xstor/owriteablestream.hxx4
-rw-r--r--package/source/zipapi/ZipFile.cxx5
-rw-r--r--ucb/source/ucp/file/filstr.cxx7
-rw-r--r--ucb/source/ucp/file/filstr.hxx6
-rw-r--r--unotools/source/streaming/streamwrap.cxx8
-rw-r--r--unotools/source/ucbhelper/ucblockbytes.cxx6
14 files changed, 14 insertions, 103 deletions
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index 934261b0c500..7b41eafbf9f1 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -175,17 +175,10 @@ void OStorageHelper::CopyInputToOutput(
{
static const sal_Int32 nConstBufferSize = 32000;
- uno::Reference< css::lang::XUnoTunnel > xInputTunnel( xInput, uno::UNO_QUERY );
- comphelper::ByteReader* pByteReader = nullptr;
+ comphelper::ByteReader* pByteReader = dynamic_cast< comphelper::ByteReader* >( xInput.get() );
comphelper::ByteWriter* pByteWriter = nullptr;
- if (xInputTunnel)
- pByteReader = reinterpret_cast< comphelper::ByteReader* >( xInputTunnel->getSomething( comphelper::ByteReader::getUnoTunnelId() ) );
if (pByteReader)
- {
- uno::Reference< css::lang::XUnoTunnel > xOutputTunnel( xOutput, uno::UNO_QUERY );
- if (xOutputTunnel)
- pByteWriter = reinterpret_cast< comphelper::ByteWriter* >( xOutputTunnel->getSomething( comphelper::ByteWriter::getUnoTunnelId() ) );
- }
+ pByteWriter = dynamic_cast< comphelper::ByteWriter* >( xOutput.get() );
if (pByteWriter)
{
diff --git a/comphelper/source/streaming/basicio.cxx b/comphelper/source/streaming/basicio.cxx
index b8c0c96e2cfa..534d8b4cd0a1 100644
--- a/comphelper/source/streaming/basicio.cxx
+++ b/comphelper/source/streaming/basicio.cxx
@@ -161,21 +161,8 @@ const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css:
ByteReader::~ByteReader() {}
-const css::uno::Sequence< sal_Int8 > & ByteReader::getUnoTunnelId()
-{
- static const comphelper::UnoIdInit implId;
- return implId.getSeq();
-}
-
ByteWriter::~ByteWriter() {}
-const css::uno::Sequence< sal_Int8 > & ByteWriter::getUnoTunnelId()
-{
- static const comphelper::UnoIdInit implId;
- return implId.getSeq();
-}
-
-
} // namespace comphelper
diff --git a/comphelper/source/streaming/memorystream.cxx b/comphelper/source/streaming/memorystream.cxx
index 97480a3aad64..dc2a39d9e5b1 100644
--- a/comphelper/source/streaming/memorystream.cxx
+++ b/comphelper/source/streaming/memorystream.cxx
@@ -55,7 +55,7 @@ namespace comphelper
namespace {
class UNOMemoryStream :
- public WeakImplHelper<XServiceInfo, XStream, XSeekableInputStream, XOutputStream, XTruncate, XUnoTunnel>,
+ public WeakImplHelper<XServiceInfo, XStream, XSeekableInputStream, XOutputStream, XTruncate>,
public comphelper::ByteWriter
{
public:
@@ -90,9 +90,6 @@ public:
// XTruncate
virtual void SAL_CALL truncate() override;
- // XUnoTunnel
- virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
-
// comphelper::ByteWriter
virtual void writeBytes(const sal_Int8* aData, sal_Int32 nBytesToWrite) override;
@@ -248,13 +245,6 @@ void SAL_CALL UNOMemoryStream::truncate()
mnCursor = 0;
}
-sal_Int64 SAL_CALL UNOMemoryStream::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier )
-{
- if (rIdentifier == comphelper::ByteWriter::getUnoTunnelId())
- return reinterpret_cast<sal_Int64>(static_cast<comphelper::ByteWriter*>(this));
- return 0;
-}
-
} // namespace comphelper
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
diff --git a/comphelper/source/streaming/seqstream.cxx b/comphelper/source/streaming/seqstream.cxx
index 1f37a7967b04..9626484f62d4 100644
--- a/comphelper/source/streaming/seqstream.cxx
+++ b/comphelper/source/streaming/seqstream.cxx
@@ -92,13 +92,6 @@ sal_Int32 SequenceInputStream::readSomeBytes( sal_Int8* pData, sal_Int32 nBytesT
return nBytesToRead;
}
-sal_Int64 SAL_CALL SequenceInputStream::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier )
-{
- if (rIdentifier == comphelper::ByteReader::getUnoTunnelId())
- return reinterpret_cast<sal_Int64>(static_cast<comphelper::ByteReader*>(this));
- return 0;
-}
-
sal_Int32 SAL_CALL SequenceInputStream::readSomeBytes( Sequence<sal_Int8>& aData, sal_Int32 nMaxBytesToRead )
{
// all data is available at once
diff --git a/include/comphelper/bytereader.hxx b/include/comphelper/bytereader.hxx
index 49d683f233b8..8ee308fb00fa 100644
--- a/include/comphelper/bytereader.hxx
+++ b/include/comphelper/bytereader.hxx
@@ -8,6 +8,7 @@
*/
#pragma once
+#include <sal/types.h>
#include <comphelper/comphelperdllapi.h>
#include <com/sun/star/uno/Sequence.hxx>
@@ -17,26 +18,22 @@ namespace comphelper
* Interface that we can cast to, to bypass the inefficiency of using Sequence<sal_Int8>
* when reading via XInputStream.
*/
-class COMPHELPER_DLLPUBLIC ByteReader
+class COMPHELPER_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") ByteReader
{
public:
virtual ~ByteReader();
virtual sal_Int32 readSomeBytes(sal_Int8* aData, sal_Int32 nBytesToRead) = 0;
-
- static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
};
/**
* Interface that we can cast to, to bypass the inefficiency of using Sequence<sal_Int8>
* when writing via XOutputStream.
*/
-class COMPHELPER_DLLPUBLIC ByteWriter
+class COMPHELPER_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") ByteWriter
{
public:
virtual ~ByteWriter();
virtual void writeBytes(const sal_Int8* aData, sal_Int32 nBytesToWrite) = 0;
-
- static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
};
} // namespace utl
diff --git a/include/comphelper/seqstream.hxx b/include/comphelper/seqstream.hxx
index c2ba3913432b..1f1db113116a 100644
--- a/include/comphelper/seqstream.hxx
+++ b/include/comphelper/seqstream.hxx
@@ -39,7 +39,7 @@ namespace comphelper
class COMPHELPER_DLLPUBLIC SequenceInputStream final
- : public ::cppu::WeakImplHelper< css::io::XInputStream, css::io::XSeekable, css::lang::XUnoTunnel >,
+ : public ::cppu::WeakImplHelper< css::io::XInputStream, css::io::XSeekable >,
public comphelper::ByteReader
{
std::mutex m_aMutex;
@@ -64,9 +64,6 @@ public:
virtual sal_Int64 SAL_CALL getPosition( ) override;
virtual sal_Int64 SAL_CALL getLength( ) override;
-// css::lang::XUnoTunnel
- virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
-
// comphelper::ByteReader
virtual sal_Int32 readSomeBytes( sal_Int8* pData, sal_Int32 nBytesToRead ) override;
diff --git a/include/unotools/streamwrap.hxx b/include/unotools/streamwrap.hxx
index 429bbe91c36c..479f73e514e8 100644
--- a/include/unotools/streamwrap.hxx
+++ b/include/unotools/streamwrap.hxx
@@ -39,7 +39,7 @@ namespace utl
{
// workaround for incremental linking bugs in MSVC2015
-class SAL_DLLPUBLIC_TEMPLATE OInputStreamWrapper_Base : public cppu::WeakImplHelper< css::io::XInputStream, css::lang::XUnoTunnel > {};
+class SAL_DLLPUBLIC_TEMPLATE OInputStreamWrapper_Base : public cppu::WeakImplHelper< css::io::XInputStream > {};
/// helper class for wrapping an SvStream into a com.sun.star.io::XInputStream
class UNOTOOLS_DLLPUBLIC OInputStreamWrapper : public OInputStreamWrapper_Base, public comphelper::ByteReader
@@ -66,9 +66,6 @@ public:
virtual sal_Int32 SAL_CALL available() override;
virtual void SAL_CALL closeInput() override;
-// css::lang::XUnoTunnel
- virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& _rIdentifier ) override;
-
// utl::ByteReader
virtual sal_Int32 readSomeBytes( sal_Int8* aData, sal_Int32 nMaxBytesToRead ) final override;
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index 2d6bda378d34..88d85c9fc5d2 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -90,10 +90,7 @@ static void CopyInputToOutput(
{
static const sal_Int32 nConstBufferSize = 32000;
- uno::Reference< css::lang::XUnoTunnel > xInputTunnel( xInput, uno::UNO_QUERY );
- comphelper::ByteReader* pByteReader = nullptr;
- if (xInputTunnel)
- pByteReader = reinterpret_cast< comphelper::ByteReader* >( xInputTunnel->getSomething( comphelper::ByteReader::getUnoTunnelId() ) );
+ comphelper::ByteReader* pByteReader = dynamic_cast< comphelper::ByteReader* >( xInput.get() );
if (pByteReader)
{
@@ -1734,8 +1731,7 @@ uno::Any SAL_CALL OWriteStream::queryInterface( const uno::Type& rType )
, static_cast<io::XSeekable*> ( this )
, static_cast<io::XTruncate*> ( this )
, static_cast<lang::XComponent*> ( this )
- , static_cast<beans::XPropertySet*> ( this )
- , static_cast<lang::XUnoTunnel*> ( this ) );
+ , static_cast<beans::XPropertySet*> ( this ) );
if ( aReturn.hasValue() )
return aReturn ;
@@ -2160,9 +2156,7 @@ void OWriteStream::writeBytes( const sal_Int8* pData, sal_Int32 nBytesToWrite )
throw io::NotConnectedException();
uno::Reference< css::lang::XUnoTunnel > xOutputTunnel( m_xOutStream, uno::UNO_QUERY );
- comphelper::ByteWriter* pByteWriter = nullptr;
- if (xOutputTunnel)
- pByteWriter = reinterpret_cast< comphelper::ByteWriter* >( xOutputTunnel->getSomething( comphelper::ByteWriter::getUnoTunnelId() ) );
+ comphelper::ByteWriter* pByteWriter = dynamic_cast< comphelper::ByteWriter* >( m_xOutStream.get() );
if (pByteWriter)
pByteWriter->writeBytes(pData, nBytesToWrite);
else
@@ -2175,13 +2169,6 @@ void OWriteStream::writeBytes( const sal_Int8* pData, sal_Int32 nBytesToWrite )
ModifyParentUnlockMutex_Impl( aGuard );
}
-sal_Int64 SAL_CALL OWriteStream::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier )
-{
- if (rIdentifier == comphelper::ByteWriter::getUnoTunnelId())
- return reinterpret_cast<sal_Int64>(static_cast<comphelper::ByteWriter*>(this));
- return 0;
-}
-
void SAL_CALL OWriteStream::flush()
{
// In case stream is flushed its current version becomes visible
diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx
index 140257641576..16f5291eccfc 100644
--- a/package/source/xstor/owriteablestream.hxx
+++ b/package/source/xstor/owriteablestream.hxx
@@ -232,7 +232,6 @@ class OWriteStream : public css::lang::XTypeProvider
, public css::embed::XTransactedObject
, public css::embed::XTransactionBroadcaster
, public css::beans::XPropertySet
- , public css::lang::XUnoTunnel
, public ::cppu::OWeakObject
, public comphelper::ByteWriter
{
@@ -347,9 +346,6 @@ public:
virtual void SAL_CALL removeTransactionListener(
const css::uno::Reference< css::embed::XTransactionListener >& aListener ) override;
- // XUnoTunnel
- virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
-
// comphelper::ByteWriter
virtual void writeBytes(const sal_Int8* aData, sal_Int32 nBytesToWrite) override;
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 828033688189..f839590f0be3 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -548,10 +548,7 @@ public:
XBufferedStream( const uno::Reference<XInputStream>& xSrcStream ) : mnPos(0)
{
sal_Int32 nRemaining = xSrcStream->available();
- uno::Reference< css::lang::XUnoTunnel > xInputTunnel( xSrcStream, uno::UNO_QUERY );
- comphelper::ByteReader* pByteReader = nullptr;
- if (xInputTunnel)
- pByteReader = reinterpret_cast< comphelper::ByteReader* >( xInputTunnel->getSomething( comphelper::ByteReader::getUnoTunnelId() ) );
+ comphelper::ByteReader* pByteReader = dynamic_cast< comphelper::ByteReader* >( xSrcStream.get() );
if (pByteReader)
{
diff --git a/ucb/source/ucp/file/filstr.cxx b/ucb/source/ucp/file/filstr.cxx
index 8c88b9fc2e54..85222141d5a3 100644
--- a/ucb/source/ucp/file/filstr.cxx
+++ b/ucb/source/ucp/file/filstr.cxx
@@ -165,13 +165,6 @@ XStream_impl::readSomeBytes(
return static_cast<sal_Int32>(nrc);
}
-sal_Int64 SAL_CALL XStream_impl::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier )
-{
- if (rIdentifier == comphelper::ByteReader::getUnoTunnelId())
- return reinterpret_cast<sal_Int64>(static_cast<comphelper::ByteReader*>(this));
- return 0;
-}
-
sal_Int32 SAL_CALL
XStream_impl::readSomeBytes(
uno::Sequence< sal_Int8 >& aData,
diff --git a/ucb/source/ucp/file/filstr.hxx b/ucb/source/ucp/file/filstr.hxx
index 7ba43753f261..acef94aa8c6d 100644
--- a/ucb/source/ucp/file/filstr.hxx
+++ b/ucb/source/ucp/file/filstr.hxx
@@ -43,8 +43,7 @@ class XStream_impl : public cppu::WeakImplHelper<
css::io::XInputStream,
css::io::XOutputStream,
css::io::XTruncate,
- css::io::XAsyncOutputMonitor,
- css::lang::XUnoTunnel >,
+ css::io::XAsyncOutputMonitor >,
public comphelper::ByteReader
{
@@ -124,9 +123,6 @@ class XStream_impl : public cppu::WeakImplHelper<
virtual void SAL_CALL waitForCompletion() override;
- // XUnoTunnel
- virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& _rIdentifier ) override;
-
// utl::ByteReader
virtual sal_Int32
readSomeBytes(
diff --git a/unotools/source/streaming/streamwrap.cxx b/unotools/source/streaming/streamwrap.cxx
index bc6e65779a10..7cb90aa3a63f 100644
--- a/unotools/source/streaming/streamwrap.cxx
+++ b/unotools/source/streaming/streamwrap.cxx
@@ -157,14 +157,6 @@ void OInputStreamWrapper::checkError() const
throw css::io::NotConnectedException("utl::OInputStreamWrapper error " + e.toString(), const_cast<css::uno::XWeak*>(static_cast<const css::uno::XWeak*>(this)));
}
-sal_Int64 SAL_CALL OInputStreamWrapper::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier )
-{
- if (rIdentifier == comphelper::ByteReader::getUnoTunnelId())
- return reinterpret_cast<sal_Int64>(static_cast<comphelper::ByteReader*>(this));
- return 0;
-}
-
-
//= OSeekableInputStreamWrapper
OSeekableInputStreamWrapper::~OSeekableInputStreamWrapper() = default;
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx
index 7231e0b46579..83ef4f75ad0a 100644
--- a/unotools/source/ucbhelper/ucblockbytes.cxx
+++ b/unotools/source/ucbhelper/ucblockbytes.cxx
@@ -1111,11 +1111,7 @@ ErrCode UcbLockBytes::ReadAt(sal_uInt64 const nPos,
return ERRCODE_IO_PENDING;
}
- Reference< css::lang::XUnoTunnel > xTunnel( xStream, UNO_QUERY );
- comphelper::ByteReader* pByteReader = nullptr;
- if (xTunnel)
- pByteReader = reinterpret_cast< comphelper::ByteReader* >( xTunnel->getSomething( comphelper::ByteReader::getUnoTunnelId() ) );
-
+ comphelper::ByteReader* pByteReader = dynamic_cast< comphelper::ByteReader* >(xStream.get());
if (pByteReader)
{
nSize = pByteReader->readSomeBytes( static_cast<sal_Int8*>(pBuffer), sal_Int32(nCount) );