Commit | Line | Data |
---|---|---|
0b67d3bb HG |
1 | Submitted By: Ken Moffat <ken at linuxfromscratch dot org> |
2 | Date: 2017-09-21 | |
3 | Initial Package Version: 20170524 | |
4 | Upstream Status: Unknown | |
5 | Origin: Arch linux | |
6 | Description: Fixes compilation with the API changes of poppler-0.59. | |
7 | ||
8 | diff -ur source.orig/texk/web2c/luatexdir/image/pdftoepdf.w source/texk/web2c/luatexdir/image/pdftoepdf.w | |
9 | --- source.orig/texk/web2c/luatexdir/image/pdftoepdf.w 2017-05-08 22:39:36.639375783 +0200 | |
10 | +++ source/texk/web2c/luatexdir/image/pdftoepdf.w 2017-09-19 11:23:36.586768739 +0200 | |
11 | @@ -224,7 +224,7 @@ | |
12 | free(checksum); | |
13 | } | |
14 | if (pdf_doc->doc == NULL) { | |
15 | - docmemstream = new MemStream( docstream,0,streamsize, obj.initNull() ); | |
16 | + docmemstream = new MemStream( docstream,0,streamsize, Object(objNull) ); | |
17 | doc = new PDFDoc(docmemstream); /* takes ownership of docmemstream */ | |
18 | pdf_doc->pc++; | |
19 | if (!doc->isOk() || !doc->okToPrint()) { | |
20 | @@ -408,9 +408,8 @@ | |
21 | Object obj1; | |
22 | pdf_begin_array(pdf); | |
23 | for (i = 0, l = array->getLength(); i < l; ++i) { | |
24 | - array->getNF(i, &obj1); | |
25 | + obj1 = array->getNF(i); | |
26 | copyObject(pdf, pdf_doc, &obj1); | |
27 | - obj1.free(); | |
28 | } | |
29 | pdf_end_array(pdf); | |
30 | } | |
31 | @@ -422,9 +421,8 @@ | |
32 | pdf_begin_dict(pdf); | |
33 | for (i = 0, l = dict->getLength(); i < l; ++i) { | |
34 | copyName(pdf, dict->getKey(i)); | |
35 | - dict->getValNF(i, &obj1); | |
36 | + obj1 = dict->getValNF(i); | |
37 | copyObject(pdf, pdf_doc, &obj1); | |
38 | - obj1.free(); | |
39 | } | |
40 | pdf_end_dict(pdf); | |
41 | } | |
42 | @@ -510,13 +508,12 @@ | |
43 | PDFDoc *doc = pdf_doc->doc; | |
44 | xref = doc->getXRef(); | |
45 | for (r = pdf_doc->inObjList; r != NULL;) { | |
46 | - xref->fetch(r->ref.num, r->ref.gen, &obj1); | |
47 | + obj1 = xref->fetch(r->ref.num, r->ref.gen); | |
48 | if (obj1.isStream()) | |
49 | pdf_begin_obj(pdf, r->num, OBJSTM_NEVER); | |
50 | else | |
51 | pdf_begin_obj(pdf, r->num, 2); | |
52 | copyObject(pdf, pdf_doc, &obj1); | |
53 | - obj1.free(); | |
54 | pdf_end_obj(pdf); | |
55 | n = r->next; | |
56 | delete r; | |
57 | @@ -740,7 +737,7 @@ | |
58 | catalog = doc->getCatalog(); | |
59 | page = catalog->getPage(img_pagenum(idict)); | |
60 | pageref = catalog->getPageRef(img_pagenum(idict)); | |
61 | - doc->getXRef()->fetch(pageref->num, pageref->gen, &pageobj); | |
62 | + pageobj = doc->getXRef()->fetch(pageref->num, pageref->gen); | |
63 | pageDict = pageobj.getDict(); | |
64 | /* write the Page header */ | |
65 | pdf_begin_obj(pdf, img_objnum(idict), OBJSTM_NEVER); | |
66 | @@ -757,12 +754,11 @@ | |
67 | pdf_dict_add_int(pdf, "PTEX.PageNumber", (int) img_pagenum(idict)); | |
68 | } | |
69 | if ((suppress_optional_info & 8) == 0) { | |
70 | - doc->getDocInfoNF(&obj1); | |
71 | + obj1 = doc->getDocInfoNF(); | |
72 | if (obj1.isRef()) { | |
73 | /* the info dict must be indirect (PDF Ref p. 61) */ | |
74 | pdf_dict_add_ref(pdf, "PTEX.InfoDict", addInObj(pdf, pdf_doc, obj1.getRef())); | |
75 | } | |
76 | - obj1.free(); | |
77 | } | |
78 | if (img_is_bbox(idict)) { | |
79 | bbox[0] = sp2bp(img_bbox(idict)[0]); | |
80 | @@ -788,19 +784,17 @@ | |
81 | Now all relevant parts of the Page dictionary are copied. Metadata validity | |
82 | check is needed(as a stream it must be indirect). | |
83 | */ | |
84 | - pageDict->lookupNF("Metadata", &obj1); | |
85 | + obj1 = pageDict->lookupNF("Metadata"); | |
86 | if (!obj1.isNull() && !obj1.isRef()) | |
87 | formatted_warning("pdf inclusion","/Metadata must be indirect object"); | |
88 | - obj1.free(); | |
89 | /* copy selected items in Page dictionary */ | |
90 | for (i = 0; pagedictkeys[i] != NULL; i++) { | |
91 | - pageDict->lookupNF(pagedictkeys[i], &obj1); | |
92 | + obj1 = pageDict->lookupNF(pagedictkeys[i]); | |
93 | if (!obj1.isNull()) { | |
94 | pdf_add_name(pdf, pagedictkeys[i]); | |
95 | /* preserves indirection */ | |
96 | copyObject(pdf, pdf_doc, &obj1); | |
97 | } | |
98 | - obj1.free(); | |
99 | } | |
100 | /* | |
101 | If there are no Resources in the Page dict of the embedded page, | |
102 | @@ -808,32 +802,28 @@ | |
103 | PDF file, climbing up the tree until the Resources are found. | |
104 | (This fixes a problem with Scribus 1.3.3.14.) | |
105 | */ | |
106 | - pageDict->lookupNF("Resources", &obj1); | |
107 | + obj1 = pageDict->lookupNF("Resources"); | |
108 | if (obj1.isNull()) { | |
109 | op1 = &pagesobj1; | |
110 | op2 = &pagesobj2; | |
111 | - pageDict->lookup("Parent", op1); | |
112 | + *op1 = pageDict->lookup("Parent"); | |
113 | while (op1->isDict()) { | |
114 | - obj1.free(); | |
115 | - op1->dictLookupNF("Resources", &obj1); | |
116 | + obj1 = op1->dictLookupNF("Resources"); | |
117 | if (!obj1.isNull()) { | |
118 | pdf_add_name(pdf, "Resources"); | |
119 | copyObject(pdf, pdf_doc, &obj1); | |
120 | break; | |
121 | } | |
122 | - op1->dictLookup("Parent", op2); | |
123 | + *op2 = op1->dictLookup("Parent"); | |
124 | optmp = op1; | |
125 | op1 = op2; | |
126 | op2 = optmp; | |
127 | - op2->free(); | |
128 | }; | |
129 | if (!op1->isDict()) | |
130 | formatted_warning("pdf inclusion","Page /Resources missing"); | |
131 | - op1->free(); | |
132 | } | |
133 | - obj1.free(); | |
134 | /* Write the Page contents. */ | |
135 | - page->getContents(&contents); | |
136 | + contents = page->getContents(); | |
137 | if (contents.isStream()) { | |
138 | /* | |
139 | Variant A: get stream and recompress under control of \pdfcompresslevel | |
140 | @@ -844,27 +834,23 @@ | |
141 | ||
142 | Variant B: copy stream without recompressing | |
143 | */ | |
144 | - contents.streamGetDict()->lookup("F", &obj1); | |
145 | + obj1 = contents.streamGetDict()->lookup("F"); | |
146 | if (!obj1.isNull()) { | |
147 | normal_error("pdf inclusion","unsupported external stream"); | |
148 | } | |
149 | - obj1.free(); | |
150 | - contents.streamGetDict()->lookup("Length", &obj1); | |
151 | + obj1 = contents.streamGetDict()->lookup("Length"); | |
152 | pdf_add_name(pdf, "Length"); | |
153 | copyObject(pdf, pdf_doc, &obj1); | |
154 | - obj1.free(); | |
155 | - contents.streamGetDict()->lookup("Filter", &obj1); | |
156 | + obj1 = contents.streamGetDict()->lookup("Filter"); | |
157 | if (!obj1.isNull()) { | |
158 | pdf_add_name(pdf, "Filter"); | |
159 | copyObject(pdf, pdf_doc, &obj1); | |
160 | - obj1.free(); | |
161 | - contents.streamGetDict()->lookup("DecodeParms", &obj1); | |
162 | + obj1 = contents.streamGetDict()->lookup("DecodeParms"); | |
163 | if (!obj1.isNull()) { | |
164 | pdf_add_name(pdf, "DecodeParms"); | |
165 | copyObject(pdf, pdf_doc, &obj1); | |
166 | } | |
167 | } | |
168 | - obj1.free(); | |
169 | pdf_end_dict(pdf); | |
170 | pdf_begin_stream(pdf); | |
171 | copyStreamStream(pdf, contents.getStream()->getUndecodedStream()); | |
172 | @@ -875,8 +861,8 @@ | |
173 | pdf_end_dict(pdf); | |
174 | pdf_begin_stream(pdf); | |
175 | for (i = 0, l = contents.arrayGetLength(); i < l; ++i) { | |
176 | - copyStreamStream(pdf, (contents.arrayGet(i, &obj1))->getStream()); | |
177 | - obj1.free(); | |
178 | + obj1 = contents.arrayGet(i); | |
179 | + copyStreamStream(pdf, obj1.getStream()); | |
180 | if (i < (l - 1)) { | |
181 | /* | |
182 | Put a space between streams to be on the safe side (streams | |
183 | @@ -897,8 +883,6 @@ | |
184 | } | |
185 | /* write out all indirect objects */ | |
186 | writeRefs(pdf, pdf_doc); | |
187 | - contents.free(); | |
188 | - pageobj.free(); | |
189 | /* | |
190 | unrefPdfDocument() must come after contents.free() and pageobj.free()! | |
191 | TH: The next line makes repeated pdf inclusion unacceptably slow | |
192 | diff -ur source.orig/texk/web2c/luatexdir/lua/lepdflib.cc source/texk/web2c/luatexdir/lua/lepdflib.cc | |
193 | --- source.orig/texk/web2c/luatexdir/lua/lepdflib.cc 2017-05-08 22:39:36.689375107 +0200 | |
194 | +++ source/texk/web2c/luatexdir/lua/lepdflib.cc 2017-09-19 09:48:19.658021769 +0200 | |
195 | @@ -538,7 +538,7 @@ | |
196 | pdfdoc_changed_error(L); \ | |
197 | uout = new_Object_userdata(L); \ | |
198 | uout->d = new Object(); \ | |
199 | - ((in *) uin->d)->function((Object *) uout->d); \ | |
200 | + *((Object *)uout->d) = ((in *) uin->d)->function(); \ | |
201 | uout->atype = ALLOC_LEPDF; \ | |
202 | uout->pc = uin->pc; \ | |
203 | uout->pd = uin->pd; \ | |
204 | @@ -668,13 +668,11 @@ | |
205 | ||
206 | static int m_Array_incRef(lua_State * L) | |
207 | { | |
208 | - int i; | |
209 | udstruct *uin; | |
210 | uin = (udstruct *) luaL_checkudata(L, 1, M_Array); | |
211 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | |
212 | pdfdoc_changed_error(L); | |
213 | - i = ((Array *) uin->d)->incRef(); | |
214 | - lua_pushinteger(L, i); | |
215 | + lua_pushinteger(L, 1); | |
216 | return 1; | |
217 | } | |
218 | ||
219 | @@ -685,8 +683,7 @@ | |
220 | uin = (udstruct *) luaL_checkudata(L, 1, M_Array); | |
221 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | |
222 | pdfdoc_changed_error(L); | |
223 | - i = ((Array *) uin->d)->decRef(); | |
224 | - lua_pushinteger(L, i); | |
225 | + lua_pushinteger(L, 1); | |
226 | return 1; | |
227 | } | |
228 | ||
229 | @@ -702,7 +699,7 @@ | |
230 | if ((uin->pd != NULL && uin->pd->pc != uin->pc) | |
231 | || (uobj->pd != NULL && uobj->pd->pc != uobj->pc)) | |
232 | pdfdoc_changed_error(L); | |
233 | - ((Array *) uin->d)->add(((Object *) uobj->d)); | |
234 | + ((Array *) uin->d)->add(std::move(*((Object *) uobj->d))); | |
235 | return 0; | |
236 | } | |
237 | ||
238 | @@ -718,7 +715,7 @@ | |
239 | if (i > 0 && i <= len) { | |
240 | uout = new_Object_userdata(L); | |
241 | uout->d = new Object(); | |
242 | - ((Array *) uin->d)->get(i - 1, (Object *) uout->d); | |
243 | + *((Object *) uout->d) = ((Array *) uin->d)->get(i - 1); | |
244 | uout->atype = ALLOC_LEPDF; | |
245 | uout->pc = uin->pc; | |
246 | uout->pd = uin->pd; | |
247 | @@ -739,7 +736,7 @@ | |
248 | if (i > 0 && i <= len) { | |
249 | uout = new_Object_userdata(L); | |
250 | uout->d = new Object(); | |
251 | - ((Array *) uin->d)->getNF(i - 1, (Object *) uout->d); | |
252 | + *((Object *) uout->d) = ((Array *) uin->d)->getNF(i - 1); | |
253 | uout->atype = ALLOC_LEPDF; | |
254 | uout->pc = uin->pc; | |
255 | uout->pd = uin->pd; | |
256 | @@ -953,25 +950,21 @@ | |
257 | ||
258 | static int m_Dict_incRef(lua_State * L) | |
259 | { | |
260 | - int i; | |
261 | udstruct *uin; | |
262 | uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); | |
263 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | |
264 | pdfdoc_changed_error(L); | |
265 | - i = ((Dict *) uin->d)->incRef(); | |
266 | - lua_pushinteger(L, i); | |
267 | + lua_pushinteger(L, 1); | |
268 | return 1; | |
269 | } | |
270 | ||
271 | static int m_Dict_decRef(lua_State * L) | |
272 | { | |
273 | - int i; | |
274 | udstruct *uin; | |
275 | uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); | |
276 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | |
277 | pdfdoc_changed_error(L); | |
278 | - i = ((Dict *) uin->d)->decRef(); | |
279 | - lua_pushinteger(L, i); | |
280 | + lua_pushinteger(L, 1); | |
281 | return 1; | |
282 | } | |
283 | ||
284 | @@ -986,7 +979,7 @@ | |
285 | pdfdoc_changed_error(L); | |
286 | s = copyString(luaL_checkstring(L, 2)); | |
287 | uobj = (udstruct *) luaL_checkudata(L, 3, M_Object); | |
288 | - ((Dict *) uin->d)->add(s, ((Object *) uobj->d)); | |
289 | + ((Dict *) uin->d)->add(s, std::move(*((Object *) uobj->d))); | |
290 | return 0; | |
291 | } | |
292 | ||
293 | @@ -999,7 +992,7 @@ | |
294 | pdfdoc_changed_error(L); | |
295 | s = luaL_checkstring(L, 2); | |
296 | uobj = (udstruct *) luaL_checkudata(L, 3, M_Object); | |
297 | - ((Dict *) uin->d)->set(s, ((Object *) uobj->d)); | |
298 | + ((Dict *) uin->d)->set(s, std::move(*((Object *) uobj->d))); | |
299 | return 0; | |
300 | } | |
301 | ||
302 | @@ -1027,7 +1020,7 @@ | |
303 | s = luaL_checkstring(L, 2); | |
304 | uout = new_Object_userdata(L); | |
305 | uout->d = new Object(); | |
306 | - ((Dict *) uin->d)->lookup(s, (Object *) uout->d); | |
307 | + *((Object *) uout->d) = ((Dict *) uin->d)->lookup(s); | |
308 | uout->atype = ALLOC_LEPDF; | |
309 | uout->pc = uin->pc; | |
310 | uout->pd = uin->pd; | |
311 | @@ -1044,7 +1037,7 @@ | |
312 | s = luaL_checkstring(L, 2); | |
313 | uout = new_Object_userdata(L); | |
314 | uout->d = new Object(); | |
315 | - ((Dict *) uin->d)->lookupNF(s, (Object *) uout->d); | |
316 | + *((Object *) uout->d) = ((Dict *) uin->d)->lookupNF(s); | |
317 | uout->atype = ALLOC_LEPDF; | |
318 | uout->pc = uin->pc; | |
319 | uout->pd = uin->pd; | |
320 | @@ -1096,7 +1089,7 @@ | |
321 | if (i > 0 && i <= len) { | |
322 | uout = new_Object_userdata(L); | |
323 | uout->d = new Object(); | |
324 | - ((Dict *) uin->d)->getVal(i - 1, (Object *) uout->d); | |
325 | + *((Object *) uout->d) = ((Dict *) uin->d)->getVal(i - 1); | |
326 | uout->atype = ALLOC_LEPDF; | |
327 | uout->pc = uin->pc; | |
328 | uout->pd = uin->pd; | |
329 | @@ -1117,7 +1110,7 @@ | |
330 | if (i > 0 && i <= len) { | |
331 | uout = new_Object_userdata(L); | |
332 | uout->d = new Object(); | |
333 | - ((Dict *) uin->d)->getValNF(i - 1, (Object *) uout->d); | |
334 | + *((Object *) uout->d) = ((Dict *) uin->d)->getValNF(i - 1); | |
335 | uout->atype = ALLOC_LEPDF; | |
336 | uout->pc = uin->pc; | |
337 | uout->pd = uin->pd; | |
338 | @@ -1381,9 +1374,9 @@ | |
339 | pdfdoc_changed_error(L); | |
340 | luaL_checktype(L, 2, LUA_TBOOLEAN); | |
341 | if (lua_toboolean(L, 2) != 0) | |
342 | - ((Object *) uin->d)->initBool(gTrue); | |
343 | + *((Object *) uin->d) = Object(gTrue); | |
344 | else | |
345 | - ((Object *) uin->d)->initBool(gFalse); | |
346 | + *((Object *) uin->d) = Object(gFalse); | |
347 | return 0; | |
348 | } | |
349 | ||
350 | @@ -1395,7 +1388,7 @@ | |
351 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | |
352 | pdfdoc_changed_error(L); | |
353 | i = luaL_checkint(L, 2); | |
354 | - ((Object *) uin->d)->initInt(i); | |
355 | + *((Object *) uin->d) = Object(i); | |
356 | return 0; | |
357 | } | |
358 | ||
359 | @@ -1407,7 +1400,7 @@ | |
360 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | |
361 | pdfdoc_changed_error(L); | |
362 | d = luaL_checknumber(L, 2); | |
363 | - ((Object *) uin->d)->initReal(d); | |
364 | + *((Object *) uin->d) = Object(d); | |
365 | return 0; | |
366 | } | |
367 | ||
368 | @@ -1422,7 +1415,7 @@ | |
369 | pdfdoc_changed_error(L); | |
370 | s = luaL_checklstring(L, 2, &len); | |
371 | gs = new GooString(s, len); | |
372 | - ((Object *) uin->d)->initString(gs); | |
373 | + *((Object *) uin->d) = Object(gs); | |
374 | return 0; | |
375 | } | |
376 | ||
377 | @@ -1434,7 +1427,7 @@ | |
378 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | |
379 | pdfdoc_changed_error(L); | |
380 | s = luaL_checkstring(L, 2); | |
381 | - ((Object *) uin->d)->initName(s); | |
382 | + *((Object *) uin->d) = Object(objName, s); | |
383 | return 0; | |
384 | } | |
385 | ||
386 | @@ -1444,13 +1437,14 @@ | |
387 | uin = (udstruct *) luaL_checkudata(L, 1, M_Object); | |
388 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | |
389 | pdfdoc_changed_error(L); | |
390 | - ((Object *) uin->d)->initNull(); | |
391 | + *((Object *) uin->d) = Object(objNull); | |
392 | return 0; | |
393 | } | |
394 | ||
395 | static int m_Object_initArray(lua_State * L) | |
396 | { | |
397 | udstruct *uin, *uxref; | |
398 | + Array *a; | |
399 | uin = (udstruct *) luaL_checkudata(L, 1, M_Object); | |
400 | uxref = (udstruct *) luaL_checkudata(L, 2, M_XRef); | |
401 | if (uin->pd != NULL && uxref->pd != NULL && uin->pd != uxref->pd) | |
402 | @@ -1458,7 +1452,8 @@ | |
403 | if ((uin->pd != NULL && uin->pd->pc != uin->pc) | |
404 | || (uxref->pd != NULL && uxref->pd->pc != uxref->pc)) | |
405 | pdfdoc_changed_error(L); | |
406 | - ((Object *) uin->d)->initArray((XRef *) uxref->d); | |
407 | + a = new Array((XRef *) uxref->d); | |
408 | + *((Object *) uin->d) = Object(a); | |
409 | return 0; | |
410 | } | |
411 | ||
412 | @@ -1469,6 +1464,7 @@ | |
413 | static int m_Object_initDict(lua_State * L) | |
414 | { | |
415 | udstruct *uin, *uxref; | |
416 | + Dict *d; | |
417 | uin = (udstruct *) luaL_checkudata(L, 1, M_Object); | |
418 | uxref = (udstruct *) luaL_checkudata(L, 2, M_XRef); | |
419 | if (uin->pd != NULL && uxref->pd != NULL && uin->pd != uxref->pd) | |
420 | @@ -1476,7 +1472,8 @@ | |
421 | if ((uin->pd != NULL && uin->pd->pc != uin->pc) | |
422 | || (uxref->pd != NULL && uxref->pd->pc != uxref->pc)) | |
423 | pdfdoc_changed_error(L); | |
424 | - ((Object *) uin->d)->initDict((XRef *) uxref->d); | |
425 | + d = new Dict((XRef *) uxref->d); | |
426 | + *((Object *) uin->d) = Object(d); | |
427 | return 0; | |
428 | } | |
429 | ||
430 | @@ -1490,7 +1487,7 @@ | |
431 | if ((uin->pd != NULL && uin->pd->pc != uin->pc) | |
432 | || (ustream->pd != NULL && ustream->pd->pc != ustream->pc)) | |
433 | pdfdoc_changed_error(L); | |
434 | - ((Object *) uin->d)->initStream((Stream *) ustream->d); | |
435 | + *((Object *) uin->d) = Object((Stream *) ustream->d); | |
436 | return 0; | |
437 | } | |
438 | ||
439 | @@ -1503,7 +1500,7 @@ | |
440 | pdfdoc_changed_error(L); | |
441 | num = luaL_checkint(L, 2); | |
442 | gen = luaL_checkint(L, 3); | |
443 | - ((Object *) uin->d)->initRef(num, gen); | |
444 | + *((Object *) uin->d) = Object(num, gen); | |
445 | return 0; | |
446 | } | |
447 | ||
448 | @@ -1515,7 +1512,7 @@ | |
449 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | |
450 | pdfdoc_changed_error(L); | |
451 | s = luaL_checkstring(L, 2); | |
452 | - ((Object *) uin->d)->initCmd(CHARP_CAST s); | |
453 | + *((Object *) uin->d) = Object(objCmd, CHARP_CAST s); | |
454 | return 0; | |
455 | } | |
456 | ||
457 | @@ -1525,7 +1522,7 @@ | |
458 | uin = (udstruct *) luaL_checkudata(L, 1, M_Object); | |
459 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | |
460 | pdfdoc_changed_error(L); | |
461 | - ((Object *) uin->d)->initError(); | |
462 | + *((Object *) uin->d) = Object(objError); | |
463 | return 0; | |
464 | } | |
465 | ||
466 | @@ -1535,7 +1532,7 @@ | |
467 | uin = (udstruct *) luaL_checkudata(L, 1, M_Object); | |
468 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | |
469 | pdfdoc_changed_error(L); | |
470 | - ((Object *) uin->d)->initEOF(); | |
471 | + *((Object *) uin->d) = Object(objEOF); | |
472 | return 0; | |
473 | } | |
474 | ||
475 | @@ -1551,7 +1548,7 @@ | |
476 | pdfdoc_changed_error(L); | |
477 | uout = new_Object_userdata(L); | |
478 | uout->d = new Object(); | |
479 | - ((Object *) uin->d)->fetch((XRef *) uxref->d, (Object *) uout->d); | |
480 | + *((Object *) uout->d) = ((Object *) uin->d)->fetch((XRef *) uxref->d); | |
481 | uout->atype = ALLOC_LEPDF; | |
482 | uout->pc = uin->pc; | |
483 | uout->pd = uin->pd; | |
484 | @@ -1816,7 +1813,7 @@ | |
485 | pdfdoc_changed_error(L); | |
486 | if (!((Object *) uin->d)->isArray()) | |
487 | luaL_error(L, "Object is not an Array"); | |
488 | - ((Object *) uin->d)->arrayAdd((Object *) uobj->d); | |
489 | + ((Object *) uin->d)->arrayAdd(std::move(*((Object *) uobj->d))); | |
490 | return 0; | |
491 | } | |
492 | ||
493 | @@ -1833,7 +1830,7 @@ | |
494 | if (i > 0 && i <= len) { | |
495 | uout = new_Object_userdata(L); | |
496 | uout->d = new Object(); | |
497 | - ((Object *) uin->d)->arrayGet(i - 1, (Object *) uout->d); | |
498 | + *((Object *) uout->d) = ((Object *) uin->d)->arrayGet(i - 1); | |
499 | uout->atype = ALLOC_LEPDF; | |
500 | uout->pc = uin->pc; | |
501 | uout->pd = uin->pd; | |
502 | @@ -1857,7 +1854,7 @@ | |
503 | if (i > 0 && i <= len) { | |
504 | uout = new_Object_userdata(L); | |
505 | uout->d = new Object(); | |
506 | - ((Object *) uin->d)->arrayGetNF(i - 1, (Object *) uout->d); | |
507 | + *((Object *) uout->d) = ((Object *) uin->d)->arrayGetNF(i - 1); | |
508 | uout->atype = ALLOC_LEPDF; | |
509 | uout->pc = uin->pc; | |
510 | uout->pd = uin->pd; | |
511 | @@ -1897,7 +1894,7 @@ | |
512 | pdfdoc_changed_error(L); | |
513 | if (!((Object *) uin->d)->isDict()) | |
514 | luaL_error(L, "Object is not a Dict"); | |
515 | - ((Object *) uin->d)->dictAdd(copyString(s), (Object *) uobj->d); | |
516 | + ((Object *) uin->d)->dictAdd(copyString(s), std::move(*((Object *) uobj->d))); | |
517 | return 0; | |
518 | } | |
519 | ||
520 | @@ -1915,7 +1912,7 @@ | |
521 | pdfdoc_changed_error(L); | |
522 | if (!((Object *) uin->d)->isDict()) | |
523 | luaL_error(L, "Object is not a Dict"); | |
524 | - ((Object *) uin->d)->dictSet(s, (Object *) uobj->d); | |
525 | + ((Object *) uin->d)->dictSet(s, std::move(*((Object *) uobj->d))); | |
526 | return 0; | |
527 | } | |
528 | ||
529 | @@ -1930,7 +1927,7 @@ | |
530 | if (((Object *) uin->d)->isDict()) { | |
531 | uout = new_Object_userdata(L); | |
532 | uout->d = new Object(); | |
533 | - ((Object *) uin->d)->dictLookup(s, (Object *) uout->d); | |
534 | + *((Object *) uout->d) = ((Object *) uin->d)->dictLookup(s); | |
535 | uout->atype = ALLOC_LEPDF; | |
536 | uout->pc = uin->pc; | |
537 | uout->pd = uin->pd; | |
538 | @@ -1950,7 +1947,7 @@ | |
539 | if (((Object *) uin->d)->isDict()) { | |
540 | uout = new_Object_userdata(L); | |
541 | uout->d = new Object(); | |
542 | - ((Object *) uin->d)->dictLookupNF(s, (Object *) uout->d); | |
543 | + *((Object *) uout->d) = ((Object *) uin->d)->dictLookupNF(s); | |
544 | uout->atype = ALLOC_LEPDF; | |
545 | uout->pc = uin->pc; | |
546 | uout->pd = uin->pd; | |
547 | @@ -1991,7 +1988,7 @@ | |
548 | if (i > 0 && i <= len) { | |
549 | uout = new_Object_userdata(L); | |
550 | uout->d = new Object(); | |
551 | - ((Object *) uin->d)->dictGetVal(i - 1, (Object *) uout->d); | |
552 | + *((Object *) uout->d) = ((Object *) uin->d)->dictGetVal(i - 1); | |
553 | uout->atype = ALLOC_LEPDF; | |
554 | uout->pc = uin->pc; | |
555 | uout->pd = uin->pd; | |
556 | @@ -2015,7 +2012,7 @@ | |
557 | if (i > 0 && i <= len) { | |
558 | uout = new_Object_userdata(L); | |
559 | uout->d = new Object(); | |
560 | - ((Object *) uin->d)->dictGetValNF(i - 1, (Object *) uout->d); | |
561 | + *((Object *) uout->d) = ((Object *) uin->d)->dictGetValNF(i - 1); | |
562 | uout->atype = ALLOC_LEPDF; | |
563 | uout->pc = uin->pc; | |
564 | uout->pd = uin->pd; | |
565 | @@ -2243,7 +2240,7 @@ | |
566 | m_poppler_get_poppler(Page, Dict, getPieceInfo); | |
567 | m_poppler_get_poppler(Page, Dict, getSeparationInfo); | |
568 | m_poppler_get_poppler(Page, Dict, getResourceDict); | |
569 | -m_poppler_get_OBJECT(Page, getAnnots); | |
570 | +m_poppler_get_OBJECT(Page, getAnnotsObject); | |
571 | ||
572 | m_poppler_get_OBJECT(Page, getContents); | |
573 | ||
574 | @@ -2270,7 +2267,7 @@ | |
575 | {"getPieceInfo", m_Page_getPieceInfo}, | |
576 | {"getSeparationInfo", m_Page_getSeparationInfo}, | |
577 | {"getResourceDict", m_Page_getResourceDict}, | |
578 | - {"getAnnots", m_Page_getAnnots}, | |
579 | + {"getAnnots", m_Page_getAnnotsObject}, | |
580 | {"getContents", m_Page_getContents}, | |
581 | {"__tostring", m_Page__tostring}, | |
582 | {NULL, NULL} // sentinel | |
583 | @@ -2520,7 +2517,7 @@ | |
584 | if (((PdfDocument *) uin->d)->doc->getXRef()->isOk()) { | |
585 | uout = new_Object_userdata(L); | |
586 | uout->d = new Object(); | |
587 | - ((PdfDocument *) uin->d)->doc->getDocInfo((Object *) uout->d); | |
588 | + *((Object *) uout->d) = ((PdfDocument *) uin->d)->doc->getDocInfo(); | |
589 | uout->atype = ALLOC_LEPDF; | |
590 | uout->pc = uin->pc; | |
591 | uout->pd = uin->pd; | |
592 | @@ -2538,7 +2535,7 @@ | |
593 | if (((PdfDocument *) uin->d)->doc->getXRef()->isOk()) { | |
594 | uout = new_Object_userdata(L); | |
595 | uout->d = new Object(); | |
596 | - ((PdfDocument *) uin->d)->doc->getDocInfoNF((Object *) uout->d); | |
597 | + *((Object *) uout->d) = ((PdfDocument *) uin->d)->doc->getDocInfoNF(); | |
598 | uout->atype = ALLOC_LEPDF; | |
599 | uout->pc = uin->pc; | |
600 | uout->pd = uin->pd; | |
601 | @@ -2841,7 +2838,7 @@ | |
602 | uout = new_Object_userdata(L); | |
603 | uout->d = new Object(); | |
604 | origin = (Object *) (((Attribute *) uin->d)->getValue()); | |
605 | - origin->copy ( ((Object *)uout->d) ); | |
606 | + *((Object *) uout->d) = origin->copy(); | |
607 | uout->atype = ALLOC_LEPDF; | |
608 | uout->pc = uin->pc; | |
609 | uout->pd = uin->pd; | |
610 | @@ -3320,7 +3317,7 @@ | |
611 | parent = root->findParentElement(i-1); | |
612 | if (parent != NULL) { | |
613 | uout = new_StructElement_userdata(L); | |
614 | - uout->d = new StructElement( *parent ); | |
615 | + uout->d = (StructElement *) parent; | |
616 | uout->atype = ALLOC_LEPDF; | |
617 | uout->pc = uin->pc; | |
618 | uout->pd = uin->pd; | |
619 | @@ -3370,7 +3367,7 @@ | |
620 | gen = luaL_checkint(L, 3); | |
621 | uout = new_Object_userdata(L); | |
622 | uout->d = new Object(); | |
623 | - ((XRef *) uin->d)->fetch(num, gen, (Object *) uout->d); | |
624 | + *((Object *) uout->d) = ((XRef *) uin->d)->fetch(num, gen); | |
625 | uout->atype = ALLOC_LEPDF; | |
626 | uout->pc = uin->pc; | |
627 | uout->pd = uin->pd; | |
628 | diff -ur source.orig/texk/web2c/luatexdir/lua/lpdfscannerlib.cc source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc | |
629 | --- source.orig/texk/web2c/luatexdir/lua/lpdfscannerlib.cc 2017-05-08 22:39:36.692708395 +0200 | |
630 | +++ source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc 2017-09-19 09:48:19.658021769 +0200 | |
631 | @@ -634,7 +634,7 @@ | |
632 | int i; | |
633 | for (i=0;i<count;i++) { | |
634 | Object *val = new Object(); | |
635 | - arrayref->get(i, val); | |
636 | + *val = arrayref->get(i); | |
637 | if (val->isStream()) { | |
638 | ObjectList *rover = self->_streams; | |
639 | ObjectList *item = (ObjectList *)priv_xmalloc (sizeof(ObjectList)); | |
640 | diff -ur source.orig/texk/web2c/pdftexdir/pdftoepdf.cc source/texk/web2c/pdftexdir/pdftoepdf.cc | |
641 | --- source.orig/texk/web2c/pdftexdir/pdftoepdf.cc 2017-06-16 21:49:09.293857387 +0200 | |
642 | +++ source/texk/web2c/pdftexdir/pdftoepdf.cc 2017-09-19 09:48:19.661355046 +0200 | |
643 | @@ -84,31 +84,6 @@ | |
644 | #define MASK_SUPPRESS_PTEX_PAGENUMBER 0x04 | |
645 | #define MASK_SUPPRESS_PTEX_INFODICT 0x08 | |
646 | ||
647 | -// PdfObject encapsulates the xpdf Object type, | |
648 | -// and properly frees its resources on destruction. | |
649 | -// Use obj-> to access members of the Object, | |
650 | -// and &obj to get a pointer to the object. | |
651 | -// It is no longer necessary to call Object::free explicitely. | |
652 | - | |
653 | -class PdfObject { | |
654 | - public: | |
655 | - PdfObject() { // nothing | |
656 | - } ~PdfObject() { | |
657 | - iObject.free(); | |
658 | - } | |
659 | - Object *operator->() { | |
660 | - return &iObject; | |
661 | - } | |
662 | - Object *operator&() { | |
663 | - return &iObject; | |
664 | - } | |
665 | - private: // no copying or assigning | |
666 | - PdfObject(const PdfObject &); | |
667 | - void operator=(const PdfObject &); | |
668 | - public: | |
669 | - Object iObject; | |
670 | -}; | |
671 | - | |
672 | // When copying the Resources of the selected page, all objects are copied | |
673 | // recusively top-down. Indirect objects however are not fetched during | |
674 | // copying, but get a new object number from pdfTeX and then will be | |
675 | @@ -212,18 +187,6 @@ | |
676 | delete pdf_doc; | |
677 | } | |
678 | ||
679 | -// Replacement for | |
680 | -// Object *initDict(Dict *dict1){ initObj(objDict); dict = dict1; return this; } | |
681 | - | |
682 | -static void initDictFromDict(PdfObject & obj, Dict * dict) | |
683 | -{ | |
684 | - obj->initDict(xref); | |
685 | - for (int i = 0, l = dict->getLength(); i < l; i++) { | |
686 | - Object obj1; | |
687 | - obj->dictAdd(copyString(dict->getKey(i)), dict->getValNF(i, &obj1)); | |
688 | - } | |
689 | -} | |
690 | - | |
691 | // -------------------------------------------------------------------- | |
692 | ||
693 | static int addEncoding(GfxFont * gfont) | |
694 | @@ -320,10 +283,10 @@ | |
695 | ||
696 | static void copyDictEntry(Object * obj, int i) | |
697 | { | |
698 | - PdfObject obj1; | |
699 | + Object obj1; | |
700 | copyName(obj->dictGetKey(i)); | |
701 | pdf_puts(" "); | |
702 | - obj->dictGetValNF(i, &obj1); | |
703 | + obj1 = obj->dictGetValNF(i); | |
704 | copyObject(&obj1); | |
705 | pdf_puts("\n"); | |
706 | } | |
707 | @@ -376,17 +339,17 @@ | |
708 | static void copyProcSet(Object * obj) | |
709 | { | |
710 | int i, l; | |
711 | - PdfObject procset; | |
712 | + Object procset; | |
713 | if (!obj->isArray()) | |
714 | pdftex_fail("PDF inclusion: invalid ProcSet array type <%s>", | |
715 | obj->getTypeName()); | |
716 | pdf_puts("/ProcSet [ "); | |
717 | for (i = 0, l = obj->arrayGetLength(); i < l; ++i) { | |
718 | - obj->arrayGetNF(i, &procset); | |
719 | - if (!procset->isName()) | |
720 | + procset = obj->arrayGetNF(i); | |
721 | + if (!procset.isName()) | |
722 | pdftex_fail("PDF inclusion: invalid ProcSet entry type <%s>", | |
723 | - procset->getTypeName()); | |
724 | - copyName(procset->getName()); | |
725 | + procset.getTypeName()); | |
726 | + copyName(procset.getName()); | |
727 | pdf_puts(" "); | |
728 | } | |
729 | pdf_puts("]\n"); | |
730 | @@ -396,7 +359,7 @@ | |
731 | ||
732 | static void copyFont(char *tag, Object * fontRef) | |
733 | { | |
734 | - PdfObject fontdict, subtype, basefont, fontdescRef, fontdesc, charset, | |
735 | + Object fontdict, subtype, basefont, fontdescRef, fontdesc, charset, | |
736 | fontfile, ffsubtype, stemV; | |
737 | GfxFont *gfont; | |
738 | fd_entry *fd; | |
739 | @@ -413,33 +376,49 @@ | |
740 | } | |
741 | // Only handle included Type1 (and Type1C) fonts; anything else will be copied. | |
742 | // Type1C fonts are replaced by Type1 fonts, if REPLACE_TYPE1C is true. | |
743 | - if (!fixedinclusioncopyfont && fontRef->fetch(xref, &fontdict)->isDict() | |
744 | - && fontdict->dictLookup("Subtype", &subtype)->isName() | |
745 | - && !strcmp(subtype->getName(), "Type1") | |
746 | - && fontdict->dictLookup("BaseFont", &basefont)->isName() | |
747 | - && fontdict->dictLookupNF("FontDescriptor", &fontdescRef)->isRef() | |
748 | - && fontdescRef->fetch(xref, &fontdesc)->isDict() | |
749 | - && (fontdesc->dictLookup("FontFile", &fontfile)->isStream() | |
750 | - || (REPLACE_TYPE1C | |
751 | - && fontdesc->dictLookup("FontFile3", &fontfile)->isStream() | |
752 | - && fontfile->streamGetDict()->lookup("Subtype", | |
753 | - &ffsubtype)->isName() | |
754 | - && !strcmp(ffsubtype->getName(), "Type1C"))) | |
755 | - && (fontmap = lookup_fontmap(basefont->getName())) != NULL) { | |
756 | + fontdict = fontRef->fetch(xref); | |
757 | + if (fontdict.isDict()) { | |
758 | + subtype = fontdict.dictLookup("Subtype"); | |
759 | + basefont = fontdict.dictLookup("BaseFont"); | |
760 | + fontdescRef = fontdict.dictLookupNF("FontDescriptor"); | |
761 | + if (fontdescRef.isRef()) { | |
762 | + fontdesc = fontdescRef.fetch(xref); | |
763 | + if (fontdesc.isDict()) { | |
764 | + fontfile = fontdesc.dictLookup("FontFile"); | |
765 | + if (!fontfile.isStream() && REPLACE_TYPE1C) { | |
766 | + fontfile = fontdesc.dictLookup("FontFile3"); | |
767 | + ffsubtype = fontfile.streamGetDict()->lookup("Subtype"); | |
768 | + if (!(ffsubtype.isName() && !strcmp(ffsubtype.getName(), "Type1C"))) { | |
769 | + // not a Type1-C font. | |
770 | + fontfile = Object(objNull); | |
771 | + } | |
772 | + } | |
773 | + } | |
774 | + } | |
775 | + } | |
776 | + if (!fixedinclusioncopyfont && fontdict.isDict() | |
777 | + && subtype.isName() | |
778 | + && !strcmp(subtype.getName(), "Type1") | |
779 | + && basefont.isName() | |
780 | + && fontdescRef.isRef() | |
781 | + && fontdesc.isDict() | |
782 | + && fontfile.isStream() | |
783 | + && (fontmap = lookup_fontmap(basefont.getName())) != NULL) { | |
784 | // round /StemV value, since the PDF input is a float | |
785 | // (see Font Descriptors in PDF reference), but we only store an | |
786 | // integer, since we don't want to change the struct. | |
787 | - fontdesc->dictLookup("StemV", &stemV); | |
788 | - fd = epdf_create_fontdescriptor(fontmap, zround(stemV->getNum())); | |
789 | - if (fontdesc->dictLookup("CharSet", &charset) && | |
790 | - charset->isString() && is_subsetable(fontmap)) | |
791 | - epdf_mark_glyphs(fd, charset->getString()->getCString()); | |
792 | + stemV = fontdesc.dictLookup("StemV"); | |
793 | + fd = epdf_create_fontdescriptor(fontmap, zround(stemV.getNum())); | |
794 | + charset = fontdesc.dictLookup("CharSet"); | |
795 | + if (!charset.isNull() && | |
796 | + charset.isString() && is_subsetable(fontmap)) | |
797 | + epdf_mark_glyphs(fd, charset.getString()->getCString()); | |
798 | else | |
799 | embed_whole_font(fd); | |
800 | - addFontDesc(fontdescRef->getRef(), fd); | |
801 | + addFontDesc(fontdescRef.getRef(), fd); | |
802 | copyName(tag); | |
803 | gfont = GfxFont::makeFont(xref, tag, fontRef->getRef(), | |
804 | - fontdict->getDict()); | |
805 | + fontdict.getDict()); | |
806 | pdf_printf(" %d 0 R ", addFont(fontRef->getRef(), fd, | |
807 | addEncoding(gfont))); | |
808 | } else { | |
809 | @@ -451,24 +430,24 @@ | |
810 | ||
811 | static void copyFontResources(Object * obj) | |
812 | { | |
813 | - PdfObject fontRef; | |
814 | + Object fontRef; | |
815 | int i, l; | |
816 | if (!obj->isDict()) | |
817 | pdftex_fail("PDF inclusion: invalid font resources dict type <%s>", | |
818 | obj->getTypeName()); | |
819 | pdf_puts("/Font << "); | |
820 | for (i = 0, l = obj->dictGetLength(); i < l; ++i) { | |
821 | - obj->dictGetValNF(i, &fontRef); | |
822 | - if (fontRef->isRef()) | |
823 | + fontRef = obj->dictGetValNF(i); | |
824 | + if (fontRef.isRef()) | |
825 | copyFont(obj->dictGetKey(i), &fontRef); | |
826 | - else if (fontRef->isDict()) { // some programs generate pdf with embedded font object | |
827 | + else if (fontRef.isDict()) { // some programs generate pdf with embedded font object | |
828 | copyName(obj->dictGetKey(i)); | |
829 | pdf_puts(" "); | |
830 | copyObject(&fontRef); | |
831 | } | |
832 | else | |
833 | pdftex_fail("PDF inclusion: invalid font in reference type <%s>", | |
834 | - fontRef->getTypeName()); | |
835 | + fontRef.getTypeName()); | |
836 | } | |
837 | pdf_puts(">>\n"); | |
838 | } | |
839 | @@ -557,7 +536,7 @@ | |
840 | ||
841 | static void copyObject(Object * obj) | |
842 | { | |
843 | - PdfObject obj1; | |
844 | + Object obj1; | |
845 | int i, l, c; | |
846 | Ref ref; | |
847 | char *p; | |
848 | @@ -601,8 +580,8 @@ | |
849 | } else if (obj->isArray()) { | |
850 | pdf_puts("["); | |
851 | for (i = 0, l = obj->arrayGetLength(); i < l; ++i) { | |
852 | - obj->arrayGetNF(i, &obj1); | |
853 | - if (!obj1->isName()) | |
854 | + obj1 = obj->arrayGetNF(i); | |
855 | + if (!obj1.isName()) | |
856 | pdf_puts(" "); | |
857 | copyObject(&obj1); | |
858 | } | |
859 | @@ -612,7 +591,7 @@ | |
860 | copyDict(obj); | |
861 | pdf_puts(">>"); | |
862 | } else if (obj->isStream()) { | |
863 | - initDictFromDict(obj1, obj->streamGetDict()); | |
864 | + obj1 = Object(obj->streamGetDict()); | |
865 | pdf_puts("<<\n"); | |
866 | copyDict(&obj1); | |
867 | pdf_puts(">>\n"); | |
868 | @@ -638,9 +617,8 @@ | |
869 | InObj *r; | |
870 | for (r = inObjList; r != 0; r = r->next) { | |
871 | if (!r->written) { | |
872 | - Object obj1; | |
873 | r->written = 1; | |
874 | - xref->fetch(r->ref.num, r->ref.gen, &obj1); | |
875 | + Object obj1 = xref->fetch(r->ref.num, r->ref.gen); | |
876 | if (r->type == objFont) { | |
877 | assert(!obj1.isStream()); | |
878 | pdfbeginobj(r->num, 2); // \pdfobjcompresslevel = 2 is for this | |
879 | @@ -656,7 +634,6 @@ | |
880 | pdf_puts("\n"); | |
881 | pdfendobj(); | |
882 | } | |
883 | - obj1.free(); | |
884 | } | |
885 | } | |
886 | } | |
887 | @@ -839,8 +816,8 @@ | |
888 | Page *page; | |
889 | Ref *pageRef; | |
890 | Dict *pageDict; | |
891 | - PdfObject contents, obj1, obj2, pageObj, dictObj; | |
892 | - PdfObject groupDict; | |
893 | + Object contents, obj1, obj2, pageObj, dictObj; | |
894 | + Object groupDict; | |
895 | bool writeSepGroup = false; | |
896 | Object info; | |
897 | char *key; | |
898 | @@ -867,8 +844,8 @@ | |
899 | encodingList = 0; | |
900 | page = pdf_doc->doc->getCatalog()->getPage(epdf_selected_page); | |
901 | pageRef = pdf_doc->doc->getCatalog()->getPageRef(epdf_selected_page); | |
902 | - xref->fetch(pageRef->num, pageRef->gen, &pageObj); | |
903 | - pageDict = pageObj->getDict(); | |
904 | + pageObj = xref->fetch(pageRef->num, pageRef->gen); | |
905 | + pageDict = pageObj.getDict(); | |
906 | rotate = page->getRotate(); | |
907 | PDFRectangle *pagebox; | |
908 | // write the Page header | |
909 | @@ -886,7 +863,7 @@ | |
910 | pdf_printf("/%s.PageNumber %i\n", pdfkeyprefix, (int) epdf_selected_page); | |
911 | } | |
912 | if ((suppress_ptex_info & MASK_SUPPRESS_PTEX_INFODICT) == 0) { | |
913 | - pdf_doc->doc->getDocInfoNF(&info); | |
914 | + info = pdf_doc->doc->getDocInfoNF(); | |
915 | if (info.isRef()) { | |
916 | // the info dict must be indirect (PDF Ref p. 61) | |
917 | pdf_printf("/%s.InfoDict ", pdfkeyprefix); | |
918 | @@ -942,14 +919,14 @@ | |
919 | pdf_puts(stripzeros(s)); | |
920 | ||
921 | // Metadata validity check (as a stream it must be indirect) | |
922 | - pageDict->lookupNF("Metadata", &dictObj); | |
923 | - if (!dictObj->isNull() && !dictObj->isRef()) | |
924 | + dictObj = pageDict->lookupNF("Metadata"); | |
925 | + if (!dictObj.isNull() && !dictObj.isRef()) | |
926 | pdftex_warn("PDF inclusion: /Metadata must be indirect object"); | |
927 | ||
928 | // copy selected items in Page dictionary except Resources & Group | |
929 | for (i = 0; pageDictKeys[i] != NULL; i++) { | |
930 | - pageDict->lookupNF(pageDictKeys[i], &dictObj); | |
931 | - if (!dictObj->isNull()) { | |
932 | + dictObj = pageDict->lookupNF(pageDictKeys[i]); | |
933 | + if (!dictObj.isNull()) { | |
934 | pdf_newline(); | |
935 | pdf_printf("/%s ", pageDictKeys[i]); | |
936 | copyObject(&dictObj); // preserves indirection | |
937 | @@ -957,8 +934,8 @@ | |
938 | } | |
939 | ||
940 | // handle page group | |
941 | - pageDict->lookupNF("Group", &dictObj); | |
942 | - if (!dictObj->isNull()) { | |
943 | + dictObj = pageDict->lookupNF("Group"); | |
944 | + if (!dictObj.isNull()) { | |
945 | if (pdfpagegroupval == 0) { | |
946 | // another pdf with page group was included earlier on the | |
947 | // same page; copy the Group entry as is. See manual for | |
948 | @@ -972,11 +949,11 @@ | |
949 | copyObject(&dictObj); | |
950 | } else { | |
951 | // write Group dict as a separate object, since the Page dict also refers to it | |
952 | - pageDict->lookup("Group", &dictObj); | |
953 | - if (!dictObj->isDict()) | |
954 | + dictObj = pageDict->lookup("Group"); | |
955 | + if (!dictObj.isDict()) | |
956 | pdftex_fail("PDF inclusion: /Group dict missing"); | |
957 | writeSepGroup = true; | |
958 | - initDictFromDict(groupDict, page->getGroup()); | |
959 | + groupDict = Object(page->getGroup()); | |
960 | pdf_printf("/Group %ld 0 R\n", (long)pdfpagegroupval); | |
961 | } | |
962 | } | |
963 | @@ -989,15 +966,15 @@ | |
964 | pdftex_warn | |
965 | ("PDF inclusion: /Resources missing. 'This practice is not recommended' (PDF Ref)"); | |
966 | } else { | |
967 | - initDictFromDict(obj1, page->getResourceDict()); | |
968 | - if (!obj1->isDict()) | |
969 | + obj1 = Object(page->getResourceDict()); | |
970 | + if (!obj1.isDict()) | |
971 | pdftex_fail("PDF inclusion: invalid resources dict type <%s>", | |
972 | - obj1->getTypeName()); | |
973 | + obj1.getTypeName()); | |
974 | pdf_newline(); | |
975 | pdf_puts("/Resources <<\n"); | |
976 | - for (i = 0, l = obj1->dictGetLength(); i < l; ++i) { | |
977 | - obj1->dictGetVal(i, &obj2); | |
978 | - key = obj1->dictGetKey(i); | |
979 | + for (i = 0, l = obj1.dictGetLength(); i < l; ++i) { | |
980 | + obj2 = obj1.dictGetVal(i); | |
981 | + key = obj1.dictGetKey(i); | |
982 | if (strcmp("Font", key) == 0) | |
983 | copyFontResources(&obj2); | |
984 | else if (strcmp("ProcSet", key) == 0) | |
985 | @@ -1009,8 +986,8 @@ | |
986 | } | |
987 | ||
988 | // write the page contents | |
989 | - page->getContents(&contents); | |
990 | - if (contents->isStream()) { | |
991 | + contents = page->getContents(); | |
992 | + if (contents.isStream()) { | |
993 | ||
994 | // Variant A: get stream and recompress under control | |
995 | // of \pdfcompresslevel | |
996 | @@ -1021,36 +998,35 @@ | |
997 | ||
998 | // Variant B: copy stream without recompressing | |
999 | // | |
1000 | - contents->streamGetDict()->lookup("F", &obj1); | |
1001 | - if (!obj1->isNull()) { | |
1002 | + obj1 = contents.streamGetDict()->lookup("F"); | |
1003 | + if (!obj1.isNull()) { | |
1004 | pdftex_fail("PDF inclusion: Unsupported external stream"); | |
1005 | } | |
1006 | - contents->streamGetDict()->lookup("Length", &obj1); | |
1007 | - assert(!obj1->isNull()); | |
1008 | + obj1 = contents.streamGetDict()->lookup("Length"); | |
1009 | + assert(!obj1.isNull()); | |
1010 | pdf_puts("/Length "); | |
1011 | copyObject(&obj1); | |
1012 | pdf_puts("\n"); | |
1013 | - contents->streamGetDict()->lookup("Filter", &obj1); | |
1014 | - if (!obj1->isNull()) { | |
1015 | + obj1 = contents.streamGetDict()->lookup("Filter"); | |
1016 | + if (!obj1.isNull()) { | |
1017 | pdf_puts("/Filter "); | |
1018 | copyObject(&obj1); | |
1019 | pdf_puts("\n"); | |
1020 | - contents->streamGetDict()->lookup("DecodeParms", &obj1); | |
1021 | - if (!obj1->isNull()) { | |
1022 | + obj1 = contents.streamGetDict()->lookup("DecodeParms"); | |
1023 | + if (!obj1.isNull()) { | |
1024 | pdf_puts("/DecodeParms "); | |
1025 | copyObject(&obj1); | |
1026 | pdf_puts("\n"); | |
1027 | } | |
1028 | } | |
1029 | pdf_puts(">>\nstream\n"); | |
1030 | - copyStream(contents->getStream()->getUndecodedStream()); | |
1031 | + copyStream(contents.getStream()->getUndecodedStream()); | |
1032 | pdfendstream(); | |
1033 | - } else if (contents->isArray()) { | |
1034 | + } else if (contents.isArray()) { | |
1035 | pdfbeginstream(); | |
1036 | - for (i = 0, l = contents->arrayGetLength(); i < l; ++i) { | |
1037 | - Object contentsobj; | |
1038 | - copyStream((contents->arrayGet(i, &contentsobj))->getStream()); | |
1039 | - contentsobj.free(); | |
1040 | + for (i = 0, l = contents.arrayGetLength(); i < l; ++i) { | |
1041 | + Object contentsobj = contents.arrayGet(i); | |
1042 | + copyStream(contentsobj.getStream()); | |
1043 | if (i < l - 1) | |
1044 | pdf_newline(); // add a newline after each stream except the last | |
1045 | } | |
1046 | diff -ur source.orig/texk/web2c/pdftexdir/pdftosrc.cc source/texk/web2c/pdftexdir/pdftosrc.cc | |
1047 | --- source.orig/texk/web2c/pdftexdir/pdftosrc.cc 2017-06-16 21:49:09.297190679 +0200 | |
1048 | +++ source/texk/web2c/pdftexdir/pdftosrc.cc 2017-09-19 09:48:19.661355046 +0200 | |
1049 | @@ -86,22 +86,20 @@ | |
1050 | objgen = atoi(argv[3]); | |
1051 | } | |
1052 | xref = doc->getXRef(); | |
1053 | - catalogDict.initNull(); | |
1054 | - xref->getCatalog(&catalogDict); | |
1055 | + catalogDict = xref->getCatalog(); | |
1056 | if (!catalogDict.isDict("Catalog")) { | |
1057 | fprintf(stderr, "No Catalog found\n"); | |
1058 | exit(1); | |
1059 | } | |
1060 | - srcStream.initNull(); | |
1061 | + srcStream = Object(objNull); | |
1062 | if (objnum == 0) { | |
1063 | - catalogDict.dictLookup("SourceObject", &srcStream); | |
1064 | + srcStream = catalogDict.dictLookup("SourceObject"); | |
1065 | static char const_SourceFile[] = "SourceFile"; | |
1066 | if (!srcStream.isStream(const_SourceFile)) { | |
1067 | fprintf(stderr, "No SourceObject found\n"); | |
1068 | exit(1); | |
1069 | } | |
1070 | - srcName.initNull(); | |
1071 | - srcStream.getStream()->getDict()->lookup("SourceName", &srcName); | |
1072 | + srcName = srcStream.getStream()->getDict()->lookup("SourceName"); | |
1073 | if (!srcName.isString()) { | |
1074 | fprintf(stderr, "No SourceName found\n"); | |
1075 | exit(1); | |
1076 | @@ -110,7 +108,7 @@ | |
1077 | // We cannot free srcName, as objname shares its string. | |
1078 | // srcName.free(); | |
1079 | } else if (objnum > 0) { | |
1080 | - xref->fetch(objnum, objgen, &srcStream); | |
1081 | + srcStream = xref->fetch(objnum, objgen); | |
1082 | if (!srcStream.isStream()) { | |
1083 | fprintf(stderr, "Not a Stream object\n"); | |
1084 | exit(1); | |
1085 | @@ -159,29 +157,26 @@ | |
1086 | int localOffset = 0; | |
1087 | Guint firstOffset; | |
1088 | ||
1089 | - assert(xref->fetch(e->offset, 0, &objStr)->isStream()); | |
1090 | - nObjects = objStr.streamGetDict()->lookup("N", &obj1)->getInt(); | |
1091 | - obj1.free(); | |
1092 | - first = objStr.streamGetDict()->lookup("First", &obj1)->getInt(); | |
1093 | - obj1.free(); | |
1094 | + objStr = xref->fetch(e->offset, 0); | |
1095 | + assert(objStr.isStream()); | |
1096 | + obj1 = objStr.streamGetDict()->lookup("N"); | |
1097 | + nObjects = obj1.getInt(); | |
1098 | + obj1 = objStr.streamGetDict()->lookup("First"); | |
1099 | + first = obj1.getInt(); | |
1100 | firstOffset = objStr.getStream()->getBaseStream()->getStart() + first; | |
1101 | ||
1102 | // parse the header: object numbers and offsets | |
1103 | objStr.streamReset(); | |
1104 | - obj1.initNull(); | |
1105 | - str = new EmbedStream(objStr.getStream(), &obj1, gTrue, first); | |
1106 | + str = new EmbedStream(objStr.getStream(), Object(objNull), gTrue, first); | |
1107 | parser = new Parser(xref, new Lexer(xref, str), gFalse); | |
1108 | for (n = 0; n < nObjects; ++n) { | |
1109 | - parser->getObj(&obj1); | |
1110 | - parser->getObj(&obj2); | |
1111 | + obj1 = parser->getObj(); | |
1112 | + obj2 = parser->getObj(); | |
1113 | if (n == e->gen) | |
1114 | localOffset = obj2.getInt(); | |
1115 | - obj1.free(); | |
1116 | - obj2.free(); | |
1117 | } | |
1118 | while (str->getChar() != EOF) ; | |
1119 | delete parser; | |
1120 | - objStr.free(); | |
1121 | ||
1122 | fprintf(outfile, "%.10lu 00000 n\n", | |
1123 | (long unsigned)(firstOffset + localOffset)); | |
1124 | @@ -192,7 +187,6 @@ | |
1125 | s->reset(); | |
1126 | while ((c = s->getChar()) != EOF) | |
1127 | fputc(c, outfile); | |
1128 | - srcStream.free(); | |
1129 | } | |
1130 | if (objnum == 0) | |
1131 | fprintf(stderr, "Source file extracted to %s\n", outname); | |
1132 | @@ -201,7 +195,6 @@ | |
1133 | else | |
1134 | fprintf(stderr, "Cross-reference table extracted to %s\n", outname); | |
1135 | fclose(outfile); | |
1136 | - catalogDict.free(); | |
1137 | delete doc; | |
1138 | delete globalParams; | |
1139 | } |