git: d9b5ef800dbd - main - editors/libreoffice: prepare for update of poppler to 22.04

From: Tobias C. Berner <tcberner_at_FreeBSD.org>
Date: Tue, 26 Apr 2022 17:08:03 UTC
The branch main has been updated by tcberner:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d9b5ef800dbd0366eae81b03bfa89689ec73c6f7

commit d9b5ef800dbd0366eae81b03bfa89689ec73c6f7
Author:     Tobias C. Berner <tcberner@FreeBSD.org>
AuthorDate: 2022-04-26 16:02:59 +0000
Commit:     Tobias C. Berner <tcberner@FreeBSD.org>
CommitDate: 2022-04-26 16:56:49 +0000

    editors/libreoffice: prepare for update of poppler to 22.04
    
    PR:             263009
---
 ...ource_pdfimport_xpdfwrapper_pdfioutdev__gpl.cxx | 69 ++++++++++++++++++++++
 ...t_source_pdfimport_xpdfwrapper_wrapper__gpl.cxx | 26 ++++++++
 2 files changed, 95 insertions(+)

diff --git a/editors/libreoffice/files/patch-sdext_source_pdfimport_xpdfwrapper_pdfioutdev__gpl.cxx b/editors/libreoffice/files/patch-sdext_source_pdfimport_xpdfwrapper_pdfioutdev__gpl.cxx
new file mode 100644
index 000000000000..1e32c6d74fe2
--- /dev/null
+++ b/editors/libreoffice/files/patch-sdext_source_pdfimport_xpdfwrapper_pdfioutdev__gpl.cxx
@@ -0,0 +1,69 @@
+--- sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx.orig	2022-04-26 16:11:01 UTC
++++ sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+@@ -474,11 +474,17 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* g
+     {
+         // TODO(P3): Unfortunately, need to read stream twice, since
+         // we must write byte count to stdout before
++#if !POPPLER_CHECK_VERSION(22, 3, 0)
+         char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), &nSize );
++#else
++        std::optional<std::vector<unsigned char>> pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef() );
++#endif
+         if( pBuf )
+         {
+             aNewFont.isEmbedded = true;
++#if !POPPLER_CHECK_VERSION(22, 3, 0)
+             gfree(pBuf);
++#endif
+         }
+     }
+ 
+@@ -492,21 +498,32 @@ void PDFOutDev::writeFontFile( GfxFont* gfxFont ) cons
+         return;
+ 
+     int nSize = 0;
+-    char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), &nSize );
++#if !POPPLER_CHECK_VERSION(22, 3, 0)
++        char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), &nSize );
++#else
++        std::optional<std::vector<unsigned char>> pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef() );
++#endif
+     if( !pBuf )
+         return;
+ 
+     // ---sync point--- see SYNC STREAMS above
+     fflush(stdout);
+-
++#if !POPPLER_CHECK_VERSION(22, 3, 0)
+     if( fwrite(pBuf, sizeof(char), nSize, g_binary_out) != static_cast<size_t>(nSize) )
++#else
++    if( fwrite(reinterpret_cast<char*>(pBuf.value().data()), sizeof(char), nSize, g_binary_out) != static_cast<size_t>(nSize) )
++#endif
+     {
+-        gfree(pBuf);
++#if !POPPLER_CHECK_VERSION(22, 3, 0)
++            gfree(pBuf);
++#endif
+         exit(1); // error
+     }
+     // ---sync point--- see SYNC STREAMS above
+     fflush(g_binary_out);
+-    gfree(pBuf);
++#if !POPPLER_CHECK_VERSION(22, 3, 0)
++            gfree(pBuf);
++#endif
+ }
+ 
+ #if POPPLER_CHECK_VERSION(0, 83, 0)
+@@ -759,7 +776,11 @@ void PDFOutDev::updateFont(GfxState *state)
+ {
+     assert(state);
+ 
++#if !POPPLER_CHECK_VERSION(22, 3, 0)
+     GfxFont *gfxFont = state->getFont();
++#else
++    GfxFont *gfxFont = state->getFont().get();
++#endif
+     if( !gfxFont )
+         return;
+ 
diff --git a/editors/libreoffice/files/patch-sdext_source_pdfimport_xpdfwrapper_wrapper__gpl.cxx b/editors/libreoffice/files/patch-sdext_source_pdfimport_xpdfwrapper_wrapper__gpl.cxx
new file mode 100644
index 000000000000..2cc067945d3f
--- /dev/null
+++ b/editors/libreoffice/files/patch-sdext_source_pdfimport_xpdfwrapper_wrapper__gpl.cxx
@@ -0,0 +1,26 @@
+--- sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx.orig	2022-03-23 13:32:00 UTC
++++ 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, 3, 0)
++    PDFDoc aDoc( std::make_unique<GooString>(pFileName),
++                 GooString(pOwnerPasswordStr),
++                 GooString(pUserPasswordStr) );
++
++    PDFDoc aErrDoc( std::make_unique<GooString>(pErrFileName),
++                 GooString(pOwnerPasswordStr),
++                 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;