diff options
author | Mathias Bauer <mba@openoffice.org> | 2000-11-03 11:13:58 +0000 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2000-11-03 11:13:58 +0000 |
commit | 6a5d8084129363979d2ca63778916d250766afcc (patch) | |
tree | 7fd0db3d8f4f58ab04fdeb138dc3b8ffc5b34d3a /unotools/source/ucbhelper | |
parent | 57d83cb7d3d7747e3f2820835ece0a6c99b05084 (diff) |
#79606#: controlled error handling for failed readwrite access
Diffstat (limited to 'unotools/source/ucbhelper')
-rw-r--r-- | unotools/source/ucbhelper/ucblockbytes.cxx | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx index 45ae20599ca4..cea4334706e7 100644 --- a/unotools/source/ucbhelper/ucblockbytes.cxx +++ b/unotools/source/ucbhelper/ucblockbytes.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ucblockbytes.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: mba $ $Date: 2000-11-02 10:24:49 $ + * last change: $Author: mba $ $Date: 2000-11-03 12:13:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -326,7 +326,8 @@ public: virtual void SAL_CALL onTerminated(); virtual void SAL_CALL run(); void Cancel(); - void DoIt( sal_Bool bHandle = sal_True ); + sal_Bool DoIt(); + void Notify( sal_Bool bError ); }; //---------------------------------------------------------------------------- @@ -375,12 +376,12 @@ void CommandThread_Impl::run() m_bRunning = sal_True; if( !m_bCanceled && schedule() ) - DoIt(); + Notify( DoIt() ); m_bRunning = sal_False; } -void CommandThread_Impl::DoIt( sal_Bool bHandle ) +sal_Bool CommandThread_Impl::DoIt() { // create content and execute command Any aParam; @@ -404,10 +405,14 @@ void CommandThread_Impl::DoIt( sal_Bool bHandle ) bException = true; } - Reference < XActiveDataControl > xControl( m_aArgument.Sink, UNO_QUERY ); - if ( bAborted || bException ) + return ( bAborted || bException ); +} + +void CommandThread_Impl::Notify( sal_Bool bError ) +{ + if ( bError ) { - if( bHandle && m_xHandler.Is() ) + if( m_xHandler.Is() ) m_xHandler->Handle( UcbLockBytesHandler::CANCEL, m_xLockBytes ); Reference < XActiveDataSink > xSink( m_aArgument.Sink, UNO_QUERY ); @@ -417,11 +422,10 @@ void CommandThread_Impl::DoIt( sal_Bool bHandle ) Reference < XActiveDataStreamer > xStreamer( m_aArgument.Sink, UNO_QUERY ); if ( xStreamer.is() ) xStreamer->setStream( Reference < XStream >() ); - - if ( bHandle && xControl.is() ) - xControl->terminate(); } - else if ( xControl.is() ) + + Reference < XActiveDataControl > xControl( m_aArgument.Sink, UNO_QUERY ); + if ( xControl.is() ) xControl->terminate(); } @@ -756,17 +760,11 @@ UcbLockBytesRef UcbLockBytes::CreateLockBytes( const Reference < XContent > xCon if ( eOpenMode & STREAM_WRITE ) { // first try read/write mode - pThread->DoIt( sal_False ); + sal_Bool bSuccess = pThread->DoIt(); + if ( !bSuccess ) + xLockBytes->SetError( ERRCODE_IO_NOTEXISTS ); delete pThread; - if ( !xLockBytes->getInputStream_Impl().is() ) - { - // no success: try readonly mode - xSink = (XActiveDataControl*) new UcbDataSink_Impl( xLockBytes ); - aArgument.Sink = xSink; - pThread = new CommandThread_Impl( xLockBytes, xContent, aArgument, xInteractionHandler, xProgressHdl, pHandler ); - } - else - return xLockBytes; + return xLockBytes; } if ( pHandler ) |