summaryrefslogtreecommitdiff
path: root/Build/source/texk/xdvipdfmx/src/spc_pdfm.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/xdvipdfmx/src/spc_pdfm.c')
-rw-r--r--Build/source/texk/xdvipdfmx/src/spc_pdfm.c83
1 files changed, 53 insertions, 30 deletions
diff --git a/Build/source/texk/xdvipdfmx/src/spc_pdfm.c b/Build/source/texk/xdvipdfmx/src/spc_pdfm.c
index 45357cccb7f..6d914149d86 100644
--- a/Build/source/texk/xdvipdfmx/src/spc_pdfm.c
+++ b/Build/source/texk/xdvipdfmx/src/spc_pdfm.c
@@ -1,8 +1,8 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.24 2006/12/11 12:46:03 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.30 2008/02/13 20:22:21 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
@@ -331,7 +331,6 @@ spc_handler_pdfm_put (struct spc_env *spe, struct spc_arg *ap)
}
skip_white(&ap->curptr, ap->endptr);
-
obj2 = parse_pdf_object(&ap->curptr, ap->endptr);
if (!obj2) {
spc_warn(spe, "Missing (an) object(s) to put into \"%s\"!", ident);
@@ -392,7 +391,7 @@ spc_handler_pdfm_put (struct spc_env *spe, struct spc_arg *ap)
break;
}
pdf_release_obj(obj2);
-
+ RELEASE(ident);
return error;
}
@@ -526,6 +525,7 @@ maybe_reencode_utf8(pdf_obj *instring)
}
pdf_set_string(instring, wbuf, op - wbuf);
+
return 0;
}
@@ -640,7 +640,7 @@ spc_handler_pdfm_annot (struct spc_env *spe, struct spc_arg *args)
}
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
if (ident)
RELEASE(ident);
return -1;
@@ -774,9 +774,9 @@ spc_handler_pdfm_bcolor (struct spc_env *spe, struct spc_arg *ap)
if (error)
spc_warn(spe, "Invalid color specification?");
else {
- pdf_color_push(); /* save currentcolor */
- pdf_dev_setcolor(&fc, 1);
- pdf_dev_setcolor(&sc, 0);
+ pdf_color_push(&sc, &fc); /* save currentcolor */
+ pdf_dev_set_strokingcolor(&sc);
+ pdf_dev_set_nonstrokingcolor(&fc);
}
return error;
@@ -802,8 +802,8 @@ spc_handler_pdfm_scolor (struct spc_env *spe, struct spc_arg *ap)
spc_warn(spe, "Invalid color specification?");
else {
pdf_color_set_default(&fc); /* ????? */
- pdf_dev_setcolor(&fc, 1);
- pdf_dev_setcolor(&sc, 0);
+ pdf_dev_set_strokingcolor(&sc);
+ pdf_dev_set_nonstrokingcolor(&fc);
}
return error;
@@ -824,7 +824,7 @@ spc_handler_pdfm_btrans (struct spc_env *spe, struct spc_arg *args)
transform_info ti;
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
return -1;
}
@@ -862,11 +862,29 @@ spc_handler_pdfm_outline (struct spc_env *spe, struct spc_arg *args)
{
struct spc_pdf_ *sd = &_pdf_stat;
pdf_obj *item_dict, *tmp;
- int level;
+ int level, is_open = -1;
int current_depth;
skip_white(&args->curptr, args->endptr);
+ /*
+ * pdf:outline is extended to support open/close feature
+ *
+ * pdf:outline 1 ... (as DVIPDFM)
+ * pdf:outline [] 1 ... (open bookmark)
+ * pdf:outline [-] 1 ... (closed bookmark)
+ */
+ if (args->curptr+3 < args->endptr && *args->curptr == '[') {
+ args->curptr++;
+ if (*args->curptr == '-') {
+ args->curptr++;
+ } else {
+ is_open = 1;
+ }
+ args->curptr++;
+ }
+ skip_white(&args->curptr, args->endptr);
+
tmp = parse_pdf_object(&args->curptr, args->endptr);
if (!tmp) {
spc_warn(spe, "Missing number for outline item depth.");
@@ -912,7 +930,7 @@ spc_handler_pdfm_outline (struct spc_env *spe, struct spc_arg *args)
pdf_doc_bookmarks_down();
}
- pdf_doc_bookmarks_add(item_dict, -1); /* Use global setting for open/close */
+ pdf_doc_bookmarks_add(item_dict, is_open);
return 0;
}
@@ -940,8 +958,8 @@ spc_handler_pdfm_article (struct spc_env *spe, struct spc_arg *args)
info_dict = parse_pdf_dict(&args->curptr, args->endptr);
#endif /* ENABLE_TOUNICODE */
if (!info_dict) {
- RELEASE(ident);
spc_warn(spe, "Ignoring article with invalid info dictionary.");
+ RELEASE(ident);
return -1;
}
@@ -981,7 +999,7 @@ spc_handler_pdfm_bead (struct spc_env *spe, struct spc_arg *args)
/* If okay so far, try to get a bounding box */
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
RELEASE(article_name);
return -1;
}
@@ -1035,6 +1053,7 @@ spc_handler_pdfm_bead (struct spc_env *spe, struct spc_arg *args)
page_no = pdf_doc_current_page_number();
pdf_doc_add_bead(article_name, NULL, page_no, &rect);
+ RELEASE(article_name);
return 0;
}
@@ -1046,6 +1065,7 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
char *ident = NULL;
pdf_obj *fspec;
transform_info ti;
+ long page_no;
skip_white(&args->curptr, args->endptr);
if (args->curptr[0] == '@') {
@@ -1059,7 +1079,8 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
}
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
+ page_no = 1;
+ if (spc_util_read_dimtrns(spe, &ti, args, &page_no, 0) < 0) {
if (ident)
RELEASE(ident);
return -1;
@@ -1075,10 +1096,12 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
} else if (!PDF_OBJ_STRINGTYPE(fspec)) {
spc_warn(spe, "Missing filename string for pdf:image.");
pdf_release_obj(fspec);
+ if (ident)
+ RELEASE(ident);
return -1;
}
- xobj_id = pdf_ximage_findresource(pdf_string_value(fspec), 0, 0);
+ xobj_id = pdf_ximage_findresource(pdf_string_value(fspec), page_no);
if (xobj_id < 0) {
spc_warn(spe, "Could not find image resource...");
pdf_release_obj(fspec);
@@ -1311,8 +1334,8 @@ spc_handler_pdfm_object (struct spc_env *spe, struct spc_arg *args)
object = parse_pdf_object(&args->curptr, args->endptr);
if (!object) {
- RELEASE(ident);
spc_warn(spe, "Could not find an object definition for \"%s\".", ident);
+ RELEASE(ident);
return -1;
} else {
spc_push_object(ident, object);
@@ -1451,16 +1474,16 @@ spc_handler_pdfm_fstream (struct spc_env *spe, struct spc_arg *args)
pdf_release_obj(tmp);
if (!fullname) {
spc_warn(spe, "Could not find file.");
- RELEASE(ident);
pdf_release_obj(fstream);
+ RELEASE(ident);
return -1;
}
fp = MFOPEN(fullname, FOPEN_RBIN_MODE);
if (!fp) {
spc_warn(spe, "Could not open file: %s", fullname);
- RELEASE(ident);
pdf_release_obj(fstream);
+ RELEASE(ident);
return -1;
}
@@ -1488,8 +1511,8 @@ spc_handler_pdfm_fstream (struct spc_env *spe, struct spc_arg *args)
tmp = parse_pdf_dict(&args->curptr, args->endptr);
if (!tmp) {
spc_warn(spe, "Parsing dictionary failed.");
- RELEASE(ident);
pdf_release_obj(fstream);
+ RELEASE(ident);
return -1;
}
if (pdf_lookup_dict(tmp, "Length")) {
@@ -1541,7 +1564,7 @@ spc_handler_pdfm_bform (struct spc_env *spe, struct spc_arg *args)
}
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
RELEASE(ident);
return -1;
}
@@ -1654,7 +1677,7 @@ spc_handler_pdfm_uxobj (struct spc_env *spe, struct spc_arg *args)
transform_info_clear(&ti);
if (args->curptr < args->endptr) {
- if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
RELEASE(ident);
return -1;
}
@@ -1666,7 +1689,7 @@ spc_handler_pdfm_uxobj (struct spc_env *spe, struct spc_arg *args)
*/
xobj_id = findresource(sd, ident);
if (xobj_id < 0) {
- xobj_id = pdf_ximage_findresource(ident, 0, 0);
+ xobj_id = pdf_ximage_findresource(ident, 0);
if (xobj_id < 0) {
spc_warn(spe, "Specified (image) object doesn't exist: %s", ident);
RELEASE(ident);
@@ -1814,6 +1837,7 @@ spc_handler_pdfm_mapfile (struct spc_env *spe, struct spc_arg *args)
} else {
error = pdf_load_fontmap_file(mapfile, mode);
}
+ RELEASE(mapfile);
return error;
}
@@ -1825,7 +1849,6 @@ spc_handler_pdfm_tounicode (struct spc_env *spe, struct spc_arg *args)
{
struct spc_pdf_ *sd = &_pdf_stat;
char *cmap_name;
- int error = 0;
/* First clear */
sd->cd.cmap_id = -1;
@@ -1845,19 +1868,20 @@ spc_handler_pdfm_tounicode (struct spc_env *spe, struct spc_arg *args)
cmap_name = parse_ident(&args->curptr, args->endptr);
if (!cmap_name) {
spc_warn(spe, "Missing ToUnicode mapping name...");
- return -1;
+ return -1;
}
sd->cd.cmap_id = CMap_cache_find(cmap_name);
if (sd->cd.cmap_id < 0) {
spc_warn(spe, "Failed to load ToUnicode mapping: %s", cmap_name);
- error = -1;
+ RELEASE(cmap_name);
+ return -1;
}
/* Shift-JIS like encoding may contain backslash in 2nd byte.
* WARNING: This will add nasty extension to PDF parser.
*/
- if (!error && sd->cd.cmap_id >= 0) {
+ if (sd->cd.cmap_id >= 0) {
if (strstr(cmap_name, "RKSJ") ||
strstr(cmap_name, "B5") ||
strstr(cmap_name, "GBK") ||
@@ -1865,8 +1889,7 @@ spc_handler_pdfm_tounicode (struct spc_env *spe, struct spc_arg *args)
sd->cd.unescape_backslash = 1;
}
RELEASE(cmap_name);
-
- return error;
+ return 0;
}
#endif /* ENABLE_TOUNICODE */