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