openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o..@apache.org
Subject svn commit: r1583336 - /openoffice/trunk/main/vcl/source/gdi/dibtools.cxx
Date Mon, 31 Mar 2014 14:37:21 GMT
Author: orw
Date: Mon Mar 31 14:37:21 2014
New Revision: 1583336

URL: http://svn.apache.org/r1583336
Log:
124555: restore stream position after Seek to end of stream


Modified:
    openoffice/trunk/main/vcl/source/gdi/dibtools.cxx

Modified: openoffice/trunk/main/vcl/source/gdi/dibtools.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/vcl/source/gdi/dibtools.cxx?rev=1583336&r1=1583335&r2=1583336&view=diff
==============================================================================
--- openoffice/trunk/main/vcl/source/gdi/dibtools.cxx (original)
+++ openoffice/trunk/main/vcl/source/gdi/dibtools.cxx Mon Mar 31 14:37:21 2014
@@ -775,46 +775,47 @@ bool ImplReadDIBBody( SvStream& rIStm, B
 
 bool ImplReadDIBFileHeader( SvStream& rIStm, sal_uLong& rOffset )
 {
-	sal_uInt32	nTmp32;
-	sal_uInt16	nTmp16 = 0;
-	bool	bRet = false;
+    bool bRet = false;
 
-    const sal_Int64 nStreamLength (rIStm.Seek(STREAM_SEEK_TO_END));
-    rIStm.Seek(STREAM_SEEK_TO_BEGIN);
+    const sal_Int64 nSavedStreamPos( rIStm.Tell() );
+    const sal_Int64 nStreamLength( rIStm.Seek( STREAM_SEEK_TO_END ) );
+    rIStm.Seek( nSavedStreamPos );
 
-	rIStm >> nTmp16;
+    sal_uInt16 nTmp16 = 0;
+    rIStm >> nTmp16;
 
-	if ( ( 0x4D42 == nTmp16 ) || ( 0x4142 == nTmp16 ) )
-	{
-		if ( 0x4142 == nTmp16 )
-		{
-			rIStm.SeekRel( 12L );
-			rIStm >> nTmp16;
-			rIStm.SeekRel( 8L );
-			rIStm >> nTmp32;
-			rOffset = nTmp32 - 28UL;
-			bRet = ( 0x4D42 == nTmp16 );
-		}
-		else // 0x4D42 == nTmp16, 'MB' from BITMAPFILEHEADER
-		{
-			rIStm.SeekRel( 8L );        // we are on bfSize member of BITMAPFILEHEADER, forward to
bfOffBits
-			rIStm >> nTmp32;            // read bfOffBits
-			rOffset = nTmp32 - 14UL;    // adapt offset by sizeof(BITMAPFILEHEADER)
-			bRet = ( rIStm.GetError() == 0UL );
-		}
+    if ( ( 0x4D42 == nTmp16 ) || ( 0x4142 == nTmp16 ) )
+    {
+        sal_uInt32 nTmp32;
+        if ( 0x4142 == nTmp16 )
+        {
+            rIStm.SeekRel( 12L );
+            rIStm >> nTmp16;
+            rIStm.SeekRel( 8L );
+            rIStm >> nTmp32;
+            rOffset = nTmp32 - 28UL;
+            bRet = ( 0x4D42 == nTmp16 );
+        }
+        else // 0x4D42 == nTmp16, 'MB' from BITMAPFILEHEADER
+        {
+            rIStm.SeekRel( 8L );        // we are on bfSize member of BITMAPFILEHEADER, forward
to bfOffBits
+            rIStm >> nTmp32;            // read bfOffBits
+            rOffset = nTmp32 - 14UL;    // adapt offset by sizeof(BITMAPFILEHEADER)
+            bRet = ( rIStm.GetError() == 0UL );
+        }
 
-        if (rOffset >= nStreamLength)
+        if ( rOffset >= nStreamLength )
         {
             // Offset claims that image starts past the end of the
             // stream.  Unlikely.
             rIStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
             bRet = false;
         }
-	}
-	else
-		rIStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
+    }
+    else
+        rIStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
 
-	return bRet;
+    return bRet;
 }
 
 bool ImplWriteDIBPalette( SvStream& rOStm, BitmapReadAccess& rAcc )



Mime
View raw message