sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 30 ++++++++++++++++++ sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx | 10 ++++++ 2 files changed, 40 insertions(+)
New commits: commit 016d689ced3275c9f5206e4edb2e9cb28e619f7c Author: Nathan Pratta Teodosio <nathan.teodo...@canonical.com> AuthorDate: Tue Jun 21 08:47:14 2022 -0300 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Sep 15 17:40:36 2022 +0200 Update for Poppler 22.06 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136261 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 0d0469b4302dfe95b016a6f04b145834b79d5ed3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136319 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> (cherry picked from commit 56c7e666ebf47d6cdf29adf85fc5de56246be86d) Follow-up for Poppler 22.06 update Change-Id: I8ee9f1a53cc4389e6a4d44e9765b478b5edfffd4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136342 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit ad1ffc62e40c2409b610dfff25a8483b1f2556ad) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136382 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> (cherry picked from commit 71fb0151f985924af60c383331b214a5a27790a5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140008 Tested-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index 16ad04bf660a..85cd88d50162 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -456,12 +456,21 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, GfxState* state ) { // 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<std::vector<unsigned char>> pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef() ); + if ( pBuf ) + { + aNewFont.isEmbedded = true; + nSize = pBuf->size(); + } +#else char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), &nSize ); if( pBuf ) { aNewFont.isEmbedded = true; gfree(pBuf); } +#endif } m_aFontMap[ nNewId ] = aNewFont; @@ -474,13 +483,29 @@ void PDFOutDev::writeFontFile( GfxFont* gfxFont ) const return; int nSize = 0; +#if POPPLER_CHECK_VERSION(22, 6, 0) + std::optional<std::vector<unsigned char>> pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef() ); + if ( pBuf ) + 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<size_t>(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<size_t>(nSize) ) { gfree(pBuf); @@ -489,6 +514,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) @@ -742,7 +768,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 b1a54bd09c5f..3ab3381652cd 100644 --- a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx @@ -119,6 +119,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<GooString>(pFileName), + std::optional<GooString>(pOwnerPasswordStr), + std::optional<GooString>(pUserPasswordStr) ); + + PDFDoc aErrDoc( std::make_unique<GooString>(pErrFileName), + std::optional<GooString>(pOwnerPasswordStr), + std::optional<GooString>(pUserPasswordStr) ); +#else PDFDoc aDoc( pFileName, pOwnerPasswordStr, pUserPasswordStr ); @@ -126,6 +135,7 @@ int main(int argc, char **argv) PDFDoc aErrDoc( pErrFileName, pOwnerPasswordStr, pUserPasswordStr ); +#endif // Check various permissions for aDoc. PDFDoc &rDoc = aDoc.isOk()? aDoc: aErrDoc;