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 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: ieps.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -79,8 +79,6 @@ ...@@ -79,8 +79,6 @@
#include <svtools/fltcall.hxx> #include <svtools/fltcall.hxx>
#include <tools/urlobj.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, ...@@ -183,11 +181,12 @@ extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
return FALSE; return FALSE;
Graphic aGraphic; Graphic aGraphic;
BOOL bRetValue = FALSE; sal_Bool bRetValue = sal_False;
BOOL bHasPreview = FALSE; sal_Bool bHasPreview = sal_False;
UINT32 nSignature, nPSStreamPos, nPSSize, nSize, nPos; sal_Bool bGraphicLinkCreated = sal_False;
UINT32 nOrigPos = nPSStreamPos = rStream.Tell(); sal_uInt32 nSignature, nPSStreamPos, nPSSize, nSize, nPos;
USHORT nOldFormat = rStream.GetNumberFormatInt(); sal_uInt32 nOrigPos = nPSStreamPos = rStream.Tell();
sal_uInt16 nOldFormat = rStream.GetNumberFormatInt();
rStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); rStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
rStream >> nSignature; rStream >> nSignature;
if ( nSignature == 0xc6d3d0c5 ) if ( nSignature == 0xc6d3d0c5 )
...@@ -245,17 +244,19 @@ extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic, ...@@ -245,17 +244,19 @@ extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
nPSStreamPos = nOrigPos; // no preview available _>so we must get the size manually nPSStreamPos = nOrigPos; // no preview available _>so we must get the size manually
nPSSize = rStream.Seek( STREAM_SEEK_TO_END ) - nOrigPos; nPSSize = rStream.Seek( STREAM_SEEK_TO_END ) - nOrigPos;
} }
sal_uInt8* pHeader = new sal_uInt8[ 22 ];
rStream.Seek( nPSStreamPos ); rStream.Seek( nPSStreamPos );
BYTE* pBuf = new BYTE[ PS_BUF_SIZE ]; rStream.Read( pHeader, 22 ); // check PostScript header
if ( pBuf ) if ( ImplSearchEntry( pHeader, (BYTE*)"%!PS-Adobe", 10, 10 ) &&
ImplSearchEntry( &pHeader[ 15 ], (BYTE*)"EPS", 3, 3 ) )
{ {
rStream.Read( pBuf, 22 ); // check PostScript header rStream.Seek( nPSStreamPos );
if ( ImplSearchEntry( pBuf, (BYTE*)"%!PS-Adobe", 10, 10 ) && sal_uInt8* pBuf = new sal_uInt8[ nPSSize ];
ImplSearchEntry( &pBuf[15], (BYTE*)"EPS", 3, 3 ) ) if ( pBuf )
{ {
ULONG nBufStartPos = rStream.Tell(); sal_uInt32 nBufStartPos = rStream.Tell();
ULONG nBytesRead = rStream.Read( pBuf, PS_BUF_SIZE ); sal_uInt32 nBytesRead = rStream.Read( pBuf, nPSSize );
if ( nBytesRead > 64 ) // assuming a eps file is greater than 64 bytes if ( nBytesRead == nPSSize )
{ {
int nSecurityCount = 32; int nSecurityCount = 32;
if ( !bHasPreview ) // if there is no tiff/wmf preview, we will parse for an preview in the eps prolog 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, ...@@ -373,13 +374,8 @@ extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
} }
if ( nSecurityCount) if ( nSecurityCount)
{ {
BYTE* pLinkBuf = new BYTE[ nPSSize ]; bGraphicLinkCreated = sal_True;
if ( pLinkBuf ) GfxLink aGfxLink( pBuf, nPSSize, GFX_LINK_TYPE_EPS_BUFFER, TRUE ) ;
{
rStream.Seek( nPSStreamPos );
if ( rStream.Read( pLinkBuf, nPSSize ) == nPSSize )
{
GfxLink aGfxLink( pLinkBuf, nPSSize, GFX_LINK_TYPE_EPS_BUFFER, TRUE ) ;
GDIMetaFile aMtf; GDIMetaFile aMtf;
long nWidth = nNumb[2] - nNumb[0] + 1; long nWidth = nNumb[2] - nNumb[0] + 1;
...@@ -476,17 +472,15 @@ extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic, ...@@ -476,17 +472,15 @@ extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
aMtf.SetPrefMapMode( MAP_POINT ); aMtf.SetPrefMapMode( MAP_POINT );
aMtf.SetPrefSize( Size( nWidth, nHeight ) ); aMtf.SetPrefSize( Size( nWidth, nHeight ) );
rGraphic = aMtf; rGraphic = aMtf;
bRetValue = TRUE; bRetValue = sal_True;
}
else
delete[] pLinkBuf;
}
} }
} }
} }
} }
if ( !bGraphicLinkCreated )
delete[] pBuf; delete[] pBuf;
} }
delete[] pHeader;
rStream.SetNumberFormatInt(nOldFormat); rStream.SetNumberFormatInt(nOldFormat);
rStream.Seek( nOrigPos ); rStream.Seek( nOrigPos );
return ( bRetValue ); 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