From 31cc5f0ca04a990b1a6045f41cba10d2f829a921 Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Wed, 30 May 2001 10:32:19 +0000 Subject: #86671# +checkConnected --- unotools/source/streaming/streamwrap.cxx | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'unotools/source/streaming') diff --git a/unotools/source/streaming/streamwrap.cxx b/unotools/source/streaming/streamwrap.cxx index 28cd5106ba94..bf2032ad669c 100644 --- a/unotools/source/streaming/streamwrap.cxx +++ b/unotools/source/streaming/streamwrap.cxx @@ -2,9 +2,9 @@ * * $RCSfile: streamwrap.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: fs $ $Date: 2001-05-15 07:44:56 $ + * last change: $Author: fs $ $Date: 2001-05-30 11:32:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -112,8 +112,7 @@ OInputStreamWrapper::~OInputStreamWrapper() sal_Int32 SAL_CALL OInputStreamWrapper::readBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead) throw( stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException ) { - if (!m_pSvStream) - throw stario::NotConnectedException(::rtl::OUString(), static_cast(this)); + checkConnected(); if (nBytesToRead < 0) throw stario::BufferSizeExceededException(::rtl::OUString(),static_cast(this)); @@ -171,8 +170,7 @@ void SAL_CALL OInputStreamWrapper::skipBytes(sal_Int32 nBytesToSkip) throw( star sal_Int32 SAL_CALL OInputStreamWrapper::available() throw( stario::NotConnectedException, staruno::RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); - if (!m_pSvStream) - throw stario::NotConnectedException(::rtl::OUString(), static_cast(this)); + checkConnected(); sal_uInt32 nPos = m_pSvStream->Tell(); checkError(); @@ -190,8 +188,8 @@ sal_Int32 SAL_CALL OInputStreamWrapper::available() throw( stario::NotConnectedE //------------------------------------------------------------------------------ void SAL_CALL OInputStreamWrapper::closeInput() throw( stario::NotConnectedException, staruno::RuntimeException ) { - if (!m_pSvStream) - throw stario::NotConnectedException(::rtl::OUString(), static_cast(this)); + ::osl::MutexGuard aGuard( m_aMutex ); + checkConnected(); if (m_bSvStreamOwner) delete m_pSvStream; @@ -200,14 +198,20 @@ void SAL_CALL OInputStreamWrapper::closeInput() throw( stario::NotConnectedExcep } //------------------------------------------------------------------------------ -void OInputStreamWrapper::checkError() +void OInputStreamWrapper::checkConnected() const { if (!m_pSvStream) - throw stario::NotConnectedException(::rtl::OUString(),static_cast(this)); + throw stario::NotConnectedException(::rtl::OUString(), const_cast(static_cast(this))); +} + +//------------------------------------------------------------------------------ +void OInputStreamWrapper::checkError() const +{ + checkConnected(); if (m_pSvStream->SvStream::GetError() != ERRCODE_NONE) // TODO: really evaluate the error - throw stario::NotConnectedException(::rtl::OUString(),static_cast(this)); + throw stario::NotConnectedException(::rtl::OUString(), const_cast(static_cast(this))); } //================================================================== @@ -250,6 +254,7 @@ void SAL_CALL OSeekableInputStreamWrapper::release( ) throw () void SAL_CALL OSeekableInputStreamWrapper::seek( sal_Int64 _nLocation ) throw (IllegalArgumentException, IOException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); + checkConnected(); m_pSvStream->Seek((sal_uInt32)_nLocation); checkError(); @@ -259,6 +264,7 @@ void SAL_CALL OSeekableInputStreamWrapper::seek( sal_Int64 _nLocation ) throw (I sal_Int64 SAL_CALL OSeekableInputStreamWrapper::getPosition( ) throw (IOException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); + checkConnected(); sal_uInt32 nPos = m_pSvStream->Tell(); checkError(); @@ -269,6 +275,7 @@ sal_Int64 SAL_CALL OSeekableInputStreamWrapper::getPosition( ) throw (IOExcepti sal_Int64 SAL_CALL OSeekableInputStreamWrapper::getLength( ) throw (IOException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); + checkConnected(); sal_uInt32 nCurrentPos = m_pSvStream->Tell(); checkError(); -- cgit