about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/office/libreoffice/poppler-22-04-0.patch
blob: c907bf1680b4f6b692df2e3e3679a6c04d20803d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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
     }
 }