Kaydet (Commit) d9163095 authored tarafından Rüdiger Timm's avatar Rüdiger Timm

INTEGRATION: CWS draw9 (1.5.48); FILE MERGED

2003/03/24 10:47:17 sj 1.5.48.1: #i9375# allowing eps file to have their bounding box description everywhere
üst 881dd34e
......@@ -2,9 +2,9 @@
*
* $RCSfile: ieps.cxx,v $
*
* $Revision: 1.5 $
* $Revision: 1.6 $
*
* last change: $Author: ka $ $Date: 2002-05-29 13:11:36 $
* last change: $Author: rt $ $Date: 2003-04-24 14:59:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -79,8 +79,6 @@
#include <svtools/fltcall.hxx>
#include <tools/urlobj.hxx>
// we will parse only 4kb for graphic information
#define PS_BUF_SIZE 0x1000
/*************************************************************************
|*
......@@ -183,11 +181,12 @@ extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
return FALSE;
Graphic aGraphic;
BOOL bRetValue = FALSE;
BOOL bHasPreview = FALSE;
UINT32 nSignature, nPSStreamPos, nPSSize, nSize, nPos;
UINT32 nOrigPos = nPSStreamPos = rStream.Tell();
USHORT nOldFormat = rStream.GetNumberFormatInt();
sal_Bool bRetValue = sal_False;
sal_Bool bHasPreview = sal_False;
sal_Bool bGraphicLinkCreated = sal_False;
sal_uInt32 nSignature, nPSStreamPos, nPSSize, nSize, nPos;
sal_uInt32 nOrigPos = nPSStreamPos = rStream.Tell();
sal_uInt16 nOldFormat = rStream.GetNumberFormatInt();
rStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
rStream >> nSignature;
if ( nSignature == 0xc6d3d0c5 )
......@@ -245,17 +244,19 @@ extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
nPSStreamPos = nOrigPos; // no preview available _>so we must get the size manually
nPSSize = rStream.Seek( STREAM_SEEK_TO_END ) - nOrigPos;
}
sal_uInt8* pHeader = new sal_uInt8[ 22 ];
rStream.Seek( nPSStreamPos );
BYTE* pBuf = new BYTE[ PS_BUF_SIZE ];
if ( pBuf )
rStream.Read( pHeader, 22 ); // check PostScript header
if ( ImplSearchEntry( pHeader, (BYTE*)"%!PS-Adobe", 10, 10 ) &&
ImplSearchEntry( &pHeader[ 15 ], (BYTE*)"EPS", 3, 3 ) )
{
rStream.Read( pBuf, 22 ); // check PostScript header
if ( ImplSearchEntry( pBuf, (BYTE*)"%!PS-Adobe", 10, 10 ) &&
ImplSearchEntry( &pBuf[15], (BYTE*)"EPS", 3, 3 ) )
rStream.Seek( nPSStreamPos );
sal_uInt8* pBuf = new sal_uInt8[ nPSSize ];
if ( pBuf )
{
ULONG nBufStartPos = rStream.Tell();
ULONG nBytesRead = rStream.Read( pBuf, PS_BUF_SIZE );
if ( nBytesRead > 64 ) // assuming a eps file is greater than 64 bytes
sal_uInt32 nBufStartPos = rStream.Tell();
sal_uInt32 nBytesRead = rStream.Read( pBuf, nPSSize );
if ( nBytesRead == nPSSize )
{
int nSecurityCount = 32;
if ( !bHasPreview ) // if there is no tiff/wmf preview, we will parse for an preview in the eps prolog
......@@ -373,13 +374,8 @@ extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
}
if ( nSecurityCount)
{
BYTE* pLinkBuf = new BYTE[ nPSSize ];
if ( pLinkBuf )
{
rStream.Seek( nPSStreamPos );
if ( rStream.Read( pLinkBuf, nPSSize ) == nPSSize )
{
GfxLink aGfxLink( pLinkBuf, nPSSize, GFX_LINK_TYPE_EPS_BUFFER, TRUE ) ;
bGraphicLinkCreated = sal_True;
GfxLink aGfxLink( pBuf, nPSSize, GFX_LINK_TYPE_EPS_BUFFER, TRUE ) ;
GDIMetaFile aMtf;
long nWidth = nNumb[2] - nNumb[0] + 1;
......@@ -476,17 +472,15 @@ extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
aMtf.SetPrefMapMode( MAP_POINT );
aMtf.SetPrefSize( Size( nWidth, nHeight ) );
rGraphic = aMtf;
bRetValue = TRUE;
}
else
delete[] pLinkBuf;
}
bRetValue = sal_True;
}
}
}
}
if ( !bGraphicLinkCreated )
delete[] pBuf;
}
delete[] pHeader;
rStream.SetNumberFormatInt(nOldFormat);
rStream.Seek( nOrigPos );
return ( bRetValue );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment