diff options
author | Mathias Bauer <mba@openoffice.org> | 2000-11-30 08:17:11 +0000 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2000-11-30 08:17:11 +0000 |
commit | 29639a2e49c59ffdd7da01dd3f4b3843bb247bea (patch) | |
tree | 201909256d9574ad113b12326e1534a0bfc71010 /unotools | |
parent | e2be5bb346c89c8b8b90b4b385df9447033f0612 (diff) |
#80375#: better error handling
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/ucbhelper/ucblockbytes.cxx | 27 | ||||
-rw-r--r-- | unotools/source/ucbhelper/ucbstreamhelper.cxx | 17 |
2 files changed, 20 insertions, 24 deletions
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx index 8bd2a17d4556..3ba79e378731 100644 --- a/unotools/source/ucbhelper/ucblockbytes.cxx +++ b/unotools/source/ucbhelper/ucblockbytes.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ucblockbytes.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: mba $ $Date: 2000-11-16 17:12:53 $ + * last change: $Author: mba $ $Date: 2000-11-30 09:17:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -327,7 +327,6 @@ public: virtual void SAL_CALL run(); void Cancel(); sal_Bool DoIt(); - void Notify( sal_Bool bError ); }; //---------------------------------------------------------------------------- @@ -376,7 +375,7 @@ void CommandThread_Impl::run() m_bRunning = sal_True; if( !m_bCanceled && schedule() ) - Notify( DoIt() ); + DoIt(); m_bRunning = sal_False; } @@ -405,12 +404,7 @@ sal_Bool CommandThread_Impl::DoIt() bException = true; } - return ( bAborted || bException ); -} - -void CommandThread_Impl::Notify( sal_Bool bError ) -{ - if ( bError ) + if ( bAborted || bException ) { if( m_xHandler.Is() ) m_xHandler->Handle( UcbLockBytesHandler::CANCEL, m_xLockBytes ); @@ -427,8 +421,9 @@ void CommandThread_Impl::Notify( sal_Bool bError ) Reference < XActiveDataControl > xControl( m_aArgument.Sink, UNO_QUERY ); if ( xControl.is() ) xControl->terminate(); -} + return ( bAborted || bException ); +} //---------------------------------------------------------------------------- void CommandThread_Impl::onTerminated() @@ -757,7 +752,7 @@ UcbLockBytesRef UcbLockBytes::CreateLockBytes( const Reference < XContent > xCon Reference< XProgressHandler > xProgressHdl = new ProgressHandler_Impl( LINK( &xLockBytes, UcbLockBytes, DataAvailHdl ) ); CommandThread_Impl* pThread = new CommandThread_Impl( xLockBytes, xContent, aArgument, xInteractionHandler, xProgressHdl, pHandler ); - if ( eOpenMode & STREAM_WRITE ) + if ( ( eOpenMode & STREAM_WRITE ) || !pHandler ) { // first try read/write mode sal_Bool bError = pThread->DoIt(); @@ -766,15 +761,9 @@ UcbLockBytesRef UcbLockBytes::CreateLockBytes( const Reference < XContent > xCon delete pThread; return xLockBytes; } - - if ( pHandler ) - { - pThread->create(); - } else { - pThread->DoIt(); - delete pThread; + pThread->create(); } return xLockBytes; diff --git a/unotools/source/ucbhelper/ucbstreamhelper.cxx b/unotools/source/ucbhelper/ucbstreamhelper.cxx index 86e5e62c269d..11ce5fecfdf2 100644 --- a/unotools/source/ucbhelper/ucbstreamhelper.cxx +++ b/unotools/source/ucbhelper/ucbstreamhelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ucbstreamhelper.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mba $ $Date: 2000-11-15 11:51:12 $ + * last change: $Author: mba $ $Date: 2000-11-30 09:17:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -122,7 +122,10 @@ SvStream* UcbStreamHelper::CreateStream( const String& rFileName, StreamMode eOp ::ucb::Content aContent( rFileName, Reference < XCommandEnvironment >() ); xLockBytes = UcbLockBytes::CreateLockBytes( aContent.get(), eOpenMode, pHandler ); if ( xLockBytes.Is() ) + { pStream = new SvStream( xLockBytes ); + pStream->SetError( xLockBytes->GetError() ); + } } catch ( Exception e ) { @@ -138,11 +141,15 @@ SvStream* UcbStreamHelper::CreateStream( const String& rFileName, StreamMode eOp SvStream* UcbStreamHelper::CreateStream( Reference < XInputStream > xStream ) { + SvStream* pStream = NULL; UcbLockBytesRef xLockBytes = UcbLockBytes::CreateInputLockBytes( xStream ); if ( xLockBytes.Is() ) - return new SvStream( xLockBytes ); - else - return NULL; + { + pStream = new SvStream( xLockBytes ); + pStream->SetError( xLockBytes->GetError() ); + } + + return pStream; }; }; |