File: 25073.patch

package info (click to toggle)
scribus 1.5.8%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 179,080 kB
  • sloc: cpp: 483,300; python: 65,124; xml: 14,334; ansic: 2,484; sh: 192; perl: 95; makefile: 79
file content (283 lines) | stat: -rw-r--r-- 10,318 bytes parent folder | download | duplicates (2)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
Description: Fix build with poppler 22.04.0
Origin: upstream, upstream, https://www.scribus.net/websvn/revision.php?repname=Scribus&rev=25073
Bug-Debian: https://bugs.debian.org/1012850

Index: scribus/plugins/import/pdf/slaoutput.cpp
===================================================================
--- a/scribus/plugins/import/pdf/slaoutput.cpp	(revision 25072)
+++ b/scribus/plugins/import/pdf/slaoutput.cpp	(revision 25073)
@@ -174,8 +174,13 @@
 	int shade = 100;
 	currColorText = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
 	fontSize = state->getFontSize();
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0)
+	if (state->getFont() && state->getFont()->getName())
+		fontName = new GooString(state->getFont()->getName().value());
+#else
 	if (state->getFont())
 		fontName = state->getFont()->getName()->copy();
+#endif
 	itemText = s->copy();
 }
 
@@ -363,7 +368,12 @@
 GBool SlaOutputDev::annotations_callback(Annot *annota, void *user_data)
 {
 	SlaOutputDev *dev = (SlaOutputDev*)user_data;
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0)
+	const PDFRectangle& annotRect = annota->getRect();;
+	const PDFRectangle* box = &annotRect;
+#else
 	PDFRectangle *box = annota->getRect();
+#endif
 	double xCoor = dev->m_doc->currentPage()->xOffset() + box->x1 - dev->cropOffsetX;
 	double yCoor = dev->m_doc->currentPage()->yOffset() + dev->m_doc->currentPage()->height() - box->y2 + dev->cropOffsetY;
 	double width = box->x2 - box->x1;
@@ -706,7 +716,12 @@
 			if (apa || !achar)
 			{
 				AnoOutputDev *annotOutDev = new AnoOutputDev(m_doc, m_importedColors);
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0)
+				const PDFRectangle& annotaRect = annota->getRect();
+				Gfx* gfx = new Gfx(pdfDoc, annotOutDev, pdfDoc->getPage(m_actPage)->getResourceDict(), &annotaRect, nullptr);
+#else
 				Gfx *gfx = new Gfx(pdfDoc, annotOutDev, pdfDoc->getPage(m_actPage)->getResourceDict(), annota->getRect(), nullptr);
+#endif
 				ano->draw(gfx, false);
 				if (!bgFound)
 					m_currColorFill = annotOutDev->currColorFill;
@@ -3031,15 +3046,21 @@
 
 void SlaOutputDev::updateFont(GfxState *state)
 {
-	GfxFont *gfxFont;
-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0)
 	std::optional<GfxFontLoc> fontLoc;
+	std::string fileName;
+	std::unique_ptr<FoFiTrueType> ff;
+	std::optional<std::vector<unsigned char>> tmpBuf;
+#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+	std::optional<GfxFontLoc> fontLoc;
 	const GooString * fileName = nullptr;
 	std::unique_ptr<FoFiTrueType> ff;
+	char* tmpBuf = nullptr;
 #else
 	GfxFontLoc * fontLoc = nullptr;
 	GooString * fileName = nullptr;
 	FoFiTrueType * ff = nullptr;
+	char* tmpBuf = nullptr;
 #endif
 	GfxFontType fontType;
 	SlaOutFontFileID *id;
@@ -3046,7 +3067,6 @@
 	SplashFontFile *fontFile;
 	SplashFontSrc *fontsrc = nullptr;
 	Object refObj, strObj;
-	char *tmpBuf = nullptr;
 	int tmpBufLen = 0;
 	int *codeToGID = nullptr;
 	const double *textMat = nullptr;
@@ -3058,7 +3078,11 @@
 
 	m_font = nullptr;
 
-	gfxFont = state->getFont();
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0)
+	GfxFont* gfxFont = state->getFont().get();
+#else
+	GfxFont* gfxFont = state->getFont();
+#endif
 	if (!gfxFont)
 		goto err1;
 
@@ -3083,15 +3107,23 @@
 		if (fontLoc->locType == gfxFontLocEmbedded)
 		{
 			// if there is an embedded font, read it to memory
-			tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen);
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0)
+			tmpBuf = gfxFont->readEmbFontFile((xref) ? xref : pdfDoc->getXRef());
 			if (! tmpBuf)
 				goto err2;
+#else
+			tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen);
+			if (!tmpBuf)
+				goto err2;
+#endif
 
 			// external font
 		}
 		else
 		{ // gfxFontLocExternal
-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0)
+			fileName = fontLoc->path;
+#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
 			fileName = fontLoc->pathAsGooString();
 #else
 			fileName = fontLoc->path;
@@ -3100,52 +3132,54 @@
 		}
 
 		fontsrc = new SplashFontSrc;
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0)
+		if (!fileName.empty())
+			fontsrc->setFile(fileName);
+		else
+			fontsrc->setBuf(std::move(tmpBuf.value()));
+#else
 		if (fileName)
 			fontsrc->setFile(fileName, gFalse);
 		else
 			fontsrc->setBuf(tmpBuf, tmpBufLen, gTrue);
+#endif
 
 		// load the font file
 		switch (fontType) {
 		case fontType1:
-			if (!(fontFile = m_fontEngine->loadType1Font(
-				id,
-				fontsrc,
-				(const char **)((Gfx8BitFont *) gfxFont)->getEncoding())))
+			if (!(fontFile = m_fontEngine->loadType1Font(id, fontsrc, (const char **)((Gfx8BitFont *) gfxFont)->getEncoding())))
 			{
-				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
-				gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
+				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
 				goto err2;
 			}
 			break;
 		case fontType1C:
-			if (!(fontFile = m_fontEngine->loadType1CFont(
-							id,
-							fontsrc,
-							(const char **)((Gfx8BitFont *) gfxFont)->getEncoding())))
+			if (!(fontFile = m_fontEngine->loadType1CFont(id, fontsrc, (const char **)((Gfx8BitFont *) gfxFont)->getEncoding())))
 			{
-				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
-				gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
+				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
 				goto err2;
 			}
 			break;
 		case fontType1COT:
-			if (!(fontFile = m_fontEngine->loadOpenTypeT1CFont(
-							id,
-							fontsrc,
-							(const char **)((Gfx8BitFont *) gfxFont)->getEncoding())))
+			if (!(fontFile = m_fontEngine->loadOpenTypeT1CFont(id, fontsrc, (const char **)((Gfx8BitFont *) gfxFont)->getEncoding())))
 			{
-				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
-				gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
+				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
 				goto err2;
 			}
 			break;
 		case fontTrueType:
 		case fontTrueTypeOT:
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0)
+			if (!fileName.empty())
+				ff = FoFiTrueType::load(fileName.c_str());
+			else
+				ff = FoFiTrueType::make(fontsrc->buf.data(), fontsrc->buf.size());
+#else
 			if (fileName)
 				ff = FoFiTrueType::load(fileName->getCString());
 			else
 				ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
+#endif
 			if (ff)
 			{
 #if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
@@ -3162,24 +3196,17 @@
 				codeToGID = nullptr;
 				n = 0;
 			}
-			if (!(fontFile = m_fontEngine->loadTrueTypeFont(
-							id,
-							fontsrc,
-							codeToGID, n)))
+			if (!(fontFile = m_fontEngine->loadTrueTypeFont(id, fontsrc, codeToGID, n)))
 			{
-				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
-				gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
+				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
 				goto err2;
 			}
 			break;
 		case fontCIDType0:
 		case fontCIDType0C:
-			if (!(fontFile = m_fontEngine->loadCIDFont(
-							id,
-							fontsrc)))
+			if (!(fontFile = m_fontEngine->loadCIDFont(id, fontsrc)))
 			{
-				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
-				gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
+				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
 				goto err2;
 			}
 			break;
@@ -3195,10 +3222,7 @@
 				codeToGID = nullptr;
 				n = 0;
 			}
-			if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont(
-							id,
-							fontsrc,
-							codeToGID, n)))
+			if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont(id, fontsrc, codeToGID, n)))
 			{
 				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
 				gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
@@ -3220,10 +3244,17 @@
 			}
 			else
 			{
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0)
+				if (!fileName.empty())
+					ff = FoFiTrueType::load(fileName.c_str());
+				else
+					ff = FoFiTrueType::make(fontsrc->buf.data(), fontsrc->buf.size());
+#else
 				if (fileName)
 					ff = FoFiTrueType::load(fileName->getCString());
 				else
 					ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
+#endif
 				if (! ff)
 					goto err2;
 #if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
@@ -3234,13 +3265,9 @@
 				delete ff;
 #endif
 			}
-			if (!(fontFile = m_fontEngine->loadTrueTypeFont(
-							id,
-							fontsrc,
-							codeToGID, n, faceIndex)))
+			if (!(fontFile = m_fontEngine->loadTrueTypeFont(id, fontsrc, codeToGID, n, faceIndex)))
 			{
-				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
-				gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
+				error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
 				goto err2;
 			}
 			break;
@@ -3384,9 +3411,15 @@
 GBool SlaOutputDev::beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, POPPLER_CONST_082 Unicode *u, int uLen)
 {
 //	qDebug() << "beginType3Char";
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0)
 	GfxFont *gfxFont;
+	if (!(gfxFont = state->getFont().get()))
+		return gTrue;
+#else
+	GfxFont* gfxFont;
 	if (!(gfxFont = state->getFont()))
 		return gTrue;
+#endif
 	if (gfxFont->getType() != fontType3)
 		return gTrue;
 	F3Entry f3e;