summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Pratta Teodosio <nathan.teodosio@canonical.com>2022-06-21 08:47:14 -0300
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2022-06-24 16:14:38 +0200
commit56c7e666ebf47d6cdf29adf85fc5de56246be86d (patch)
treeccc9771fc249835a0264e12816e9a0d624fa18da
parenttdf#149574 sc: fix missing nullptr check (diff)
downloadcore-56c7e666ebf47d6cdf29adf85fc5de56246be86d.tar.gz
core-56c7e666ebf47d6cdf29adf85fc5de56246be86d.zip
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.stahl@allotropia.de> (cherry picked from commit 0d0469b4302dfe95b016a6f04b145834b79d5ed3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136319 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx29
-rw-r--r--sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx10
2 files changed, 39 insertions, 0 deletions
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;