summaryrefslogtreecommitdiff
path: root/pdf/pdf_interpret.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-02-26 11:15:16 -0800
committerRobin Watts <robin@ghostscript.com>2012-02-26 19:36:30 +0000
commitbbfe635555dce16858403706e2031dd3bfa1a9f1 (patch)
tree6e414005f04f233a83dbeec5607c0665a6d498bc /pdf/pdf_interpret.c
parentca578b08dc1243dc6cbb3235272d52d9e2336925 (diff)
downloadmupdf-bbfe635555dce16858403706e2031dd3bfa1a9f1.tar.xz
Move fz_obj to be pdf_obj.
Currently, we are in the slightly strange position of having the PDF specific object types as part of fitz. Here we pull them out into the pdf layer instead. This has been made possible by the recent changes to make the store no longer be tied to having fz_obj's as keys. Most of this work is a simple huge rename; to help customers who may have code that use such functions we have provided a sed script to do the renaming; scripts/rename2.sed. Various other small tweaks are required; the store used to have some debugging code that still required knowledge of fz_obj types - we extract that into a nicer 'type' based function pointer. Also, the type 3 font handling used to have an fz_obj pointer for type 3 resources, and therefore needed to know how to free this; this has become a void * with a function to free it.
Diffstat (limited to 'pdf/pdf_interpret.c')
-rw-r--r--pdf/pdf_interpret.c314
1 files changed, 157 insertions, 157 deletions
diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c
index 1cfe6a96..d2270eaa 100644
--- a/pdf/pdf_interpret.c
+++ b/pdf/pdf_interpret.c
@@ -70,7 +70,7 @@ struct pdf_csi_s
char *event; /* "View", "Print", "Export" */
/* interpreter stack */
- fz_obj *obj;
+ pdf_obj *obj;
char name[256];
unsigned char string[256];
int string_len;
@@ -104,8 +104,8 @@ struct pdf_csi_s
fz_cookie *cookie;
};
-static void pdf_run_buffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents);
-static void pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform);
+static void pdf_run_buffer(pdf_csi *csi, pdf_obj *rdb, fz_buffer *contents);
+static void pdf_run_xobject(pdf_csi *csi, pdf_obj *resources, pdf_xobject *xobj, fz_matrix transform);
static void pdf_show_pattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what);
static int
@@ -120,20 +120,20 @@ ocg_intents_include(pdf_ocg_descriptor *desc, char *name)
if (!desc->intent)
return (strcmp(name, "View") == 0);
- if (fz_is_name(desc->intent))
+ if (pdf_is_name(desc->intent))
{
- char *intent = fz_to_name(desc->intent);
+ char *intent = pdf_to_name(desc->intent);
if (strcmp(intent, "All") == 0)
return 1;
return (strcmp(intent, name) == 0);
}
- if (!fz_is_array(desc->intent))
+ if (!pdf_is_array(desc->intent))
return 0;
- len = fz_array_len(desc->intent);
+ len = pdf_array_len(desc->intent);
for (i=0; i < len; i++)
{
- char *intent = fz_to_name(fz_array_get(desc->intent, i));
+ char *intent = pdf_to_name(pdf_array_get(desc->intent, i));
if (strcmp(intent, "All") == 0)
return 1;
if (strcmp(intent, name) == 0)
@@ -143,10 +143,10 @@ ocg_intents_include(pdf_ocg_descriptor *desc, char *name)
}
static int
-pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
+pdf_is_hidden_ocg(pdf_obj *ocg, pdf_csi *csi, pdf_obj *rdb)
{
char event_state[16];
- fz_obj *obj, *obj2;
+ pdf_obj *obj, *obj2;
char *type;
pdf_ocg_descriptor *desc = csi->xref->ocg;
@@ -155,9 +155,9 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
return 0;
/* If we've been handed a name, look it up in the properties. */
- if (fz_is_name(ocg))
+ if (pdf_is_name(ocg))
{
- ocg = fz_dict_gets(fz_dict_gets(rdb, "Properties"), fz_to_name(ocg));
+ ocg = pdf_dict_gets(pdf_dict_gets(rdb, "Properties"), pdf_to_name(ocg));
}
/* If we haven't been given an ocg at all, then we're visible */
if (!ocg)
@@ -166,13 +166,13 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
fz_strlcpy(event_state, csi->event, sizeof event_state);
fz_strlcat(event_state, "State", sizeof event_state);
- type = fz_to_name(fz_dict_gets(ocg, "Type"));
+ type = pdf_to_name(pdf_dict_gets(ocg, "Type"));
if (strcmp(type, "OCG") == 0)
{
/* An Optional Content Group */
- int num = fz_to_num(ocg);
- int gen = fz_to_gen(ocg);
+ int num = pdf_to_num(ocg);
+ int gen = pdf_to_gen(ocg);
int len = desc->len;
int i;
@@ -188,19 +188,19 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
/* Check Intents; if our intent is not part of the set given
* by the current config, we should ignore it. */
- obj = fz_dict_gets(ocg, "Intent");
- if (fz_is_name(obj))
+ obj = pdf_dict_gets(ocg, "Intent");
+ if (pdf_is_name(obj))
{
/* If it doesn't match, it's hidden */
- if (ocg_intents_include(desc, fz_to_name(obj)) == 0)
+ if (ocg_intents_include(desc, pdf_to_name(obj)) == 0)
return 1;
}
- else if (fz_is_array(obj))
+ else if (pdf_is_array(obj))
{
int match = 0;
- len = fz_array_len(obj);
+ len = pdf_array_len(obj);
for (i=0; i<len; i++) {
- match |= ocg_intents_include(desc, fz_to_name(fz_array_get(obj, i)));
+ match |= ocg_intents_include(desc, pdf_to_name(pdf_array_get(obj, i)));
if (match)
break;
}
@@ -224,15 +224,15 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
* correspond to entries in the AS list in the OCG config.
* Given that we don't handle Zoom or User, or Language
* dicts, this is not really a problem. */
- obj = fz_dict_gets(ocg, "Usage");
- if (!fz_is_dict(obj))
+ obj = pdf_dict_gets(ocg, "Usage");
+ if (!pdf_is_dict(obj))
return 0;
/* FIXME: Should look at Zoom (and return hidden if out of
* max/min range) */
/* FIXME: Could provide hooks to the caller to check if
* User is appropriate - if not return hidden. */
- obj2 = fz_dict_gets(obj, csi->event);
- if (strcmp(fz_to_name(fz_dict_gets(obj2, event_state)), "OFF") == 0)
+ obj2 = pdf_dict_gets(obj, csi->event);
+ if (strcmp(pdf_to_name(pdf_dict_gets(obj2, event_state)), "OFF") == 0)
{
return 1;
}
@@ -244,12 +244,12 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
char *name;
int combine, on;
- obj = fz_dict_gets(ocg, "VE");
- if (fz_is_array(obj)) {
+ obj = pdf_dict_gets(ocg, "VE");
+ if (pdf_is_array(obj)) {
/* FIXME: Calculate visibility from array */
return 0;
}
- name = fz_to_name(fz_dict_gets(ocg, "P"));
+ name = pdf_to_name(pdf_dict_gets(ocg, "P"));
/* Set combine; Bit 0 set => AND, Bit 1 set => true means
* Off, otherwise true means On */
if (strcmp(name, "AllOn") == 0)
@@ -269,15 +269,15 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
combine = 0;
}
- obj = fz_dict_gets(ocg, "OCGs");
+ obj = pdf_dict_gets(ocg, "OCGs");
on = combine & 1;
- if (fz_is_array(obj)) {
+ if (pdf_is_array(obj)) {
int i, len;
- len = fz_array_len(obj);
+ len = pdf_array_len(obj);
for (i = 0; i < len; i++)
{
int hidden;
- hidden = pdf_is_hidden_ocg(fz_array_get(obj, i), csi, rdb);
+ hidden = pdf_is_hidden_ocg(pdf_array_get(obj, i), csi, rdb);
if ((combine & 1) == 0)
hidden = !hidden;
if (combine & 2)
@@ -831,26 +831,26 @@ pdf_show_string(pdf_csi *csi, unsigned char *buf, int len)
}
static void
-pdf_show_text(pdf_csi *csi, fz_obj *text)
+pdf_show_text(pdf_csi *csi, pdf_obj *text)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
int i;
- if (fz_is_array(text))
+ if (pdf_is_array(text))
{
- int n = fz_array_len(text);
+ int n = pdf_array_len(text);
for (i = 0; i < n; i++)
{
- fz_obj *item = fz_array_get(text, i);
- if (fz_is_string(item))
- pdf_show_string(csi, (unsigned char *)fz_to_str_buf(item), fz_to_str_len(item));
+ pdf_obj *item = pdf_array_get(text, i);
+ if (pdf_is_string(item))
+ pdf_show_string(csi, (unsigned char *)pdf_to_str_buf(item), pdf_to_str_len(item));
else
- pdf_show_space(csi, - fz_to_real(item) * gstate->size * 0.001f);
+ pdf_show_space(csi, - pdf_to_real(item) * gstate->size * 0.001f);
}
}
- else if (fz_is_string(text))
+ else if (pdf_is_string(text))
{
- pdf_show_string(csi, (unsigned char *)fz_to_str_buf(text), fz_to_str_len(text));
+ pdf_show_string(csi, (unsigned char *)pdf_to_str_buf(text), pdf_to_str_len(text));
}
}
@@ -1004,7 +1004,7 @@ pdf_clear_stack(pdf_csi *csi)
int i;
if (csi->obj)
- fz_drop_obj(csi->obj);
+ pdf_drop_obj(csi->obj);
csi->obj = NULL;
csi->name[0] = 0;
@@ -1335,7 +1335,7 @@ pdf_show_pattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what)
}
static void
-pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform)
+pdf_run_xobject(pdf_csi *csi, pdf_obj *resources, pdf_xobject *xobj, fz_matrix transform)
{
fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate = NULL;
@@ -1344,7 +1344,7 @@ pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tr
int popmask;
/* Avoid infinite recursion */
- if (xobj == NULL || fz_dict_mark(xobj->me))
+ if (xobj == NULL || pdf_dict_mark(xobj->me))
return;
fz_var(gstate);
@@ -1425,7 +1425,7 @@ pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tr
pdf_grestore(csi);
}
- fz_dict_unmark(xobj->me);
+ pdf_dict_unmark(xobj->me);
}
fz_catch(ctx)
{
@@ -1442,7 +1442,7 @@ pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tr
}
static void
-pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
+pdf_run_extgstate(pdf_csi *csi, pdf_obj *rdb, pdf_obj *extgstate)
{
fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate = csi->gstate + csi->gtop;
@@ -1451,18 +1451,18 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
pdf_flush_text(csi);
- n = fz_dict_len(extgstate);
+ n = pdf_dict_len(extgstate);
for (i = 0; i < n; i++)
{
- fz_obj *key = fz_dict_get_key(extgstate, i);
- fz_obj *val = fz_dict_get_val(extgstate, i);
- char *s = fz_to_name(key);
+ pdf_obj *key = pdf_dict_get_key(extgstate, i);
+ pdf_obj *val = pdf_dict_get_val(extgstate, i);
+ char *s = pdf_to_name(key);
if (!strcmp(s, "Font"))
{
- if (fz_is_array(val) && fz_array_len(val) == 2)
+ if (pdf_is_array(val) && pdf_array_len(val) == 2)
{
- fz_obj *font = fz_array_get(val, 0);
+ pdf_obj *font = pdf_array_get(val, 0);
if (gstate->font)
{
@@ -1471,10 +1471,10 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
}
gstate->font = pdf_load_font(csi->xref, rdb, font);
- /* RJW: "cannot load font (%d %d R)", fz_to_num(font), fz_to_gen(font) */
+ /* RJW: "cannot load font (%d %d R)", pdf_to_num(font), pdf_to_gen(font) */
if (!gstate->font)
fz_throw(ctx, "cannot find font in store");
- gstate->size = fz_to_real(fz_array_get(val, 1));
+ gstate->size = pdf_to_real(pdf_array_get(val, 1));
}
else
fz_throw(ctx, "malformed /Font dictionary");
@@ -1483,59 +1483,59 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
else if (!strcmp(s, "LC"))
{
csi->dev->flags &= ~(FZ_DEVFLAG_STARTCAP_UNDEFINED | FZ_DEVFLAG_DASHCAP_UNDEFINED | FZ_DEVFLAG_ENDCAP_UNDEFINED);
- gstate->stroke_state.start_cap = fz_to_int(val);
- gstate->stroke_state.dash_cap = fz_to_int(val);
- gstate->stroke_state.end_cap = fz_to_int(val);
+ gstate->stroke_state.start_cap = pdf_to_int(val);
+ gstate->stroke_state.dash_cap = pdf_to_int(val);
+ gstate->stroke_state.end_cap = pdf_to_int(val);
}
else if (!strcmp(s, "LW"))
{
csi->dev->flags &= ~FZ_DEVFLAG_LINEWIDTH_UNDEFINED;
- gstate->stroke_state.linewidth = fz_to_real(val);
+ gstate->stroke_state.linewidth = pdf_to_real(val);
}
else if (!strcmp(s, "LJ"))
{
csi->dev->flags &= ~FZ_DEVFLAG_LINEJOIN_UNDEFINED;
- gstate->stroke_state.linejoin = fz_to_int(val);
+ gstate->stroke_state.linejoin = pdf_to_int(val);
}
else if (!strcmp(s, "ML"))
{
csi->dev->flags &= ~FZ_DEVFLAG_MITERLIMIT_UNDEFINED;
- gstate->stroke_state.miterlimit = fz_to_real(val);
+ gstate->stroke_state.miterlimit = pdf_to_real(val);
}
else if (!strcmp(s, "D"))
{
- if (fz_is_array(val) && fz_array_len(val) == 2)
+ if (pdf_is_array(val) && pdf_array_len(val) == 2)
{
- fz_obj *dashes = fz_array_get(val, 0);
- gstate->stroke_state.dash_len = MAX(fz_array_len(dashes), 32);
+ pdf_obj *dashes = pdf_array_get(val, 0);
+ gstate->stroke_state.dash_len = MAX(pdf_array_len(dashes), 32);
for (k = 0; k < gstate->stroke_state.dash_len; k++)
- gstate->stroke_state.dash_list[k] = fz_to_real(fz_array_get(dashes, k));
- gstate->stroke_state.dash_phase = fz_to_real(fz_array_get(val, 1));
+ gstate->stroke_state.dash_list[k] = pdf_to_real(pdf_array_get(dashes, k));
+ gstate->stroke_state.dash_phase = pdf_to_real(pdf_array_get(val, 1));
}
else
fz_throw(ctx, "malformed /D");
}
else if (!strcmp(s, "CA"))
- gstate->stroke.alpha = fz_to_real(val);
+ gstate->stroke.alpha = pdf_to_real(val);
else if (!strcmp(s, "ca"))
- gstate->fill.alpha = fz_to_real(val);
+ gstate->fill.alpha = pdf_to_real(val);
else if (!strcmp(s, "BM"))
{
- if (fz_is_array(val))
- val = fz_array_get(val, 0);
- gstate->blendmode = fz_find_blendmode(fz_to_name(val));
+ if (pdf_is_array(val))
+ val = pdf_array_get(val, 0);
+ gstate->blendmode = fz_find_blendmode(pdf_to_name(val));
}
else if (!strcmp(s, "SMask"))
{
- if (fz_is_dict(val))
+ if (pdf_is_dict(val))
{
pdf_xobject *xobj;
- fz_obj *group, *luminosity, *bc;
+ pdf_obj *group, *luminosity, *bc;
if (gstate->softmask)
{
@@ -1543,11 +1543,11 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
gstate->softmask = NULL;
}
- group = fz_dict_gets(val, "G");
+ group = pdf_dict_gets(val, "G");
if (!group)
- fz_throw(ctx, "cannot load softmask xobject (%d %d R)", fz_to_num(val), fz_to_gen(val));
+ fz_throw(ctx, "cannot load softmask xobject (%d %d R)", pdf_to_num(val), pdf_to_gen(val));
xobj = pdf_load_xobject(csi->xref, group);
- /* RJW: "cannot load xobject (%d %d R)", fz_to_num(val), fz_to_gen(val) */
+ /* RJW: "cannot load xobject (%d %d R)", pdf_to_num(val), pdf_to_gen(val) */
colorspace = xobj->colorspace;
if (!colorspace)
@@ -1558,20 +1558,20 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
for (k = 0; k < colorspace->n; k++)
gstate->softmask_bc[k] = 0;
- bc = fz_dict_gets(val, "BC");
- if (fz_is_array(bc))
+ bc = pdf_dict_gets(val, "BC");
+ if (pdf_is_array(bc))
{
for (k = 0; k < colorspace->n; k++)
- gstate->softmask_bc[k] = fz_to_real(fz_array_get(bc, k));
+ gstate->softmask_bc[k] = pdf_to_real(pdf_array_get(bc, k));
}
- luminosity = fz_dict_gets(val, "S");
- if (fz_is_name(luminosity) && !strcmp(fz_to_name(luminosity), "Luminosity"))
+ luminosity = pdf_dict_gets(val, "S");
+ if (pdf_is_name(luminosity) && !strcmp(pdf_to_name(luminosity), "Luminosity"))
gstate->luminosity = 1;
else
gstate->luminosity = 0;
}
- else if (fz_is_name(val) && !strcmp(fz_to_name(val), "None"))
+ else if (pdf_is_name(val) && !strcmp(pdf_to_name(val), "None"))
{
if (gstate->softmask)
{
@@ -1583,7 +1583,7 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
else if (!strcmp(s, "TR"))
{
- if (!fz_is_name(val) || strcmp(fz_to_name(val), "Identity"))
+ if (!pdf_is_name(val) || strcmp(pdf_to_name(val), "Identity"))
fz_warn(ctx, "ignoring transfer function");
}
}
@@ -1593,9 +1593,9 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
* Operators
*/
-static void pdf_run_BDC(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_BDC(pdf_csi *csi, pdf_obj *rdb)
{
- fz_obj *ocg;
+ pdf_obj *ocg;
/* If we are already in a hidden OCG, then we'll still be hidden -
* just increment the depth so we pop back to visibility when we've
@@ -1606,14 +1606,14 @@ static void pdf_run_BDC(pdf_csi *csi, fz_obj *rdb)
return;
}
- ocg = fz_dict_gets(fz_dict_gets(rdb, "Properties"), csi->name);
+ ocg = pdf_dict_gets(pdf_dict_gets(rdb, "Properties"), csi->name);
if (!ocg)
{
/* No Properties array, or name not found in the properties
* means visible. */
return;
}
- if (strcmp(fz_to_name(fz_dict_gets(ocg, "Type")), "OCG") != 0)
+ if (strcmp(pdf_to_name(pdf_dict_gets(ocg, "Type")), "OCG") != 0)
{
/* Wrong type of property */
return;
@@ -1622,12 +1622,12 @@ static void pdf_run_BDC(pdf_csi *csi, fz_obj *rdb)
csi->in_hidden_ocg++;
}
-static void pdf_run_BI(pdf_csi *csi, fz_obj *rdb, fz_stream *file)
+static void pdf_run_BI(pdf_csi *csi, pdf_obj *rdb, fz_stream *file)
{
fz_context *ctx = csi->dev->ctx;
int ch;
fz_image *img;
- fz_obj *obj;
+ pdf_obj *obj;
obj = pdf_parse_dict(csi->xref, file, &csi->xref->lexbuf.base);
/* RJW: "cannot parse inline image dictionary" */
@@ -1639,7 +1639,7 @@ static void pdf_run_BI(pdf_csi *csi, fz_obj *rdb, fz_stream *file)
fz_read_byte(file);
img = pdf_load_inline_image(csi->xref, rdb, obj, file);
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
/* RJW: "cannot load inline image" */
pdf_show_image(csi, img);
@@ -1688,11 +1688,11 @@ static void pdf_run_Bstar(pdf_csi *csi)
pdf_show_path(csi, 0, 1, 1, 1);
}
-static void pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what)
+static void pdf_run_cs_imp(pdf_csi *csi, pdf_obj *rdb, int what)
{
fz_context *ctx = csi->dev->ctx;
fz_colorspace *colorspace;
- fz_obj *obj, *dict;
+ pdf_obj *obj, *dict;
if (!strcmp(csi->name, "Pattern"))
{
@@ -1708,14 +1708,14 @@ static void pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what)
colorspace = fz_device_cmyk; /* No fz_keep_colorspace as static */
else
{
- dict = fz_dict_gets(rdb, "ColorSpace");
+ dict = pdf_dict_gets(rdb, "ColorSpace");
if (!dict)
fz_throw(ctx, "cannot find ColorSpace dictionary");
- obj = fz_dict_gets(dict, csi->name);
+ obj = pdf_dict_gets(dict, csi->name);
if (!obj)
fz_throw(ctx, "cannot find colorspace resource '%s'", csi->name);
colorspace = pdf_load_colorspace(csi->xref, obj);
- /* RJW: "cannot load colorspace (%d 0 R)", fz_to_num(obj) */
+ /* RJW: "cannot load colorspace (%d 0 R)", pdf_to_num(obj) */
}
pdf_set_colorspace(csi, what, colorspace);
@@ -1724,7 +1724,7 @@ static void pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what)
}
}
-static void pdf_run_CS(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_CS(pdf_csi *csi, pdf_obj *rdb)
{
csi->dev->flags &= ~FZ_DEVFLAG_STROKECOLOR_UNDEFINED;
@@ -1732,7 +1732,7 @@ static void pdf_run_CS(pdf_csi *csi, fz_obj *rdb)
/* RJW: "cannot set colorspace" */
}
-static void pdf_run_cs(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_cs(pdf_csi *csi, pdf_obj *rdb)
{
csi->dev->flags &= ~FZ_DEVFLAG_FILLCOLOR_UNDEFINED;
@@ -1744,41 +1744,41 @@ static void pdf_run_DP(pdf_csi *csi)
{
}
-static void pdf_run_Do(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_Do(pdf_csi *csi, pdf_obj *rdb)
{
fz_context *ctx = csi->dev->ctx;
- fz_obj *dict;
- fz_obj *obj;
- fz_obj *subtype;
+ pdf_obj *dict;
+ pdf_obj *obj;
+ pdf_obj *subtype;
- dict = fz_dict_gets(rdb, "XObject");
+ dict = pdf_dict_gets(rdb, "XObject");
if (!dict)
fz_throw(ctx, "cannot find XObject dictionary when looking for: '%s'", csi->name);
- obj = fz_dict_gets(dict, csi->name);
+ obj = pdf_dict_gets(dict, csi->name);
if (!obj)
fz_throw(ctx, "cannot find xobject resource: '%s'", csi->name);
- subtype = fz_dict_gets(obj, "Subtype");
- if (!fz_is_name(subtype))
+ subtype = pdf_dict_gets(obj, "Subtype");
+ if (!pdf_is_name(subtype))
fz_throw(ctx, "no XObject subtype specified");
- if (pdf_is_hidden_ocg(fz_dict_gets(obj, "OC"), csi, rdb))
+ if (pdf_is_hidden_ocg(pdf_dict_gets(obj, "OC"), csi, rdb))
return;
- if (!strcmp(fz_to_name(subtype), "Form") && fz_dict_gets(obj, "Subtype2"))
- subtype = fz_dict_gets(obj, "Subtype2");
+ if (!strcmp(pdf_to_name(subtype), "Form") && pdf_dict_gets(obj, "Subtype2"))
+ subtype = pdf_dict_gets(obj, "Subtype2");
- if (!strcmp(fz_to_name(subtype), "Form"))
+ if (!strcmp(pdf_to_name(subtype), "Form"))
{
pdf_xobject *xobj;
xobj = pdf_load_xobject(csi->xref, obj);
- /* RJW: "cannot load xobject (%d %d R)", fz_to_num(obj), fz_to_gen(obj) */
+ /* RJW: "cannot load xobject (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj) */
/* Inherit parent resources, in case this one was empty XXX check where it's loaded */
if (!xobj->resources)
- xobj->resources = fz_keep_obj(rdb);
+ xobj->resources = pdf_keep_obj(rdb);
fz_try(ctx)
{
@@ -1787,18 +1787,18 @@ static void pdf_run_Do(pdf_csi *csi, fz_obj *rdb)
fz_catch(ctx)
{
pdf_drop_xobject(ctx, xobj);
- fz_throw(ctx, "cannot draw xobject (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
+ fz_throw(ctx, "cannot draw xobject (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj));
}
pdf_drop_xobject(ctx, xobj);
}
- else if (!strcmp(fz_to_name(subtype), "Image"))
+ else if (!strcmp(pdf_to_name(subtype), "Image"))
{
if ((csi->dev->hints & FZ_IGNORE_IMAGE) == 0)
{
fz_image *img = pdf_load_image(csi->xref, obj);
- /* RJW: "cannot load image (%d %d R)", fz_to_num(obj), fz_to_gen(obj) */
+ /* RJW: "cannot load image (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj) */
fz_try(ctx)
{
pdf_show_image(csi, img);
@@ -1814,14 +1814,14 @@ static void pdf_run_Do(pdf_csi *csi, fz_obj *rdb)
}
}
- else if (!strcmp(fz_to_name(subtype), "PS"))
+ else if (!strcmp(pdf_to_name(subtype), "PS"))
{
fz_warn(ctx, "ignoring XObject with subtype PS");
}
else
{
- fz_throw(ctx, "unknown XObject subtype: '%s'", fz_to_name(subtype));
+ fz_throw(ctx, "unknown XObject subtype: '%s'", pdf_to_name(subtype));
}
}
@@ -1899,12 +1899,12 @@ static void pdf_run_S(pdf_csi *csi)
pdf_show_path(csi, 0, 0, 1, 0);
}
-static void pdf_run_SC_imp(pdf_csi *csi, fz_obj *rdb, int what, pdf_material *mat)
+static void pdf_run_SC_imp(pdf_csi *csi, pdf_obj *rdb, int what, pdf_material *mat)
{
fz_context *ctx = csi->dev->ctx;
- fz_obj *patterntype;
- fz_obj *dict;
- fz_obj *obj;
+ pdf_obj *patterntype;
+ pdf_obj *dict;
+ pdf_obj *obj;
int kind;
kind = mat->kind;
@@ -1921,35 +1921,35 @@ static void pdf_run_SC_imp(pdf_csi *csi, fz_obj *rdb, int what, pdf_material *ma
break;
case PDF_MAT_PATTERN:
- dict = fz_dict_gets(rdb, "Pattern");
+ dict = pdf_dict_gets(rdb, "Pattern");
if (!dict)
fz_throw(ctx, "cannot find Pattern dictionary");
- obj = fz_dict_gets(dict, csi->name);
+ obj = pdf_dict_gets(dict, csi->name);
if (!obj)
fz_throw(ctx, "cannot find pattern resource '%s'", csi->name);
- patterntype = fz_dict_gets(obj, "PatternType");
+ patterntype = pdf_dict_gets(obj, "PatternType");
- if (fz_to_int(patterntype) == 1)
+ if (pdf_to_int(patterntype) == 1)
{
pdf_pattern *pat;
pat = pdf_load_pattern(csi->xref, obj);
- /* RJW: "cannot load pattern (%d 0 R)", fz_to_num(obj) */
+ /* RJW: "cannot load pattern (%d 0 R)", pdf_to_num(obj) */
pdf_set_pattern(csi, what, pat, csi->top > 0 ? csi->stack : NULL);
pdf_drop_pattern(ctx, pat);
}
- else if (fz_to_int(patterntype) == 2)
+ else if (pdf_to_int(patterntype) == 2)
{
fz_shade *shd;
shd = pdf_load_shading(csi->xref, obj);
- /* RJW: "cannot load shading (%d 0 R)", fz_to_num(obj) */
+ /* RJW: "cannot load shading (%d 0 R)", pdf_to_num(obj) */
pdf_set_shade(csi, what, shd);
fz_drop_shade(ctx, shd);
}
else
{
- fz_throw(ctx, "unknown pattern type: %d", fz_to_int(patterntype));
+ fz_throw(ctx, "unknown pattern type: %d", pdf_to_int(patterntype));
}
break;
@@ -1958,7 +1958,7 @@ static void pdf_run_SC_imp(pdf_csi *csi, fz_obj *rdb, int what, pdf_material *ma
}
}
-static void pdf_run_SC(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_SC(pdf_csi *csi, pdf_obj *rdb)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
csi->dev->flags &= ~FZ_DEVFLAG_STROKECOLOR_UNDEFINED;
@@ -1966,7 +1966,7 @@ static void pdf_run_SC(pdf_csi *csi, fz_obj *rdb)
/* RJW: "cannot set color and colorspace" */
}
-static void pdf_run_sc(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_sc(pdf_csi *csi, pdf_obj *rdb)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
csi->dev->flags &= ~FZ_DEVFLAG_FILLCOLOR_UNDEFINED;
@@ -2000,28 +2000,28 @@ static void pdf_run_TL(pdf_csi *csi)
gstate->leading = csi->stack[0];
}
-static void pdf_run_Tf(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_Tf(pdf_csi *csi, pdf_obj *rdb)
{
fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate = csi->gstate + csi->gtop;
- fz_obj *dict;
- fz_obj *obj;
+ pdf_obj *dict;
+ pdf_obj *obj;
gstate->size = csi->stack[0];
if (gstate->font)
pdf_drop_font(ctx, gstate->font);
gstate->font = NULL;
- dict = fz_dict_gets(rdb, "Font");
+ dict = pdf_dict_gets(rdb, "Font");
if (!dict)
fz_throw(ctx, "cannot find Font dictionary");
- obj = fz_dict_gets(dict, csi->name);
+ obj = pdf_dict_gets(dict, csi->name);
if (!obj)
fz_throw(ctx, "cannot find font resource: '%s'", csi->name);
gstate->font = pdf_load_font(csi->xref, rdb, obj);
- /* RJW: "cannot load font (%d 0 R)", fz_to_num(obj) */
+ /* RJW: "cannot load font (%d 0 R)", pdf_to_num(obj) */
}
static void pdf_run_Tr(pdf_csi *csi)
@@ -2141,13 +2141,13 @@ static void pdf_run_cm(pdf_csi *csi)
static void pdf_run_d(pdf_csi *csi)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- fz_obj *array;
+ pdf_obj *array;
int i;
array = csi->obj;
- gstate->stroke_state.dash_len = MIN(fz_array_len(array), nelem(gstate->stroke_state.dash_list));
+ gstate->stroke_state.dash_len = MIN(pdf_array_len(array), nelem(gstate->stroke_state.dash_list));
for (i = 0; i < gstate->stroke_state.dash_len; i++)
- gstate->stroke_state.dash_list[i] = fz_to_real(fz_array_get(array, i));
+ gstate->stroke_state.dash_list[i] = pdf_to_real(pdf_array_get(array, i));
gstate->stroke_state.dash_phase = csi->stack[0];
}
@@ -2186,22 +2186,22 @@ static void pdf_run_g(pdf_csi *csi)
pdf_set_color(csi, PDF_FILL, csi->stack);
}
-static void pdf_run_gs(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_gs(pdf_csi *csi, pdf_obj *rdb)
{
- fz_obj *dict;
- fz_obj *obj;
+ pdf_obj *dict;
+ pdf_obj *obj;
fz_context *ctx = csi->dev->ctx;
- dict = fz_dict_gets(rdb, "ExtGState");
+ dict = pdf_dict_gets(rdb, "ExtGState");
if (!dict)
fz_throw(ctx, "cannot find ExtGState dictionary");
- obj = fz_dict_gets(dict, csi->name);
+ obj = pdf_dict_gets(dict, csi->name);
if (!obj)
fz_throw(ctx, "cannot find extgstate resource '%s'", csi->name);
pdf_run_extgstate(csi, rdb, obj);
- /* RJW: "cannot set ExtGState (%d 0 R)", fz_to_num(obj) */
+ /* RJW: "cannot set ExtGState (%d 0 R)", pdf_to_num(obj) */
}
static void pdf_run_h(pdf_csi *csi)
@@ -2286,25 +2286,25 @@ static void pdf_run(pdf_csi *csi)
pdf_show_path(csi, 1, 0, 1, 0);
}
-static void pdf_run_sh(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_sh(pdf_csi *csi, pdf_obj *rdb)
{
fz_context *ctx = csi->dev->ctx;
- fz_obj *dict;
- fz_obj *obj;
+ pdf_obj *dict;
+ pdf_obj *obj;
fz_shade *shd;
- dict = fz_dict_gets(rdb, "Shading");
+ dict = pdf_dict_gets(rdb, "Shading");
if (!dict)
fz_throw(ctx, "cannot find shading dictionary");
- obj = fz_dict_gets(dict, csi->name);
+ obj = pdf_dict_gets(dict, csi->name);
if (!obj)
fz_throw(ctx, "cannot find shading resource: '%s'", csi->name);
if ((csi->dev->hints & FZ_IGNORE_SHADE) == 0)
{
shd = pdf_load_shading(csi->xref, obj);
- /* RJW: "cannot load shading (%d %d R)", fz_to_num(obj), fz_to_gen(obj) */
+ /* RJW: "cannot load shading (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj) */
fz_try(ctx)
{
pdf_show_shade(csi, shd);
@@ -2384,7 +2384,7 @@ static void pdf_run_dquote(pdf_csi *csi)
#define C(a,b,c) (a | b << 8 | c << 16)
static void
-pdf_run_keyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf)
+pdf_run_keyword(pdf_csi *csi, pdf_obj *rdb, fz_stream *file, char *buf)
{
fz_context *ctx = csi->dev->ctx;
int key;
@@ -2522,7 +2522,7 @@ pdf_run_keyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf)
}
static void
-pdf_run_stream(pdf_csi *csi, fz_obj *rdb, fz_stream *file, pdf_lexbuf *buf)
+pdf_run_stream(pdf_csi *csi, pdf_obj *rdb, fz_stream *file, pdf_lexbuf *buf)
{
fz_context *ctx = csi->dev->ctx;
int tok, in_array;
@@ -2631,7 +2631,7 @@ pdf_run_stream(pdf_csi *csi, fz_obj *rdb, fz_stream *file, pdf_lexbuf *buf)
}
else
{
- csi->obj = fz_new_string(ctx, buf->scratch, buf->len);
+ csi->obj = pdf_new_string(ctx, buf->scratch, buf->len);
}
break;
@@ -2652,7 +2652,7 @@ pdf_run_stream(pdf_csi *csi, fz_obj *rdb, fz_stream *file, pdf_lexbuf *buf)
*/
static void
-pdf_run_buffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents)
+pdf_run_buffer(pdf_csi *csi, pdf_obj *rdb, fz_buffer *contents)
{
fz_context *ctx = csi->dev->ctx;
pdf_lexbuf_large *buf;
@@ -2736,7 +2736,7 @@ pdf_run_page_with_usage(pdf_document *xref, pdf_page *page, fz_device *dev, fz_m
cookie->progress++;
}
- flags = fz_to_int(fz_dict_gets(annot->obj, "F"));
+ flags = pdf_to_int(pdf_dict_gets(annot->obj, "F"));
/* TODO: NoZoom and NoRotate */
if (flags & (1 << 0)) /* Invisible */
@@ -2749,7 +2749,7 @@ pdf_run_page_with_usage(pdf_document *xref, pdf_page *page, fz_device *dev, fz_m
continue;
csi = pdf_new_csi(xref, dev, ctm, event, cookie, NULL);
- if (!pdf_is_hidden_ocg(fz_dict_gets(annot->obj, "OC"), csi, page->resources))
+ if (!pdf_is_hidden_ocg(pdf_dict_gets(annot->obj, "OC"), csi, page->resources))
{
fz_try(ctx)
{
@@ -2775,7 +2775,7 @@ pdf_run_page(pdf_document *xref, pdf_page *page, fz_device *dev, fz_matrix ctm,
}
void
-pdf_run_glyph(pdf_document *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate)
+pdf_run_glyph(pdf_document *xref, pdf_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate)
{
pdf_csi *csi = pdf_new_csi(xref, dev, ctm, "View", NULL, gstate);
fz_context *ctx = xref->ctx;