1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ieps.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_goodies.hxx"
38 #include <vcl/svapp.hxx>
39 #include <vcl/bitmap.hxx>
40 #include <vcl/bitmapex.hxx>
41 #include <vcl/animate.hxx>
42 #include <vcl/gdimtf.hxx>
43 #include <vcl/graph.h>
44 #include <vcl/window.hxx>
45 #include <vcl/graph.hxx>
46 #include <vcl/metaact.hxx>
47 #include <vcl/gdimtf.hxx>
48 #include <vcl/virdev.hxx>
49 #include <vcl/cvtgrf.hxx>
50 #include <vcl/bmpacc.hxx>
51 #include <svtools/fltcall.hxx>
52 #include <tools/urlobj.hxx>
53 #include <tools/tempfile.hxx>
54 #include <osl/process.h>
55 #include <osl/file.hxx>
57 /*************************************************************************
61 |* Beschreibung Prueft ob im Speicherbereich pSource der nComp Bytes
62 |* gross ist eine Zeichenkette(pDest) mit der l�nge nSize
63 |* liegt. Geprueft wird NON-CASE-SENSITIVE und der Rueck-
64 |* gabewert ist die Adresse an der die Zeichekette gefunden
67 |* Ersterstellung SJ 04.03.98 ( und das an meinem Geburtstag )
68 |* Letzte Aenderung SJ 04.03.98
70 *************************************************************************/
72 static BYTE
* ImplSearchEntry( BYTE
* pSource
, BYTE
* pDest
, ULONG nComp
, ULONG nSize
)
74 while ( nComp
-- >= nSize
)
77 for ( i
= 0; i
< nSize
; i
++ )
79 if ( ( pSource
[i
]&~0x20 ) != ( pDest
[i
]&~0x20 ) )
89 //--------------------------------------------------------------------------
90 // SecurityCount is the buffersize of the buffer in which we will parse for a number
91 static long ImplGetNumber( BYTE
**pBuf
, int& nSecurityCount
)
94 BOOL bNegative
= FALSE
;
96 while ( ( --nSecurityCount
) && ( ( **pBuf
== ' ' ) || ( **pBuf
== 0x9 ) ) )
99 while ( nSecurityCount
&& ( nByte
!= ' ' ) && ( nByte
!= 0x9 ) && ( nByte
!= 0xd ) && ( nByte
!= 0xa ) )
104 // we'll only use the integer format
111 if ( ( nByte
< '0' ) || ( nByte
> '9' ) )
112 nSecurityCount
= 1; // error parsing the bounding box values
116 nRetValue
+= nByte
- '0';
121 nByte
= *(++(*pBuf
));
124 nRetValue
= -nRetValue
;
128 //--------------------------------------------------------------------------
130 static int ImplGetLen( BYTE
* pBuf
, int nMax
)
133 while( nLen
!= nMax
)
136 if ( nDat
== 0x0a || nDat
== 0x25 )
143 static void MakeAsMeta(Graphic
&rGraphic
)
147 Bitmap
aBmp( rGraphic
.GetBitmap() );
148 Size aSize
= aBmp
.GetPrefSize();
150 if( !aSize
.Width() || !aSize
.Height() )
151 aSize
= Application::GetDefaultDevice()->PixelToLogic(
152 aBmp
.GetSizePixel(), MAP_100TH_MM
);
154 aSize
= Application::GetDefaultDevice()->LogicToLogic( aSize
,
155 aBmp
.GetPrefMapMode(), MAP_100TH_MM
);
157 aVDev
.EnableOutput( FALSE
);
158 aMtf
.Record( &aVDev
);
159 aVDev
.DrawBitmap( Point(), aSize
, rGraphic
.GetBitmap() );
162 aMtf
.SetPrefMapMode( MAP_100TH_MM
);
163 aMtf
.SetPrefSize( aSize
);
167 static bool RenderAsEMF(const sal_uInt8
* pBuf
, sal_uInt32 nBytesRead
, Graphic
&rGraphic
)
170 aTemp
.EnableKillingFile();
171 rtl::OUString fileName
=
172 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pstoedit"));
174 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-f"));
176 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("emf:-OO"));
178 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
179 rtl::OUString output
;
180 osl::FileBase::getSystemPathFromFileURL(aTemp
.GetName(), output
);
181 rtl_uString
*args
[] =
183 arg1
.pData
, arg2
.pData
, arg3
.pData
, output
.pData
186 oslFileHandle pIn
= NULL
;
187 oslFileHandle pOut
= NULL
;
188 oslFileHandle pErr
= NULL
;
189 oslProcessError eErr
= osl_executeProcess_WithRedirectedIO(fileName
.pData
,
190 args
, sizeof(args
)/sizeof(rtl_uString
*),
191 osl_Process_SEARCHPATH
| osl_Process_HIDDEN
,
192 osl_getCurrentSecurity(), 0, 0, 0, &aProcess
, &pIn
, &pOut
, &pErr
);
193 if (eErr
!=osl_Process_E_None
)
198 osl_writeFile(pIn
, pBuf
, nBytesRead
, &nCount
);
199 if (pIn
) osl_closeFile(pIn
);
200 bool bEMFSupported
=true;
203 rtl::ByteSequence seq
;
204 if (osl_File_E_None
== osl_readLine(pOut
, (sal_Sequence
**)&seq
))
206 rtl::OString
line( (const sal_Char
*) seq
.getConstArray(), seq
.getLength() );
207 if (line
.indexOf(rtl::OString("Unsupported output format")) == 0)
212 if (pErr
) osl_closeFile(pErr
);
213 if (nCount
== nBytesRead
&& bEMFSupported
)
215 SvFileStream
aFile(output
, STREAM_READ
);
216 if (GraphicConverter::Import(aFile
, rGraphic
, CVT_EMF
) == ERRCODE_NONE
)
219 osl_joinProcess(aProcess
);
220 osl_freeProcessHandle(aProcess
);
224 static bool RenderAsPNGThroughHelper(const sal_uInt8
* pBuf
, sal_uInt32 nBytesRead
,
225 Graphic
&rGraphic
, rtl::OUString
&rProgName
, rtl_uString
**pArgs
, size_t nArgs
)
228 oslFileHandle pIn
= NULL
;
229 oslFileHandle pOut
= NULL
;
230 oslFileHandle pErr
= NULL
;
231 oslProcessError eErr
= osl_executeProcess_WithRedirectedIO(rProgName
.pData
,
232 pArgs
, nArgs
, osl_Process_SEARCHPATH
| osl_Process_HIDDEN
,
233 osl_getCurrentSecurity(), 0, 0, 0, &aProcess
, &pIn
, &pOut
, &pErr
);
234 if (eErr
!=osl_Process_E_None
)
239 osl_writeFile(pIn
, pBuf
, nBytesRead
, &nCount
);
240 if (pIn
) osl_closeFile(pIn
);
241 if (nCount
== nBytesRead
)
243 SvMemoryStream aMemStm
;
244 sal_uInt8 aBuf
[32000];
245 oslFileError eFileErr
= osl_readFile(pOut
, aBuf
, 32000, &nCount
);
246 while (eFileErr
== osl_File_E_None
&& nCount
)
248 aMemStm
.Write(aBuf
, sal::static_int_cast
< sal_Size
>(nCount
));
249 eFileErr
= osl_readFile(pOut
, aBuf
, 32000, &nCount
);
254 eFileErr
== osl_File_E_None
&&
255 GraphicConverter::Import(aMemStm
, rGraphic
, CVT_PNG
) == ERRCODE_NONE
258 MakeAsMeta(rGraphic
);
262 if (pOut
) osl_closeFile(pOut
);
263 if (pErr
) osl_closeFile(pErr
);
264 osl_joinProcess(aProcess
);
265 osl_freeProcessHandle(aProcess
);
269 static bool RenderAsPNGThroughConvert(const sal_uInt8
* pBuf
, sal_uInt32 nBytesRead
,
272 rtl::OUString fileName
=
273 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("convert"));
274 // density in pixel/inch
275 rtl::OUString arg1
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-density"));
276 // since the preview is also used for PDF-Export & printing on non-PS-printers,
277 // use some better quality - 300x300 should allow some resizing as well
278 rtl::OUString arg2
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("300x300"));
279 // read eps from STDIN
280 rtl::OUString arg3
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("eps:-"));
281 // write png to STDOUT
282 rtl::OUString arg4
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("png:-"));
283 rtl_uString
*args
[] =
285 arg1
.pData
, arg2
.pData
, arg3
.pData
, arg4
.pData
287 return RenderAsPNGThroughHelper(pBuf
, nBytesRead
, rGraphic
, fileName
, args
,
288 sizeof(args
)/sizeof(rtl_uString
*));
291 static bool RenderAsPNGThroughGS(const sal_uInt8
* pBuf
, sal_uInt32 nBytesRead
,
295 rtl::OUString fileName
=
296 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gswin32c"));
298 rtl::OUString fileName
=
299 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gs"));
302 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-q"));
304 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-dBATCH"));
306 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-dNOPAUSE"));
308 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-dPARANOIDSAFER"));
310 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-dEPSCrop"));
312 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-dTextAlphaBits=4"));
314 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-dGraphicsAlphaBits=4"));
316 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-r300x300"));
318 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-sDEVICE=png256"));
319 rtl::OUString arg10
=
320 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-sOutputFile=-"));
321 rtl::OUString arg11
=
322 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
323 rtl_uString
*args
[] =
325 arg1
.pData
, arg2
.pData
, arg3
.pData
, arg4
.pData
, arg5
.pData
,
326 arg6
.pData
, arg7
.pData
, arg8
.pData
, arg9
.pData
, arg10
.pData
,
329 return RenderAsPNGThroughHelper(pBuf
, nBytesRead
, rGraphic
, fileName
, args
,
330 sizeof(args
)/sizeof(rtl_uString
*));
333 static bool RenderAsPNG(const sal_uInt8
* pBuf
, sal_uInt32 nBytesRead
, Graphic
&rGraphic
)
335 if (RenderAsPNGThroughConvert(pBuf
, nBytesRead
, rGraphic
))
338 return RenderAsPNGThroughGS(pBuf
, nBytesRead
, rGraphic
);
341 // this method adds a replacement action containing the original wmf or tiff replacement,
342 // so the original eps can be written when storing to ODF.
343 void CreateMtfReplacementAction( GDIMetaFile
& rMtf
, SvStream
& rStrm
, sal_uInt32 nOrigPos
, sal_uInt32 nPSSize
,
344 sal_uInt32 nPosWMF
, sal_uInt32 nSizeWMF
, sal_uInt32 nPosTIFF
, sal_uInt32 nSizeTIFF
)
346 ByteString
aComment( (const sal_Char
*)"EPSReplacementGraphic" );
347 if ( nSizeWMF
|| nSizeTIFF
)
349 SvMemoryStream
aReplacement( nSizeWMF
+ nSizeTIFF
+ 28 );
350 sal_uInt32 nMagic
= 0xc6d3d0c5;
351 sal_uInt32 nPPos
= 28 + nSizeWMF
+ nSizeTIFF
;
352 sal_uInt32 nWPos
= nSizeWMF
? 28 : 0;
353 sal_uInt32 nTPos
= nSizeTIFF
? 28 + nSizeWMF
: 0;
355 aReplacement
<< nMagic
<< nPPos
<< nPSSize
357 << nTPos
<< nSizeTIFF
;
360 sal_uInt8
* pBuf
= new sal_uInt8
[ nSizeWMF
];
361 rStrm
.Seek( nOrigPos
+ nPosWMF
);
362 rStrm
.Read( pBuf
, nSizeWMF
);
363 aReplacement
.Write( pBuf
, nSizeWMF
);
368 sal_uInt8
* pBuf
= new sal_uInt8
[ nSizeTIFF
];
369 rStrm
.Seek( nOrigPos
+ nPosTIFF
);
370 rStrm
.Read( pBuf
, nSizeTIFF
);
371 aReplacement
.Write( pBuf
, nSizeTIFF
);
374 rMtf
.AddAction( (MetaAction
*)( new MetaCommentAction( aComment
, 0, (const BYTE
*)aReplacement
.GetData(), aReplacement
.Tell() ) ) );
377 rMtf
.AddAction( (MetaAction
*)( new MetaCommentAction( aComment
, 0, NULL
, 0 ) ) );
380 //there is no preview -> make a red box
381 void MakePreview(sal_uInt8
* pBuf
, sal_uInt32 nBytesRead
,
382 long nWidth
, long nHeight
, Graphic
&rGraphic
)
388 aVDev
.EnableOutput( FALSE
);
389 aMtf
.Record( &aVDev
);
390 aVDev
.SetLineColor( Color( COL_RED
) );
391 aVDev
.SetFillColor();
393 aFont
.SetColor( COL_LIGHTRED
);
394 // aFont.SetSize( Size( 0, 32 ) );
396 aVDev
.Push( PUSH_FONT
);
397 aVDev
.SetFont( aFont
);
399 Rectangle
aRect( Point( 1, 1 ), Size( nWidth
- 2, nHeight
- 2 ) );
400 aVDev
.DrawRect( aRect
);
404 BYTE
* pDest
= ImplSearchEntry( pBuf
, (BYTE
*)"%%Title:", nBytesRead
- 32, 8 );
410 nLen
= ImplGetLen( pDest
, 32 );
411 BYTE
aOldValue(pDest
[ nLen
]); pDest
[ nLen
] = 0;
412 if ( strcmp( (const char*)pDest
, "none" ) != 0 )
414 aString
.AppendAscii( " Title:" );
415 aString
.AppendAscii( (char*)pDest
);
416 aString
.AppendAscii( "\n" );
418 pDest
[ nLen
] = aOldValue
;
420 pDest
= ImplSearchEntry( pBuf
, (BYTE
*)"%%Creator:", nBytesRead
- 32, 10 );
426 nLen
= ImplGetLen( pDest
, 32 );
427 BYTE
aOldValue(pDest
[ nLen
]); pDest
[ nLen
] = 0;
428 aString
.AppendAscii( " Creator:" );
429 aString
.AppendAscii( (char*)pDest
);
430 aString
.AppendAscii( "\n" );
431 pDest
[ nLen
] = aOldValue
;
433 pDest
= ImplSearchEntry( pBuf
, (BYTE
*)"%%CreationDate:", nBytesRead
- 32, 15 );
439 nLen
= ImplGetLen( pDest
, 32 );
440 BYTE
aOldValue(pDest
[ nLen
]); pDest
[ nLen
] = 0;
441 if ( strcmp( (const char*)pDest
, "none" ) != 0 )
443 aString
.AppendAscii( " CreationDate:" );
444 aString
.AppendAscii( (char*)pDest
);
445 aString
.AppendAscii( "\n" );
447 pDest
[ nLen
] = aOldValue
;
449 pDest
= ImplSearchEntry( pBuf
, (BYTE
*)"%%LanguageLevel:", nBytesRead
- 4, 16 );
454 long nNumber
= ImplGetNumber( &pDest
, nCount
);
455 if ( nCount
&& ( (UINT32
)nNumber
< 10 ) )
457 aString
.AppendAscii( " LanguageLevel:" );
458 aString
.Append( UniString::CreateFromInt32( nNumber
) );
461 aVDev
.DrawText( aRect
, aString
, TEXT_DRAW_CLIP
| TEXT_DRAW_MULTILINE
);
465 aMtf
.SetPrefMapMode( MAP_POINT
);
466 aMtf
.SetPrefSize( Size( nWidth
, nHeight
) );
471 //================== GraphicImport - die exportierte Funktion ================
474 extern "C" BOOL _cdecl
GraphicImport(SvStream
& rStream
, Graphic
& rGraphic
, FilterConfigItem
*, BOOL
)
476 extern "C" BOOL
GraphicImport(SvStream
& rStream
, Graphic
& rGraphic
, FilterConfigItem
*, BOOL
)
479 if ( rStream
.GetError() )
483 sal_Bool bRetValue
= sal_False
;
484 sal_Bool bHasPreview
= sal_False
;
485 sal_Bool bGraphicLinkCreated
= sal_False
;
486 sal_uInt32 nSignature
, nPSStreamPos
, nPSSize
;
487 sal_uInt32 nSizeWMF
= 0;
488 sal_uInt32 nPosWMF
= 0;
489 sal_uInt32 nSizeTIFF
= 0;
490 sal_uInt32 nPosTIFF
= 0;
491 sal_uInt32 nOrigPos
= nPSStreamPos
= rStream
.Tell();
492 sal_uInt16 nOldFormat
= rStream
.GetNumberFormatInt();
493 rStream
.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN
);
494 rStream
>> nSignature
;
495 if ( nSignature
== 0xc6d3d0c5 )
497 rStream
>> nPSStreamPos
>> nPSSize
>> nPosWMF
>> nSizeWMF
;
499 // first we try to get the metafile grafix
505 rStream
.Seek( nOrigPos
+ nPosWMF
);
506 if ( GraphicConverter::Import( rStream
, aGraphic
, CVT_WMF
) == ERRCODE_NONE
)
507 bHasPreview
= bRetValue
= TRUE
;
512 rStream
>> nPosTIFF
>> nSizeTIFF
;
514 // else we have to get the tiff grafix
516 if ( nPosTIFF
&& nSizeTIFF
)
518 rStream
.Seek( nOrigPos
+ nPosTIFF
);
519 if ( GraphicConverter::Import( rStream
, aGraphic
, CVT_TIF
) == ERRCODE_NONE
)
521 MakeAsMeta(aGraphic
);
522 rStream
.Seek( nOrigPos
+ nPosTIFF
);
523 bHasPreview
= bRetValue
= TRUE
;
530 nPSStreamPos
= nOrigPos
; // no preview available _>so we must get the size manually
531 nPSSize
= rStream
.Seek( STREAM_SEEK_TO_END
) - nOrigPos
;
533 sal_uInt8
* pHeader
= new sal_uInt8
[ 22 ];
534 rStream
.Seek( nPSStreamPos
);
535 rStream
.Read( pHeader
, 22 ); // check PostScript header
536 if ( ImplSearchEntry( pHeader
, (BYTE
*)"%!PS-Adobe", 10, 10 ) &&
537 ImplSearchEntry( &pHeader
[ 15 ], (BYTE
*)"EPS", 3, 3 ) )
539 rStream
.Seek( nPSStreamPos
);
540 sal_uInt8
* pBuf
= new sal_uInt8
[ nPSSize
];
543 sal_uInt32 nBufStartPos
= rStream
.Tell();
544 sal_uInt32 nBytesRead
= rStream
.Read( pBuf
, nPSSize
);
545 if ( nBytesRead
== nPSSize
)
547 int nSecurityCount
= 32;
548 if ( !bHasPreview
) // if there is no tiff/wmf preview, we will parse for an preview in the eps prolog
550 BYTE
* pDest
= ImplSearchEntry( pBuf
, (BYTE
*)"%%BeginPreview:", nBytesRead
- 32, 15 );
554 long nWidth
= ImplGetNumber( &pDest
, nSecurityCount
);
555 long nHeight
= ImplGetNumber( &pDest
, nSecurityCount
);
556 long nBitDepth
= ImplGetNumber( &pDest
, nSecurityCount
);
557 long nScanLines
= ImplGetNumber( &pDest
, nSecurityCount
);
558 pDest
= ImplSearchEntry( pDest
, (BYTE
*)"%", 16, 1 ); // go to the first Scanline
559 if ( nSecurityCount
&& pDest
&& nWidth
&& nHeight
&& ( ( nBitDepth
== 1 ) || ( nBitDepth
== 8 ) ) && nScanLines
)
561 rStream
.Seek( nBufStartPos
+ ( pDest
- pBuf
) );
563 Bitmap
aBitmap( Size( nWidth
, nHeight
), 1 );
564 BitmapWriteAccess
* pAcc
= aBitmap
.AcquireWriteAccess();
568 BOOL bIsValid
= TRUE
;
571 for ( long y
= 0; bIsValid
&& ( y
< nHeight
); y
++ )
574 for ( long x
= 0; x
< nWidth
; x
++ )
576 if ( --nBitsLeft
< 0 )
578 while ( bIsValid
&& ( nBitsLeft
!= 7 ) )
584 if ( --nScanLines
< 0 )
597 nByte
&=~0x20; // case none sensitive for hexadezimal values
598 nByte
-= ( 'A' - 10 );
606 nDat
|= ( nByte
^ 0xf ); // in epsi a zero bit represents white color
615 if ( nBitDepth
== 1 )
616 pAcc
->SetPixel( y
, x
, sal::static_int_cast
< BYTE
>(( nDat
>> nBitsLeft
) & 1) );
619 pAcc
->SetPixel( y
, x
, ( nDat
) ? 1 : 0 ); // nBitDepth == 8
629 aVDev
.EnableOutput( FALSE
);
630 aMtf
.Record( &aVDev
);
631 aSize
= aBitmap
.GetPrefSize();
632 if( !aSize
.Width() || !aSize
.Height() )
633 aSize
= Application::GetDefaultDevice()->PixelToLogic( aBitmap
.GetSizePixel(), MAP_100TH_MM
);
635 aSize
= Application::GetDefaultDevice()->LogicToLogic( aSize
, aBitmap
.GetPrefMapMode(), MAP_100TH_MM
);
636 aVDev
.DrawBitmap( Point(), aSize
, aBitmap
);
639 aMtf
.SetPrefMapMode( MAP_100TH_MM
);
640 aMtf
.SetPrefSize( aSize
);
642 bHasPreview
= bRetValue
= TRUE
;
644 aBitmap
.ReleaseAccess( pAcc
);
650 BYTE
* pDest
= ImplSearchEntry( pBuf
, (BYTE
*)"%%BoundingBox:", nBytesRead
, 14 );
653 nSecurityCount
= 100;
655 nNumb
[0] = nNumb
[1] = nNumb
[2] = nNumb
[3] = 0;
657 for ( int i
= 0; ( i
< 4 ) && nSecurityCount
; i
++ )
659 nNumb
[ i
] = ImplGetNumber( &pDest
, nSecurityCount
);
663 bGraphicLinkCreated
= sal_True
;
664 GfxLink
aGfxLink( pBuf
, nPSSize
, GFX_LINK_TYPE_EPS_BUFFER
, TRUE
) ;
667 long nWidth
= nNumb
[2] - nNumb
[0] + 1;
668 long nHeight
= nNumb
[3] - nNumb
[1] + 1;
670 // if there is no preview -> try with gs to make one
673 bHasPreview
= RenderAsEMF(pBuf
, nBytesRead
, aGraphic
);
675 bHasPreview
= RenderAsPNG(pBuf
, nBytesRead
, aGraphic
);
678 // if there is no preview -> make a red box
681 MakePreview(pBuf
, nBytesRead
, nWidth
, nHeight
,
685 aMtf
.AddAction( (MetaAction
*)( new MetaEPSAction( Point(), Size( nWidth
, nHeight
),
686 aGfxLink
, aGraphic
.GetGDIMetaFile() ) ) );
687 CreateMtfReplacementAction( aMtf
, rStream
, nOrigPos
, nPSSize
, nPosWMF
, nSizeWMF
, nPosTIFF
, nSizeTIFF
);
689 aMtf
.SetPrefMapMode( MAP_POINT
);
690 aMtf
.SetPrefSize( Size( nWidth
, nHeight
) );
692 bRetValue
= sal_True
;
697 if ( !bGraphicLinkCreated
)
701 rStream
.SetNumberFormatInt(nOldFormat
);
702 rStream
.Seek( nOrigPos
);
703 return ( bRetValue
);
706 //================== ein bischen Muell fuer Windows ==========================
712 static HINSTANCE hDLLInst
= 0; // HANDLE der DLL
714 extern "C" int CALLBACK
LibMain( HINSTANCE hDLL
, WORD
, WORD nHeap
, LPSTR
)
726 extern "C" int CALLBACK
WEP( int )