You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2014/03/31 16:59:30 UTC

svn commit: r1583342 - in /openoffice/branches/AOO410: ./ main/ main/vcl/source/gdi/dibtools.cxx

Author: orw
Date: Mon Mar 31 14:59:30 2014
New Revision: 1583342

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

	cherry-picked from trunk


Modified:
    openoffice/branches/AOO410/   (props changed)
    openoffice/branches/AOO410/main/   (props changed)
    openoffice/branches/AOO410/main/vcl/source/gdi/dibtools.cxx

Propchange: openoffice/branches/AOO410/
------------------------------------------------------------------------------
  Merged /openoffice/trunk:r1583336

Propchange: openoffice/branches/AOO410/main/
------------------------------------------------------------------------------
  Merged /openoffice/trunk/main:r1583336

Modified: openoffice/branches/AOO410/main/vcl/source/gdi/dibtools.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/vcl/source/gdi/dibtools.cxx?rev=1583342&r1=1583341&r2=1583342&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/vcl/source/gdi/dibtools.cxx (original)
+++ openoffice/branches/AOO410/main/vcl/source/gdi/dibtools.cxx Mon Mar 31 14:59:30 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 )