[ooo-build-commit] Branch 'ooo/master' - package/inc package/source

Jan Holesovsky kendy at kemper.freedesktop.org
Fri Jul 31 17:22:46 PDT 2009


 package/inc/Inflater.hxx                    |    4 +
 package/source/xstor/owriteablestream.cxx   |   59 ----------------------------
 package/source/xstor/owriteablestream.hxx   |    2 
 package/source/zipapi/Inflater.cxx          |   27 +++++++++---
 package/source/zipapi/XUnbufferedStream.cxx |    8 ++-
 5 files changed, 28 insertions(+), 72 deletions(-)

New commits:
commit 46edacda438759a3febdd9f95ed03efdf9464d9e
Author: Jens-Heiner Rechtien <hr at openoffice.org>
Date:   Thu Jul 30 10:52:48 2009 +0000

    CWS-TOOLING: integrate CWS fwk114
    2009-07-08 Mikhail Voytenko #i102448# fix typo
    2009-07-08 Mikhail Voytenko #i102448# detect the document of new format correctly
    2009-07-03 Mikhail Voytenko #i101418# adjust header
    2009-07-02 Mikhail Voytenko #i103001# Integrate the patch
    2009-07-01 Mikhail Voytenko rebase to DEV300_m51
    2009-06-25 Mikhail Voytenko #i71512# integrate the patch
    2009-06-19 Mikhail Voytenko #i102931# check whether the file was changed even in case of system file locking
    2009-06-10 Mikhail Voytenko #i102448# allow to turn the office update dialog off
    2009-06-10 Mikhail Voytenko #i102448# allow to turn the office update dialog off
    2009-06-09 Mikhail Voytenko #i96091# the disposed frame should throw DisposedException
    2009-06-09 Mikhail Voytenko #i100835# commit the patch
    2009-05-26 Mikhail Voytenko #i89514# integrate the patch
    2009-05-26 Mikhail Voytenko #i30373# integrate the patch
    2009-05-26 Mikhail Voytenko #i101418# fix the error handling

diff --git a/package/inc/Inflater.hxx b/package/inc/Inflater.hxx
index 42cb207..7108960 100644
--- a/package/inc/Inflater.hxx
+++ b/package/inc/Inflater.hxx
@@ -40,7 +40,7 @@ class Inflater
 {
 protected:
     sal_Bool				bFinish, bFinished, bSetParams, bNeedDict;
-    sal_Int32				nOffset, nLength;
+    sal_Int32				nOffset, nLength, nLastInflateError;
     z_stream*				pStream;
     com::sun::star::uno::Sequence < sal_Int8 > 	sInBuffer;
     sal_Int32	doInflateBytes (com::sun::star::uno::Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength);
@@ -53,6 +53,8 @@ public:
     sal_Bool SAL_CALL finished(  );
     sal_Int32 SAL_CALL doInflateSegment( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength );
     void SAL_CALL end(  );
+
+    sal_Int32 getLastInflateError() { return nLastInflateError; }
 };
 
 #endif
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index cab33f5..60aacfb 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -743,65 +743,6 @@ uno::Reference< io::XInputStream > OWriteStream_Impl::GetTempFileAsInputStream()
     return xInputStream;
 }
 
-//-----------------------------------------------
-void OWriteStream_Impl::CopyTempFileToOutput( uno::Reference< io::XOutputStream > xOutStream )
-{
-    OSL_ENSURE( xOutStream.is(), "The stream must be specified!\n" );
-    OSL_ENSURE( m_aTempURL.getLength() || m_xCacheStream.is(), "The temporary must exist!\n" );
-
-    uno::Reference< io::XInputStream > xTempInStream;
-
-    if ( m_xCacheStream.is() )
-    {
-        if ( !m_xCacheSeek.is() )
-            throw uno::RuntimeException();
-        sal_Int64 nPos = m_xCacheSeek->getPosition();
-
-        try
-        {
-            m_xCacheSeek->seek( 0 );
-            uno::Reference< io::XInputStream > xTempInp = m_xCacheStream->getInputStream();
-            if ( xTempInp.is() )
-                ::comphelper::OStorageHelper::CopyInputToOutput( xTempInStream, xOutStream );
-        }
-        catch( uno::Exception& aException )
-        {
-            AddLog( aException.Message );
-            AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Quiet exception" ) ) );
-
-            m_xCacheSeek->seek( nPos );
-            throw io::IOException(); //TODO:
-        }
-        
-        m_xCacheSeek->seek( nPos );
-    }
-    else if ( m_aTempURL.getLength() )
-    {
-        uno::Reference < ucb::XSimpleFileAccess > xTempAccess( 
-                        GetServiceFactory()->createInstance ( 
-                                ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ),
-                        uno::UNO_QUERY );
-
-        if ( !xTempAccess.is() )
-            throw uno::RuntimeException(); // TODO:
-
-        try
-        {
-            xTempInStream = xTempAccess->openFileRead( m_aTempURL );
-        }
-        catch( uno::Exception& aException )
-        {
-            AddLog( aException.Message );
-            AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Quiet exception" ) ) );
-        }
-
-        if ( !xTempInStream.is() )
-            throw io::IOException(); //TODO:
-
-        ::comphelper::OStorageHelper::CopyInputToOutput( xTempInStream, xOutStream );
-    }
-}
-
 // =================================================================================================
 
 //-----------------------------------------------
diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx
index b10790b..47eff23 100644
--- a/package/source/xstor/owriteablestream.hxx
+++ b/package/source/xstor/owriteablestream.hxx
@@ -161,8 +161,6 @@ private:
     ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >		GetTempFileAsStream();
     ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >	GetTempFileAsInputStream();
 
-    void CopyTempFileToOutput( ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xOutStream );
-
     ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > GetStream_Impl( sal_Int32 nStreamMode,
                                                                                         sal_Bool bHierarchyAccess );
 
diff --git a/package/source/zipapi/Inflater.cxx b/package/source/zipapi/Inflater.cxx
index dfe2c61..a8db3dd 100644
--- a/package/source/zipapi/Inflater.cxx
+++ b/package/source/zipapi/Inflater.cxx
@@ -45,12 +45,12 @@ using namespace com::sun::star::uno;
 /** Provides general purpose decompression using the ZLIB library */
 
 Inflater::Inflater(sal_Bool bNoWrap)
-: bFinish(sal_False),
-  bFinished(sal_False),
+: bFinished(sal_False),
   bSetParams(sal_False),
   bNeedDict(sal_False),
   nOffset(0),
   nLength(0),
+  nLastInflateError(0),
   pStream(NULL)
 {
     pStream = new z_stream;
@@ -120,16 +120,23 @@ void SAL_CALL Inflater::end(  )
 
 sal_Int32 Inflater::doInflateBytes (Sequence < sal_Int8 >  &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength)
 {
-    sal_Int32 nResult;
+    if ( !pStream )
+    {
+        nLastInflateError = Z_STREAM_ERROR;
+        return 0;
+    }
+
+    nLastInflateError = 0;
+
     pStream->next_in   = ( unsigned char* ) ( sInBuffer.getConstArray() + nOffset );
     pStream->avail_in  = nLength;
     pStream->next_out  = reinterpret_cast < unsigned char* > ( rBuffer.getArray() + nNewOffset );
     pStream->avail_out = nNewLength;
 
 #ifdef SYSTEM_ZLIB
-    nResult = ::inflate(pStream, bFinish ? Z_SYNC_FLUSH : Z_PARTIAL_FLUSH);
+    sal_Int32 nResult = ::inflate(pStream, Z_PARTIAL_FLUSH);
 #else
-    nResult = ::z_inflate(pStream, bFinish ? Z_SYNC_FLUSH : Z_PARTIAL_FLUSH);
+    sal_Int32 nResult = ::z_inflate(pStream, Z_PARTIAL_FLUSH);
 #endif
 
     switch (nResult)
@@ -140,15 +147,19 @@ sal_Int32 Inflater::doInflateBytes (Sequence < sal_Int8 >  &rBuffer, sal_Int32 n
             nOffset += nLength - pStream->avail_in;
             nLength = pStream->avail_in;
             return nNewLength - pStream->avail_out;
+
         case Z_NEED_DICT:
             bNeedDict = sal_True;
             nOffset += nLength - pStream->avail_in;
             nLength = pStream->avail_in;
-        case Z_BUF_ERROR:
-            return 0;
-        case Z_DATA_ERROR:
             return 0;
+
+        default:
+            // it is no error, if there is no input or no output
+            if ( nLength && nNewLength )
+                nLastInflateError = nResult;
     }
+
     return 0;
 }
 
diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx
index 0b14d6c..66976d5 100644
--- a/package/source/zipapi/XUnbufferedStream.cxx
+++ b/package/source/zipapi/XUnbufferedStream.cxx
@@ -230,20 +230,24 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
                         OUString( RTL_CONSTASCII_USTRINGPARAM( "Should not be possible to read more then requested!" ) ),
                         Reference< XInterface >() );
                     
-                if ( maInflater.finished() ) 
+                if ( maInflater.finished() || maInflater.getLastInflateError() )
                     throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "The stream seems to be broken!" ) ),
                                         Reference< XInterface >() );
 
                 if ( maInflater.needsDictionary() )
                     throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "Dictionaries are not supported!" ) ),
                                         Reference< XInterface >() );
-                
+
                 sal_Int32 nDiff = static_cast < sal_Int32 > ( mnZipEnd - mnZipCurrent );
                 if ( nDiff > 0 )
                 {
                     mxZipSeek->seek ( mnZipCurrent );
                     sal_Int32 nToRead = std::min ( nDiff, std::max ( nRequestedBytes, static_cast< sal_Int32 >( 8192 ) ) );
                     sal_Int32 nZipRead = mxZipStream->readBytes ( maCompBuffer, nToRead );
+                    if ( nZipRead < nToRead )
+                        throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "No expected data!" ) ),
+                                            Reference< XInterface >() );
+
                     mnZipCurrent += nZipRead;
                     // maCompBuffer now has the data, check if we need to decrypt
                     // before passing to the Inflater


More information about the ooo-build-commit mailing list