Skip to content

Commit

Permalink
libreoffice-fresh: Fix build with poppler 22.04
Browse files Browse the repository at this point in the history
  • Loading branch information
jtojnar committed May 4, 2022
1 parent 7c952f7 commit ced814a
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkgs/applications/office/libreoffice/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ in (mkDrv rec {
url = "https://github.com/archlinux/svntogit-packages/raw/f82958b9538f86e41b51f1ba7134968d2f3788d1/trunk/poppler-22.03.0.patch";
sha256 = "5h4qJmx6Q3Q3dHUlSi8JXBziN2mAswGVWk5aDTLTwls=";
})

# Fix build with poppler 22.04
./poppler-22-04-0.patch

This comment has been minimized.

Copy link
@t184256

t184256 May 6, 2022

Contributor

nix build 'nixpkgs#libreoffice':

applying patch /nix/store/jn5la8d1brpj9x65c0j51s7rn58cps4p-poppler-22-04-0.patch
patching file sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
Hunk #1 succeeded at 456 (offset -18 lines).
Hunk #2 succeeded at 483 (offset -18 lines).
Hunk #3 succeeded at 765 (offset -17 lines).
Hunk #4 succeeded at 786 (offset -17 lines).
Hunk #5 FAILED at 837.

This comment has been minimized.

Copy link
@jtojnar

jtojnar May 8, 2022

Author Member

Will be fixed by #172046

];

### QT/KDE
Expand Down
100 changes: 100 additions & 0 deletions pkgs/applications/office/libreoffice/poppler-22-04-0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
Patch from OpenSUSE
https://build.opensuse.org/package/view_file/LibreOffice:Factory/libreoffice/poppler-22-04-0.patch?expand=1&rev=45e176f964509ebe3560d0dbf1ec8be9
Index: libreoffice-7.3.3.1/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
===================================================================
--- libreoffice-7.3.3.1.orig/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ libreoffice-7.3.3.1/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -474,12 +474,21 @@ 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, 04, 0) // readEmbFontFile signature changed
+ auto 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;
@@ -492,21 +501,35 @@ void PDFOutDev::writeFontFile( GfxFont*
return;

int nSize = 0;
+#if POPPLER_CHECK_VERSION(22, 04, 0) // readEmbFontFile signature changed
+ auto pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef());
+ if ( !pBuf )
+ return;
+ nSize = pBuf->size();
+#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, 04, 0) // readEmbFontFile signature changed
+ if( fwrite(pBuf->data(), sizeof(unsigned char), nSize, g_binary_out) != static_cast<size_t>(nSize) )
+ {
+#else
if( fwrite(pBuf, sizeof(char), nSize, g_binary_out) != static_cast<size_t>(nSize) )
{
gfree(pBuf);
+#endif
exit(1); // error
}
// ---sync point--- see SYNC STREAMS above
fflush(g_binary_out);
+#if !POPPLER_CHECK_VERSION(22, 04, 0) // readEmbFontFile signature changed
gfree(pBuf);
+#endif
}

#if POPPLER_CHECK_VERSION(0, 83, 0)
@@ -759,7 +782,11 @@ void PDFOutDev::updateFont(GfxState *sta
{
assert(state);

+#if POPPLER_CHECK_VERSION(22, 04, 0)
+ std::shared_ptr<GfxFont> gfxFont = state->getFont();
+#else
GfxFont *gfxFont = state->getFont();
+#endif
if( !gfxFont )
return;

@@ -776,7 +803,11 @@ void PDFOutDev::updateFont(GfxState *sta
m_aFontMap.find( fontID );
if( it == m_aFontMap.end() )
{
+#if POPPLER_CHECK_VERSION(22, 04, 0)
+ nEmbedSize = parseFont( fontID, gfxFont.get(), state );
+#else
nEmbedSize = parseFont( fontID, gfxFont, state );
+#endif
it = m_aFontMap.find( fontID );
}

@@ -806,7 +837,11 @@ void PDFOutDev::updateFont(GfxState *sta

if (nEmbedSize)
{
+#if POPPLER_CHECK_VERSION(22, 04, 0)
+ writeFontFile(gfxFont.get());
+#else
writeFontFile(gfxFont);
+#endif
}
}

0 comments on commit ced814a

Please sign in to comment.