rpms/openoffice.org/devel openoffice.org-1.9.108.ooo9290.goodies.epstoepdf.patch, NONE, 1.1 openoffice.org.spec, 1.230, 1.231
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Tue Jun 14 10:47:45 UTC 2005
- Previous message (by thread): rpms/xerces-j2/devel .cvsignore, 1.7, 1.8 sources, 1.5, 1.6 xerces-j2-build.patch, 1.5, 1.6 xerces-j2.spec, 1.28, 1.29
- Next message (by thread): rpms/openoffice.org/devel openoffice.org.spec,1.231,1.232
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: caolanm
Update of /cvs/dist/rpms/openoffice.org/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv26779
Modified Files:
openoffice.org.spec
Added Files:
openoffice.org-1.9.108.ooo9290.goodies.epstoepdf.patch
Log Message:
rh#142535# use pstoedit/ImageMagick or gs to make an eps preview where one is missing
openoffice.org-1.9.108.ooo9290.goodies.epstoepdf.patch:
goodies/source/filter.vcl/ieps/ieps.cxx | 391 +++++++++++++++++++++++---------
source/filter.vcl/ieps/ieps.cxx | 0
2 files changed, 288 insertions(+), 103 deletions(-)
--- NEW FILE openoffice.org-1.9.108.ooo9290.goodies.epstoepdf.patch ---
Index: source/filter.vcl/ieps/ieps.cxx
===================================================================
RCS file: /cvs/graphics/goodies/source/filter.vcl/ieps/ieps.cxx,v
retrieving revision 1.8
diff -u -p -r1.8 ieps.cxx
--- openoffice.org.orig/goodies/source/filter.vcl/ieps/ieps.cxx 8 Sep 2004 15:28:30 -0000 1.8
+++ openoffice.org/goodies/source/filter.vcl/ieps/ieps.cxx 14 Jun 2005 10:48:59 -0000
@@ -78,7 +78,9 @@
#include <vcl/bmpacc.hxx>
#include <svtools/fltcall.hxx>
#include <tools/urlobj.hxx>
-
+#include <tools/tempfile.hxx>
+#include <osl/process.h>
+#include <osl/file.hxx>
/*************************************************************************
|*
@@ -165,6 +167,275 @@ static int ImplGetLen( BYTE* pBuf, int n
return nLen;
}
+static void MakeAsMeta(Graphic &rGraphic)
+{
+ VirtualDevice aVDev;
+ GDIMetaFile aMtf;
+ Bitmap aBmp( rGraphic.GetBitmap() );
+ Size aSize = aBmp.GetPrefSize();
+
+ if( !aSize.Width() || !aSize.Height() )
+ aSize = Application::GetDefaultDevice()->PixelToLogic(
+ aBmp.GetSizePixel(), MAP_100TH_MM );
+ else
+ aSize = Application::GetDefaultDevice()->LogicToLogic( aSize,
+ aBmp.GetPrefMapMode(), MAP_100TH_MM );
+
+ aVDev.EnableOutput( FALSE );
+ aMtf.Record( &aVDev );
+ aVDev.DrawBitmap( Point(), aSize, rGraphic.GetBitmap() );
+ aMtf.Stop();
+ aMtf.WindStart();
+ aMtf.SetPrefMapMode( MAP_100TH_MM );
+ aMtf.SetPrefSize( aSize );
+ rGraphic = aMtf;
+}
+
+static bool RenderAsEMF(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &rGraphic)
+{
+ TempFile aTemp;
+ aTemp.EnableKillingFile();
+ rtl::OUString fileName =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pstoedit"));
+ rtl::OUString arg1 =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-f"));
+ rtl::OUString arg2 =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("emf"));
+ rtl::OUString arg3 =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
+ rtl::OUString output;
+ osl::FileBase::getSystemPathFromFileURL(aTemp.GetName(), output);
+ rtl_uString *args[] =
+ {
+ arg1.pData, arg2.pData, arg3.pData, output.pData
+ };
+ oslProcess aProcess;
+ oslFileHandle pIn = NULL;
+ oslFileHandle pOut = NULL;
+ oslFileHandle pErr = NULL;
+ oslProcessError eErr = osl_executeProcess_WithRedirectedIO(fileName.pData,
+ args, sizeof(args)/sizeof(rtl_uString *), osl_Process_SEARCHPATH,
+ osl_getCurrentSecurity(), 0, 0, 0, &aProcess, &pIn, 0, &pErr);
+ if (eErr!=osl_Process_E_None)
+ return false;
+
+ bool bRet = false;
+ sal_uInt64 nCount;
+ osl_writeFile(pIn, pBuf, nBytesRead, &nCount);
+ osl_closeFile(pIn);
+ osl_joinProcess(aProcess);
+ if (nCount == nBytesRead)
+ {
+ SvFileStream aFile(output, STREAM_READ);
+ if (GraphicConverter::Import(aFile, rGraphic, CVT_EMF) == ERRCODE_NONE)
+ bRet = true;
+ }
+ return bRet;
+}
+
+static bool RenderAsPNGThroughHelper(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
+ const Size &rSize, Graphic &rGraphic, rtl::OUString &rProgName, rtl_uString **pArgs, size_t nArgs)
+{
+ oslProcess aProcess;
+ oslFileHandle pIn = NULL;
+ oslFileHandle pOut = NULL;
+ oslFileHandle pErr = NULL;
+ oslProcessError eErr = osl_executeProcess_WithRedirectedIO(rProgName.pData,
+ pArgs, nArgs, osl_Process_SEARCHPATH,
+ osl_getCurrentSecurity(), 0, 0, 0, &aProcess, &pIn, &pOut, &pErr);
+ if (eErr!=osl_Process_E_None)
+ return false;
+
+ bool bRet = false;
+ sal_uInt64 nCount;
+ osl_writeFile(pIn, pBuf, nBytesRead, &nCount);
+ osl_closeFile(pIn);
+ if (nCount == nBytesRead)
+ {
+ SvMemoryStream aMemStm;
+ sal_uInt8 aBuf[32000];
+ oslFileError eFileErr = osl_readFile(pOut, aBuf, 32000, &nCount);
+ while (eFileErr == osl_File_E_None && nCount)
+ {
+ aMemStm.Write(aBuf, nCount);
+ eFileErr = osl_readFile(pOut, aBuf, 32000, &nCount);
+ }
+
+ aMemStm.Seek(0);
+ if (
+ eFileErr == osl_File_E_None &&
+ GraphicConverter::Import(aMemStm, rGraphic, CVT_PNG) == ERRCODE_NONE
+ )
+ {
+ MakeAsMeta(rGraphic);
+ bRet = true;
+ }
+ }
+ osl_closeFile(pOut);
+ return bRet;
+}
+
+static bool RenderAsPNGThroughConvert(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
+ const Size &rSize, Graphic &rGraphic)
+{
+ rtl::OUString fileName =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("convert"));
+ // density in pixel/inch
+ rtl::OUString arg1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-density"));
+ // since the preview is also used for PDF-Export & printing on non-PS-printers,
+ // use some better quality - 300x300 should allow some resizing as well
+ rtl::OUString arg2 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("300x300"));
+ // read eps from STDIN
+ rtl::OUString arg3 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("eps:-"));
+ // write png to STDOUT
+ rtl::OUString arg4 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("png:-"));
+ rtl_uString *args[] =
+ {
+ arg1.pData, arg2.pData, arg3.pData, arg4.pData
+ };
+ return RenderAsPNGThroughHelper(pBuf, nBytesRead, rSize, rGraphic, fileName, args,
+ sizeof(args)/sizeof(rtl_uString *));
+}
+
+static bool RenderAsPNGThroughGS(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
+ const Size &rSize, Graphic &rGraphic)
+{
+#ifdef WNT
+ rtl::OUString fileName =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gswin32c"));
+#else
+ rtl::OUString fileName =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gs"));
+#endif
+ rtl::OUString arg1 =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-q"));
+ rtl::OUString arg2 =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-dNOPAUSE"));
+ rtl::OUString arg3 =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-g"));
+ arg3 = arg3 + rtl::OUString::valueOf(rSize.Width());
+ arg3 = arg3 + rtl::OUString::valueOf(sal_Unicode('x'));
+ arg3 = arg3 + rtl::OUString::valueOf(rSize.Height());
+ rtl::OUString arg4 =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-dTextAlphaBits=4"));
+ rtl::OUString arg5 =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-dGraphicsAlphaBits=4"));
+ rtl::OUString arg6 =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-sDEVICE=png256"));
+ rtl::OUString arg7 =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-sOutputFile=-"));
+ rtl::OUString arg8 =
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
+ rtl_uString *args[] =
+ {
+ arg1.pData, arg2.pData, arg3.pData, arg4.pData, arg5.pData,
+ arg6.pData, arg7.pData, arg8.pData
+ };
+ return RenderAsPNGThroughHelper(pBuf, nBytesRead, rSize, rGraphic, fileName, args,
+ sizeof(args)/sizeof(rtl_uString *));
+}
+
+static bool RenderAsPNG(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
+ const Size &rSize, Graphic &rGraphic)
+{
+ if (RenderAsPNGThroughConvert(pBuf, nBytesRead, rSize, rGraphic))
+ return true;
+ else
+ return RenderAsPNGThroughGS(pBuf, nBytesRead, rSize, rGraphic);
+}
+
+
+//there is no preview -> make a red box
+void MakePreview(sal_uInt8* pBuf, sal_uInt32 nBytesRead,
+ long nWidth, long nHeight, Graphic &rGraphic)
+{
+ GDIMetaFile aMtf;
+ VirtualDevice aVDev;
+ Font aFont;
+
+ aVDev.EnableOutput( FALSE );
+ aMtf.Record( &aVDev );
+ aVDev.SetLineColor( Color( COL_RED ) );
+ aVDev.SetFillColor();
+
+ aFont.SetColor( COL_LIGHTRED );
+// aFont.SetSize( Size( 0, 32 ) );
+
+ aVDev.Push( PUSH_FONT );
+ aVDev.SetFont( aFont );
+
+ Rectangle aRect( Point( 1, 1 ), Size( nWidth - 2, nHeight - 2 ) );
+ aVDev.DrawRect( aRect );
+
+ String aString;
+ int nLen;
+ BYTE* pDest = ImplSearchEntry( pBuf, (BYTE*)"%%Title:", nBytesRead - 32, 8 );
+ if ( pDest )
+ {
+ pDest += 8;
+ if ( *pDest == ' ' )
+ pDest++;
+ nLen = ImplGetLen( pDest, 32 );
+ BYTE aOldValue(pDest[ nLen ]); pDest[ nLen ] = 0;
+ if ( strcmp( (const char*)pDest, "none" ) != 0 )
+ {
+ aString.AppendAscii( " Title:" );
+ aString.AppendAscii( (char*)pDest );
+ aString.AppendAscii( "\n" );
+ }
+ pDest[ nLen ] = aOldValue;
+ }
+ pDest = ImplSearchEntry( pBuf, (BYTE*)"%%Creator:", nBytesRead - 32, 10 );
+ if ( pDest )
+ {
+ pDest += 10;
+ if ( *pDest == ' ' )
+ pDest++;
+ nLen = ImplGetLen( pDest, 32 );
+ BYTE aOldValue(pDest[ nLen ]); pDest[ nLen ] = 0;
+ aString.AppendAscii( " Creator:" );
+ aString.AppendAscii( (char*)pDest );
+ aString.AppendAscii( "\n" );
+ pDest[ nLen ] = aOldValue;
+ }
+ pDest = ImplSearchEntry( pBuf, (BYTE*)"%%CreationDate:", nBytesRead - 32, 15 );
+ if ( pDest )
+ {
+ pDest += 15;
+ if ( *pDest == ' ' )
+ pDest++;
+ nLen = ImplGetLen( pDest, 32 );
+ BYTE aOldValue(pDest[ nLen ]); pDest[ nLen ] = 0;
+ if ( strcmp( (const char*)pDest, "none" ) != 0 )
+ {
+ aString.AppendAscii( " CreationDate:" );
+ aString.AppendAscii( (char*)pDest );
+ aString.AppendAscii( "\n" );
+ }
+ pDest[ nLen ] = aOldValue;
+ }
+ pDest = ImplSearchEntry( pBuf, (BYTE*)"%%LanguageLevel:", nBytesRead - 4, 16 );
+ if ( pDest )
+ {
+ pDest += 16;
+ int nCount = 4;
+ long nNumber = ImplGetNumber( &pDest, nCount );
+ if ( nCount && ( (UINT32)nNumber < 10 ) )
+ {
+ aString.AppendAscii( " LanguageLevel:" );
+ aString.Append( UniString::CreateFromInt32( nNumber ) );
+ }
+ }
+ aVDev.DrawText( aRect, aString, TEXT_DRAW_CLIP | TEXT_DRAW_MULTILINE );
+ aVDev.Pop();
+ aMtf.Stop();
+ aMtf.WindStart();
+ aMtf.SetPrefMapMode( MAP_POINT );
+ aMtf.SetPrefSize( Size( nWidth, nHeight ) );
+ rGraphic = aMtf;
+}
+
+
//================== GraphicImport - die exportierte Funktion ================
#ifdef WNT
@@ -215,24 +486,7 @@ extern "C" BOOL GraphicImport(SvStream &
rStream.Seek( nOrigPos + nPos );
if ( GraphicConverter::Import( rStream, aGraphic, CVT_TIF ) == ERRCODE_NONE )
{
- VirtualDevice aVDev;
- GDIMetaFile aMtf;
- Bitmap aBmp( aGraphic.GetBitmap() );
- Size aSize = aBmp.GetPrefSize();
-
- if( !aSize.Width() || !aSize.Height() )
- aSize = Application::GetDefaultDevice()->PixelToLogic( aBmp.GetSizePixel(), MAP_100TH_MM );
- else
- aSize = Application::GetDefaultDevice()->LogicToLogic( aSize, aBmp.GetPrefMapMode(), MAP_100TH_MM );
-
- aVDev.EnableOutput( FALSE );
- aMtf.Record( &aVDev );
- aVDev.DrawBitmap( Point(), aSize, aGraphic.GetBitmap() );
- aMtf.Stop();
- aMtf.WindStart();
- aMtf.SetPrefMapMode( MAP_100TH_MM );
- aMtf.SetPrefSize( aSize );
- aGraphic = aMtf;
+ MakeAsMeta(aGraphic);
rStream.Seek( nOrigPos + nPos );
bHasPreview = bRetValue = TRUE;
}
@@ -380,93 +634,24 @@ extern "C" BOOL GraphicImport(SvStream &
long nWidth = nNumb[2] - nNumb[0] + 1;
long nHeight = nNumb[3] - nNumb[1] + 1;
-
- if( !bHasPreview ) // if there is no preview -> make a red box
+
+ // if there is no preview -> try with gs to make one
+ if( !bHasPreview )
{
- VirtualDevice aVDev;
- GDIMetaFile aMtf2;
- Font aFont;
-
- aVDev.EnableOutput( FALSE );
- aMtf2.Record( &aVDev );
- aVDev.SetLineColor( Color( COL_RED ) );
- aVDev.SetFillColor();
-
- aFont.SetColor( COL_LIGHTRED );
-// aFont.SetSize( Size( 0, 32 ) );
-
- aVDev.Push( PUSH_FONT );
- aVDev.SetFont( aFont );
-
- Rectangle aRect( Point( 1, 1 ), Size( nWidth - 2, nHeight - 2 ) );
- aVDev.DrawRect( aRect );
-
- String aString;
- int nLen;
- pDest = ImplSearchEntry( pBuf, (BYTE*)"%%Title:", nBytesRead - 32, 8 );
- if ( pDest )
- {
- pDest += 8;
- if ( *pDest == ' ' )
- pDest++;
- nLen = ImplGetLen( pDest, 32 );
- BYTE aOldValue(pDest[ nLen ]); pDest[ nLen ] = 0;
- if ( strcmp( (const char*)pDest, "none" ) != 0 )
- {
- aString.AppendAscii( " Title:" );
- aString.AppendAscii( (char*)pDest );
- aString.AppendAscii( "\n" );
- }
- pDest[ nLen ] = aOldValue;
- }
- pDest = ImplSearchEntry( pBuf, (BYTE*)"%%Creator:", nBytesRead - 32, 10 );
- if ( pDest )
- {
- pDest += 10;
- if ( *pDest == ' ' )
- pDest++;
- nLen = ImplGetLen( pDest, 32 );
- BYTE aOldValue(pDest[ nLen ]); pDest[ nLen ] = 0;
- aString.AppendAscii( " Creator:" );
- aString.AppendAscii( (char*)pDest );
- aString.AppendAscii( "\n" );
- pDest[ nLen ] = aOldValue;
- }
- pDest = ImplSearchEntry( pBuf, (BYTE*)"%%CreationDate:", nBytesRead - 32, 15 );
- if ( pDest )
+ bHasPreview = RenderAsEMF(pBuf, nBytesRead, aGraphic);
+ if (!bHasPreview)
{
- pDest += 15;
- if ( *pDest == ' ' )
- pDest++;
- nLen = ImplGetLen( pDest, 32 );
- BYTE aOldValue(pDest[ nLen ]); pDest[ nLen ] = 0;
- if ( strcmp( (const char*)pDest, "none" ) != 0 )
- {
- aString.AppendAscii( " CreationDate:" );
- aString.AppendAscii( (char*)pDest );
- aString.AppendAscii( "\n" );
- }
- pDest[ nLen ] = aOldValue;
+ Size aSize(nWidth, nHeight);
+ aSize = Application::GetDefaultDevice()->LogicToPixel(aSize, MAP_POINT);
+ bHasPreview = RenderAsPNG(pBuf, nBytesRead, aSize, aGraphic);
}
- pDest = ImplSearchEntry( pBuf, (BYTE*)"%%LanguageLevel:", nBytesRead - 4, 16 );
- if ( pDest )
- {
- pDest += 16;
- int nCount = 4;
- long nNumber = ImplGetNumber( &pDest, nCount );
- if ( nCount && ( (UINT32)nNumber < 10 ) )
- {
- aString.AppendAscii( " LanguageLevel:" );
- aString.Append( UniString::CreateFromInt32( nNumber ) );
- }
- }
- aVDev.DrawText( aRect, aString, TEXT_DRAW_CLIP | TEXT_DRAW_MULTILINE );
- aVDev.Pop();
- aMtf2.Stop();
- aMtf2.WindStart();
- aMtf2.SetPrefMapMode( MAP_POINT );
- aMtf2.SetPrefSize( Size( nWidth, nHeight ) );
- aGraphic = aMtf2;
+ }
+
+ // if there is no preview -> make a red box
+ if( !bHasPreview )
+ {
+ MakePreview(pBuf, nBytesRead, nWidth, nHeight,
+ aGraphic);
}
aMtf.AddAction( (MetaAction*)( new MetaEPSAction( Point(), Size( nWidth, nHeight ),
Index: openoffice.org.spec
===================================================================
RCS file: /cvs/dist/rpms/openoffice.org/devel/openoffice.org.spec,v
retrieving revision 1.230
retrieving revision 1.231
diff -u -r1.230 -r1.231
--- openoffice.org.spec 14 Jun 2005 08:41:39 -0000 1.230
+++ openoffice.org.spec 14 Jun 2005 10:47:41 -0000 1.231
@@ -110,6 +110,7 @@
Patch44: workspace.gslpatches2.patch
Patch45: openoffice.org-1.9.108.oooXXXXX.pyuno.pushrpath.patch
Patch46: openoffice.org-1.9.88.NONE.gcc3gcj4.patch
+Patch47: openoffice.org-1.9.108.ooo9290.goodies.epstoepdf.patch
%define instdir %{_libdir}/openoffice.org%{version}
@@ -725,6 +726,7 @@
%patch44 -p1 -b .workspace.gslpatches2.patch
%patch45 -p1 -b .oooXXXXX.pyuno.pushrpath.patch
%patch46 -p1 -b .NONE.gcc3gcj4.patch
+%patch47 -p1 -b .ooo9290.goodies.epstoepdf.patch
#start ludicrous workaround
#while we include these libs we need this, if/when we move to system
@@ -2546,6 +2548,7 @@
%changelog
* Mon Jun 13 2005 Caolan McNamara <caolanm at redhat.com> - 1:1.9.109-4
- readd openoffice.org-1.9.88.NONE.gcc3gcj4.patch
+- add openoffice.org-1.9.108.ooo9290.goodies.epstoepdf.patch for rh#142535#
* Mon Jun 13 2005 Caolan McNamara <caolanm at redhat.com> - 1:1.9.109-3
- add openoffice.org-1.9.108.oooXXXXX.pyuno.pushrpath.patch
- Previous message (by thread): rpms/xerces-j2/devel .cvsignore, 1.7, 1.8 sources, 1.5, 1.6 xerces-j2-build.patch, 1.5, 1.6 xerces-j2.spec, 1.28, 1.29
- Next message (by thread): rpms/openoffice.org/devel openoffice.org.spec,1.231,1.232
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-cvs-commits
mailing list