texlive[55887] Build/source/texk/dvipdfm-x: support forward reference
commits+kakuto at tug.org
commits+kakuto at tug.org
Mon Jul 20 22:56:58 CEST 2020
Revision: 55887
http://tug.org/svn/texlive?view=revision&revision=55887
Author: kakuto
Date: 2020-07-20 22:56:58 +0200 (Mon, 20 Jul 2020)
Log Message:
-----------
support forward reference of image objects (S. Hirata)
Modified Paths:
--------------
trunk/Build/source/texk/dvipdfm-x/ChangeLog
trunk/Build/source/texk/dvipdfm-x/configure
trunk/Build/source/texk/dvipdfm-x/configure.ac
trunk/Build/source/texk/dvipdfm-x/pdfdoc.c
trunk/Build/source/texk/dvipdfm-x/pdfdoc.h
trunk/Build/source/texk/dvipdfm-x/pdfnames.c
trunk/Build/source/texk/dvipdfm-x/pdfnames.h
trunk/Build/source/texk/dvipdfm-x/pdfobj.c
trunk/Build/source/texk/dvipdfm-x/pdfximage.c
trunk/Build/source/texk/dvipdfm-x/pdfximage.h
trunk/Build/source/texk/dvipdfm-x/spc_dvips.c
trunk/Build/source/texk/dvipdfm-x/spc_html.c
trunk/Build/source/texk/dvipdfm-x/spc_misc.c
trunk/Build/source/texk/dvipdfm-x/spc_pdfm.c
trunk/Build/source/texk/dvipdfm-x/specials.c
Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog 2020-07-20 20:56:58 UTC (rev 55887)
@@ -1,3 +1,12 @@
+2020-07-21 Shunsaku Hirata <shunsaku.hirata74 at gmail.com>
+
+ * pdfdoc.[ch], pdfnames.[ch], pdfobj.c, pdfximage.[ch],
+ spc_dvips.c, spc_html.c, spc_misc.c, spc_pdfm.c, specials.c:
+ "Forward reference" of image objects is also supported.
+ Object reference by name is now available globally but not
+ only for the "special" module.
+ * configure.ac: Version 20200721.
+
2020-07-19 Shunsaku Hirata <shunsaku.hirata74 at gmail.com>
* pdfdraw.c: Avoid invoking gs operation for an empty ExtGState.
Modified: trunk/Build/source/texk/dvipdfm-x/configure
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/configure 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/configure 2020-07-20 20:56:58 UTC (rev 55887)
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20200711.
+# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20200721.
#
# Report bugs to <dvipdfmx at tug.org>.
#
@@ -590,8 +590,8 @@
# Identity of this package.
PACKAGE_NAME='dvipdfm-x (TeX Live)'
PACKAGE_TARNAME='dvipdfm-x--tex-live-'
-PACKAGE_VERSION='20200711'
-PACKAGE_STRING='dvipdfm-x (TeX Live) 20200711'
+PACKAGE_VERSION='20200721'
+PACKAGE_STRING='dvipdfm-x (TeX Live) 20200721'
PACKAGE_BUGREPORT='dvipdfmx at tug.org'
PACKAGE_URL=''
@@ -1350,7 +1350,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures dvipdfm-x (TeX Live) 20200711 to adapt to many kinds of systems.
+\`configure' configures dvipdfm-x (TeX Live) 20200721 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1421,7 +1421,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20200711:";;
+ short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20200721:";;
esac
cat <<\_ACEOF
@@ -1551,7 +1551,7 @@
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-dvipdfm-x (TeX Live) configure 20200711
+dvipdfm-x (TeX Live) configure 20200721
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2390,7 +2390,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by dvipdfm-x (TeX Live) $as_me 20200711, which was
+It was created by dvipdfm-x (TeX Live) $as_me 20200721, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -8077,7 +8077,7 @@
# Define the identity of the package.
PACKAGE='dvipdfm-x--tex-live-'
- VERSION='20200711'
+ VERSION='20200721'
cat >>confdefs.h <<_ACEOF
@@ -14746,7 +14746,7 @@
Report bugs to <bug-libtool at gnu.org>."
lt_cl_version="\
-dvipdfm-x (TeX Live) config.lt 20200711
+dvipdfm-x (TeX Live) config.lt 20200721
configured by $0, generated by GNU Autoconf 2.69.
Copyright (C) 2011 Free Software Foundation, Inc.
@@ -16636,7 +16636,7 @@
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by dvipdfm-x (TeX Live) $as_me 20200711, which was
+This file was extended by dvipdfm-x (TeX Live) $as_me 20200721, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -16706,7 +16706,7 @@
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-dvipdfm-x (TeX Live) config.status 20200711
+dvipdfm-x (TeX Live) config.status 20200721
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Modified: trunk/Build/source/texk/dvipdfm-x/configure.ac
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/configure.ac 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/configure.ac 2020-07-20 20:56:58 UTC (rev 55887)
@@ -8,7 +8,7 @@
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl
-AC_INIT([dvipdfm-x (TeX Live)], [20200711], [dvipdfmx at tug.org])
+AC_INIT([dvipdfm-x (TeX Live)], [20200721], [dvipdfmx at tug.org])
AC_PREREQ([2.65])
AC_CONFIG_SRCDIR([agl.c])
AC_CONFIG_AUX_DIR([../../build-aux])
Modified: trunk/Build/source/texk/dvipdfm-x/pdfdoc.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdfdoc.c 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/pdfdoc.c 2020-07-20 20:56:58 UTC (rev 55887)
@@ -99,7 +99,7 @@
}
MFCLOSE(fp);
- xobj_id = pdf_ximage_findresource(thumb_filename, options);
+ xobj_id = pdf_ximage_load_image(thumb_filename, thumb_filename, options);
if (xobj_id < 0) {
WARN("Could not read thumbnail file \"%s\".", thumb_filename);
image_ref = NULL;
@@ -110,6 +110,8 @@
return image_ref;
}
+/* Sorry no appropriate place to put this... */
+struct ht_table *global_names = NULL;
typedef struct pdf_form
{
@@ -2561,6 +2563,9 @@
pdf_init_device(settings.device.dvi2pts, settings.device.precision,
settings.device.ignore_colors);
+
+ global_names = pdf_new_name_tree();
+
return;
}
@@ -2569,6 +2574,8 @@
{
pdf_doc *p = &pdoc;
+ pdf_delete_name_tree(&global_names);
+
pdf_close_device();
/*
@@ -2704,10 +2711,12 @@
info.bbox.urx = cropbox->urx;
info.bbox.ury = cropbox->ury;
- /* Use reference since content itself isn't available yet. */
+ /* Use reference since content itself isn't available yet.
+ * - 2020/07/21 Changed... "forward reference" support requires object itself.
+ */
xobj_id = pdf_ximage_defineresource(ident,
PDF_XOBJECT_TYPE_FORM,
- &info, pdf_ref_obj(form->contents));
+ &info, pdf_link_obj(form->contents));
p->pending_forms = fnode;
Modified: trunk/Build/source/texk/dvipdfm-x/pdfdoc.h
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdfdoc.h 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/pdfdoc.h 2020-07-20 20:56:58 UTC (rev 55887)
@@ -1,6 +1,6 @@
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2007-2020 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team.
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -164,4 +164,7 @@
#include "pdfcolor.h"
extern void pdf_doc_set_bgcolor(const pdf_color *color);
+/* Sorry no appropriate place to put this... */
+extern struct ht_table *global_names;
+
#endif /* _PDFDOC_H_ */
Modified: trunk/Build/source/texk/dvipdfm-x/pdfnames.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdfnames.c 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/pdfnames.c 2020-07-20 20:56:58 UTC (rev 55887)
@@ -1,6 +1,6 @@
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team.
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -44,6 +44,7 @@
struct obj_data
{
+ pdf_obj *reference;
pdf_obj *object;
int closed; /* 1 if object is closed */
};
@@ -80,9 +81,13 @@
value = (struct obj_data *) hval;
+ if (value->reference) {
+ pdf_release_obj(value->reference);
+ value->reference = NULL;
+ }
if (value->object) {
pdf_release_obj(value->object);
- value->object = NULL;
+ value->object = NULL;
}
RELEASE(value);
@@ -114,11 +119,10 @@
key = ht_iter_getkey(&iter, &keylen);
value = ht_iter_getval(&iter);
- ASSERT(value->object);
if (PDF_OBJ_UNDEFINED(value->object)) {
- pdf_names_add_object(ht_tab, key, keylen, pdf_new_null());
- WARN("Object @%s used, but not defined. Replaced by null.",
- printable_key(key, keylen));
+ pdf_names_add_object(ht_tab, key, keylen, pdf_new_null());
+ WARN("Object @%s used, but not defined. Replaced by null.",
+ printable_key(key, keylen));
}
} while (ht_iter_next(&iter) >= 0);
ht_clear_iter(&iter);
@@ -138,8 +142,7 @@
}
int
-pdf_names_add_object (struct ht_table *names,
- const void *key, int keylen, pdf_obj *object)
+pdf_names_add_object (struct ht_table *names, const void *key, int keylen, pdf_obj *object)
{
struct obj_data *value;
@@ -154,11 +157,11 @@
if (!value) {
value = NEW(1, struct obj_data);
value->object = object;
+ value->reference = NULL;
value->closed = 0;
ht_append_table(names, key, keylen, value);
} else {
- ASSERT(value->object);
- if (PDF_OBJ_UNDEFINED(value->object)) {
+ if (value->object && PDF_OBJ_UNDEFINED(value->object)) {
pdf_transfer_label(object, value->object);
pdf_release_obj(value->object);
value->object = object;
@@ -172,15 +175,49 @@
return 0;
}
+pdf_obj *
+pdf_names_reserve (struct ht_table *names, const void *key, int keylen)
+{
+ pdf_obj *obj_ref = NULL;
+ struct obj_data *value;
+
+ ASSERT(names);
+
+ if (!key || keylen < 1) {
+ WARN("Null string used for name tree key.");
+ return NULL;
+ }
+
+ value = ht_lookup_table(names, key, keylen);
+ if (!value) {
+ value = NEW(1, struct obj_data);
+ value->object = pdf_new_undefined();
+ value->reference = NULL;
+ value->closed = 0;
+ ht_append_table(names, key, keylen, value);
+ obj_ref = pdf_ref_obj(value->object);
+ } else {
+ if (value->object && PDF_OBJ_UNDEFINED(value->object)) {
+ if (!value->reference)
+ value->reference = pdf_ref_obj(value->object);
+ obj_ref = pdf_link_obj(value->reference);
+ } else {
+ WARN("Object @%s already defined.", printable_key(key, keylen));
+ obj_ref = NULL;
+ }
+ }
+
+ return obj_ref;
+}
+
/*
* The following routine returns copies, not the original object.
*/
pdf_obj *
-pdf_names_lookup_reference (struct ht_table *names,
- const void *key, int keylen)
+pdf_names_lookup_reference (struct ht_table *names, const void *key, int keylen)
{
struct obj_data *value;
- pdf_obj *object;
+ pdf_obj *obj_ref;
ASSERT(names);
@@ -187,23 +224,22 @@
value = ht_lookup_table(names, key, keylen);
if (value) {
- object = value->object;
- ASSERT(object);
+ if (!value->reference)
+ value->reference = pdf_ref_obj(value->object);
+ obj_ref = pdf_link_obj(value->reference);
} else {
/* A null object as dummy would create problems because as value
* of a dictionary entry, a null object is be equivalent to no entry
* at all. This matters for optimization of PDF destinations.
*/
- object = pdf_new_undefined();
- pdf_names_add_object(names, key, keylen, object);
+ obj_ref = pdf_names_reserve(names, key, keylen);
}
- return pdf_ref_obj(object);
+ return obj_ref;
}
pdf_obj *
-pdf_names_lookup_object (struct ht_table *names,
- const void *key, int keylen)
+pdf_names_lookup_object (struct ht_table *names, const void *key, int keylen)
{
struct obj_data *value;
@@ -212,14 +248,14 @@
value = ht_lookup_table(names, key, keylen);
if (!value || PDF_OBJ_UNDEFINED(value->object))
return NULL;
- ASSERT(value->object);
+ if (value->closed)
+ WARN("Object \"%s\" already closed.", printable_key(key, keylen));
return value->object;
}
int
-pdf_names_close_object (struct ht_table *names,
- const void *key, int keylen)
+pdf_names_close_object (struct ht_table *names, const void *key, int keylen)
{
struct obj_data *value;
@@ -237,6 +273,8 @@
return -1;
}
+ pdf_release_obj(value->object);
+ value->object = NULL;
value->closed = 1;
return 0;
Modified: trunk/Build/source/texk/dvipdfm-x/pdfnames.h
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdfnames.h 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/pdfnames.h 2020-07-20 20:56:58 UTC (rev 55887)
@@ -1,6 +1,6 @@
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team.
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -32,7 +32,7 @@
extern void pdf_delete_name_tree (struct ht_table **names);
extern int pdf_names_add_object (struct ht_table *names,
- const void *key, int keylen, pdf_obj *object);
+ const void *key, int keylen, pdf_obj *object);
extern pdf_obj *pdf_names_lookup_reference (struct ht_table *names,
const void *key, int keylen);
extern pdf_obj *pdf_names_lookup_object (struct ht_table *names,
@@ -39,7 +39,8 @@
const void *key, int keylen);
extern int pdf_names_close_object (struct ht_table *names,
const void *key, int keylen);
-
+extern pdf_obj *pdf_names_reserve (struct ht_table *names,
+ const void *key, int keylen);
/* Really create name tree... */
extern pdf_obj *pdf_names_create_tree (struct ht_table *names,
int *count,
Modified: trunk/Build/source/texk/dvipdfm-x/pdfobj.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdfobj.c 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/pdfobj.c 2020-07-20 20:56:58 UTC (rev 55887)
@@ -4268,7 +4268,9 @@
{
int r = 0;
- if (!obj1 && obj2) {
+ if (!obj1 && !obj2) {
+ return 0;
+ } else if (!obj1 && obj2) {
return 1;
} else if (obj1 && !obj2) {
return 1;
Modified: trunk/Build/source/texk/dvipdfm-x/pdfximage.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdfximage.c 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/pdfximage.c 2020-07-20 20:56:58 UTC (rev 55887)
@@ -37,6 +37,8 @@
#include "pdfdoc.h"
#include "pdfdev.h"
#include "pdfdraw.h"
+#include "pdfnames.h"
+#include "specials.h"
#include "epdf.h"
#include "mpost.h"
@@ -90,9 +92,11 @@
struct attr_ attr;
char *filename;
+ char *fullname;
pdf_obj *reference;
pdf_obj *resource;
+ int reserved;
};
@@ -120,12 +124,14 @@
pdf_init_ximage_struct (pdf_ximage *I)
{
I->ident = NULL;
- I->filename = NULL;
+ I->filename = NULL;
+ I->fullname = NULL;
I->subtype = -1;
memset(I->res_name, 0, 16);
I->reference = NULL;
I->resource = NULL;
+ I->reserved = 0;
I->attr.width = I->attr.height = 0;
I->attr.xdensity = I->attr.ydensity = 1.0;
@@ -141,12 +147,12 @@
}
static void
-pdf_set_ximage_tempfile (pdf_ximage *I, const char *filename)
+pdf_set_ximage_tempfile (pdf_ximage *I, const char *fullname)
{
- if (I->filename)
- RELEASE(I->filename);
- I->filename = NEW(strlen(filename)+1, char);
- strcpy(I->filename, filename);
+ if (I->fullname)
+ RELEASE(I->fullname);
+ I->fullname = NEW(strlen(fullname)+1, char);
+ strcpy(I->fullname, fullname);
I->attr.tempfile = 1;
}
@@ -157,6 +163,8 @@
RELEASE(I->ident);
if (I->filename)
RELEASE(I->filename);
+ if (I->fullname)
+ RELEASE(I->fullname);
if (I->reference)
pdf_release_obj(I->reference);
if (I->resource)
@@ -196,8 +204,8 @@
if (dpx_conf.verbose_level > 1 &&
dpx_conf.file.keep_cache != 1)
MESG("pdf_image>> deleting temporary file \"%s\"\n", I->filename);
- dpx_delete_temp_file(I->filename, false); /* temporary filename freed here */
- I->filename = NULL;
+ dpx_delete_temp_file(I->fullname, false); /* temporary filename freed here */
+ I->fullname = NULL;
}
pdf_clean_ximage_struct(I);
}
@@ -253,28 +261,45 @@
}
static int
-load_image (const char *ident, const char *fullname, int format, FILE *fp,
+load_image (const char *ident, const char *filename, const char *fullname, int format, FILE *fp,
load_options options)
{
struct ic_ *ic = &_ic;
- int id = -1; /* ret */
+ int id = -1, reserved = 0;
pdf_ximage *I;
- id = ic->count;
- if (ic->count >= ic->capacity) {
- ic->capacity += 16;
- ic->ximages = RENEW(ic->ximages, ic->capacity, pdf_ximage);
- }
-
- I = &ic->ximages[id];
- pdf_init_ximage_struct(I);
if (ident) {
- I->ident = NEW(strlen(ident)+1, char);
- strcpy(I->ident, ident);
+ for (id = 0; id < ic->count; id++) {
+ I = &ic->ximages[id];
+ if (I->ident && !strcmp(ident, I->ident)) {
+ if (I->reserved) {
+ reserved = 1;
+ break;
+ }
+ }
+ }
}
+ if (!reserved) {
+ id = ic->count;
+ if (ic->count >= ic->capacity) {
+ ic->capacity += 16;
+ ic->ximages = RENEW(ic->ximages, ic->capacity, pdf_ximage);
+ }
+ I = &ic->ximages[id];
+ pdf_init_ximage_struct(I);
+ if (ident) {
+ I->ident = NEW(strlen(ident)+1, char);
+ strcpy(I->ident, ident);
+ }
+ ic->count++;
+ }
+ if (filename) {
+ I->filename = NEW(strlen(filename)+1, char);
+ strcpy(I->filename, filename);
+ }
if (fullname) {
- I->filename = NEW(strlen(fullname)+1, char);
- strcpy(I->filename, fullname);
+ I->fullname = NEW(strlen(fullname)+1, char);
+ strcpy(I->fullname, fullname);
}
I->attr.page_no = options.page_no;
@@ -352,8 +377,6 @@
goto error;
}
- ic->count++;
-
return id;
error:
@@ -371,30 +394,30 @@
#endif /* WIN32 */
int
-pdf_ximage_findresource (const char *ident, load_options options)
+pdf_ximage_load_image (const char *ident, const char *filename, load_options options)
{
struct ic_ *ic = &_ic;
- int id = -1;
+ int i, id = -1;
pdf_ximage *I;
char *fullname, *f = NULL;
int format;
FILE *fp;
- /* I don't understand why there is comparision against I->attr.dict here...
- * I->attr.dict and options.dict are simply pointers to PDF dictionaries.
- */
- for (id = 0; id < ic->count; id++) {
- I = &ic->ximages[id];
- if (I->ident && !strcmp(ident, I->ident)) {
- f = I->filename;
- if (I->attr.page_no == options.page_no /* Not sure */
- && I->attr.dict == options.dict /* ????? */
- && I->attr.bbox_type == options.bbox_type) {
- return id;
- }
- }
+ for (i = 0; i < ic->count; i++) {
+ I = &ic->ximages[i];
+ if (I->filename && !strcmp(filename, I->filename)) {
+ id = i;
+ break;
}
-
+ }
+ if (id >= 0) {
+ if (I->attr.page_no == options.page_no &&
+ !pdf_compare_object(I->attr.dict, options.dict) && /* ????? */
+ I->attr.bbox_type == options.bbox_type) {
+ return id;
+ }
+ f = I->filename;
+ }
if (f) {
/* we already have converted this file; f is the temporary file name */
fullname = NEW(strlen(f)+1, char);
@@ -404,13 +427,13 @@
#if defined(WIN32)
utf8name_failed = 0;
#endif /* WIN32 */
- fullname = dpx_find_file(ident, "_pic_", "");
+ fullname = dpx_find_file(filename, "_pic_", "");
#if defined(WIN32)
if (!fullname && file_system_codepage != win32_codepage) {
int tmpcp = file_system_codepage;
utf8name_failed = 1;
file_system_codepage = win32_codepage;
- fullname = dpx_find_file(ident, "_pic_", "");
+ fullname = dpx_find_file(filename, "_pic_", "");
file_system_codepage = tmpcp;
}
#endif /* WIN32 */
@@ -418,7 +441,6 @@
#if defined(WIN32)
utf8name_failed = 0;
#endif /* WIN32 */
- WARN("Error locating image file \"%s\"", ident);
return -1;
}
}
@@ -430,7 +452,7 @@
return -1;
}
if (dpx_conf.verbose_level > 0) {
- MESG("(Image:%s", ident);
+ MESG("(Image:%s", filename);
if (dpx_conf.verbose_level > 1)
MESG("[%s]", fullname);
}
@@ -440,7 +462,7 @@
case IMAGE_TYPE_MPS:
if (dpx_conf.verbose_level > 0)
MESG("[MPS]");
- id = mps_include_page(ident, fp);
+ id = mps_include_page(filename, fp);
if (id < 0) {
WARN("Try again with the distiller.");
format = IMAGE_TYPE_EPS;
@@ -448,7 +470,7 @@
} else
break;
default:
- id = load_image(ident, fullname, format, fp, options);
+ id = load_image(ident, filename, fullname, format, fp, options);
break;
}
dpx_fclose(fp);
@@ -459,11 +481,28 @@
MESG(")");
if (id < 0)
- WARN("pdf: image inclusion failed for \"%s\".", ident);
+ WARN("pdf: image inclusion failed for \"%s\".", filename);
return id;
}
+int
+pdf_ximage_findresource (const char *ident)
+{
+ struct ic_ *ic = &_ic;
+ int id = -1;
+ pdf_ximage *I;
+
+ for (id = 0; id < ic->count; id++) {
+ I = &ic->ximages[id];
+ if (I->ident && !strcmp(ident, I->ident)) {
+ return id;
+ }
+ }
+
+ return -1;
+}
+
/* Reference: PDF Reference 1.5 v6, pp.321--322
*
* TABLE 4.42 Additional entries specific to a type 1 form dictionary
@@ -552,8 +591,6 @@
I->attr.xdensity = info->xdensity;
I->attr.ydensity = info->ydensity;
- I->reference = pdf_ref_obj(resource);
-
dict = pdf_stream_dict(resource);
pdf_add_dict(dict, pdf_new_name("Type"), pdf_new_name("XObject"));
pdf_add_dict(dict, pdf_new_name("Subtype"), pdf_new_name("Image"));
@@ -565,6 +602,17 @@
if (I->attr.dict)
pdf_merge_dict(dict, I->attr.dict);
+ if (I->ident) {
+ pdf_names_add_object(global_names, I->ident, strlen(I->ident), pdf_link_obj(resource));
+ if (I->reference)
+ pdf_release_obj(I->reference);
+ /* Need to create object reference before closing it */
+ I->reference = pdf_names_lookup_reference(global_names, I->ident, strlen(I->ident));
+ pdf_names_close_object(global_names, I->ident, strlen(I->ident));
+ I->reserved = 0;
+ } else {
+ I->reference = pdf_ref_obj(resource);
+ }
pdf_release_obj(resource); /* Caller don't know we are using reference. */
I->resource = NULL;
}
@@ -594,8 +642,17 @@
I->attr.bbox.urx = max4(p1.x, p2.x, p3.x, p4.x);
I->attr.bbox.ury = max4(p1.y, p2.y, p3.y, p4.y);
- I->reference = pdf_ref_obj(resource);
-
+ if (I->ident) {
+ pdf_names_add_object(global_names, I->ident, strlen(I->ident), pdf_link_obj(resource));
+ if (I->reference)
+ pdf_release_obj(I->reference);
+ /* Need to create object reference before closing it */
+ I->reference = pdf_names_lookup_reference(global_names, I->ident, strlen(I->ident));
+ pdf_names_close_object(global_names, I->ident, strlen(I->ident));
+ I->reserved = 0;
+ } else {
+ I->reference = pdf_ref_obj(resource);
+ }
pdf_release_obj(resource); /* Caller don't know we are using reference. */
I->resource = NULL;
}
@@ -622,7 +679,7 @@
CHECK_ID(ic, id);
I = GET_IMAGE(ic, id);
- if (!I->reference)
+ if (!I->reference && I->resource)
I->reference = pdf_ref_obj(I->resource);
return pdf_link_obj(I->reference);
@@ -634,22 +691,33 @@
int subtype, void *info, pdf_obj *resource)
{
struct ic_ *ic = &_ic;
- int id;
+ int id, reserved = 0;
pdf_ximage *I;
- id = ic->count;
- if (ic->count >= ic->capacity) {
- ic->capacity += 16;
- ic->ximages = RENEW(ic->ximages, ic->capacity, pdf_ximage);
+ if (ident) {
+ for (id = 0; id < ic->count; id++) {
+ I = &ic->ximages[id];
+ if (I->ident && !strcmp(ident, I->ident) && I->reserved) {
+ reserved = 1;
+ break;
+ }
+ }
}
- I = &ic->ximages[id];
+ if (!reserved) {
+ id = ic->count;
+ if (ic->count >= ic->capacity) {
+ ic->capacity += 16;
+ ic->ximages = RENEW(ic->ximages, ic->capacity, pdf_ximage);
+ }
+ I = &ic->ximages[id];
+ pdf_init_ximage_struct(I);
- pdf_init_ximage_struct(I);
-
- if (ident) {
- I->ident = NEW(strlen(ident)+1, char);
- strcpy(I->ident, ident);
+ if (ident) {
+ I->ident = NEW(strlen(ident)+1, char);
+ strcpy(I->ident, ident);
+ }
+ ic->count++;
}
switch (subtype) {
@@ -664,12 +732,47 @@
default:
ERROR("Unknown XObject subtype: %d", subtype);
}
- ic->count++;
return id;
}
+int
+pdf_ximage_reserve (const char *ident)
+{
+ struct ic_ *ic = &_ic;
+ int id;
+ pdf_ximage *I;
+ for (id = 0; id < ic->count; id++) {
+ I = &ic->ximages[id];
+ if (I->ident && !strcmp(ident, I->ident)) {
+ WARN("XObject ID \"%s\" already used!", ident);
+ return -1;
+ }
+ }
+
+ id = ic->count;
+ if (ic->count >= ic->capacity) {
+ ic->capacity += 16;
+ ic->ximages = RENEW(ic->ximages, ic->capacity, pdf_ximage);
+ }
+
+ I = &ic->ximages[id];
+
+ pdf_init_ximage_struct(I);
+
+ if (ident) {
+ I->ident = NEW(strlen(ident)+1, char);
+ strcpy(I->ident, ident);
+ }
+ I->reference = pdf_names_reserve(global_names, ident, strlen(ident));
+ sprintf(I->res_name, "Fm%d", id);
+ I->reserved = 1;
+ ic->count++;
+
+ return id;
+}
+
char *
pdf_ximage_get_resname (int id)
{
@@ -908,6 +1011,18 @@
r->ury = I->attr.bbox.ury;
}
break;
+ default: /* maybe reserved */
+ if (p->flags & INFO_HAS_USER_BBOX) {
+ r->llx = p->bbox.llx;
+ r->lly = p->bbox.lly;
+ r->urx = p->bbox.urx;
+ r->ury = p->bbox.ury;
+ } else { /* I->attr.bbox from the image bounding box */
+ r->llx = 0.0;
+ r->lly = 0.0;
+ r->urx = 1.0;
+ r->ury = 1.0;
+ }
}
return 0;
@@ -1069,7 +1184,7 @@
for (i = 0; i < ic->count; i++) {
I = &ic->ximages[i];
if (I->attr.tempfile) {
- dpx_delete_temp_file(I->filename, false); /* temporary filename freed here */
+ dpx_delete_temp_file(I->fullname, false); /* temporary filename freed here */
}
}
}
Modified: trunk/Build/source/texk/dvipdfm-x/pdfximage.h
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdfximage.h 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/pdfximage.h 2020-07-20 20:56:58 UTC (rev 55887)
@@ -64,14 +64,10 @@
extern char *pdf_ximage_get_resname (int xobj_id);
extern pdf_obj *pdf_ximage_get_reference (int xobj_id);
-/* Please use different interface than findresource...
- * This is not intended to be used for specifying page number and others.
- * Only pdf:image special in spc_pdfm.c want optinal dict!
- */
-extern int pdf_ximage_findresource (const char *ident,
- load_options options);
-extern int pdf_ximage_defineresource (const char *ident, int subtype,
- void *cdata, pdf_obj *resource);
+extern int pdf_ximage_findresource (const char *ident);
+extern int pdf_ximage_load_image (const char *ident, const char *filename, load_options options);
+extern int pdf_ximage_defineresource (const char *ident, int subtype, void *cdata, pdf_obj *resource);
+extern int pdf_ximage_reserve (const char *ident);
/* Called by pngimage, jpegimage, epdf, mpost, etc. */
extern void pdf_ximage_init_image_info (ximage_info *info);
Modified: trunk/Build/source/texk/dvipdfm-x/spc_dvips.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/spc_dvips.c 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/spc_dvips.c 2020-07-20 20:56:58 UTC (rev 55887)
@@ -1,6 +1,6 @@
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2002-2019 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team.
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -164,7 +164,7 @@
return -1;
}
- form_id = pdf_ximage_findresource(filename, options);
+ form_id = pdf_ximage_load_image(NULL, filename, options);
if (form_id < 0) {
spc_warn(spe, "Failed to read image file: %s", filename);
RELEASE(filename);
@@ -198,7 +198,7 @@
return -1;
}
- form_id = pdf_ximage_findresource(filename, options);
+ form_id = pdf_ximage_load_image(NULL, filename, options);
if (form_id < 0) {
spc_warn(spe, "Could not open PS file: %s", filename);
error = -1;
@@ -709,7 +709,7 @@
return error;
}
- form_id = pdf_ximage_findresource(gs_out, options);
+ form_id = pdf_ximage_load_image(NULL, gs_out, options);
if (form_id < 0) {
spc_warn(spe, "Failed to read converted PSTricks image file.");
RELEASE(gs_in);
Modified: trunk/Build/source/texk/dvipdfm-x/spc_html.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/spc_html.c 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/spc_html.c 2020-07-20 20:56:58 UTC (rev 55887)
@@ -1,6 +1,6 @@
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2002-2017 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team.
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -645,7 +645,7 @@
return error;
}
- id = pdf_ximage_findresource(pdf_string_value(src), options);
+ id = pdf_ximage_load_image(NULL, pdf_string_value(src), options);
if (id < 0) {
spc_warn(spe, "Could not find/load image: %s", pdf_string_value(src));
error = -1;
Modified: trunk/Build/source/texk/dvipdfm-x/spc_misc.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/spc_misc.c 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/spc_misc.c 2020-07-20 20:56:58 UTC (rev 55887)
@@ -1,6 +1,6 @@
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team.
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -110,7 +110,7 @@
}
MFCLOSE(fp);
- form_id = pdf_ximage_findresource(filename, options);
+ form_id = pdf_ximage_load_image(NULL, filename, options);
if (form_id < 0) {
spc_warn(spe, "Failed to load image file: %s", filename);
return -1;
Modified: trunk/Build/source/texk/dvipdfm-x/spc_pdfm.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/spc_pdfm.c 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/spc_pdfm.c 2020-07-20 20:56:58 UTC (rev 55887)
@@ -75,7 +75,6 @@
{
pdf_obj *annot_dict; /* pending annotation dict */
int lowest_level; /* current min level of outlines */
- struct ht_table *resourcemap; /* see remark below (somewhere) */
struct tounicode cd; /* For to-UTF16-BE conversion :( */
pdf_obj *pageresources; /* Add to all page resource dict */
};
@@ -83,52 +82,12 @@
static struct spc_pdf_ _pdf_stat = {
NULL,
255,
- NULL,
{ -1, 0, NULL },
NULL
};
-/* PLEASE REMOVE THIS */
-static void
-hval_free (void *vp)
-{
- RELEASE(vp);
-}
-
static int
-addresource (struct spc_pdf_ *sd, const char *ident, int res_id)
-{
- struct resource_map *r;
-
- if (!ident || res_id < 0)
- return -1;
-
- r = NEW(1, struct resource_map);
- r->type = 0; /* unused */
- r->res_id = res_id;
-
- ht_append_table(sd->resourcemap, ident, strlen(ident), r);
- spc_push_object(ident, pdf_ximage_get_reference(res_id));
-
- return 0;
-}
-
-static int
-findresource (struct spc_pdf_ *sd, const char *ident)
-{
- struct resource_map *r;
-
- if (!ident)
- return -1;
-
- r = ht_lookup_table(sd->resourcemap, ident, strlen(ident));
-
- return (r ? r->res_id : -1);
-}
-
-
-static int
spc_handler_pdfm__init (void *dp)
{
struct spc_pdf_ *sd = dp;
@@ -144,9 +103,6 @@
sd->annot_dict = NULL;
sd->lowest_level = 255;
- sd->resourcemap = NEW(1, struct ht_table);
- ht_init_table(sd->resourcemap, hval_free);
-
sd->cd.taintkeys = pdf_new_array();
for (i = 0; default_taintkeys[i] != NULL; i++) {
pdf_add_array(sd->cd.taintkeys,
@@ -168,12 +124,6 @@
}
sd->lowest_level = 255;
sd->annot_dict = NULL;
- if (sd->resourcemap) {
- ht_clear_table(sd->resourcemap);
- RELEASE(sd->resourcemap);
- }
- sd->resourcemap = NULL;
-
if (sd->cd.taintkeys)
pdf_release_obj(sd->cd.taintkeys);
sd->cd.taintkeys = NULL;
@@ -1253,7 +1203,6 @@
static int
spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
{
- struct spc_pdf_ *sd = &_pdf_stat;
int xobj_id;
char *ident = NULL;
pdf_obj *fspec;
@@ -1263,12 +1212,7 @@
skip_white(&args->curptr, args->endptr);
if (args->curptr[0] == '@') {
ident = parse_opt_ident(&args->curptr, args->endptr);
- xobj_id = findresource(sd, ident);
- if (xobj_id >= 0) {
- spc_warn(spe, "Object reference name for image \"%s\" already used.", ident);
- RELEASE(ident);
- return -1;
- }
+ skip_white(&args->curptr, args->endptr);
}
/* 2015/12/29
@@ -1305,7 +1249,7 @@
options.dict = parse_pdf_object(&args->curptr, args->endptr, NULL);
}
- xobj_id = pdf_ximage_findresource(pdf_string_value(fspec), options);
+ xobj_id = pdf_ximage_load_image(ident, pdf_string_value(fspec), options);
if (xobj_id < 0) {
spc_warn(spe, "Could not find image resource...");
@@ -1322,7 +1266,6 @@
if ((dpx_conf.compat_mode == dpx_mode_compat_mode) &&
pdf_ximage_get_subtype(xobj_id) == PDF_XOBJECT_TYPE_IMAGE)
pdf_ximage_set_attr(xobj_id, 1, 1, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0);
- addresource(sd, ident, xobj_id);
RELEASE(ident);
}
@@ -1511,6 +1454,7 @@
spc_flush_object(ident);
RELEASE(ident);
} else { /* Close all? */
+ spc_warn(spe, "pdf:close without an argument no longer supported!");
spc_clear_objects();
}
@@ -1867,8 +1811,6 @@
spc_warn(spe, "Couldn't start form object.");
return -1;
}
-
- spc_push_object(ident, pdf_ximage_get_reference(xobj_id));
RELEASE(ident);
return 0;
@@ -1927,11 +1869,9 @@
static int
spc_handler_pdfm_uxobj (struct spc_env *spe, struct spc_arg *args)
{
- struct spc_pdf_ *sd = &_pdf_stat;
int xobj_id;
char *ident;
transform_info ti;
- load_options options = {1, 0, NULL};
skip_white(&args->curptr, args->endptr);
@@ -1949,18 +1889,9 @@
}
}
- /* Dvipdfmx was suddenly changed to use file name to identify
- * external images. We can't use ident to find image resource
- * here.
- */
- xobj_id = findresource(sd, ident);
+ xobj_id = pdf_ximage_findresource(ident);
if (xobj_id < 0) {
- xobj_id = pdf_ximage_findresource(ident, options);
- if (xobj_id < 0) {
- spc_warn(spe, "Specified (image) object doesn't exist: %s", ident);
- RELEASE(ident);
- return -1;
- }
+ xobj_id = pdf_ximage_reserve(ident);
}
pdf_dev_put_image(xobj_id, &ti, spe->x_user, spe->y_user);
Modified: trunk/Build/source/texk/dvipdfm-x/specials.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/specials.c 2020-07-20 16:49:19 UTC (rev 55886)
+++ trunk/Build/source/texk/dvipdfm-x/specials.c 2020-07-20 20:56:58 UTC (rev 55887)
@@ -123,7 +123,6 @@
dvi_set_phantom_height(height, depth);
}
-static struct ht_table *named_objects = NULL;
/* reserved keys */
static const char *_rkeys[] = {
@@ -177,8 +176,6 @@
pdf_coord cp;
int k;
- ASSERT(named_objects);
-
if (!key)
return NULL;
@@ -223,7 +220,7 @@
if (ispageref(key))
value = pdf_doc_ref_page(atoi(key + 4));
else {
- value = pdf_names_lookup_reference(named_objects, key, strlen(key));
+ value = pdf_names_lookup_reference(global_names, key, strlen(key));
}
break;
}
@@ -242,8 +239,6 @@
pdf_coord cp;
int k;
- ASSERT(named_objects);
-
if (!key)
return NULL;
@@ -278,7 +273,7 @@
value = pdf_doc_docinfo();
break;
default:
- value = pdf_names_lookup_object(named_objects, key, strlen(key));
+ value = pdf_names_lookup_object(global_names, key, strlen(key));
break;
}
@@ -294,25 +289,22 @@
void
spc_push_object (const char *key, pdf_obj *value)
{
- ASSERT(named_objects);
-
if (!key || !value)
return;
- pdf_names_add_object(named_objects, key, strlen(key), value);
+ pdf_names_add_object(global_names, key, strlen(key), value);
}
void
spc_flush_object (const char *key)
{
- pdf_names_close_object(named_objects, key, strlen(key));
+ pdf_names_close_object(global_names, key, strlen(key));
}
void
spc_clear_objects (void)
{
- pdf_delete_name_tree(&named_objects);
- named_objects = pdf_new_name_tree();
+ /* Do nothing... */
}
@@ -489,10 +481,6 @@
int error = 0;
int i;
- ASSERT(!named_objects);
-
- named_objects = pdf_new_name_tree();
-
for (i = 0; known_specials[i].key != NULL; i++) {
if (known_specials[i].bodhk_func) {
error = known_specials[i].bodhk_func();
@@ -514,10 +502,6 @@
}
}
- if (named_objects) {
- pdf_delete_name_tree(&named_objects);
- }
-
return error;
}
More information about the tex-live-commits
mailing list.