--- libreoffice-7.2.6.2/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx.orig 2022-03-03 14:25:45.000000000 +0100 +++ libreoffice-7.2.6.2/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx 2022-04-19 20:30:14.031282962 +0200 @@ -115,6 +115,21 @@ int main(int argc, char **argv) } // PDFDoc takes over ownership for all strings below +#if POPPLER_CHECK_VERSION(22, 3, 0) + auto pFileName = std::make_unique(argv[1]); + auto pErrFileName = std::make_unique(argv[2]); + + // check for password string(s) + std::optional pOwnerPasswordStr, pUserPasswordStr; + if( aPwBuf[0] != 0 ) + pOwnerPasswordStr = GooString(aPwBuf); + else if( ownerPassword[0] != '\001' ) + pOwnerPasswordStr = GooString(ownerPassword); + if( aPwBuf[0] != 0 ) + pUserPasswordStr = GooString(aPwBuf); + else if( userPassword[0] != '\001' ) + pUserPasswordStr = GooString(userPassword); +#else GooString* pFileName = new GooString(argv[1]); GooString* pErrFileName = new GooString(argv[2]); @@ -129,6 +144,7 @@ int main(int argc, char **argv) : (userPassword[0] != '\001' ? new GooString(userPassword) : nullptr ) ); +#endif if( outputFile[0] != '\001' ) g_binary_out = fopen(outputFile,"wb"); @@ -138,6 +154,15 @@ int main(int argc, char **argv) _setmode( _fileno( g_binary_out ), _O_BINARY ); #endif +#if POPPLER_CHECK_VERSION(22, 3, 0) + PDFDoc aDoc( std::move(pFileName), + pOwnerPasswordStr, + pUserPasswordStr ); + + PDFDoc aErrDoc( std::move(pErrFileName), + pOwnerPasswordStr, + pUserPasswordStr ); +#else PDFDoc aDoc( pFileName, pOwnerPasswordStr, pUserPasswordStr ); @@ -145,6 +170,7 @@ int main(int argc, char **argv) PDFDoc aErrDoc( pErrFileName, pOwnerPasswordStr, pUserPasswordStr ); +#endif // Check various permissions for aDoc. PDFDoc &rDoc = aDoc.isOk()? aDoc: aErrDoc; --- libreoffice-7.2.6.2/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx.orig 2022-03-03 14:25:45.000000000 +0100 +++ libreoffice-7.2.6.2/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx 2022-04-19 19:53:39.226719292 +0200 @@ -147,8 +147,13 @@ namespace pdfi std::unique_ptr m_pUtf8Map; bool m_bSkipImages; +#if POPPLER_CHECK_VERSION(22, 4, 0) + int parseFont( long long nNewId, std::shared_ptr pFont, GfxState* state ) const; + void writeFontFile( std::shared_ptr gfxFont ) const; +#else int parseFont( long long nNewId, GfxFont* pFont, GfxState* state ) const; void writeFontFile( GfxFont* gfxFont ) const; +#endif #if POPPLER_CHECK_VERSION(0, 83, 0) static void printPath( const GfxPath* pPath ); #else --- libreoffice-7.2.6.2/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx.orig 2022-03-03 14:25:45.000000000 +0100 +++ libreoffice-7.2.6.2/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx 2022-04-19 19:58:44.165967063 +0200 @@ -427,7 +427,11 @@ static void writeMaskLF( OutputBuffer& bool bInvert ) { writeMask_(o_rOutputBuf,str,width,height,bInvert); } +#if POPPLER_CHECK_VERSION(22, 4, 0) +int PDFOutDev::parseFont( long long nNewId, std::shared_ptr gfxFont, GfxState* state ) const +#else int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, GfxState* state ) const +#endif { FontAttributes aNewFont; int nSize = 0; @@ -461,23 +465,49 @@ int PDFOutDev::parseFont( long long nNew { // TODO(P3): Unfortunately, need to read stream twice, since // we must write byte count to stdout before +#if POPPLER_CHECK_VERSION(22, 4, 0) + auto buf = gfxFont->readEmbFontFile( m_pDoc->getXRef() ); + if( buf ) + { + aNewFont.isEmbedded = true; + nSize = buf->size(); + } +#else char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), &nSize ); if( pBuf ) { aNewFont.isEmbedded = true; gfree(pBuf); } +#endif } m_aFontMap[ nNewId ] = aNewFont; return nSize; } +#if POPPLER_CHECK_VERSION(22, 4, 0) +void PDFOutDev::writeFontFile( std::shared_ptr gfxFont ) const +#else void PDFOutDev::writeFontFile( GfxFont* gfxFont ) const +#endif { if( gfxFont->getType() != fontTrueType && gfxFont->getType() != fontType1 ) return; +#if POPPLER_CHECK_VERSION(22, 4, 0) + auto buf = gfxFont->readEmbFontFile( m_pDoc->getXRef() ); + if( !buf ) + return; + + // ---sync point--- see SYNC STREAMS above + fflush(stdout); + + if( fwrite(buf->data(), 1, buf->size(), g_binary_out) != buf->size() ) + exit(1); // error + // ---sync point--- see SYNC STREAMS above + fflush(g_binary_out); +#else int nSize = 0; char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), &nSize ); if( !pBuf ) @@ -494,6 +524,7 @@ void PDFOutDev::writeFontFile( GfxFont* // ---sync point--- see SYNC STREAMS above fflush(g_binary_out); gfree(pBuf); +#endif } #if POPPLER_CHECK_VERSION(0, 83, 0) @@ -747,7 +778,11 @@ void PDFOutDev::updateFont(GfxState *sta { assert(state); +#if POPPLER_CHECK_VERSION(22, 4, 0) + auto gfxFont = state->getFont(); +#else GfxFont *gfxFont = state->getFont(); +#endif if( !gfxFont ) return;