filter/source/graphicfilter/ieps/ieps.cxx | 43 +++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 12 deletions(-)
New commits: commit 1a428ed5670e0257b21c04590ce95b86b2896ee4 Author: Caolán McNamara <caol...@redhat.com> Date: Wed May 14 14:12:30 2014 +0100 Related: fdo#64161 ask pstoedit to mark out the bounding box and tell pstoedit to use the original ps bounding box not its own calculation of it Change-Id: I06f3440a0def45ec8c3a4247c046ec499ed1012e diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx index 26a2025..c361bc2c 100644 --- a/filter/source/graphicfilter/ieps/ieps.cxx +++ b/filter/source/graphicfilter/ieps/ieps.cxx @@ -195,17 +195,37 @@ static oslProcessError runProcessWithPathSearch(const OUString &rProgName, static bool RenderAsEMF(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &rGraphic) { - utl::TempFile aTemp; - aTemp.EnableKillingFile(); - OUString fileName("pstoedit" EXESUFFIX); - OUString arg1("-f"); - OUString arg2("emf:-OO"); - OUString arg3("-"); + utl::TempFile aTempOutput; + utl::TempFile aTempInput; + aTempOutput.EnableKillingFile(); + aTempInput.EnableKillingFile(); OUString output; - osl::FileBase::getSystemPathFromFileURL(aTemp.GetURL(), output); + osl::FileBase::getSystemPathFromFileURL(aTempOutput.GetURL(), output); + OUString input; + osl::FileBase::getSystemPathFromFileURL(aTempInput.GetURL(), input); + + SvStream* pInputStream = aTempInput.GetStream(STREAM_WRITE); + sal_uInt64 nCount = pInputStream->Write(pBuf, nBytesRead); + aTempInput.CloseStream(); + + OUString fileName("pstoedit" EXESUFFIX); + //fdo#64161 pstoedit under non-windows uses libEMF to output the EMF, but + //libEMF cannot calculate the bounding box of text, so the overall bounding + //box is not increased to include that of any text in the eps + // + //-drawbb will force pstoedit to draw a pair of pixels with the bg color to + //the topleft and bottom right of the bounding box as pstoedit sees it, + //which libEMF will then extend its bounding box to fit + // + //-usebbfrominput forces pstoedit to take the original ps bounding box + //as the bounding box as it sees it, instead of calculating its own + //which also doesn't work for this example + OUString arg1("-usebbfrominput"); //-usebbfrominput use the original ps bounding box + OUString arg2("-f"); + OUString arg3("emf:-OO -drawbb"); //-drawbb mark out the bounding box extent with bg pixels rtl_uString *args[] = { - arg1.pData, arg2.pData, arg3.pData, output.pData + arg1.pData, arg2.pData, arg3.pData, input.pData, output.pData }; oslProcess aProcess; oslFileHandle pIn = NULL; @@ -219,9 +239,9 @@ static bool RenderAsEMF(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &r return false; bool bRet = false; - sal_uInt64 nCount; - osl_writeFile(pIn, pBuf, nBytesRead, &nCount); if (pIn) osl_closeFile(pIn); + osl_joinProcess(aProcess); + osl_freeProcessHandle(aProcess); bool bEMFSupported=true; if (pOut) { @@ -235,14 +255,13 @@ static bool RenderAsEMF(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &r osl_closeFile(pOut); } if (pErr) osl_closeFile(pErr); - osl_joinProcess(aProcess); - osl_freeProcessHandle(aProcess); if (nCount == nBytesRead && bEMFSupported) { SvFileStream aFile(output, STREAM_READ); if (GraphicConverter::Import(aFile, rGraphic, CVT_EMF) == ERRCODE_NONE) bRet = true; } + return bRet; }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits