diff options
author | Rüdiger Timm <rt@openoffice.org> | 2006-02-07 09:28:31 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2006-02-07 09:28:31 +0000 |
commit | 51497cdd3abfcefbd9e214e169bc61656a4d949e (patch) | |
tree | 0475aab7df273396081a48783846fb08065d1199 /unotools/source/ucbhelper/ucblockbytes.cxx | |
parent | 650b07e94601578a4451f5ff3ea4aee7da7f0843 (diff) |
INTEGRATION: CWS fwk31 (1.51.28); FILE MERGED
2006/01/06 10:47:18 mav 1.51.28.1: #126194# catch possible exceptions
Diffstat (limited to 'unotools/source/ucbhelper/ucblockbytes.cxx')
-rw-r--r-- | unotools/source/ucbhelper/ucblockbytes.cxx | 76 |
1 files changed, 31 insertions, 45 deletions
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx index 335c3c807f2c..eed88ad0f0e1 100644 --- a/unotools/source/ucbhelper/ucblockbytes.cxx +++ b/unotools/source/ucbhelper/ucblockbytes.cxx @@ -4,9 +4,9 @@ * * $RCSfile: ucblockbytes.cxx,v $ * - * $Revision: 1.51 $ + * $Revision: 1.52 $ * - * last change: $Author: rt $ $Date: 2005-09-09 09:51:56 $ + * last change: $Author: rt $ $Date: 2006-02-07 10:28:31 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -127,6 +127,8 @@ #include <com/sun/star/lang/IllegalArgumentException.hpp> #endif +#include <comphelper/storagehelper.hxx> + #include <ucbhelper/contentbroker.hxx> #include <ucbhelper/content.hxx> @@ -1334,28 +1336,6 @@ static sal_Bool _UCBOpenContentSync( //---------------------------------------------------------------------------- -static void copyInputToOutput( const Reference< XInputStream >& aIn, const Reference< XOutputStream >& aOut ) -{ - const sal_Int32 nConstBufferSize = 32000; - - sal_Int32 nRead; - Sequence < sal_Int8 > aSequence ( nConstBufferSize ); - - do - { - nRead = aIn->readBytes ( aSequence, nConstBufferSize ); - if ( nRead < nConstBufferSize ) - { - Sequence < sal_Int8 > aTempBuf ( aSequence.getConstArray(), nRead ); - aOut->writeBytes ( aTempBuf ); - } - else - aOut->writeBytes ( aSequence ); - } - while ( nRead == nConstBufferSize ); -} - -//---------------------------------------------------------------------------- UcbLockBytes::UcbLockBytes( UcbLockBytesHandler* pHandler ) : m_xInputStream (NULL) , m_pCommandThread( NULL ) @@ -1437,35 +1417,41 @@ sal_Bool UcbLockBytes::setStream_Impl( const Reference<XStream>& aStream ) sal_Bool UcbLockBytes::setInputStream_Impl( const Reference<XInputStream> &rxInputStream, sal_Bool bSetXSeekable ) { - BOOL bRet; + sal_Bool bRet = sal_False; - vos::OClearableGuard aGuard( m_aMutex ); - if ( !m_bDontClose && m_xInputStream.is() ) - m_xInputStream->closeInput(); + try + { + vos::OClearableGuard aGuard( m_aMutex ); - m_xInputStream = rxInputStream; + if ( !m_bDontClose && m_xInputStream.is() ) + m_xInputStream->closeInput(); - if( bSetXSeekable ) - { - m_xSeekable = Reference < XSeekable > ( rxInputStream, UNO_QUERY ); - if( !m_xSeekable.is() && rxInputStream.is() ) - { - Reference < XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - Reference< XOutputStream > rxTempOut = Reference < XOutputStream > ( - xFactory->createInstance ( ::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ) ), - UNO_QUERY ); + m_xInputStream = rxInputStream; - if( rxTempOut.is() ) + if( bSetXSeekable ) + { + m_xSeekable = Reference < XSeekable > ( rxInputStream, UNO_QUERY ); + if( !m_xSeekable.is() && rxInputStream.is() ) { - copyInputToOutput( rxInputStream, rxTempOut ); - m_xInputStream = Reference< XInputStream >( rxTempOut, UNO_QUERY ); - m_xSeekable = Reference < XSeekable > ( rxTempOut, UNO_QUERY ); + Reference < XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); + Reference< XOutputStream > rxTempOut = Reference < XOutputStream > ( + xFactory->createInstance ( ::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ) ), + UNO_QUERY ); + + if( rxTempOut.is() ) + { + ::comphelper::OStorageHelper::CopyInputToOutput( rxInputStream, rxTempOut ); + m_xInputStream = Reference< XInputStream >( rxTempOut, UNO_QUERY ); + m_xSeekable = Reference < XSeekable > ( rxTempOut, UNO_QUERY ); + } } } - } - bRet = m_xInputStream.is(); - aGuard.clear(); + bRet = m_xInputStream.is(); + // aGuard.clear(); + } + catch( Exception& ) + {} if ( m_bStreamValid && m_xInputStream.is() ) m_aInitialized.set(); |