sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |   29 ++++++++++++++++++
 sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx    |   10 ++++++
 2 files changed, 39 insertions(+)

New commits:
commit ab6543b81006eb84e26ffb6f3db0c539352066f1
Author:     Nathan Pratta Teodosio <nathan.teodo...@canonical.com>
AuthorDate: Tue Jun 21 08:47:14 2022 -0300
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Fri Jun 24 16:26:18 2022 +0200

    Update for Poppler 22.06
    
    Change-Id: I8ee9f1a53cc4389e6a4d44e9765b478b5edfffd3
    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>

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<std::vector<unsigned char>> 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<std::vector<unsigned char>> 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<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);
@@ -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<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 );
@@ -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;

Reply via email to