From 0d0469b4302dfe95b016a6f04b145834b79d5ed3 Mon Sep 17 00:00:00 2001 From: Nathan Pratta Teodosio Date: Tue, 21 Jun 2022 08:47:14 -0300 Subject: Update for Poppler 22.06 Change-Id: I8ee9f1a53cc4389e6a4d44e9765b478b5edfffd3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136261 Tested-by: Jenkins Reviewed-by: Michael Stahl --- .../pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 29 ++++++++++++++++++++++ sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx | 10 ++++++++ 2 files changed, 39 insertions(+) (limited to 'sdext/source') diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index 02b6fe6a1b9e..d9efa39d8a54 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -474,12 +474,21 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, const GfxState* st { // TODO(P3): Unfortunately, need to read stream twice, since // we must write byte count to stdout before +#if POPPLER_CHECK_VERSION(22, 6, 0) + std::optional> pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef() ); + nSize = pBuf->size(); + if ( nSize > 0 ) + { + aNewFont.isEmbedded = true; + } +#else char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), &nSize ); if( pBuf ) { aNewFont.isEmbedded = true; gfree(pBuf); } +#endif } m_aFontMap[ nNewId ] = aNewFont; @@ -492,13 +501,28 @@ void PDFOutDev::writeFontFile( GfxFont* gfxFont ) const return; int nSize = 0; +#if POPPLER_CHECK_VERSION(22, 6, 0) + std::optional> pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef() ); + nSize = pBuf->size(); + if ( nSize == 0 ) + return; +#else char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), &nSize ); if( !pBuf ) return; +#endif // ---sync point--- see SYNC STREAMS above fflush(stdout); +#if POPPLER_CHECK_VERSION(22, 6, 0) + if( fwrite(pBuf->data(), sizeof(*pBuf->data()), nSize, g_binary_out) != static_cast(nSize) ) + { + exit(1); // error + } + // ---sync point--- see SYNC STREAMS above + fflush(g_binary_out); +#else if( fwrite(pBuf, sizeof(char), nSize, g_binary_out) != static_cast(nSize) ) { gfree(pBuf); @@ -507,6 +531,7 @@ void PDFOutDev::writeFontFile( GfxFont* gfxFont ) const // ---sync point--- see SYNC STREAMS above fflush(g_binary_out); gfree(pBuf); +#endif } #if POPPLER_CHECK_VERSION(0, 83, 0) @@ -759,7 +784,11 @@ void PDFOutDev::updateFont(GfxState *state) { assert(state); +#if POPPLER_CHECK_VERSION(22, 6, 0) + GfxFont *gfxFont = state->getFont().get(); +#else GfxFont *gfxFont = state->getFont(); +#endif if( !gfxFont ) return; diff --git a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx index ad6320139473..e924547e9357 100644 --- a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx @@ -138,6 +138,15 @@ int main(int argc, char **argv) _setmode( _fileno( g_binary_out ), _O_BINARY ); #endif +#if POPPLER_CHECK_VERSION(22, 6, 0) + PDFDoc aDoc( std::make_unique(pFileName), + std::optional(pOwnerPasswordStr), + std::optional(pUserPasswordStr) ); + + PDFDoc aErrDoc( std::make_unique(pErrFileName), + std::optional(pOwnerPasswordStr), + std::optional(pUserPasswordStr) ); +#else PDFDoc aDoc( pFileName, pOwnerPasswordStr, pUserPasswordStr ); @@ -145,6 +154,7 @@ int main(int argc, char **argv) PDFDoc aErrDoc( pErrFileName, pOwnerPasswordStr, pUserPasswordStr ); +#endif // Check various permissions for aDoc. PDFDoc &rDoc = aDoc.isOk()? aDoc: aErrDoc; -- cgit