summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
Diffstat (limited to 'source/pdf')
-rw-r--r--source/pdf/pdf-annot-edit.c358
-rw-r--r--source/pdf/pdf-annot.c72
-rw-r--r--source/pdf/pdf-appearance.c120
-rw-r--r--source/pdf/pdf-clean-file.c80
-rw-r--r--source/pdf/pdf-clean.c48
-rw-r--r--source/pdf/pdf-cmap-load.c4
-rw-r--r--source/pdf/pdf-colorspace.c64
-rw-r--r--source/pdf/pdf-crypt.c46
-rw-r--r--source/pdf/pdf-device.c40
-rw-r--r--source/pdf/pdf-field.c38
-rw-r--r--source/pdf/pdf-font.c238
-rw-r--r--source/pdf/pdf-form.c164
-rw-r--r--source/pdf/pdf-function.c26
-rw-r--r--source/pdf/pdf-image.c118
-rw-r--r--source/pdf/pdf-interpret.c86
-rw-r--r--source/pdf/pdf-js.c10
-rw-r--r--source/pdf/pdf-layer.c108
-rw-r--r--source/pdf/pdf-nametree.c26
-rw-r--r--source/pdf/pdf-object.c156
-rw-r--r--source/pdf/pdf-op-filter.c22
-rw-r--r--source/pdf/pdf-op-run.c4
-rw-r--r--source/pdf/pdf-outline.c20
-rw-r--r--source/pdf/pdf-page.c208
-rw-r--r--source/pdf/pdf-parse.c4
-rw-r--r--source/pdf/pdf-pattern.c12
-rw-r--r--source/pdf/pdf-portfolio.c120
-rw-r--r--source/pdf/pdf-repair.c42
-rw-r--r--source/pdf/pdf-resources.c4
-rw-r--r--source/pdf/pdf-run.c2
-rw-r--r--source/pdf/pdf-shade.c46
-rw-r--r--source/pdf/pdf-signature.c2
-rw-r--r--source/pdf/pdf-stream.c74
-rw-r--r--source/pdf/pdf-type3.c24
-rw-r--r--source/pdf/pdf-write.c244
-rw-r--r--source/pdf/pdf-xobject.c42
-rw-r--r--source/pdf/pdf-xref.c76
36 files changed, 1379 insertions, 1369 deletions
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c
index 900145a5..f559828b 100644
--- a/source/pdf/pdf-annot-edit.c
+++ b/source/pdf/pdf-annot-edit.c
@@ -79,7 +79,7 @@ pdf_annot_type_from_string(fz_context *ctx, const char *subtype)
static int is_allowed_subtype(fz_context *ctx, pdf_annot *annot, pdf_obj *property, pdf_obj **allowed)
{
- pdf_obj *subtype = pdf_dict_get(ctx, annot->obj, PDF_NAME_Subtype);
+ pdf_obj *subtype = pdf_dict_get(ctx, annot->obj, PDF_NAME(Subtype));
while (*allowed) {
if (pdf_name_eq(ctx, subtype, *allowed))
return 1;
@@ -91,7 +91,7 @@ static int is_allowed_subtype(fz_context *ctx, pdf_annot *annot, pdf_obj *proper
static void check_allowed_subtypes(fz_context *ctx, pdf_annot *annot, pdf_obj *property, pdf_obj **allowed)
{
- pdf_obj *subtype = pdf_dict_get(ctx, annot->obj, PDF_NAME_Subtype);
+ pdf_obj *subtype = pdf_dict_get(ctx, annot->obj, PDF_NAME(Subtype));
if (!is_allowed_subtype(ctx, annot, property, allowed))
fz_throw(ctx, FZ_ERROR_GENERIC, "%s annotations have no %s property", pdf_to_name(ctx, subtype), pdf_to_name(ctx, property));
}
@@ -116,18 +116,18 @@ pdf_create_annot(fz_context *ctx, pdf_page *page, enum pdf_annot_type type)
if (type == PDF_ANNOT_UNKNOWN)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot create unknown annotation");
- annot_arr = pdf_dict_get(ctx, page->obj, PDF_NAME_Annots);
+ annot_arr = pdf_dict_get(ctx, page->obj, PDF_NAME(Annots));
if (annot_arr == NULL)
{
annot_arr = pdf_new_array(ctx, doc, 0);
- pdf_dict_put_drop(ctx, page->obj, PDF_NAME_Annots, annot_arr);
+ pdf_dict_put_drop(ctx, page->obj, PDF_NAME(Annots), annot_arr);
}
- pdf_dict_put(ctx, annot_obj, PDF_NAME_Type, PDF_NAME_Annot);
- pdf_dict_put_name(ctx, annot_obj, PDF_NAME_Subtype, type_str);
+ pdf_dict_put(ctx, annot_obj, PDF_NAME(Type), PDF_NAME(Annot));
+ pdf_dict_put_name(ctx, annot_obj, PDF_NAME(Subtype), type_str);
/* Make printable as default */
- pdf_dict_put_int(ctx, annot_obj, PDF_NAME_F, PDF_ANNOT_IS_PRINT);
+ pdf_dict_put_int(ctx, annot_obj, PDF_NAME(F), PDF_ANNOT_IS_PRINT);
/*
Both annotation object and annotation structure are now created.
@@ -202,7 +202,7 @@ pdf_delete_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot)
}
/* Remove the annot from the "Annots" array. */
- annot_arr = pdf_dict_get(ctx, page->obj, PDF_NAME_Annots);
+ annot_arr = pdf_dict_get(ctx, page->obj, PDF_NAME(Annots));
i = pdf_array_find(ctx, annot_arr, annot->obj);
if (i >= 0)
pdf_array_delete(ctx, annot_arr, i);
@@ -220,20 +220,20 @@ int
pdf_annot_type(fz_context *ctx, pdf_annot *annot)
{
pdf_obj *obj = annot->obj;
- pdf_obj *subtype = pdf_dict_get(ctx, obj, PDF_NAME_Subtype);
+ pdf_obj *subtype = pdf_dict_get(ctx, obj, PDF_NAME(Subtype));
return pdf_annot_type_from_string(ctx, pdf_to_name(ctx, subtype));
}
int
pdf_annot_flags(fz_context *ctx, pdf_annot *annot)
{
- return pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_F));
+ return pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(F)));
}
void
pdf_set_annot_flags(fz_context *ctx, pdf_annot *annot, int flags)
{
- pdf_dict_put_int(ctx, annot->obj, PDF_NAME_F, flags);
+ pdf_dict_put_int(ctx, annot->obj, PDF_NAME(F), flags);
pdf_dirty_annot(ctx, annot);
}
@@ -242,7 +242,7 @@ pdf_annot_rect(fz_context *ctx, pdf_annot *annot, fz_rect *rect)
{
fz_matrix page_ctm;
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Rect), rect);
+ pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)), rect);
fz_transform_rect(rect, &page_ctm);
}
@@ -256,82 +256,82 @@ pdf_set_annot_rect(fz_context *ctx, pdf_annot *annot, const fz_rect *rect)
fz_invert_matrix(&inv_page_ctm, &page_ctm);
fz_transform_rect(&trect, &inv_page_ctm);
- pdf_dict_put_rect(ctx, annot->obj, PDF_NAME_Rect, &trect);
+ pdf_dict_put_rect(ctx, annot->obj, PDF_NAME(Rect), &trect);
pdf_dirty_annot(ctx, annot);
}
char *
pdf_copy_annot_contents(fz_context *ctx, pdf_annot *annot)
{
- return pdf_to_utf8(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Contents));
+ return pdf_to_utf8(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Contents)));
}
void
pdf_set_annot_contents(fz_context *ctx, pdf_annot *annot, const char *text)
{
- pdf_dict_put_text_string(ctx, annot->obj, PDF_NAME_Contents, text);
+ pdf_dict_put_text_string(ctx, annot->obj, PDF_NAME(Contents), text);
pdf_dirty_annot(ctx, annot);
}
static pdf_obj *open_subtypes[] = {
- PDF_NAME_Popup,
- PDF_NAME_Text,
+ PDF_NAME(Popup),
+ PDF_NAME(Text),
NULL,
};
int
pdf_annot_has_open(fz_context *ctx, pdf_annot *annot)
{
- return is_allowed_subtype(ctx, annot, PDF_NAME_Open, open_subtypes);
+ return is_allowed_subtype(ctx, annot, PDF_NAME(Open), open_subtypes);
}
int
pdf_annot_is_open(fz_context *ctx, pdf_annot *annot)
{
- check_allowed_subtypes(ctx, annot, PDF_NAME_Open, open_subtypes);
- return pdf_to_bool(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Open));
+ check_allowed_subtypes(ctx, annot, PDF_NAME(Open), open_subtypes);
+ return pdf_to_bool(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Open)));
}
void
pdf_set_annot_is_open(fz_context *ctx, pdf_annot *annot, int is_open)
{
pdf_document *doc = annot->page->doc;
- check_allowed_subtypes(ctx, annot, PDF_NAME_Open, open_subtypes);
- pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Open,
+ check_allowed_subtypes(ctx, annot, PDF_NAME(Open), open_subtypes);
+ pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(Open),
pdf_new_bool(ctx, doc, is_open));
pdf_dirty_annot(ctx, annot);
}
static pdf_obj *icon_name_subtypes[] = {
- PDF_NAME_FileAttachment,
- PDF_NAME_Sound,
- PDF_NAME_Stamp,
- PDF_NAME_Text,
+ PDF_NAME(FileAttachment),
+ PDF_NAME(Sound),
+ PDF_NAME(Stamp),
+ PDF_NAME(Text),
NULL,
};
int
pdf_annot_has_icon_name(fz_context *ctx, pdf_annot *annot)
{
- return is_allowed_subtype(ctx, annot, PDF_NAME_Name, icon_name_subtypes);
+ return is_allowed_subtype(ctx, annot, PDF_NAME(Name), icon_name_subtypes);
}
const char *
pdf_annot_icon_name(fz_context *ctx, pdf_annot *annot)
{
pdf_obj *name;
- check_allowed_subtypes(ctx, annot, PDF_NAME_Name, icon_name_subtypes);
- name = pdf_dict_get(ctx, annot->obj, PDF_NAME_Name);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(Name), icon_name_subtypes);
+ name = pdf_dict_get(ctx, annot->obj, PDF_NAME(Name));
if (!name)
{
- pdf_obj *subtype = pdf_dict_get(ctx, annot->obj, PDF_NAME_Subtype);
- if (pdf_name_eq(ctx, subtype, PDF_NAME_Text))
+ pdf_obj *subtype = pdf_dict_get(ctx, annot->obj, PDF_NAME(Subtype));
+ if (pdf_name_eq(ctx, subtype, PDF_NAME(Text)))
return "Note";
- if (pdf_name_eq(ctx, subtype, PDF_NAME_Stamp))
+ if (pdf_name_eq(ctx, subtype, PDF_NAME(Stamp)))
return "Draft";
- if (pdf_name_eq(ctx, subtype, PDF_NAME_FileAttachment))
+ if (pdf_name_eq(ctx, subtype, PDF_NAME(FileAttachment)))
return "PushPin";
- if (pdf_name_eq(ctx, subtype, PDF_NAME_Sound))
+ if (pdf_name_eq(ctx, subtype, PDF_NAME(Sound)))
return "Speaker";
}
return pdf_to_name(ctx, name);
@@ -340,23 +340,23 @@ pdf_annot_icon_name(fz_context *ctx, pdf_annot *annot)
void
pdf_set_annot_icon_name(fz_context *ctx, pdf_annot *annot, const char *name)
{
- check_allowed_subtypes(ctx, annot, PDF_NAME_Name, icon_name_subtypes);
- pdf_dict_put_name(ctx, annot->obj, PDF_NAME_Name, name);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(Name), icon_name_subtypes);
+ pdf_dict_put_name(ctx, annot->obj, PDF_NAME(Name), name);
pdf_dirty_annot(ctx, annot);
}
enum pdf_line_ending pdf_line_ending_from_name(fz_context *ctx, pdf_obj *end)
{
- if (pdf_name_eq(ctx, end, PDF_NAME_None)) return PDF_ANNOT_LE_NONE;
- else if (pdf_name_eq(ctx, end, PDF_NAME_Square)) return PDF_ANNOT_LE_SQUARE;
- else if (pdf_name_eq(ctx, end, PDF_NAME_Circle)) return PDF_ANNOT_LE_CIRCLE;
- else if (pdf_name_eq(ctx, end, PDF_NAME_Diamond)) return PDF_ANNOT_LE_DIAMOND;
- else if (pdf_name_eq(ctx, end, PDF_NAME_OpenArrow)) return PDF_ANNOT_LE_OPEN_ARROW;
- else if (pdf_name_eq(ctx, end, PDF_NAME_ClosedArrow)) return PDF_ANNOT_LE_CLOSED_ARROW;
- else if (pdf_name_eq(ctx, end, PDF_NAME_Butt)) return PDF_ANNOT_LE_BUTT;
- else if (pdf_name_eq(ctx, end, PDF_NAME_ROpenArrow)) return PDF_ANNOT_LE_R_OPEN_ARROW;
- else if (pdf_name_eq(ctx, end, PDF_NAME_RClosedArrow)) return PDF_ANNOT_LE_R_CLOSED_ARROW;
- else if (pdf_name_eq(ctx, end, PDF_NAME_Slash)) return PDF_ANNOT_LE_SLASH;
+ if (pdf_name_eq(ctx, end, PDF_NAME(None))) return PDF_ANNOT_LE_NONE;
+ else if (pdf_name_eq(ctx, end, PDF_NAME(Square))) return PDF_ANNOT_LE_SQUARE;
+ else if (pdf_name_eq(ctx, end, PDF_NAME(Circle))) return PDF_ANNOT_LE_CIRCLE;
+ else if (pdf_name_eq(ctx, end, PDF_NAME(Diamond))) return PDF_ANNOT_LE_DIAMOND;
+ else if (pdf_name_eq(ctx, end, PDF_NAME(OpenArrow))) return PDF_ANNOT_LE_OPEN_ARROW;
+ else if (pdf_name_eq(ctx, end, PDF_NAME(ClosedArrow))) return PDF_ANNOT_LE_CLOSED_ARROW;
+ else if (pdf_name_eq(ctx, end, PDF_NAME(Butt))) return PDF_ANNOT_LE_BUTT;
+ else if (pdf_name_eq(ctx, end, PDF_NAME(ROpenArrow))) return PDF_ANNOT_LE_R_OPEN_ARROW;
+ else if (pdf_name_eq(ctx, end, PDF_NAME(RClosedArrow))) return PDF_ANNOT_LE_R_CLOSED_ARROW;
+ else if (pdf_name_eq(ctx, end, PDF_NAME(Slash))) return PDF_ANNOT_LE_SLASH;
else return PDF_ANNOT_LE_NONE;
}
@@ -380,16 +380,16 @@ pdf_obj *pdf_name_from_line_ending(fz_context *ctx, enum pdf_line_ending end)
switch (end)
{
default:
- case PDF_ANNOT_LE_NONE: return PDF_NAME_None;
- case PDF_ANNOT_LE_SQUARE: return PDF_NAME_Square;
- case PDF_ANNOT_LE_CIRCLE: return PDF_NAME_Circle;
- case PDF_ANNOT_LE_DIAMOND: return PDF_NAME_Diamond;
- case PDF_ANNOT_LE_OPEN_ARROW: return PDF_NAME_OpenArrow;
- case PDF_ANNOT_LE_CLOSED_ARROW: return PDF_NAME_ClosedArrow;
- case PDF_ANNOT_LE_BUTT: return PDF_NAME_Butt;
- case PDF_ANNOT_LE_R_OPEN_ARROW: return PDF_NAME_ROpenArrow;
- case PDF_ANNOT_LE_R_CLOSED_ARROW: return PDF_NAME_RClosedArrow;
- case PDF_ANNOT_LE_SLASH: return PDF_NAME_Slash;
+ case PDF_ANNOT_LE_NONE: return PDF_NAME(None);
+ case PDF_ANNOT_LE_SQUARE: return PDF_NAME(Square);
+ case PDF_ANNOT_LE_CIRCLE: return PDF_NAME(Circle);
+ case PDF_ANNOT_LE_DIAMOND: return PDF_NAME(Diamond);
+ case PDF_ANNOT_LE_OPEN_ARROW: return PDF_NAME(OpenArrow);
+ case PDF_ANNOT_LE_CLOSED_ARROW: return PDF_NAME(ClosedArrow);
+ case PDF_ANNOT_LE_BUTT: return PDF_NAME(Butt);
+ case PDF_ANNOT_LE_R_OPEN_ARROW: return PDF_NAME(ROpenArrow);
+ case PDF_ANNOT_LE_R_CLOSED_ARROW: return PDF_NAME(RClosedArrow);
+ case PDF_ANNOT_LE_SLASH: return PDF_NAME(Slash);
}
}
@@ -412,17 +412,17 @@ const char *pdf_string_from_line_ending(fz_context *ctx, enum pdf_line_ending en
}
static pdf_obj *line_ending_subtypes[] = {
- PDF_NAME_FreeText,
- PDF_NAME_Line,
- PDF_NAME_PolyLine,
- PDF_NAME_Polygon,
+ PDF_NAME(FreeText),
+ PDF_NAME(Line),
+ PDF_NAME(PolyLine),
+ PDF_NAME(Polygon),
NULL,
};
int
pdf_annot_has_line_ending_styles(fz_context *ctx, pdf_annot *annot)
{
- return is_allowed_subtype(ctx, annot, PDF_NAME_LE, line_ending_subtypes);
+ return is_allowed_subtype(ctx, annot, PDF_NAME(LE), line_ending_subtypes);
}
void
@@ -431,8 +431,8 @@ pdf_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot,
enum pdf_line_ending *end_style)
{
pdf_obj *style;
- check_allowed_subtypes(ctx, annot, PDF_NAME_LE, line_ending_subtypes);
- style = pdf_dict_get(ctx, annot->obj, PDF_NAME_LE);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(LE), line_ending_subtypes);
+ style = pdf_dict_get(ctx, annot->obj, PDF_NAME(LE));
*start_style = pdf_line_ending_from_name(ctx, pdf_array_get(ctx, style, 0));
*end_style = pdf_line_ending_from_name(ctx, pdf_array_get(ctx, style, 1));
}
@@ -440,14 +440,14 @@ pdf_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot,
enum pdf_line_ending
pdf_annot_line_start_style(fz_context *ctx, pdf_annot *annot)
{
- pdf_obj *le = pdf_dict_get(ctx, annot->obj, PDF_NAME_LE);
+ pdf_obj *le = pdf_dict_get(ctx, annot->obj, PDF_NAME(LE));
return pdf_line_ending_from_name(ctx, pdf_array_get(ctx, le, 0));
}
enum pdf_line_ending
pdf_annot_line_end_style(fz_context *ctx, pdf_annot *annot)
{
- pdf_obj *le = pdf_dict_get(ctx, annot->obj, PDF_NAME_LE);
+ pdf_obj *le = pdf_dict_get(ctx, annot->obj, PDF_NAME(LE));
return pdf_line_ending_from_name(ctx, pdf_array_get(ctx, le, 1));
}
@@ -458,9 +458,9 @@ pdf_set_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot,
{
pdf_document *doc = annot->page->doc;
pdf_obj *style;
- check_allowed_subtypes(ctx, annot, PDF_NAME_LE, line_ending_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(LE), line_ending_subtypes);
style = pdf_new_array(ctx, doc, 2);
- pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_LE, style);
+ pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(LE), style);
pdf_array_put_drop(ctx, style, 0, pdf_name_from_line_ending(ctx, start_style));
pdf_array_put_drop(ctx, style, 1, pdf_name_from_line_ending(ctx, end_style));
pdf_dirty_annot(ctx, annot);
@@ -484,8 +484,8 @@ float
pdf_annot_border(fz_context *ctx, pdf_annot *annot)
{
pdf_obj *bs, *bs_w;
- bs = pdf_dict_get(ctx, annot->obj, PDF_NAME_BS);
- bs_w = pdf_dict_get(ctx, bs, PDF_NAME_W);
+ bs = pdf_dict_get(ctx, annot->obj, PDF_NAME(BS));
+ bs_w = pdf_dict_get(ctx, bs, PDF_NAME(W));
if (pdf_is_number(ctx, bs_w))
return pdf_to_real(ctx, bs_w);
return 1;
@@ -494,17 +494,17 @@ pdf_annot_border(fz_context *ctx, pdf_annot *annot)
void
pdf_set_annot_border(fz_context *ctx, pdf_annot *annot, float w)
{
- pdf_obj *bs = pdf_dict_get(ctx, annot->obj, PDF_NAME_BS);
+ pdf_obj *bs = pdf_dict_get(ctx, annot->obj, PDF_NAME(BS));
if (!pdf_is_dict(ctx, bs))
- bs = pdf_dict_put_dict(ctx, annot->obj, PDF_NAME_BS, 1);
- pdf_dict_put_real(ctx, bs, PDF_NAME_W, w);
+ bs = pdf_dict_put_dict(ctx, annot->obj, PDF_NAME(BS), 1);
+ pdf_dict_put_real(ctx, bs, PDF_NAME(W), w);
pdf_dirty_annot(ctx, annot);
}
int
pdf_annot_quadding(fz_context *ctx, pdf_annot *annot)
{
- int q = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Q));
+ int q = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Q)));
return (q < 0 || q > 2) ? 0 : q;
}
@@ -512,13 +512,13 @@ void
pdf_set_annot_quadding(fz_context *ctx, pdf_annot *annot, int q)
{
q = (q < 0 || q > 2) ? 0 : q;
- pdf_dict_put_int(ctx, annot->obj, PDF_NAME_Q, q);
+ pdf_dict_put_int(ctx, annot->obj, PDF_NAME(Q), q);
pdf_dirty_annot(ctx, annot);
}
float pdf_annot_opacity(fz_context *ctx, pdf_annot *annot)
{
- pdf_obj *ca = pdf_dict_get(ctx, annot->obj, PDF_NAME_CA);
+ pdf_obj *ca = pdf_dict_get(ctx, annot->obj, PDF_NAME(CA));
if (pdf_is_number(ctx, ca))
return pdf_to_real(ctx, ca);
return 1;
@@ -527,9 +527,9 @@ float pdf_annot_opacity(fz_context *ctx, pdf_annot *annot)
void pdf_set_annot_opacity(fz_context *ctx, pdf_annot *annot, float opacity)
{
if (opacity != 1)
- pdf_dict_put_real(ctx, annot->obj, PDF_NAME_CA, opacity);
+ pdf_dict_put_real(ctx, annot->obj, PDF_NAME(CA), opacity);
else
- pdf_dict_del(ctx, annot->obj, PDF_NAME_CA);
+ pdf_dict_del(ctx, annot->obj, PDF_NAME(CA));
pdf_dirty_annot(ctx, annot);
}
@@ -628,51 +628,51 @@ static void pdf_set_annot_color_imp(fz_context *ctx, pdf_annot *annot, pdf_obj *
void
pdf_annot_color(fz_context *ctx, pdf_annot *annot, int *n, float color[4])
{
- pdf_annot_color_imp(ctx, annot, PDF_NAME_C, n, color, NULL);
+ pdf_annot_color_imp(ctx, annot, PDF_NAME(C), n, color, NULL);
}
void
pdf_set_annot_color(fz_context *ctx, pdf_annot *annot, int n, const float color[4])
{
- pdf_set_annot_color_imp(ctx, annot, PDF_NAME_C, n, color, NULL);
+ pdf_set_annot_color_imp(ctx, annot, PDF_NAME(C), n, color, NULL);
}
static pdf_obj *interior_color_subtypes[] = {
- PDF_NAME_Circle,
- PDF_NAME_Line,
- PDF_NAME_PolyLine,
- PDF_NAME_Polygon,
- PDF_NAME_Square,
+ PDF_NAME(Circle),
+ PDF_NAME(Line),
+ PDF_NAME(PolyLine),
+ PDF_NAME(Polygon),
+ PDF_NAME(Square),
NULL,
};
int
pdf_annot_has_interior_color(fz_context *ctx, pdf_annot *annot)
{
- return is_allowed_subtype(ctx, annot, PDF_NAME_IC, interior_color_subtypes);
+ return is_allowed_subtype(ctx, annot, PDF_NAME(IC), interior_color_subtypes);
}
void
pdf_annot_interior_color(fz_context *ctx, pdf_annot *annot, int *n, float color[4])
{
- pdf_annot_color_imp(ctx, annot, PDF_NAME_IC, n, color, interior_color_subtypes);
+ pdf_annot_color_imp(ctx, annot, PDF_NAME(IC), n, color, interior_color_subtypes);
}
void
pdf_set_annot_interior_color(fz_context *ctx, pdf_annot *annot, int n, const float color[4])
{
- pdf_set_annot_color_imp(ctx, annot, PDF_NAME_IC, n, color, interior_color_subtypes);
+ pdf_set_annot_color_imp(ctx, annot, PDF_NAME(IC), n, color, interior_color_subtypes);
}
static pdf_obj *line_subtypes[] = {
- PDF_NAME_Line,
+ PDF_NAME(Line),
NULL,
};
int
pdf_annot_has_line(fz_context *ctx, pdf_annot *annot)
{
- return is_allowed_subtype(ctx, annot, PDF_NAME_L, line_subtypes);
+ return is_allowed_subtype(ctx, annot, PDF_NAME(L), line_subtypes);
}
void
@@ -681,11 +681,11 @@ pdf_annot_line(fz_context *ctx, pdf_annot *annot, fz_point *a, fz_point *b)
fz_matrix page_ctm;
pdf_obj *line;
- check_allowed_subtypes(ctx, annot, PDF_NAME_L, line_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(L), line_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- line = pdf_dict_get(ctx, annot->obj, PDF_NAME_L);
+ line = pdf_dict_get(ctx, annot->obj, PDF_NAME(L));
a->x = pdf_to_real(ctx, pdf_array_get(ctx, line, 0));
a->y = pdf_to_real(ctx, pdf_array_get(ctx, line, 1));
b->x = pdf_to_real(ctx, pdf_array_get(ctx, line, 2));
@@ -700,7 +700,7 @@ pdf_set_annot_line(fz_context *ctx, pdf_annot *annot, fz_point a, fz_point b)
fz_matrix page_ctm, inv_page_ctm;
pdf_obj *line;
- check_allowed_subtypes(ctx, annot, PDF_NAME_L, line_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(L), line_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
fz_invert_matrix(&inv_page_ctm, &page_ctm);
@@ -709,7 +709,7 @@ pdf_set_annot_line(fz_context *ctx, pdf_annot *annot, fz_point a, fz_point b)
fz_transform_point(&b, &inv_page_ctm);
line = pdf_new_array(ctx, annot->page->doc, 4);
- pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_L, line);
+ pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(L), line);
pdf_array_push_real(ctx, line, a.x);
pdf_array_push_real(ctx, line, a.y);
pdf_array_push_real(ctx, line, b.x);
@@ -719,23 +719,23 @@ pdf_set_annot_line(fz_context *ctx, pdf_annot *annot, fz_point a, fz_point b)
}
static pdf_obj *vertices_subtypes[] = {
- PDF_NAME_PolyLine,
- PDF_NAME_Polygon,
+ PDF_NAME(PolyLine),
+ PDF_NAME(Polygon),
NULL,
};
int
pdf_annot_has_vertices(fz_context *ctx, pdf_annot *annot)
{
- return is_allowed_subtype(ctx, annot, PDF_NAME_Vertices, vertices_subtypes);
+ return is_allowed_subtype(ctx, annot, PDF_NAME(Vertices), vertices_subtypes);
}
int
pdf_annot_vertex_count(fz_context *ctx, pdf_annot *annot)
{
pdf_obj *vertices;
- check_allowed_subtypes(ctx, annot, PDF_NAME_Vertices, vertices_subtypes);
- vertices = pdf_dict_get(ctx, annot->obj, PDF_NAME_Vertices);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(Vertices), vertices_subtypes);
+ vertices = pdf_dict_get(ctx, annot->obj, PDF_NAME(Vertices));
return pdf_array_len(ctx, vertices) / 2;
}
@@ -746,9 +746,9 @@ pdf_annot_vertex(fz_context *ctx, pdf_annot *annot, int i)
fz_matrix page_ctm;
fz_point point;
- check_allowed_subtypes(ctx, annot, PDF_NAME_Vertices, vertices_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(Vertices), vertices_subtypes);
- vertices = pdf_dict_get(ctx, annot->obj, PDF_NAME_Vertices);
+ vertices = pdf_dict_get(ctx, annot->obj, PDF_NAME(Vertices));
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
@@ -768,7 +768,7 @@ pdf_set_annot_vertices(fz_context *ctx, pdf_annot *annot, int n, const fz_point
fz_point point;
int i;
- check_allowed_subtypes(ctx, annot, PDF_NAME_Vertices, vertices_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(Vertices), vertices_subtypes);
if (n <= 0 || !v)
fz_throw(ctx, FZ_ERROR_GENERIC, "invalid number of vertices");
@@ -783,14 +783,14 @@ pdf_set_annot_vertices(fz_context *ctx, pdf_annot *annot, int n, const fz_point
pdf_array_push_real(ctx, vertices, point.x);
pdf_array_push_real(ctx, vertices, point.y);
}
- pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Vertices, vertices);
+ pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(Vertices), vertices);
pdf_dirty_annot(ctx, annot);
}
void pdf_clear_annot_vertices(fz_context *ctx, pdf_annot *annot)
{
- check_allowed_subtypes(ctx, annot, PDF_NAME_Vertices, vertices_subtypes);
- pdf_dict_del(ctx, annot->obj, PDF_NAME_Vertices);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(Vertices), vertices_subtypes);
+ pdf_dict_del(ctx, annot->obj, PDF_NAME(Vertices));
pdf_dirty_annot(ctx, annot);
}
@@ -800,16 +800,16 @@ void pdf_add_annot_vertex(fz_context *ctx, pdf_annot *annot, fz_point p)
fz_matrix page_ctm, inv_page_ctm;
pdf_obj *vertices;
- check_allowed_subtypes(ctx, annot, PDF_NAME_Vertices, vertices_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(Vertices), vertices_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
fz_invert_matrix(&inv_page_ctm, &page_ctm);
- vertices = pdf_dict_get(ctx, annot->obj, PDF_NAME_Vertices);
+ vertices = pdf_dict_get(ctx, annot->obj, PDF_NAME(Vertices));
if (!pdf_is_array(ctx, vertices))
{
vertices = pdf_new_array(ctx, doc, 32);
- pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Vertices, vertices);
+ pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(Vertices), vertices);
}
fz_transform_point(&p, &inv_page_ctm);
@@ -825,39 +825,39 @@ void pdf_set_annot_vertex(fz_context *ctx, pdf_annot *annot, int i, fz_point p)
fz_matrix page_ctm, inv_page_ctm;
pdf_obj *vertices;
- check_allowed_subtypes(ctx, annot, PDF_NAME_Vertices, vertices_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(Vertices), vertices_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
fz_invert_matrix(&inv_page_ctm, &page_ctm);
fz_transform_point(&p, &inv_page_ctm);
- vertices = pdf_dict_get(ctx, annot->obj, PDF_NAME_Vertices);
+ vertices = pdf_dict_get(ctx, annot->obj, PDF_NAME(Vertices));
pdf_array_put_drop(ctx, vertices, i * 2 + 0, pdf_new_real(ctx, doc, p.x));
pdf_array_put_drop(ctx, vertices, i * 2 + 1, pdf_new_real(ctx, doc, p.y));
}
static pdf_obj *quad_point_subtypes[] = {
- PDF_NAME_Highlight,
- PDF_NAME_Link,
- PDF_NAME_Squiggly,
- PDF_NAME_StrikeOut,
- PDF_NAME_Underline,
+ PDF_NAME(Highlight),
+ PDF_NAME(Link),
+ PDF_NAME(Squiggly),
+ PDF_NAME(StrikeOut),
+ PDF_NAME(Underline),
NULL,
};
int
pdf_annot_has_quad_points(fz_context *ctx, pdf_annot *annot)
{
- return is_allowed_subtype(ctx, annot, PDF_NAME_QuadPoints, quad_point_subtypes);
+ return is_allowed_subtype(ctx, annot, PDF_NAME(QuadPoints), quad_point_subtypes);
}
int
pdf_annot_quad_point_count(fz_context *ctx, pdf_annot *annot)
{
pdf_obj *quad_points;
- check_allowed_subtypes(ctx, annot, PDF_NAME_QuadPoints, quad_point_subtypes);
- quad_points = pdf_dict_get(ctx, annot->obj, PDF_NAME_QuadPoints);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(QuadPoints), quad_point_subtypes);
+ quad_points = pdf_dict_get(ctx, annot->obj, PDF_NAME(QuadPoints));
return pdf_array_len(ctx, quad_points) / 8;
}
@@ -868,8 +868,8 @@ pdf_annot_quad_point(fz_context *ctx, pdf_annot *annot, int idx, float v[8])
fz_matrix page_ctm;
int i;
- check_allowed_subtypes(ctx, annot, PDF_NAME_QuadPoints, quad_point_subtypes);
- quad_points = pdf_dict_get(ctx, annot->obj, PDF_NAME_QuadPoints);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(QuadPoints), quad_point_subtypes);
+ quad_points = pdf_dict_get(ctx, annot->obj, PDF_NAME(QuadPoints));
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
for (i = 0; i < 8; i += 2)
@@ -892,7 +892,7 @@ pdf_set_annot_quad_points(fz_context *ctx, pdf_annot *annot, int n, const float
fz_point point;
int i, k;
- check_allowed_subtypes(ctx, annot, PDF_NAME_QuadPoints, quad_point_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(QuadPoints), quad_point_subtypes);
if (n <= 0 || !v)
fz_throw(ctx, FZ_ERROR_GENERIC, "invalid number of quadrilaterals");
@@ -911,15 +911,15 @@ pdf_set_annot_quad_points(fz_context *ctx, pdf_annot *annot, int n, const float
pdf_array_push_real(ctx, quad_points, point.y);
}
}
- pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_QuadPoints, quad_points);
+ pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(QuadPoints), quad_points);
pdf_dirty_annot(ctx, annot);
}
void
pdf_clear_annot_quad_points(fz_context *ctx, pdf_annot *annot)
{
- check_allowed_subtypes(ctx, annot, PDF_NAME_QuadPoints, quad_point_subtypes);
- pdf_dict_del(ctx, annot->obj, PDF_NAME_QuadPoints);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(QuadPoints), quad_point_subtypes);
+ pdf_dict_del(ctx, annot->obj, PDF_NAME(QuadPoints));
pdf_dirty_annot(ctx, annot);
}
@@ -930,16 +930,16 @@ pdf_add_annot_quad_point(fz_context *ctx, pdf_annot *annot, fz_rect bbox)
fz_matrix page_ctm, inv_page_ctm;
pdf_obj *quad_points;
- check_allowed_subtypes(ctx, annot, PDF_NAME_QuadPoints, quad_point_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(QuadPoints), quad_point_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
fz_invert_matrix(&inv_page_ctm, &page_ctm);
- quad_points = pdf_dict_get(ctx, annot->obj, PDF_NAME_QuadPoints);
+ quad_points = pdf_dict_get(ctx, annot->obj, PDF_NAME(QuadPoints));
if (!pdf_is_array(ctx, quad_points))
{
quad_points = pdf_new_array(ctx, doc, 8);
- pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_QuadPoints, quad_points);
+ pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(QuadPoints), quad_points);
}
/* Contrary to the specification, the points within a QuadPoint are NOT ordered
@@ -960,22 +960,22 @@ pdf_add_annot_quad_point(fz_context *ctx, pdf_annot *annot, fz_rect bbox)
}
static pdf_obj *ink_list_subtypes[] = {
- PDF_NAME_Ink,
+ PDF_NAME(Ink),
NULL,
};
int
pdf_annot_has_ink_list(fz_context *ctx, pdf_annot *annot)
{
- return is_allowed_subtype(ctx, annot, PDF_NAME_InkList, ink_list_subtypes);
+ return is_allowed_subtype(ctx, annot, PDF_NAME(InkList), ink_list_subtypes);
}
int
pdf_annot_ink_list_count(fz_context *ctx, pdf_annot *annot)
{
pdf_obj *ink_list;
- check_allowed_subtypes(ctx, annot, PDF_NAME_InkList, ink_list_subtypes);
- ink_list = pdf_dict_get(ctx, annot->obj, PDF_NAME_InkList);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(InkList), ink_list_subtypes);
+ ink_list = pdf_dict_get(ctx, annot->obj, PDF_NAME(InkList));
return pdf_array_len(ctx, ink_list);
}
@@ -984,8 +984,8 @@ pdf_annot_ink_list_stroke_count(fz_context *ctx, pdf_annot *annot, int i)
{
pdf_obj *ink_list;
pdf_obj *stroke;
- check_allowed_subtypes(ctx, annot, PDF_NAME_InkList, ink_list_subtypes);
- ink_list = pdf_dict_get(ctx, annot->obj, PDF_NAME_InkList);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(InkList), ink_list_subtypes);
+ ink_list = pdf_dict_get(ctx, annot->obj, PDF_NAME(InkList));
stroke = pdf_array_get(ctx, ink_list, i);
return pdf_array_len(ctx, stroke) / 2;
}
@@ -998,9 +998,9 @@ pdf_annot_ink_list_stroke_vertex(fz_context *ctx, pdf_annot *annot, int i, int k
fz_matrix page_ctm;
fz_point point;
- check_allowed_subtypes(ctx, annot, PDF_NAME_InkList, ink_list_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(InkList), ink_list_subtypes);
- ink_list = pdf_dict_get(ctx, annot->obj, PDF_NAME_InkList);
+ ink_list = pdf_dict_get(ctx, annot->obj, PDF_NAME(InkList));
stroke = pdf_array_get(ctx, ink_list, i);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
@@ -1021,7 +1021,7 @@ pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *coun
fz_point point;
int i, k;
- check_allowed_subtypes(ctx, annot, PDF_NAME_InkList, ink_list_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(InkList), ink_list_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
fz_invert_matrix(&inv_page_ctm, &page_ctm);
@@ -1041,15 +1041,15 @@ pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *coun
}
pdf_array_push_drop(ctx, ink_list, stroke);
}
- pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_InkList, ink_list);
+ pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(InkList), ink_list);
pdf_dirty_annot(ctx, annot);
}
void
pdf_clear_annot_ink_list(fz_context *ctx, pdf_annot *annot)
{
- check_allowed_subtypes(ctx, annot, PDF_NAME_InkList, ink_list_subtypes);
- pdf_dict_del(ctx, annot->obj, PDF_NAME_InkList);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(InkList), ink_list_subtypes);
+ pdf_dict_del(ctx, annot->obj, PDF_NAME(InkList));
pdf_dirty_annot(ctx, annot);
}
@@ -1061,16 +1061,16 @@ pdf_add_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, fz_point p[])
pdf_obj *ink_list, *stroke;
int i;
- check_allowed_subtypes(ctx, annot, PDF_NAME_InkList, ink_list_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(InkList), ink_list_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
fz_invert_matrix(&inv_page_ctm, &page_ctm);
- ink_list = pdf_dict_get(ctx, annot->obj, PDF_NAME_InkList);
+ ink_list = pdf_dict_get(ctx, annot->obj, PDF_NAME(InkList));
if (!pdf_is_array(ctx, ink_list))
{
ink_list = pdf_new_array(ctx, doc, 10);
- pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_InkList, ink_list);
+ pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(InkList), ink_list);
}
stroke = pdf_new_array(ctx, doc, n * 2);
@@ -1111,11 +1111,11 @@ pdf_set_text_annot_position(fz_context *ctx, pdf_annot *annot, fz_point pt)
rect.y1 = pt.y + TEXT_ANNOT_SIZE;
fz_transform_rect(&rect, &inv_page_ctm);
- pdf_dict_put_rect(ctx, annot->obj, PDF_NAME_Rect, &rect);
+ pdf_dict_put_rect(ctx, annot->obj, PDF_NAME(Rect), &rect);
- flags = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_F));
+ flags = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(F)));
flags |= (PDF_ANNOT_IS_NO_ZOOM|PDF_ANNOT_IS_NO_ROTATE);
- pdf_dict_put_int(ctx, annot->obj, PDF_NAME_F, flags);
+ pdf_dict_put_int(ctx, annot->obj, PDF_NAME(F), flags);
}
static void
@@ -1219,29 +1219,29 @@ pdf_parse_date(fz_context *ctx, const char *s)
}
static pdf_obj *markup_subtypes[] = {
- PDF_NAME_Text,
- PDF_NAME_FreeText,
- PDF_NAME_Line,
- PDF_NAME_Square,
- PDF_NAME_Circle,
- PDF_NAME_Polygon,
- PDF_NAME_PolyLine,
- PDF_NAME_Highlight,
- PDF_NAME_Underline,
- PDF_NAME_Squiggly,
- PDF_NAME_StrikeOut,
- PDF_NAME_Stamp,
- PDF_NAME_Caret,
- PDF_NAME_Ink,
- PDF_NAME_FileAttachment,
- PDF_NAME_Sound,
+ PDF_NAME(Text),
+ PDF_NAME(FreeText),
+ PDF_NAME(Line),
+ PDF_NAME(Square),
+ PDF_NAME(Circle),
+ PDF_NAME(Polygon),
+ PDF_NAME(PolyLine),
+ PDF_NAME(Highlight),
+ PDF_NAME(Underline),
+ PDF_NAME(Squiggly),
+ PDF_NAME(StrikeOut),
+ PDF_NAME(Stamp),
+ PDF_NAME(Caret),
+ PDF_NAME(Ink),
+ PDF_NAME(FileAttachment),
+ PDF_NAME(Sound),
NULL,
};
int64_t
pdf_annot_modification_date(fz_context *ctx, pdf_annot *annot)
{
- pdf_obj *date = pdf_dict_get(ctx, annot->obj, PDF_NAME_M);
+ pdf_obj *date = pdf_dict_get(ctx, annot->obj, PDF_NAME(M));
return date ? pdf_parse_date(ctx, pdf_to_str_buf(ctx, date)) : 0;
}
@@ -1250,31 +1250,31 @@ pdf_set_annot_modification_date(fz_context *ctx, pdf_annot *annot, int64_t secs)
{
char s[40];
- check_allowed_subtypes(ctx, annot, PDF_NAME_M, markup_subtypes);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(M), markup_subtypes);
pdf_format_date(ctx, s, sizeof s, secs);
- pdf_dict_put_string(ctx, annot->obj, PDF_NAME_M, s, strlen(s));
+ pdf_dict_put_string(ctx, annot->obj, PDF_NAME(M), s, strlen(s));
pdf_dirty_annot(ctx, annot);
}
int
pdf_annot_has_author(fz_context *ctx, pdf_annot *annot)
{
- return is_allowed_subtype(ctx, annot, PDF_NAME_T, markup_subtypes);
+ return is_allowed_subtype(ctx, annot, PDF_NAME(T), markup_subtypes);
}
char *
pdf_copy_annot_author(fz_context *ctx, pdf_annot *annot)
{
- check_allowed_subtypes(ctx, annot, PDF_NAME_T, markup_subtypes);
- return pdf_to_utf8(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_T));
+ check_allowed_subtypes(ctx, annot, PDF_NAME(T), markup_subtypes);
+ return pdf_to_utf8(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(T)));
}
void
pdf_set_annot_author(fz_context *ctx, pdf_annot *annot, const char *author)
{
- check_allowed_subtypes(ctx, annot, PDF_NAME_T, markup_subtypes);
- pdf_dict_put_text_string(ctx, annot->obj, PDF_NAME_T, author);
+ check_allowed_subtypes(ctx, annot, PDF_NAME(T), markup_subtypes);
+ pdf_dict_put_text_string(ctx, annot->obj, PDF_NAME(T), author);
pdf_dirty_annot(ctx, annot);
}
@@ -1310,19 +1310,19 @@ pdf_set_free_text_details(fz_context *ctx, pdf_annot *annot, fz_point *pos, char
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
fz_invert_matrix(&inv_page_ctm, &page_ctm);
- dr = pdf_dict_get(ctx, annot->page->obj, PDF_NAME_Resources);
+ dr = pdf_dict_get(ctx, annot->page->obj, PDF_NAME(Resources));
if (!dr)
{
dr = pdf_new_dict(ctx, doc, 1);
- pdf_dict_put_drop(ctx, annot->page->obj, PDF_NAME_Resources, dr);
+ pdf_dict_put_drop(ctx, annot->page->obj, PDF_NAME(Resources), dr);
}
/* Ensure the resource dictionary includes a font dict */
- form_fonts = pdf_dict_get(ctx, dr, PDF_NAME_Font);
+ form_fonts = pdf_dict_get(ctx, dr, PDF_NAME(Font));
if (!form_fonts)
{
form_fonts = pdf_new_dict(ctx, doc, 1);
- pdf_dict_put_drop(ctx, dr, PDF_NAME_Font, form_fonts);
+ pdf_dict_put_drop(ctx, dr, PDF_NAME(Font), form_fonts);
/* form_fonts is still valid if execution continues past the above call */
}
@@ -1340,10 +1340,10 @@ pdf_set_free_text_details(fz_context *ctx, pdf_annot *annot, fz_point *pos, char
ref = pdf_add_object(ctx, doc, font);
pdf_dict_puts_drop(ctx, form_fonts, nbuf, ref);
- pdf_dict_put(ctx, font, PDF_NAME_Type, PDF_NAME_Font);
- pdf_dict_put(ctx, font, PDF_NAME_Subtype, PDF_NAME_Type1);
- pdf_dict_put_name(ctx, font, PDF_NAME_BaseFont, font_name);
- pdf_dict_put(ctx, font, PDF_NAME_Encoding, PDF_NAME_WinAnsiEncoding);
+ pdf_dict_put(ctx, font, PDF_NAME(Type), PDF_NAME(Font));
+ pdf_dict_put(ctx, font, PDF_NAME(Subtype), PDF_NAME(Type1));
+ pdf_dict_put_name(ctx, font, PDF_NAME(BaseFont), font_name);
+ pdf_dict_put(ctx, font, PDF_NAME(Encoding), PDF_NAME(WinAnsiEncoding));
memcpy(da_info.col, color, sizeof(float)*3);
da_info.col_size = 3;
@@ -1354,10 +1354,10 @@ pdf_set_free_text_details(fz_context *ctx, pdf_annot *annot, fz_point *pos, char
pdf_fzbuf_print_da(ctx, fzbuf, &da_info);
da_len = fz_buffer_storage(ctx, fzbuf, &da_str);
- pdf_dict_put_string(ctx, annot->obj, PDF_NAME_DA, (char *)da_str, da_len);
+ pdf_dict_put_string(ctx, annot->obj, PDF_NAME(DA), (char *)da_str, da_len);
/* FIXME: should convert to WinAnsiEncoding */
- pdf_dict_put_text_string(ctx, annot->obj, PDF_NAME_Contents, text);
+ pdf_dict_put_text_string(ctx, annot->obj, PDF_NAME(Contents), text);
font_desc = pdf_load_font(ctx, doc, NULL, font, 0);
pdf_measure_text(ctx, font_desc, (unsigned char *)text, strlen(text), &bounds);
@@ -1375,7 +1375,7 @@ pdf_set_free_text_details(fz_context *ctx, pdf_annot *annot, fz_point *pos, char
bounds.y0 += page_pos.y;
bounds.y1 += page_pos.y;
- pdf_dict_put_rect(ctx, annot->obj, PDF_NAME_Rect, &bounds);
+ pdf_dict_put_rect(ctx, annot->obj, PDF_NAME(Rect), &bounds);
}
fz_always(ctx)
{
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c
index f60401af..b1bddf5c 100644
--- a/source/pdf/pdf-annot.c
+++ b/source/pdf/pdf-annot.c
@@ -23,7 +23,7 @@ resolve_dest_rec(fz_context *ctx, pdf_document *doc, pdf_obj *dest, int depth)
else if (pdf_is_dict(ctx, dest))
{
- dest = pdf_dict_get(ctx, dest, PDF_NAME_D);
+ dest = pdf_dict_get(ctx, dest, PDF_NAME(D));
return resolve_dest_rec(ctx, doc, dest, depth+1);
}
@@ -79,19 +79,19 @@ pdf_parse_link_dest(fz_context *ctx, pdf_document *doc, pdf_obj *dest)
x = y = 0;
obj = pdf_array_get(ctx, dest, 1);
- if (pdf_name_eq(ctx, obj, PDF_NAME_XYZ))
+ if (pdf_name_eq(ctx, obj, PDF_NAME(XYZ)))
{
x = pdf_to_int(ctx, pdf_array_get(ctx, dest, 2));
y = pdf_to_int(ctx, pdf_array_get(ctx, dest, 3));
}
- else if (pdf_name_eq(ctx, obj, PDF_NAME_FitR))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(FitR)))
{
x = pdf_to_int(ctx, pdf_array_get(ctx, dest, 2));
y = pdf_to_int(ctx, pdf_array_get(ctx, dest, 5));
}
- else if (pdf_name_eq(ctx, obj, PDF_NAME_FitH) || pdf_name_eq(ctx, obj, PDF_NAME_FitBH))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(FitH)) || pdf_name_eq(ctx, obj, PDF_NAME(FitBH)))
y = pdf_to_int(ctx, pdf_array_get(ctx, dest, 2));
- else if (pdf_name_eq(ctx, obj, PDF_NAME_FitV) || pdf_name_eq(ctx, obj, PDF_NAME_FitBV))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(FitV)) || pdf_name_eq(ctx, obj, PDF_NAME(FitBV)))
x = pdf_to_int(ctx, pdf_array_get(ctx, dest, 2));
if (page >= 0)
@@ -120,12 +120,12 @@ pdf_parse_file_spec(fz_context *ctx, pdf_document *doc, pdf_obj *file_spec, pdf_
if (pdf_is_dict(ctx, file_spec)) {
#ifdef _WIN32
- filename = pdf_dict_get(ctx, file_spec, PDF_NAME_DOS);
+ filename = pdf_dict_get(ctx, file_spec, PDF_NAME(DOS));
#else
- filename = pdf_dict_get(ctx, file_spec, PDF_NAME_Unix);
+ filename = pdf_dict_get(ctx, file_spec, PDF_NAME(Unix));
#endif
if (!filename)
- filename = pdf_dict_geta(ctx, file_spec, PDF_NAME_UF, PDF_NAME_F);
+ filename = pdf_dict_geta(ctx, file_spec, PDF_NAME(UF), PDF_NAME(F));
}
if (!pdf_is_string(ctx, filename))
@@ -136,7 +136,7 @@ pdf_parse_file_spec(fz_context *ctx, pdf_document *doc, pdf_obj *file_spec, pdf_
path = pdf_to_utf8(ctx, filename);
#ifdef _WIN32
- if (!pdf_name_eq(ctx, pdf_dict_get(ctx, file_spec, PDF_NAME_FS), PDF_NAME_URL))
+ if (!pdf_name_eq(ctx, pdf_dict_get(ctx, file_spec, PDF_NAME(FS)), PDF_NAME(URL)))
{
/* move the file name into the expected place and use the expected path separator */
char *c;
@@ -179,16 +179,16 @@ pdf_parse_link_action(fz_context *ctx, pdf_document *doc, pdf_obj *action, int p
if (!action)
return NULL;
- obj = pdf_dict_get(ctx, action, PDF_NAME_S);
- if (pdf_name_eq(ctx, PDF_NAME_GoTo, obj))
+ obj = pdf_dict_get(ctx, action, PDF_NAME(S));
+ if (pdf_name_eq(ctx, PDF_NAME(GoTo), obj))
{
- dest = pdf_dict_get(ctx, action, PDF_NAME_D);
+ dest = pdf_dict_get(ctx, action, PDF_NAME(D));
return pdf_parse_link_dest(ctx, doc, dest);
}
- else if (pdf_name_eq(ctx, PDF_NAME_URI, obj))
+ else if (pdf_name_eq(ctx, PDF_NAME(URI), obj))
{
/* URI entries are ASCII strings */
- const char *uri = pdf_to_str_buf(ctx, pdf_dict_get(ctx, action, PDF_NAME_URI));
+ const char *uri = pdf_to_str_buf(ctx, pdf_dict_get(ctx, action, PDF_NAME(URI)));
if (!fz_is_external_link(ctx, uri))
{
pdf_obj *uri_base_obj = pdf_dict_getp(ctx, pdf_trailer(ctx, doc), "Root/URI/Base");
@@ -200,31 +200,31 @@ pdf_parse_link_action(fz_context *ctx, pdf_document *doc, pdf_obj *action, int p
}
return fz_strdup(ctx, uri);
}
- else if (pdf_name_eq(ctx, PDF_NAME_Launch, obj))
+ else if (pdf_name_eq(ctx, PDF_NAME(Launch), obj))
{
- file_spec = pdf_dict_get(ctx, action, PDF_NAME_F);
+ file_spec = pdf_dict_get(ctx, action, PDF_NAME(F));
return pdf_parse_file_spec(ctx, doc, file_spec, NULL);
}
- else if (pdf_name_eq(ctx, PDF_NAME_GoToR, obj))
+ else if (pdf_name_eq(ctx, PDF_NAME(GoToR), obj))
{
- dest = pdf_dict_get(ctx, action, PDF_NAME_D);
- file_spec = pdf_dict_get(ctx, action, PDF_NAME_F);
+ dest = pdf_dict_get(ctx, action, PDF_NAME(D));
+ file_spec = pdf_dict_get(ctx, action, PDF_NAME(F));
return pdf_parse_file_spec(ctx, doc, file_spec, dest);
}
- else if (pdf_name_eq(ctx, PDF_NAME_Named, obj))
+ else if (pdf_name_eq(ctx, PDF_NAME(Named), obj))
{
- dest = pdf_dict_get(ctx, action, PDF_NAME_N);
+ dest = pdf_dict_get(ctx, action, PDF_NAME(N));
- if (pdf_name_eq(ctx, PDF_NAME_FirstPage, dest))
+ if (pdf_name_eq(ctx, PDF_NAME(FirstPage), dest))
pagenum = 0;
- else if (pdf_name_eq(ctx, PDF_NAME_LastPage, dest))
+ else if (pdf_name_eq(ctx, PDF_NAME(LastPage), dest))
pagenum = pdf_count_pages(ctx, doc) - 1;
- else if (pdf_name_eq(ctx, PDF_NAME_PrevPage, dest) && pagenum >= 0)
+ else if (pdf_name_eq(ctx, PDF_NAME(PrevPage), dest) && pagenum >= 0)
{
if (pagenum > 0)
pagenum--;
}
- else if (pdf_name_eq(ctx, PDF_NAME_NextPage, dest) && pagenum >= 0)
+ else if (pdf_name_eq(ctx, PDF_NAME(NextPage), dest) && pagenum >= 0)
{
if (pagenum < pdf_count_pages(ctx, doc) - 1)
pagenum++;
@@ -247,26 +247,26 @@ pdf_load_link(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int pagenum, co
char *uri;
fz_link *link = NULL;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Subtype);
- if (!pdf_name_eq(ctx, obj, PDF_NAME_Link))
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Subtype));
+ if (!pdf_name_eq(ctx, obj, PDF_NAME(Link)))
return NULL;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Rect);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Rect));
if (!obj)
return NULL;
pdf_to_rect(ctx, obj, &bbox);
fz_transform_rect(&bbox, page_ctm);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Dest);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Dest));
if (obj)
uri = pdf_parse_link_dest(ctx, doc, obj);
else
{
- action = pdf_dict_get(ctx, dict, PDF_NAME_A);
+ action = pdf_dict_get(ctx, dict, PDF_NAME(A));
/* fall back to additional action button's down/up action */
if (!action)
- action = pdf_dict_geta(ctx, pdf_dict_get(ctx, dict, PDF_NAME_AA), PDF_NAME_U, PDF_NAME_D);
+ action = pdf_dict_geta(ctx, pdf_dict_get(ctx, dict, PDF_NAME(AA)), PDF_NAME(U), PDF_NAME(D));
uri = pdf_parse_link_action(ctx, doc, action, pagenum);
}
@@ -381,7 +381,7 @@ pdf_annot_transform(fz_context *ctx, pdf_annot *annot, fz_matrix *annot_ctm)
fz_matrix matrix;
float w, h, x, y;
- pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Rect), &rect);
+ pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)), &rect);
pdf_xobject_bbox(ctx, annot->ap, &bbox);
pdf_xobject_matrix(ctx, annot->ap, &matrix);
@@ -430,10 +430,10 @@ pdf_load_annots(fz_context *ctx, pdf_page *page, pdf_obj *annots)
pdf_obj *obj = pdf_array_get(ctx, annots, i);
if (obj)
{
- subtype = pdf_dict_get(ctx, obj, PDF_NAME_Subtype);
- if (pdf_name_eq(ctx, subtype, PDF_NAME_Link))
+ subtype = pdf_dict_get(ctx, obj, PDF_NAME(Subtype));
+ if (pdf_name_eq(ctx, subtype, PDF_NAME(Link)))
continue;
- if (pdf_name_eq(ctx, subtype, PDF_NAME_Popup))
+ if (pdf_name_eq(ctx, subtype, PDF_NAME(Popup)))
continue;
annot = pdf_new_annot(ctx, page, obj);
@@ -466,7 +466,7 @@ pdf_next_annot(fz_context *ctx, pdf_annot *annot)
fz_rect *
pdf_bound_annot(fz_context *ctx, pdf_annot *annot, fz_rect *rect)
{
- pdf_obj *obj = pdf_dict_get(ctx, annot->obj, PDF_NAME_Rect);
+ pdf_obj *obj = pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect));
fz_rect mediabox;
fz_matrix page_ctm;
pdf_to_rect(ctx, obj, rect);
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index 22621fe5..b7f8f31b 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -174,13 +174,13 @@ static void get_font_info(fz_context *ctx, pdf_document *doc, pdf_obj *dr, char
if (font_rec->da_rec.font_name == NULL)
fz_throw(ctx, FZ_ERROR_GENERIC, "No font name in default appearance");
- fontobj = pdf_dict_gets(ctx, pdf_dict_get(ctx, dr, PDF_NAME_Font), font_rec->da_rec.font_name);
+ fontobj = pdf_dict_gets(ctx, pdf_dict_get(ctx, dr, PDF_NAME(Font)), font_rec->da_rec.font_name);
if (!fontobj)
{
fz_font *helv = fz_new_base14_font(ctx, "Helvetica");
fz_warn(ctx, "form resource dictionary is missing the default appearance font");
fontobj = pdf_add_simple_font(ctx, doc, helv, PDF_SIMPLE_ENCODING_LATIN);
- pdf_dict_puts_drop(ctx, pdf_dict_get(ctx, dr, PDF_NAME_Font), font_rec->da_rec.font_name, fontobj);
+ pdf_dict_puts_drop(ctx, pdf_dict_get(ctx, dr, PDF_NAME(Font)), font_rec->da_rec.font_name, fontobj);
fz_drop_font(ctx, helv);
}
font_rec->font = font = pdf_load_font(ctx, doc, dr, fontobj, 0);
@@ -198,13 +198,13 @@ static void font_info_fin(fz_context *ctx, font_info *font_rec)
static void get_text_widget_info(fz_context *ctx, pdf_document *doc, pdf_obj *widget, text_widget_info *info)
{
- char *da = pdf_to_str_buf(ctx, pdf_get_inheritable(ctx, doc, widget, PDF_NAME_DA));
+ char *da = pdf_to_str_buf(ctx, pdf_get_inheritable(ctx, doc, widget, PDF_NAME(DA)));
int ff = pdf_get_field_flags(ctx, doc, widget);
- pdf_obj *ml = pdf_get_inheritable(ctx, doc, widget, PDF_NAME_MaxLen);
+ pdf_obj *ml = pdf_get_inheritable(ctx, doc, widget, PDF_NAME(MaxLen));
- info->dr = pdf_get_inheritable(ctx, doc, widget, PDF_NAME_DR);
- info->col = pdf_dict_getl(ctx, widget, PDF_NAME_MK, PDF_NAME_BG, NULL);
- info->q = pdf_to_int(ctx, pdf_get_inheritable(ctx, doc, widget, PDF_NAME_Q));
+ info->dr = pdf_get_inheritable(ctx, doc, widget, PDF_NAME(DR));
+ info->col = pdf_dict_getl(ctx, widget, PDF_NAME(MK), PDF_NAME(BG), NULL);
+ info->q = pdf_to_int(ctx, pdf_get_inheritable(ctx, doc, widget, PDF_NAME(Q)));
info->multiline = (ff & Ff_Multiline) != 0;
info->comb = (ff & (Ff_Multiline|Ff_Password|Ff_FileSelect|Ff_Comb)) == Ff_Comb;
@@ -840,7 +840,7 @@ static int get_matrix(fz_context *ctx, pdf_document *doc, pdf_obj *form, int q,
if (found)
{
fz_rect bbox;
- pdf_to_rect(ctx, pdf_dict_get(ctx, form, PDF_NAME_BBox), &bbox);
+ pdf_to_rect(ctx, pdf_dict_get(ctx, form, PDF_NAME(BBox)), &bbox);
switch (q)
{
@@ -990,25 +990,25 @@ static pdf_obj *load_or_create_form(fz_context *ctx, pdf_document *doc, pdf_obj
fz_var(fzbuf);
fz_try(ctx)
{
- rot = pdf_to_int(ctx, pdf_dict_getl(ctx, obj, PDF_NAME_MK, PDF_NAME_R, NULL));
- pdf_to_rect(ctx, pdf_dict_get(ctx, obj, PDF_NAME_Rect), rect);
+ rot = pdf_to_int(ctx, pdf_dict_getl(ctx, obj, PDF_NAME(MK), PDF_NAME(R), NULL));
+ pdf_to_rect(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Rect)), rect);
rect->x1 -= rect->x0;
rect->y1 -= rect->y0;
rect->x0 = rect->y0 = 0;
account_for_rot(rect, &mat, rot);
- ap = pdf_dict_get(ctx, obj, PDF_NAME_AP);
+ ap = pdf_dict_get(ctx, obj, PDF_NAME(AP));
if (ap == NULL)
{
ap = pdf_new_dict(ctx, doc, 1);
- pdf_dict_put_drop(ctx, obj, PDF_NAME_AP, ap);
+ pdf_dict_put_drop(ctx, obj, PDF_NAME(AP), ap);
}
- formobj = pdf_dict_get(ctx, ap, PDF_NAME_N);
+ formobj = pdf_dict_get(ctx, ap, PDF_NAME(N));
if (formobj == NULL)
{
formobj = pdf_new_xobject(ctx, doc, rect, &mat);
- pdf_dict_put_drop(ctx, ap, PDF_NAME_N, formobj);
+ pdf_dict_put_drop(ctx, ap, PDF_NAME(N), formobj);
create_form = 1;
}
@@ -1018,7 +1018,7 @@ static pdf_obj *load_or_create_form(fz_context *ctx, pdf_document *doc, pdf_obj
pdf_update_stream(ctx, doc, formobj, fzbuf, 0);
}
- copy_resources(ctx, pdf_xobject_resources(ctx, formobj), pdf_get_inheritable(ctx, doc, obj, PDF_NAME_DR));
+ copy_resources(ctx, pdf_xobject_resources(ctx, formobj), pdf_get_inheritable(ctx, doc, obj, PDF_NAME(DR)));
}
fz_always(ctx)
{
@@ -1121,15 +1121,15 @@ static void update_marked_content(fz_context *ctx, pdf_document *doc, pdf_obj *f
static int get_border_style(fz_context *ctx, pdf_obj *obj)
{
- pdf_obj *sname = pdf_dict_getl(ctx, obj, PDF_NAME_BS, PDF_NAME_S, NULL);
+ pdf_obj *sname = pdf_dict_getl(ctx, obj, PDF_NAME(BS), PDF_NAME(S), NULL);
- if (pdf_name_eq(ctx, PDF_NAME_D, sname))
+ if (pdf_name_eq(ctx, PDF_NAME(D), sname))
return BS_Dashed;
- else if (pdf_name_eq(ctx, PDF_NAME_B, sname))
+ else if (pdf_name_eq(ctx, PDF_NAME(B), sname))
return BS_Beveled;
- else if (pdf_name_eq(ctx, PDF_NAME_I, sname))
+ else if (pdf_name_eq(ctx, PDF_NAME(I), sname))
return BS_Inset;
- else if (pdf_name_eq(ctx, PDF_NAME_U, sname))
+ else if (pdf_name_eq(ctx, PDF_NAME(U), sname))
return BS_Underline;
else
return BS_Solid;
@@ -1137,7 +1137,7 @@ static int get_border_style(fz_context *ctx, pdf_obj *obj)
static float get_border_width(fz_context *ctx, pdf_obj *obj)
{
- float w = pdf_to_real(ctx, pdf_dict_getl(ctx, obj, PDF_NAME_BS, PDF_NAME_W, NULL));
+ float w = pdf_to_real(ctx, pdf_dict_getl(ctx, obj, PDF_NAME(BS), PDF_NAME(W), NULL));
return w == 0.0f ? 1.0f : w;
}
@@ -1224,7 +1224,7 @@ void pdf_update_listbox_appearance(fz_context *ctx, pdf_document *doc, pdf_obj *
fz_var(sel_indices);
fz_try(ctx)
{
- optarr = pdf_dict_get(ctx, obj, PDF_NAME_Opt);
+ optarr = pdf_dict_get(ctx, obj, PDF_NAME(Opt));
n = pdf_array_len(ctx, optarr);
opts = (char **)fz_malloc(ctx, n * sizeof(*opts));
vals = (char **)fz_malloc(ctx, n * sizeof(*vals));
@@ -1254,7 +1254,7 @@ void pdf_update_listbox_appearance(fz_context *ctx, pdf_document *doc, pdf_obj *
form = load_or_create_form(ctx, doc, obj, &clip_rect);
/* See which ones are selected */
- valarr = pdf_get_inheritable(ctx, doc, obj, PDF_NAME_V);
+ valarr = pdf_get_inheritable(ctx, doc, obj, PDF_NAME(V));
if (pdf_is_array(ctx, valarr))
{
num_sel = pdf_array_len(ctx, valarr);
@@ -1403,7 +1403,7 @@ void pdf_update_combobox_appearance(fz_context *ctx, pdf_document *doc, pdf_obj
{
get_text_widget_info(ctx, doc, obj, &info);
- val = pdf_get_inheritable(ctx, doc, obj, PDF_NAME_V);
+ val = pdf_get_inheritable(ctx, doc, obj, PDF_NAME(V));
if (pdf_is_array(ctx, val))
val = pdf_array_get(ctx, val, 0);
@@ -1453,7 +1453,7 @@ void pdf_update_pushbutton_appearance(fz_context *ctx, pdf_document *doc, pdf_ob
{
form = load_or_create_form(ctx, doc, obj, &rect);
fzbuf = fz_new_buffer(ctx, 0);
- tobj = pdf_dict_getl(ctx, obj, PDF_NAME_MK, PDF_NAME_BG, NULL);
+ tobj = pdf_dict_getl(ctx, obj, PDF_NAME(MK), PDF_NAME(BG), NULL);
if (pdf_is_array(ctx, tobj))
{
fzbuf_print_color(ctx, fzbuf, tobj, 0, 0.0f);
@@ -1492,7 +1492,7 @@ void pdf_update_pushbutton_appearance(fz_context *ctx, pdf_document *doc, pdf_ob
fz_append_printf(ctx, fzbuf, fmt_f);
}
- tobj = pdf_dict_getl(ctx, obj, PDF_NAME_MK, PDF_NAME_BC, NULL);
+ tobj = pdf_dict_getl(ctx, obj, PDF_NAME(MK), PDF_NAME(BC), NULL);
if (tobj)
{
fzbuf_print_color(ctx, fzbuf, tobj, 1, 0.0f);
@@ -1503,13 +1503,13 @@ void pdf_update_pushbutton_appearance(fz_context *ctx, pdf_document *doc, pdf_ob
fz_append_printf(ctx, fzbuf, fmt_s);
}
- tobj = pdf_dict_getl(ctx, obj, PDF_NAME_MK, PDF_NAME_CA, NULL);
+ tobj = pdf_dict_getl(ctx, obj, PDF_NAME(MK), PDF_NAME(CA), NULL);
if (tobj)
{
fz_rect clip = rect;
fz_rect bounds;
fz_matrix mat;
- char *da = pdf_to_str_buf(ctx, pdf_get_inheritable(ctx, doc, obj, PDF_NAME_DA));
+ char *da = pdf_to_str_buf(ctx, pdf_get_inheritable(ctx, doc, obj, PDF_NAME(DA)));
char *text = pdf_to_str_buf(ctx, tobj);
clip.x0 += btotal;
@@ -1575,7 +1575,7 @@ void pdf_update_text_markup_appearance(fz_context *ctx, pdf_document *doc, pdf_a
return;
}
- annotcolor = pdf_dict_get(ctx, annot->obj, PDF_NAME_C);
+ annotcolor = pdf_dict_get(ctx, annot->obj, PDF_NAME(C));
if (pdf_is_array(ctx, annotcolor))
{
@@ -1604,27 +1604,27 @@ void pdf_set_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *ann
fz_transform_rect(&trect, &inv_page_ctm);
- pdf_dict_put_drop(ctx, obj, PDF_NAME_Rect, pdf_new_rect(ctx, doc, &trect));
+ pdf_dict_put_drop(ctx, obj, PDF_NAME(Rect), pdf_new_rect(ctx, doc, &trect));
/* See if there is a current normal appearance */
- ap_obj = pdf_dict_getl(ctx, obj, PDF_NAME_AP, PDF_NAME_N, NULL);
+ ap_obj = pdf_dict_getl(ctx, obj, PDF_NAME(AP), PDF_NAME(N), NULL);
if (!pdf_is_stream(ctx, ap_obj))
ap_obj = NULL;
if (ap_obj == NULL)
{
ap_obj = pdf_new_xobject(ctx, doc, &trect, &fz_identity);
- pdf_dict_putl_drop(ctx, obj, ap_obj, PDF_NAME_AP, PDF_NAME_N, NULL);
+ pdf_dict_putl_drop(ctx, obj, ap_obj, PDF_NAME(AP), PDF_NAME(N), NULL);
}
else
{
pdf_xref_ensure_incremental_object(ctx, doc, pdf_to_num(ctx, ap_obj));
/* Update bounding box and matrix in reused xobject obj */
- pdf_dict_put_drop(ctx, ap_obj, PDF_NAME_BBox, pdf_new_rect(ctx, doc, &trect));
- pdf_dict_put_drop(ctx, ap_obj, PDF_NAME_Matrix, pdf_new_matrix(ctx, doc, &fz_identity));
+ pdf_dict_put_drop(ctx, ap_obj, PDF_NAME(BBox), pdf_new_rect(ctx, doc, &trect));
+ pdf_dict_put_drop(ctx, ap_obj, PDF_NAME(Matrix), pdf_new_matrix(ctx, doc, &fz_identity));
}
- resources = pdf_dict_get(ctx, ap_obj, PDF_NAME_Resources);
+ resources = pdf_dict_get(ctx, ap_obj, PDF_NAME(Resources));
contents = fz_new_buffer(ctx, 0);
@@ -1652,7 +1652,7 @@ void pdf_set_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *ann
static fz_point *
quadpoints(fz_context *ctx, pdf_document *doc, pdf_obj *annot, int *nout)
{
- pdf_obj *quad = pdf_dict_get(ctx, annot, PDF_NAME_QuadPoints);
+ pdf_obj *quad = pdf_dict_get(ctx, annot, PDF_NAME(QuadPoints));
fz_point *qp = NULL;
int i, n;
@@ -1831,7 +1831,7 @@ void pdf_update_ink_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *an
if (width == 0.0f)
width = 1.0f;
- list = pdf_dict_get(ctx, annot->obj, PDF_NAME_InkList);
+ list = pdf_dict_get(ctx, annot->obj, PDF_NAME(InkList));
n = pdf_array_len(ctx, list);
@@ -1875,7 +1875,7 @@ void pdf_update_ink_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *an
fz_lineto(ctx, path, pt_last.x, pt_last.y);
}
- cs = pdf_to_color(ctx, doc, pdf_dict_get(ctx, annot->obj, PDF_NAME_C), color);
+ cs = pdf_to_color(ctx, doc, pdf_dict_get(ctx, annot->obj, PDF_NAME(C)), color);
fz_stroke_path(ctx, dev, path, stroke, &page_ctm, cs, color, 1.0f, NULL);
fz_expand_rect(&rect, width);
@@ -2116,7 +2116,7 @@ void pdf_update_text_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_an
fz_rect bounds;
fz_matrix tm;
- pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Rect), &rect);
+ pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)), &rect);
dlist = fz_new_display_list(ctx, NULL);
dev = fz_new_list_device(ctx, dlist);
stroke = fz_new_stroke_state(ctx);
@@ -2166,7 +2166,7 @@ void pdf_update_text_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_an
void pdf_update_free_text_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot)
{
pdf_obj *obj = annot->obj;
- pdf_obj *dr = pdf_dict_get(ctx, annot->page->obj, PDF_NAME_Resources);
+ pdf_obj *dr = pdf_dict_get(ctx, annot->page->obj, PDF_NAME(Resources));
fz_display_list *dlist = NULL;
fz_device *dev = NULL;
font_info font_rec;
@@ -2186,13 +2186,13 @@ void pdf_update_free_text_annot_appearance(fz_context *ctx, pdf_document *doc, p
fz_var(text);
fz_try(ctx)
{
- char *contents = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME_Contents));
- char *da = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME_DA));
+ char *contents = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Contents)));
+ char *da = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME(DA)));
fz_colorspace *cs;
fz_point pos;
fz_rect rect;
- pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Rect), &rect);
+ pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)), &rect);
get_font_info(ctx, doc, dr, da, &font_rec);
@@ -2292,14 +2292,14 @@ static void draw_logo(fz_context *ctx, fz_path *path)
static void insert_signature_appearance_layers(fz_context *ctx, pdf_document *doc, pdf_annot *annot)
{
- pdf_obj *ap = pdf_dict_getl(ctx, annot->obj, PDF_NAME_AP, PDF_NAME_N, NULL);
+ pdf_obj *ap = pdf_dict_getl(ctx, annot->obj, PDF_NAME(AP), PDF_NAME(N), NULL);
pdf_obj *main_ap = NULL;
pdf_obj *frm = NULL;
pdf_obj *n0 = NULL;
fz_rect bbox;
fz_buffer *fzbuf = NULL;
- pdf_to_rect(ctx, pdf_dict_get(ctx, ap, PDF_NAME_BBox), &bbox);
+ pdf_to_rect(ctx, pdf_dict_get(ctx, ap, PDF_NAME(BBox)), &bbox);
fz_var(main_ap);
fz_var(frm);
@@ -2311,15 +2311,15 @@ static void insert_signature_appearance_layers(fz_context *ctx, pdf_document *do
frm = pdf_new_xobject(ctx, doc, &bbox, &fz_identity);
n0 = pdf_new_xobject(ctx, doc, &bbox, &fz_identity);
- pdf_dict_putl(ctx, main_ap, frm, PDF_NAME_Resources, PDF_NAME_XObject, PDF_NAME_FRM, NULL);
+ pdf_dict_putl(ctx, main_ap, frm, PDF_NAME(Resources), PDF_NAME(XObject), PDF_NAME(FRM), NULL);
fzbuf = fz_new_buffer(ctx, 8);
fz_append_printf(ctx, fzbuf, "/FRM Do");
pdf_update_stream(ctx, doc, main_ap, fzbuf, 0);
fz_drop_buffer(ctx, fzbuf);
fzbuf = NULL;
- pdf_dict_putl(ctx, frm, n0, PDF_NAME_Resources, PDF_NAME_XObject, PDF_NAME_n0, NULL);
- pdf_dict_putl(ctx, frm, ap, PDF_NAME_Resources, PDF_NAME_XObject, PDF_NAME_n2, NULL);
+ pdf_dict_putl(ctx, frm, n0, PDF_NAME(Resources), PDF_NAME(XObject), PDF_NAME(n0), NULL);
+ pdf_dict_putl(ctx, frm, ap, PDF_NAME(Resources), PDF_NAME(XObject), PDF_NAME(n2), NULL);
fzbuf = fz_new_buffer(ctx, 8);
fz_append_printf(ctx, fzbuf, "q 1 0 0 1 0 0 cm /n0 Do Q q 1 0 0 1 0 0 cm /n2 Do Q");
pdf_update_stream(ctx, doc, frm, fzbuf, 0);
@@ -2332,7 +2332,7 @@ static void insert_signature_appearance_layers(fz_context *ctx, pdf_document *do
fz_drop_buffer(ctx, fzbuf);
fzbuf = NULL;
- pdf_dict_putl(ctx, annot->obj, main_ap, PDF_NAME_AP, PDF_NAME_N, NULL);
+ pdf_dict_putl(ctx, annot->obj, main_ap, PDF_NAME(AP), PDF_NAME(N), NULL);
}
fz_always(ctx)
{
@@ -2353,7 +2353,7 @@ static float logo_color[3] = {(float)0x25/(float)0xFF, (float)0x72/(float)0xFF,
void pdf_set_signature_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot, char *name, const char *dn, char *date)
{
pdf_obj *obj = annot->obj;
- pdf_obj *dr = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_AcroForm, PDF_NAME_DR, NULL);
+ pdf_obj *dr = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), PDF_NAME(AcroForm), PDF_NAME(DR), NULL);
fz_display_list *dlist = NULL;
fz_device *dev = NULL;
font_info font_rec;
@@ -2365,7 +2365,7 @@ void pdf_set_signature_appearance(fz_context *ctx, pdf_document *doc, pdf_annot
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
if (!dr)
- pdf_dict_putl_drop(ctx, pdf_trailer(ctx, doc), pdf_new_dict(ctx, doc, 1), PDF_NAME_Root, PDF_NAME_AcroForm, PDF_NAME_DR, NULL);
+ pdf_dict_putl_drop(ctx, pdf_trailer(ctx, doc), pdf_new_dict(ctx, doc, 1), PDF_NAME(Root), PDF_NAME(AcroForm), PDF_NAME(DR), NULL);
memset(&font_rec, 0, sizeof(font_rec));
@@ -2376,14 +2376,14 @@ void pdf_set_signature_appearance(fz_context *ctx, pdf_document *doc, pdf_annot
fz_var(fzbuf);
fz_try(ctx)
{
- char *da = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME_DA));
+ char *da = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME(DA)));
fz_rect annot_rect;
fz_rect logo_bounds;
fz_matrix logo_tm;
fz_rect rect;
fz_colorspace *cs = fz_device_rgb(ctx); /* Borrowed reference */
- pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Rect), &annot_rect);
+ pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)), &annot_rect);
rect = annot_rect;
dlist = fz_new_display_list(ctx, NULL);
@@ -2455,9 +2455,9 @@ void pdf_update_appearance(fz_context *ctx, pdf_annot *annot)
{
pdf_document *doc = annot->page->doc;
pdf_obj *obj = annot->obj;
- pdf_obj *ap = pdf_dict_get(ctx, obj, PDF_NAME_AP);
+ pdf_obj *ap = pdf_dict_get(ctx, obj, PDF_NAME(AP));
- if (!ap || !pdf_dict_get(ctx, ap, PDF_NAME_N) || pdf_obj_is_dirty(ctx, obj) || annot->needs_new_ap)
+ if (!ap || !pdf_dict_get(ctx, ap, PDF_NAME(N)) || pdf_obj_is_dirty(ctx, obj) || annot->needs_new_ap)
{
enum pdf_annot_type type = pdf_annot_type(ctx, annot);
switch (type)
@@ -2468,7 +2468,7 @@ void pdf_update_appearance(fz_context *ctx, pdf_annot *annot)
case PDF_WIDGET_TYPE_TEXT:
{
#if 0
- pdf_obj *formatting = pdf_dict_getl(ctx, obj, PDF_NAME_AA, PDF_NAME_F, NULL);
+ pdf_obj *formatting = pdf_dict_getl(ctx, obj, PDF_NAME(AA), PDF_NAME(F), NULL);
if (formatting && doc->js)
{
/* Apply formatting */
@@ -2543,8 +2543,8 @@ pdf_update_annot(fz_context *ctx, pdf_annot *annot)
obj = annot->obj;
- ap = pdf_dict_get(ctx, obj, PDF_NAME_AP);
- as = pdf_dict_get(ctx, obj, PDF_NAME_AS);
+ ap = pdf_dict_get(ctx, obj, PDF_NAME(AP));
+ as = pdf_dict_get(ctx, obj, PDF_NAME(AS));
if (pdf_is_dict(ctx, ap))
{
@@ -2552,9 +2552,9 @@ pdf_update_annot(fz_context *ctx, pdf_annot *annot)
n = NULL;
if (hp->num == pdf_to_num(ctx, obj) && (hp->state & HOTSPOT_POINTER_DOWN))
- n = pdf_dict_get(ctx, ap, PDF_NAME_D); /* down state */
+ n = pdf_dict_get(ctx, ap, PDF_NAME(D)); /* down state */
if (n == NULL)
- n = pdf_dict_get(ctx, ap, PDF_NAME_N); /* normal state */
+ n = pdf_dict_get(ctx, ap, PDF_NAME(N)); /* normal state */
/* lookup current state in sub-dictionary */
if (!pdf_is_stream(ctx, n))
diff --git a/source/pdf/pdf-clean-file.c b/source/pdf/pdf-clean-file.c
index 52d97c67..9cdd7c91 100644
--- a/source/pdf/pdf-clean-file.c
+++ b/source/pdf/pdf-clean-file.c
@@ -34,7 +34,7 @@ static void retainpage(fz_context *ctx, pdf_document *doc, pdf_obj *parent, pdf_
pdf_flatten_inheritable_page_items(ctx, pageref);
- pdf_dict_put(ctx, pageref, PDF_NAME_Parent, parent);
+ pdf_dict_put(ctx, pageref, PDF_NAME(Parent), parent);
/* Store page object in new kids array */
pdf_array_push(ctx, kids, pageref);
@@ -59,12 +59,12 @@ static int dest_is_valid(fz_context *ctx, pdf_obj *o, int page_count, int *page_
{
pdf_obj *p;
- p = pdf_dict_get(ctx, o, PDF_NAME_A);
- if (pdf_name_eq(ctx, pdf_dict_get(ctx, p, PDF_NAME_S), PDF_NAME_GoTo) &&
- !string_in_names_list(ctx, pdf_dict_get(ctx, p, PDF_NAME_D), names_list))
+ p = pdf_dict_get(ctx, o, PDF_NAME(A));
+ if (pdf_name_eq(ctx, pdf_dict_get(ctx, p, PDF_NAME(S)), PDF_NAME(GoTo)) &&
+ !string_in_names_list(ctx, pdf_dict_get(ctx, p, PDF_NAME(D)), names_list))
return 0;
- p = pdf_dict_get(ctx, o, PDF_NAME_Dest);
+ p = pdf_dict_get(ctx, o, PDF_NAME(Dest));
if (p == NULL)
{}
else if (pdf_is_string(ctx, p))
@@ -100,30 +100,30 @@ static int strip_outline(fz_context *ctx, pdf_document *doc, pdf_obj *outlines,
{
/* Outline with invalid dest and no children. Drop it by
* pulling the next one in here. */
- pdf_obj *next = pdf_dict_get(ctx, current, PDF_NAME_Next);
+ pdf_obj *next = pdf_dict_get(ctx, current, PDF_NAME(Next));
if (next == NULL)
{
/* There is no next one to pull in */
if (prev != NULL)
- pdf_dict_del(ctx, prev, PDF_NAME_Next);
+ pdf_dict_del(ctx, prev, PDF_NAME(Next));
}
else if (prev != NULL)
{
- pdf_dict_put(ctx, prev, PDF_NAME_Next, next);
- pdf_dict_put(ctx, next, PDF_NAME_Prev, prev);
+ pdf_dict_put(ctx, prev, PDF_NAME(Next), next);
+ pdf_dict_put(ctx, next, PDF_NAME(Prev), prev);
}
else
{
- pdf_dict_del(ctx, next, PDF_NAME_Prev);
+ pdf_dict_del(ctx, next, PDF_NAME(Prev));
}
current = next;
}
else
{
/* Outline with invalid dest, but children. Just drop the dest. */
- pdf_dict_del(ctx, current, PDF_NAME_Dest);
- pdf_dict_del(ctx, current, PDF_NAME_A);
- current = pdf_dict_get(ctx, current, PDF_NAME_Next);
+ pdf_dict_del(ctx, current, PDF_NAME(Dest));
+ pdf_dict_del(ctx, current, PDF_NAME(A));
+ current = pdf_dict_get(ctx, current, PDF_NAME(Next));
}
}
else
@@ -132,7 +132,7 @@ static int strip_outline(fz_context *ctx, pdf_document *doc, pdf_obj *outlines,
if (first == NULL)
first = current;
prev = current;
- current = pdf_dict_get(ctx, current, PDF_NAME_Next);
+ current = pdf_dict_get(ctx, current, PDF_NAME(Next));
count++;
}
}
@@ -152,7 +152,7 @@ static int strip_outlines(fz_context *ctx, pdf_document *doc, pdf_obj *outlines,
if (outlines == NULL)
return 0;
- first = pdf_dict_get(ctx, outlines, PDF_NAME_First);
+ first = pdf_dict_get(ctx, outlines, PDF_NAME(First));
if (first == NULL)
nc = 0;
else
@@ -160,16 +160,16 @@ static int strip_outlines(fz_context *ctx, pdf_document *doc, pdf_obj *outlines,
if (nc == 0)
{
- pdf_dict_del(ctx, outlines, PDF_NAME_First);
- pdf_dict_del(ctx, outlines, PDF_NAME_Last);
- pdf_dict_del(ctx, outlines, PDF_NAME_Count);
+ pdf_dict_del(ctx, outlines, PDF_NAME(First));
+ pdf_dict_del(ctx, outlines, PDF_NAME(Last));
+ pdf_dict_del(ctx, outlines, PDF_NAME(Count));
}
else
{
- int old_count = pdf_to_int(ctx, pdf_dict_get(ctx, outlines, PDF_NAME_Count));
- pdf_dict_put(ctx, outlines, PDF_NAME_First, first);
- pdf_dict_put(ctx, outlines, PDF_NAME_Last, last);
- pdf_dict_put_int(ctx, outlines, PDF_NAME_Count, old_count > 0 ? nc : -nc);
+ int old_count = pdf_to_int(ctx, pdf_dict_get(ctx, outlines, PDF_NAME(Count)));
+ pdf_dict_put(ctx, outlines, PDF_NAME(First), first);
+ pdf_dict_put(ctx, outlines, PDF_NAME(Last), last);
+ pdf_dict_put_int(ctx, outlines, PDF_NAME(Count), old_count > 0 ? nc : -nc);
}
return nc;
@@ -189,19 +189,19 @@ static void retainpages(fz_context *ctx, globals *glo, int argc, char **argv)
/* Keep only pages/type and (reduced) dest entries to avoid
* references to unretained pages */
- oldroot = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
- pages = pdf_dict_get(ctx, oldroot, PDF_NAME_Pages);
- olddests = pdf_load_name_tree(ctx, doc, PDF_NAME_Dests);
- outlines = pdf_dict_get(ctx, oldroot, PDF_NAME_Outlines);
- ocproperties = pdf_dict_get(ctx, oldroot, PDF_NAME_OCProperties);
+ oldroot = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
+ pages = pdf_dict_get(ctx, oldroot, PDF_NAME(Pages));
+ olddests = pdf_load_name_tree(ctx, doc, PDF_NAME(Dests));
+ outlines = pdf_dict_get(ctx, oldroot, PDF_NAME(Outlines));
+ ocproperties = pdf_dict_get(ctx, oldroot, PDF_NAME(OCProperties));
root = pdf_new_dict(ctx, doc, 3);
- pdf_dict_put(ctx, root, PDF_NAME_Type, pdf_dict_get(ctx, oldroot, PDF_NAME_Type));
- pdf_dict_put(ctx, root, PDF_NAME_Pages, pdf_dict_get(ctx, oldroot, PDF_NAME_Pages));
+ pdf_dict_put(ctx, root, PDF_NAME(Type), pdf_dict_get(ctx, oldroot, PDF_NAME(Type)));
+ pdf_dict_put(ctx, root, PDF_NAME(Pages), pdf_dict_get(ctx, oldroot, PDF_NAME(Pages)));
if (outlines)
- pdf_dict_put(ctx, root, PDF_NAME_Outlines, outlines);
+ pdf_dict_put(ctx, root, PDF_NAME(Outlines), outlines);
if (ocproperties)
- pdf_dict_put(ctx, root, PDF_NAME_OCProperties, ocproperties);
+ pdf_dict_put(ctx, root, PDF_NAME(OCProperties), ocproperties);
pdf_update_object(ctx, doc, pdf_to_num(ctx, oldroot), root);
@@ -231,8 +231,8 @@ static void retainpages(fz_context *ctx, globals *glo, int argc, char **argv)
/* Update page count and kids array */
countobj = pdf_new_int(ctx, doc, pdf_array_len(ctx, kids));
- pdf_dict_put_drop(ctx, pages, PDF_NAME_Count, countobj);
- pdf_dict_put_drop(ctx, pages, PDF_NAME_Kids, kids);
+ pdf_dict_put_drop(ctx, pages, PDF_NAME(Count), countobj);
+ pdf_dict_put_drop(ctx, pages, PDF_NAME(Kids), kids);
pagecount = pdf_count_pages(ctx, doc);
page_object_nums = fz_calloc(ctx, pagecount, sizeof(*page_object_nums));
@@ -258,7 +258,7 @@ static void retainpages(fz_context *ctx, globals *glo, int argc, char **argv)
{
pdf_obj *key = pdf_dict_get_key(ctx, olddests, i);
pdf_obj *val = pdf_dict_get_val(ctx, olddests, i);
- pdf_obj *dest = pdf_dict_get(ctx, val, PDF_NAME_D);
+ pdf_obj *dest = pdf_dict_get(ctx, val, PDF_NAME(D));
dest = pdf_array_get(ctx, dest ? dest : val, 0);
if (dest_is_valid_page(ctx, dest, page_object_nums, pagecount))
@@ -269,9 +269,9 @@ static void retainpages(fz_context *ctx, globals *glo, int argc, char **argv)
}
}
- pdf_dict_put(ctx, dests, PDF_NAME_Names, names_list);
- pdf_dict_put(ctx, names, PDF_NAME_Dests, dests);
- pdf_dict_put(ctx, root, PDF_NAME_Names, names);
+ pdf_dict_put(ctx, dests, PDF_NAME(Names), names_list);
+ pdf_dict_put(ctx, names, PDF_NAME(Dests), dests);
+ pdf_dict_put(ctx, root, PDF_NAME(Names), names);
pdf_drop_obj(ctx, names);
pdf_drop_obj(ctx, dests);
@@ -284,7 +284,7 @@ static void retainpages(fz_context *ctx, globals *glo, int argc, char **argv)
{
pdf_obj *pageref = pdf_lookup_page_obj(ctx, doc, i);
- pdf_obj *annots = pdf_dict_get(ctx, pageref, PDF_NAME_Annots);
+ pdf_obj *annots = pdf_dict_get(ctx, pageref, PDF_NAME(Annots));
int len = pdf_array_len(ctx, annots);
int j;
@@ -293,7 +293,7 @@ static void retainpages(fz_context *ctx, globals *glo, int argc, char **argv)
{
pdf_obj *o = pdf_array_get(ctx, annots, j);
- if (!pdf_name_eq(ctx, pdf_dict_get(ctx, o, PDF_NAME_Subtype), PDF_NAME_Link))
+ if (!pdf_name_eq(ctx, pdf_dict_get(ctx, o, PDF_NAME(Subtype)), PDF_NAME(Link)))
continue;
if (!dest_is_valid(ctx, o, pagecount, page_object_nums, names_list))
@@ -308,7 +308,7 @@ static void retainpages(fz_context *ctx, globals *glo, int argc, char **argv)
if (strip_outlines(ctx, doc, outlines, pagecount, page_object_nums, names_list) == 0)
{
- pdf_dict_del(ctx, root, PDF_NAME_Outlines);
+ pdf_dict_del(ctx, root, PDF_NAME(Outlines));
}
fz_free(ctx, page_object_nums);
diff --git a/source/pdf/pdf-clean.c b/source/pdf/pdf-clean.c
index eaa4c0e2..4e8dd3f4 100644
--- a/source/pdf/pdf-clean.c
+++ b/source/pdf/pdf-clean.c
@@ -25,7 +25,7 @@ pdf_clean_stream_object(fz_context *ctx, pdf_document *doc, pdf_obj *obj, pdf_ob
{
if (own_res)
{
- pdf_obj *r = pdf_dict_get(ctx, obj, PDF_NAME_Resources);
+ pdf_obj *r = pdf_dict_get(ctx, obj, PDF_NAME(Resources));
if (r)
orig_res = r;
}
@@ -44,7 +44,7 @@ pdf_clean_stream_object(fz_context *ctx, pdf_document *doc, pdf_obj *obj, pdf_ob
if (own_res)
{
ref = pdf_add_object(ctx, doc, res);
- pdf_dict_put_drop(ctx, obj, PDF_NAME_Resources, ref);
+ pdf_dict_put_drop(ctx, obj, PDF_NAME(Resources), ref);
}
}
fz_always(ctx)
@@ -76,14 +76,14 @@ pdf_clean_type3(fz_context *ctx, pdf_document *doc, pdf_obj *obj, pdf_obj *orig_
fz_try(ctx)
{
- res = pdf_dict_get(ctx, obj, PDF_NAME_Resources);
+ res = pdf_dict_get(ctx, obj, PDF_NAME(Resources));
if (res)
orig_res = res;
res = NULL;
res = pdf_new_dict(ctx, doc, 1);
- charprocs = pdf_dict_get(ctx, obj, PDF_NAME_CharProcs);
+ charprocs = pdf_dict_get(ctx, obj, PDF_NAME(CharProcs));
l = pdf_dict_len(ctx, charprocs);
for (i = 0; i < l; i++)
@@ -120,10 +120,10 @@ pdf_clean_type3(fz_context *ctx, pdf_document *doc, pdf_obj *obj, pdf_obj *orig_
}
/* ProcSet - no cleaning possible. Inherit this from the old dict. */
- pdf_dict_put(ctx, res, PDF_NAME_ProcSet, pdf_dict_get(ctx, orig_res, PDF_NAME_ProcSet));
+ pdf_dict_put(ctx, res, PDF_NAME(ProcSet), pdf_dict_get(ctx, orig_res, PDF_NAME(ProcSet)));
ref = pdf_add_object(ctx, doc, res);
- pdf_dict_put_drop(ctx, obj, PDF_NAME_Resources, ref);
+ pdf_dict_put_drop(ctx, obj, PDF_NAME(Resources), ref);
}
fz_always(ctx)
{
@@ -193,12 +193,12 @@ void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page
new_obj = pdf_new_dict(ctx, doc, 1);
new_ref = pdf_add_object(ctx, doc, new_obj);
contents = new_ref;
- pdf_dict_put(ctx, page->obj, PDF_NAME_Contents, contents);
+ pdf_dict_put(ctx, page->obj, PDF_NAME(Contents), contents);
}
else
{
- pdf_dict_del(ctx, contents, PDF_NAME_Filter);
- pdf_dict_del(ctx, contents, PDF_NAME_DecodeParms);
+ pdf_dict_del(ctx, contents, PDF_NAME(Filter));
+ pdf_dict_del(ctx, contents, PDF_NAME(DecodeParms));
}
pdf_update_stream(ctx, doc, contents, buffer, 0);
@@ -209,7 +209,7 @@ void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page
* conceivably cause changes in rendering, but we don't care. */
/* ExtGState */
- obj = pdf_dict_get(ctx, res, PDF_NAME_ExtGState);
+ obj = pdf_dict_get(ctx, res, PDF_NAME(ExtGState));
if (obj)
{
int i, l;
@@ -217,10 +217,10 @@ void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page
l = pdf_dict_len(ctx, obj);
for (i = 0; i < l; i++)
{
- pdf_obj *o = pdf_dict_get(ctx, pdf_dict_get_val(ctx, obj, i), PDF_NAME_SMask);
+ pdf_obj *o = pdf_dict_get(ctx, pdf_dict_get_val(ctx, obj, i), PDF_NAME(SMask));
if (!o)
continue;
- o = pdf_dict_get(ctx, o, PDF_NAME_G);
+ o = pdf_dict_get(ctx, o, PDF_NAME(G));
if (!o)
continue;
/* Transparency group XObject */
@@ -229,7 +229,7 @@ void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page
}
/* Pattern */
- obj = pdf_dict_get(ctx, res, PDF_NAME_Pattern);
+ obj = pdf_dict_get(ctx, res, PDF_NAME(Pattern));
if (obj)
{
int i, l;
@@ -240,16 +240,16 @@ void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page
pdf_obj *pat = pdf_dict_get_val(ctx, obj, i);
if (!pat)
continue;
- pat_res = pdf_dict_get(ctx, pat, PDF_NAME_Resources);
+ pat_res = pdf_dict_get(ctx, pat, PDF_NAME(Resources));
if (pat_res == NULL)
pat_res = resources;
- if (pdf_to_int(ctx, pdf_dict_get(ctx, pat, PDF_NAME_PatternType)) == 1)
+ if (pdf_to_int(ctx, pdf_dict_get(ctx, pat, PDF_NAME(PatternType))) == 1)
pdf_clean_stream_object(ctx, doc, pat, pat_res, cookie, 0, text_filter, after_text, proc_arg, sanitize, ascii);
}
}
/* XObject */
- obj = pdf_dict_get(ctx, res, PDF_NAME_XObject);
+ obj = pdf_dict_get(ctx, res, PDF_NAME(XObject));
if (obj)
{
int i, l;
@@ -260,16 +260,16 @@ void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page
pdf_obj *xobj = pdf_dict_get_val(ctx, obj, i);
if (!xobj)
continue;
- xobj_res = pdf_dict_get(ctx, xobj, PDF_NAME_Resources);
+ xobj_res = pdf_dict_get(ctx, xobj, PDF_NAME(Resources));
if (xobj_res == NULL)
xobj_res = resources;
- if (pdf_name_eq(ctx, PDF_NAME_Form, pdf_dict_get(ctx, xobj, PDF_NAME_Subtype)))
+ if (pdf_name_eq(ctx, PDF_NAME(Form), pdf_dict_get(ctx, xobj, PDF_NAME(Subtype))))
pdf_clean_stream_object(ctx, doc, xobj, xobj_res, cookie, 1, text_filter, after_text, proc_arg, sanitize, ascii);
}
}
/* Font */
- obj = pdf_dict_get(ctx, res, PDF_NAME_Font);
+ obj = pdf_dict_get(ctx, res, PDF_NAME(Font));
if (obj)
{
int i, l;
@@ -279,15 +279,15 @@ void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page
pdf_obj *o = pdf_dict_get_val(ctx, obj, i);
if (!o)
continue;
- if (pdf_name_eq(ctx, PDF_NAME_Type3, pdf_dict_get(ctx, o, PDF_NAME_Subtype)))
+ if (pdf_name_eq(ctx, PDF_NAME(Type3), pdf_dict_get(ctx, o, PDF_NAME(Subtype))))
pdf_clean_type3(ctx, doc, o, resources, cookie, sanitize, ascii);
}
}
/* ProcSet - no cleaning possible. Inherit this from the old dict. */
- obj = pdf_dict_get(ctx, resources, PDF_NAME_ProcSet);
+ obj = pdf_dict_get(ctx, resources, PDF_NAME(ProcSet));
if (obj)
- pdf_dict_put(ctx, res, PDF_NAME_ProcSet, obj);
+ pdf_dict_put(ctx, res, PDF_NAME(ProcSet), obj);
/* ColorSpace - no cleaning possible. */
/* Properties - no cleaning possible. */
@@ -297,7 +297,7 @@ void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page
/* Update resource dictionary */
res_ref = pdf_add_object(ctx, doc, res);
- pdf_dict_put(ctx, page->obj, PDF_NAME_Resources, res_ref);
+ pdf_dict_put(ctx, page->obj, PDF_NAME(Resources), res_ref);
}
fz_always(ctx)
{
@@ -326,7 +326,7 @@ void pdf_filter_annot_contents(fz_context *ctx, pdf_document *doc, pdf_annot *an
pdf_obj *ap;
int i, n;
- ap = pdf_dict_get(ctx, annot->obj, PDF_NAME_AP);
+ ap = pdf_dict_get(ctx, annot->obj, PDF_NAME(AP));
if (ap == NULL)
return;
diff --git a/source/pdf/pdf-cmap-load.c b/source/pdf/pdf-cmap-load.c
index 03c2eb35..96cef618 100644
--- a/source/pdf/pdf-cmap-load.c
+++ b/source/pdf/pdf-cmap-load.c
@@ -38,11 +38,11 @@ pdf_load_embedded_cmap(fz_context *ctx, pdf_document *doc, pdf_obj *stmobj)
file = pdf_open_stream(ctx, stmobj);
cmap = pdf_load_cmap(ctx, file);
- obj = pdf_dict_get(ctx, stmobj, PDF_NAME_WMode);
+ obj = pdf_dict_get(ctx, stmobj, PDF_NAME(WMode));
if (pdf_is_int(ctx, obj))
pdf_set_cmap_wmode(ctx, cmap, pdf_to_int(ctx, obj));
- obj = pdf_dict_get(ctx, stmobj, PDF_NAME_UseCMap);
+ obj = pdf_dict_get(ctx, stmobj, PDF_NAME(UseCMap));
if (pdf_is_name(ctx, obj))
{
usecmap = pdf_load_system_cmap(ctx, pdf_to_name(ctx, obj));
diff --git a/source/pdf/pdf-colorspace.c b/source/pdf/pdf-colorspace.c
index 44615977..ec4da7b0 100644
--- a/source/pdf/pdf-colorspace.c
+++ b/source/pdf/pdf-colorspace.c
@@ -31,7 +31,7 @@ load_icc_based(fz_context *ctx, pdf_obj *dict, int alt)
*/
fz_try(ctx)
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Alternate);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Alternate));
if (obj)
{
cs_alt = pdf_load_colorspace(ctx, obj);
@@ -52,7 +52,7 @@ load_icc_based(fz_context *ctx, pdf_obj *dict, int alt)
cs_alt = NULL;
}
- n = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_N));
+ n = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(N)));
fz_try(ctx)
{
@@ -314,7 +314,7 @@ pdf_load_cal_common(fz_context *ctx, pdf_obj *dict, float *wp, float *bp, float
pdf_obj *obj;
int i;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_WhitePoint);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(WhitePoint));
if (pdf_array_len(ctx, obj) != 3)
fz_throw(ctx, FZ_ERROR_SYNTAX, "WhitePoint must be a 3-element array");
@@ -327,7 +327,7 @@ pdf_load_cal_common(fz_context *ctx, pdf_obj *dict, float *wp, float *bp, float
if (wp[1] != 1)
fz_throw(ctx, FZ_ERROR_SYNTAX, "WhitePoint Yw must be 1.0");
- obj = pdf_dict_get(ctx, dict, PDF_NAME_BlackPoint);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(BlackPoint));
if (pdf_array_len(ctx, obj) == 3)
{
for (i = 0; i < 3; i++)
@@ -338,7 +338,7 @@ pdf_load_cal_common(fz_context *ctx, pdf_obj *dict, float *wp, float *bp, float
}
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Gamma);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Gamma));
if (pdf_is_number(ctx, obj))
{
gamma[0] = pdf_to_real(ctx, obj);
@@ -394,7 +394,7 @@ pdf_load_cal_rgb(fz_context *ctx, pdf_obj *dict)
{
pdf_load_cal_common(ctx, dict, wp, bp, gamma);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Matrix);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix));
if (pdf_array_len(ctx, obj) == 9)
{
for (i = 0; i < 9; i++)
@@ -416,19 +416,19 @@ pdf_load_colorspace_imp(fz_context *ctx, pdf_obj *obj)
if (pdf_is_name(ctx, obj))
{
- if (pdf_name_eq(ctx, obj, PDF_NAME_Pattern))
+ if (pdf_name_eq(ctx, obj, PDF_NAME(Pattern)))
return fz_keep_colorspace(ctx, fz_device_gray(ctx));
- else if (pdf_name_eq(ctx, obj, PDF_NAME_G))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(G)))
return fz_keep_colorspace(ctx, fz_device_gray(ctx));
- else if (pdf_name_eq(ctx, obj, PDF_NAME_RGB))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(RGB)))
return fz_keep_colorspace(ctx, fz_device_rgb(ctx));
- else if (pdf_name_eq(ctx, obj, PDF_NAME_CMYK))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(CMYK)))
return fz_keep_colorspace(ctx, fz_device_cmyk(ctx));
- else if (pdf_name_eq(ctx, obj, PDF_NAME_DeviceGray))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(DeviceGray)))
return fz_keep_colorspace(ctx, fz_device_gray(ctx));
- else if (pdf_name_eq(ctx, obj, PDF_NAME_DeviceRGB))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(DeviceRGB)))
return fz_keep_colorspace(ctx, fz_device_rgb(ctx));
- else if (pdf_name_eq(ctx, obj, PDF_NAME_DeviceCMYK))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(DeviceCMYK)))
return fz_keep_colorspace(ctx, fz_device_cmyk(ctx));
else
fz_throw(ctx, FZ_ERROR_SYNTAX, "unknown colorspace: %s", pdf_to_name(ctx, obj));
@@ -441,35 +441,35 @@ pdf_load_colorspace_imp(fz_context *ctx, pdf_obj *obj)
if (pdf_is_name(ctx, name))
{
/* load base colorspace instead */
- if (pdf_name_eq(ctx, name, PDF_NAME_G))
+ if (pdf_name_eq(ctx, name, PDF_NAME(G)))
return fz_keep_colorspace(ctx, fz_device_gray(ctx));
- else if (pdf_name_eq(ctx, name, PDF_NAME_RGB))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(RGB)))
return fz_keep_colorspace(ctx, fz_device_rgb(ctx));
- else if (pdf_name_eq(ctx, name, PDF_NAME_CMYK))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(CMYK)))
return fz_keep_colorspace(ctx, fz_device_cmyk(ctx));
- else if (pdf_name_eq(ctx, name, PDF_NAME_DeviceGray))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(DeviceGray)))
return fz_keep_colorspace(ctx, fz_device_gray(ctx));
- else if (pdf_name_eq(ctx, name, PDF_NAME_DeviceRGB))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(DeviceRGB)))
return fz_keep_colorspace(ctx, fz_device_rgb(ctx));
- else if (pdf_name_eq(ctx, name, PDF_NAME_DeviceCMYK))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(DeviceCMYK)))
return fz_keep_colorspace(ctx, fz_device_cmyk(ctx));
- else if (pdf_name_eq(ctx, name, PDF_NAME_CalGray))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(CalGray)))
{
if (fz_get_cmm_engine(ctx))
return pdf_load_cal_gray(ctx, pdf_array_get(ctx, obj, 1));
else
return fz_keep_colorspace(ctx, fz_device_gray(ctx));
}
- else if (pdf_name_eq(ctx, name, PDF_NAME_CalRGB))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(CalRGB)))
{
if (fz_get_cmm_engine(ctx))
return pdf_load_cal_rgb(ctx, pdf_array_get(ctx, obj, 1));
else
return fz_keep_colorspace(ctx, fz_device_rgb(ctx));
}
- else if (pdf_name_eq(ctx, name, PDF_NAME_CalCMYK))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(CalCMYK)))
return fz_keep_colorspace(ctx, fz_device_cmyk(ctx));
- else if (pdf_name_eq(ctx, name, PDF_NAME_Lab))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(Lab)))
return fz_keep_colorspace(ctx, fz_device_lab(ctx));
else
{
@@ -478,20 +478,20 @@ pdf_load_colorspace_imp(fz_context *ctx, pdf_obj *obj)
{
if (pdf_mark_obj(ctx, obj))
fz_throw(ctx, FZ_ERROR_SYNTAX, "recursive colorspace");
- if (pdf_name_eq(ctx, name, PDF_NAME_ICCBased))
+ if (pdf_name_eq(ctx, name, PDF_NAME(ICCBased)))
cs = load_icc_based(ctx, pdf_array_get(ctx, obj, 1), 1);
- else if (pdf_name_eq(ctx, name, PDF_NAME_Indexed))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(Indexed)))
cs = load_indexed(ctx, obj);
- else if (pdf_name_eq(ctx, name, PDF_NAME_I))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(I)))
cs = load_indexed(ctx, obj);
- else if (pdf_name_eq(ctx, name, PDF_NAME_Separation))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(Separation)))
cs = load_devicen(ctx, obj);
- else if (pdf_name_eq(ctx, name, PDF_NAME_DeviceN))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(DeviceN)))
cs = load_devicen(ctx, obj);
- else if (pdf_name_eq(ctx, name, PDF_NAME_Pattern))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(Pattern)))
{
pdf_obj *pobj;
@@ -553,8 +553,8 @@ pdf_load_colorspace(fz_context *ctx, pdf_obj *obj)
static fz_colorspace *
pdf_load_output_intent(fz_context *ctx, pdf_document *doc)
{
- pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
- pdf_obj *intents = pdf_dict_get(ctx, root, PDF_NAME_OutputIntents);
+ pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
+ pdf_obj *intents = pdf_dict_get(ctx, root, PDF_NAME(OutputIntents));
pdf_obj *intent_dict;
pdf_obj *dest_profile;
fz_colorspace *cs = NULL;
@@ -568,7 +568,7 @@ pdf_load_output_intent(fz_context *ctx, pdf_document *doc)
intent_dict = pdf_array_get(ctx, intents, 0);
if (!intent_dict)
return NULL;
- dest_profile = pdf_dict_get(ctx, intent_dict, PDF_NAME_DestOutputProfile);
+ dest_profile = pdf_dict_get(ctx, intent_dict, PDF_NAME(DestOutputProfile));
if (!dest_profile)
return NULL;
diff --git a/source/pdf/pdf-crypt.c b/source/pdf/pdf-crypt.c
index 1056b4fe..7be666d2 100644
--- a/source/pdf/pdf-crypt.c
+++ b/source/pdf/pdf-crypt.c
@@ -58,20 +58,20 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
/* Common to all security handlers (PDF 1.7 table 3.18) */
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Filter);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Filter));
if (!pdf_is_name(ctx, obj))
{
pdf_drop_crypt(ctx, crypt);
fz_throw(ctx, FZ_ERROR_GENERIC, "unspecified encryption handler");
}
- if (!pdf_name_eq(ctx, PDF_NAME_Standard, obj))
+ if (!pdf_name_eq(ctx, PDF_NAME(Standard), obj))
{
pdf_drop_crypt(ctx, crypt);
fz_throw(ctx, FZ_ERROR_GENERIC, "unknown encryption handler: '%s'", pdf_to_name(ctx, obj));
}
crypt->v = 0;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_V);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(V));
if (pdf_is_int(ctx, obj))
crypt->v = pdf_to_int(ctx, obj);
if (crypt->v != 1 && crypt->v != 2 && crypt->v != 4 && crypt->v != 5)
@@ -82,7 +82,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
/* Standard security handler (PDF 1.7 table 3.19) */
- obj = pdf_dict_get(ctx, dict, PDF_NAME_R);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(R));
if (pdf_is_int(ctx, obj))
crypt->r = pdf_to_int(ctx, obj);
else if (crypt->v <= 4)
@@ -107,7 +107,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
fz_throw(ctx, FZ_ERROR_GENERIC, "unknown crypt revision %d", r);
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_O);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(O));
if (pdf_is_string(ctx, obj) && pdf_to_str_len(ctx, obj) == 32)
memcpy(crypt->o, pdf_to_str_buf(ctx, obj), 32);
/* /O and /U are supposed to be 48 bytes long for revision 5 and 6, they're often longer, though */
@@ -119,7 +119,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
fz_throw(ctx, FZ_ERROR_GENERIC, "encryption dictionary missing owner password");
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_U);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(U));
if (pdf_is_string(ctx, obj) && pdf_to_str_len(ctx, obj) == 32)
memcpy(crypt->u, pdf_to_str_buf(ctx, obj), 32);
/* /O and /U are supposed to be 48 bytes long for revision 5 and 6, they're often longer, though */
@@ -136,7 +136,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
fz_throw(ctx, FZ_ERROR_GENERIC, "encryption dictionary missing user password");
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_P);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(P));
if (pdf_is_int(ctx, obj))
crypt->p = pdf_to_int(ctx, obj);
else
@@ -147,7 +147,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
if (crypt->r == 5 || crypt->r == 6)
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_OE);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(OE));
if (!pdf_is_string(ctx, obj) || pdf_to_str_len(ctx, obj) != 32)
{
pdf_drop_crypt(ctx, crypt);
@@ -155,7 +155,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
}
memcpy(crypt->oe, pdf_to_str_buf(ctx, obj), 32);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_UE);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(UE));
if (!pdf_is_string(ctx, obj) || pdf_to_str_len(ctx, obj) != 32)
{
pdf_drop_crypt(ctx, crypt);
@@ -165,7 +165,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
}
crypt->encrypt_metadata = 1;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_EncryptMetadata);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(EncryptMetadata));
if (pdf_is_bool(ctx, obj))
crypt->encrypt_metadata = pdf_to_bool(ctx, obj);
@@ -185,7 +185,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
crypt->length = 40;
if (crypt->v == 2 || crypt->v == 4)
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Length);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Length));
if (pdf_is_int(ctx, obj))
crypt->length = pdf_to_int(ctx, obj);
@@ -225,7 +225,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
crypt->strf.method = PDF_CRYPT_NONE;
crypt->strf.length = crypt->length;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_CF);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(CF));
if (pdf_is_dict(ctx, obj))
{
crypt->cf = pdf_keep_obj(ctx, obj);
@@ -237,11 +237,11 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
fz_try(ctx)
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_StmF);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(StmF));
if (pdf_is_name(ctx, obj))
pdf_parse_crypt_filter(ctx, &crypt->stmf, crypt, obj);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_StrF);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(StrF));
if (pdf_is_name(ctx, obj))
pdf_parse_crypt_filter(ctx, &crypt->strf, crypt, obj);
}
@@ -279,8 +279,8 @@ pdf_parse_crypt_filter(fz_context *ctx, pdf_crypt_filter *cf, pdf_crypt *crypt,
{
pdf_obj *obj;
pdf_obj *dict;
- int is_identity = (pdf_name_eq(ctx, name, PDF_NAME_Identity));
- int is_stdcf = (!is_identity && pdf_name_eq(ctx, name, PDF_NAME_StdCF));
+ int is_identity = (pdf_name_eq(ctx, name, PDF_NAME(Identity)));
+ int is_stdcf = (!is_identity && pdf_name_eq(ctx, name, PDF_NAME(StdCF)));
if (!is_identity && !is_stdcf)
fz_throw(ctx, FZ_ERROR_GENERIC, "Crypt Filter not Identity or StdCF (%d 0 R)", pdf_to_num(ctx, crypt->cf));
@@ -297,22 +297,22 @@ pdf_parse_crypt_filter(fz_context *ctx, pdf_crypt_filter *cf, pdf_crypt *crypt,
dict = pdf_dict_get(ctx, crypt->cf, name);
if (pdf_is_dict(ctx, dict))
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_CFM);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(CFM));
if (pdf_is_name(ctx, obj))
{
- if (pdf_name_eq(ctx, PDF_NAME_None, obj))
+ if (pdf_name_eq(ctx, PDF_NAME(None), obj))
cf->method = PDF_CRYPT_NONE;
- else if (pdf_name_eq(ctx, PDF_NAME_V2, obj))
+ else if (pdf_name_eq(ctx, PDF_NAME(V2), obj))
cf->method = PDF_CRYPT_RC4;
- else if (pdf_name_eq(ctx, PDF_NAME_AESV2, obj))
+ else if (pdf_name_eq(ctx, PDF_NAME(AESV2), obj))
cf->method = PDF_CRYPT_AESV2;
- else if (pdf_name_eq(ctx, PDF_NAME_AESV3, obj))
+ else if (pdf_name_eq(ctx, PDF_NAME(AESV3), obj))
cf->method = PDF_CRYPT_AESV3;
else
fz_warn(ctx, "unknown encryption method: %s", pdf_to_name(ctx, obj));
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Length);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Length));
if (pdf_is_int(ctx, obj))
cf->length = pdf_to_int(ctx, obj);
}
@@ -1035,7 +1035,7 @@ pdf_open_crypt(fz_context *ctx, fz_stream *chain, pdf_crypt *crypt, int num, int
fz_stream *
pdf_open_crypt_with_filter(fz_context *ctx, fz_stream *chain, pdf_crypt *crypt, pdf_obj *name, int num, int gen)
{
- if (!pdf_name_eq(ctx, name, PDF_NAME_Identity))
+ if (!pdf_name_eq(ctx, name, PDF_NAME(Identity)))
{
pdf_crypt_filter cf;
pdf_parse_crypt_filter(ctx, &cf, crypt, name);
diff --git a/source/pdf/pdf-device.c b/source/pdf/pdf-device.c
index db699dd0..9b33e5c9 100644
--- a/source/pdf/pdf-device.c
+++ b/source/pdf/pdf-device.c
@@ -313,7 +313,7 @@ pdf_dev_alpha(fz_context *ctx, pdf_device *pdev, float alpha, int stroke)
fz_try(ctx)
{
char text[32];
- pdf_dict_put_real(ctx, o, (stroke ? PDF_NAME_CA : PDF_NAME_ca), alpha);
+ pdf_dict_put_real(ctx, o, (stroke ? PDF_NAME(CA) : PDF_NAME(ca)), alpha);
fz_snprintf(text, sizeof(text), "ExtGState/Alp%d", i);
ref = pdf_add_object(ctx, doc, o);
pdf_dict_putp_drop(ctx, pdev->resources, text, ref);
@@ -567,20 +567,20 @@ pdf_dev_new_form(fz_context *ctx, pdf_obj **form_ref, pdf_device *pdev, const fz
group = pdf_new_dict(ctx, doc, 5);
fz_try(ctx)
{
- pdf_dict_put(ctx, group, PDF_NAME_Type, PDF_NAME_Group);
- pdf_dict_put(ctx, group, PDF_NAME_S, PDF_NAME_Transparency);
- pdf_dict_put_bool(ctx, group, PDF_NAME_K, knockout);
- pdf_dict_put_bool(ctx, group, PDF_NAME_I, isolated);
+ pdf_dict_put(ctx, group, PDF_NAME(Type), PDF_NAME(Group));
+ pdf_dict_put(ctx, group, PDF_NAME(S), PDF_NAME(Transparency));
+ pdf_dict_put_bool(ctx, group, PDF_NAME(K), knockout);
+ pdf_dict_put_bool(ctx, group, PDF_NAME(I), isolated);
switch (fz_colorspace_type(ctx, colorspace))
{
case FZ_COLORSPACE_GRAY:
- pdf_dict_put(ctx, group, PDF_NAME_CS, PDF_NAME_DeviceGray);
+ pdf_dict_put(ctx, group, PDF_NAME(CS), PDF_NAME(DeviceGray));
break;
case FZ_COLORSPACE_RGB:
- pdf_dict_put(ctx, group, PDF_NAME_CS, PDF_NAME_DeviceRGB);
+ pdf_dict_put(ctx, group, PDF_NAME(CS), PDF_NAME(DeviceRGB));
break;
case FZ_COLORSPACE_CMYK:
- pdf_dict_put(ctx, group, PDF_NAME_CS, PDF_NAME_DeviceCMYK);
+ pdf_dict_put(ctx, group, PDF_NAME(CS), PDF_NAME(DeviceCMYK));
break;
default:
break;
@@ -602,10 +602,10 @@ pdf_dev_new_form(fz_context *ctx, pdf_obj **form_ref, pdf_device *pdev, const fz
form = pdf_new_dict(ctx, doc, 4);
fz_try(ctx)
{
- pdf_dict_put(ctx, form, PDF_NAME_Subtype, PDF_NAME_Form);
- pdf_dict_put(ctx, form, PDF_NAME_Group, group_ref);
- pdf_dict_put_int(ctx, form, PDF_NAME_FormType, 1);
- pdf_dict_put_rect(ctx, form, PDF_NAME_BBox, bbox);
+ pdf_dict_put(ctx, form, PDF_NAME(Subtype), PDF_NAME(Form));
+ pdf_dict_put(ctx, form, PDF_NAME(Group), group_ref);
+ pdf_dict_put_int(ctx, form, PDF_NAME(FormType), 1);
+ pdf_dict_put_rect(ctx, form, PDF_NAME(BBox), bbox);
*form_ref = pdf_add_object(ctx, doc, form);
}
fz_always(ctx)
@@ -918,18 +918,18 @@ pdf_dev_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int lum
{
int n = fz_colorspace_n(ctx, colorspace);
smask = pdf_new_dict(ctx, doc, 4);
- pdf_dict_put(ctx, smask, PDF_NAME_Type, PDF_NAME_Mask);
- pdf_dict_put(ctx, smask, PDF_NAME_S, (luminosity ? PDF_NAME_Luminosity : PDF_NAME_Alpha));
- pdf_dict_put(ctx, smask, PDF_NAME_G, form_ref);
+ pdf_dict_put(ctx, smask, PDF_NAME(Type), PDF_NAME(Mask));
+ pdf_dict_put(ctx, smask, PDF_NAME(S), (luminosity ? PDF_NAME(Luminosity) : PDF_NAME(Alpha)));
+ pdf_dict_put(ctx, smask, PDF_NAME(G), form_ref);
color_obj = pdf_new_array(ctx, doc, n);
for (i = 0; i < n; i++)
pdf_array_push_real(ctx, color_obj, color[i]);
- pdf_dict_put_drop(ctx, smask, PDF_NAME_BC, color_obj);
+ pdf_dict_put_drop(ctx, smask, PDF_NAME(BC), color_obj);
color_obj = NULL;
egs = pdf_new_dict(ctx, doc, 5);
- pdf_dict_put(ctx, egs, PDF_NAME_Type, PDF_NAME_ExtGState);
- pdf_dict_put_drop(ctx, egs, PDF_NAME_SMask, pdf_add_object(ctx, doc, smask));
+ pdf_dict_put(ctx, egs, PDF_NAME(Type), PDF_NAME(ExtGState));
+ pdf_dict_put_drop(ctx, egs, PDF_NAME(SMask), pdf_add_object(ctx, doc, smask));
{
char text[32];
@@ -999,8 +999,8 @@ pdf_dev_begin_group(fz_context *ctx, fz_device *dev, const fz_rect *bbox, fz_col
{
/* No, better make one */
obj = pdf_new_dict(ctx, doc, 2);
- pdf_dict_put(ctx, obj, PDF_NAME_Type, PDF_NAME_ExtGState);
- pdf_dict_put_name(ctx, obj, PDF_NAME_BM, fz_blendmode_name(blendmode));
+ pdf_dict_put(ctx, obj, PDF_NAME(Type), PDF_NAME(ExtGState));
+ pdf_dict_put_name(ctx, obj, PDF_NAME(BM), fz_blendmode_name(blendmode));
pdf_dict_putp_drop(ctx, pdev->resources, text, obj);
}
}
diff --git a/source/pdf/pdf-field.c b/source/pdf/pdf-field.c
index 97479d54..7989db8d 100644
--- a/source/pdf/pdf-field.c
+++ b/source/pdf/pdf-field.c
@@ -12,10 +12,10 @@ pdf_obj *pdf_get_inheritable(fz_context *ctx, pdf_document *doc, pdf_obj *obj, p
fobj = pdf_dict_get(ctx, obj, key);
if (!fobj)
- obj = pdf_dict_get(ctx, obj, PDF_NAME_Parent);
+ obj = pdf_dict_get(ctx, obj, PDF_NAME(Parent));
}
- return fobj ? fobj : pdf_dict_get(ctx, pdf_dict_get(ctx, pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root), PDF_NAME_AcroForm), key);
+ return fobj ? fobj : pdf_dict_get(ctx, pdf_dict_get(ctx, pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root)), PDF_NAME(AcroForm)), key);
}
char *pdf_get_string_or_stream(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
@@ -62,17 +62,17 @@ char *pdf_get_string_or_stream(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
char *pdf_field_value(fz_context *ctx, pdf_document *doc, pdf_obj *field)
{
- return pdf_load_stream_or_string_as_utf8(ctx, pdf_get_inheritable(ctx, doc, field, PDF_NAME_V));
+ return pdf_load_stream_or_string_as_utf8(ctx, pdf_get_inheritable(ctx, doc, field, PDF_NAME(V)));
}
int pdf_get_field_flags(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
{
- return pdf_to_int(ctx, pdf_get_inheritable(ctx, doc, obj, PDF_NAME_Ff));
+ return pdf_to_int(ctx, pdf_get_inheritable(ctx, doc, obj, PDF_NAME(Ff)));
}
static pdf_obj *get_field_type_name(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
{
- return pdf_get_inheritable(ctx, doc, obj, PDF_NAME_FT);
+ return pdf_get_inheritable(ctx, doc, obj, PDF_NAME(FT));
}
int pdf_field_type(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
@@ -80,7 +80,7 @@ int pdf_field_type(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
pdf_obj *type = get_field_type_name(ctx, doc, obj);
int flags = pdf_get_field_flags(ctx, doc, obj);
- if (pdf_name_eq(ctx, type, PDF_NAME_Btn))
+ if (pdf_name_eq(ctx, type, PDF_NAME(Btn)))
{
if (flags & Ff_Pushbutton)
return PDF_WIDGET_TYPE_PUSHBUTTON;
@@ -89,16 +89,16 @@ int pdf_field_type(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
else
return PDF_WIDGET_TYPE_CHECKBOX;
}
- else if (pdf_name_eq(ctx, type, PDF_NAME_Tx))
+ else if (pdf_name_eq(ctx, type, PDF_NAME(Tx)))
return PDF_WIDGET_TYPE_TEXT;
- else if (pdf_name_eq(ctx, type, PDF_NAME_Ch))
+ else if (pdf_name_eq(ctx, type, PDF_NAME(Ch)))
{
if (flags & Ff_Combo)
return PDF_WIDGET_TYPE_COMBOBOX;
else
return PDF_WIDGET_TYPE_LISTBOX;
}
- else if (pdf_name_eq(ctx, type, PDF_NAME_Sig))
+ else if (pdf_name_eq(ctx, type, PDF_NAME(Sig)))
return PDF_WIDGET_TYPE_SIGNATURE;
else
return PDF_WIDGET_TYPE_NOT_WIDGET;
@@ -113,42 +113,42 @@ void pdf_set_field_type(fz_context *ctx, pdf_document *doc, pdf_obj *obj, int ty
switch(type)
{
case PDF_WIDGET_TYPE_PUSHBUTTON:
- typename = PDF_NAME_Btn;
+ typename = PDF_NAME(Btn);
setbits = Ff_Pushbutton;
break;
case PDF_WIDGET_TYPE_CHECKBOX:
- typename = PDF_NAME_Btn;
+ typename = PDF_NAME(Btn);
clearbits = Ff_Pushbutton;
setbits = Ff_Radio;
break;
case PDF_WIDGET_TYPE_RADIOBUTTON:
- typename = PDF_NAME_Btn;
+ typename = PDF_NAME(Btn);
clearbits = (Ff_Pushbutton|Ff_Radio);
break;
case PDF_WIDGET_TYPE_TEXT:
- typename = PDF_NAME_Tx;
+ typename = PDF_NAME(Tx);
break;
case PDF_WIDGET_TYPE_LISTBOX:
- typename = PDF_NAME_Ch;
+ typename = PDF_NAME(Ch);
clearbits = Ff_Combo;
break;
case PDF_WIDGET_TYPE_COMBOBOX:
- typename = PDF_NAME_Ch;
+ typename = PDF_NAME(Ch);
setbits = Ff_Combo;
break;
case PDF_WIDGET_TYPE_SIGNATURE:
- typename = PDF_NAME_Sig;
+ typename = PDF_NAME(Sig);
break;
}
if (typename)
- pdf_dict_put_drop(ctx, obj, PDF_NAME_FT, typename);
+ pdf_dict_put_drop(ctx, obj, PDF_NAME(FT), typename);
if (setbits != 0 || clearbits != 0)
{
- int bits = pdf_to_int(ctx, pdf_dict_get(ctx, obj, PDF_NAME_Ff));
+ int bits = pdf_to_int(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Ff)));
bits &= ~clearbits;
bits |= setbits;
- pdf_dict_put_int(ctx, obj, PDF_NAME_Ff, bits);
+ pdf_dict_put_int(ctx, obj, PDF_NAME(Ff), bits);
}
}
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index 148f4c29..cf72b5ba 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -651,17 +651,17 @@ pdf_load_simple_font_by_name(fz_context *ctx, pdf_document *doc, pdf_obj *dict,
{
fontdesc = pdf_new_font_desc(ctx);
- descriptor = pdf_dict_get(ctx, dict, PDF_NAME_FontDescriptor);
+ descriptor = pdf_dict_get(ctx, dict, PDF_NAME(FontDescriptor));
if (descriptor)
pdf_load_font_descriptor(ctx, doc, fontdesc, descriptor, NULL, basefont, 0);
else
pdf_load_builtin_font(ctx, fontdesc, basefont, 0);
/* Some chinese documents mistakenly consider WinAnsiEncoding to be codepage 936 */
- if (descriptor && pdf_is_string(ctx, pdf_dict_get(ctx, descriptor, PDF_NAME_FontName)) &&
- !pdf_dict_get(ctx, dict, PDF_NAME_ToUnicode) &&
- pdf_name_eq(ctx, pdf_dict_get(ctx, dict, PDF_NAME_Encoding), PDF_NAME_WinAnsiEncoding) &&
- pdf_to_int(ctx, pdf_dict_get(ctx, descriptor, PDF_NAME_Flags)) == 4)
+ if (descriptor && pdf_is_string(ctx, pdf_dict_get(ctx, descriptor, PDF_NAME(FontName))) &&
+ !pdf_dict_get(ctx, dict, PDF_NAME(ToUnicode)) &&
+ pdf_name_eq(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Encoding)), PDF_NAME(WinAnsiEncoding)) &&
+ pdf_to_int(ctx, pdf_dict_get(ctx, descriptor, PDF_NAME(Flags))) == 4)
{
char *cp936fonts[] = {
"\xCB\xCE\xCC\xE5", "SimSun,Regular",
@@ -720,7 +720,7 @@ pdf_load_simple_font_by_name(fz_context *ctx, pdf_document *doc, pdf_obj *dict,
etable[i] = 0;
}
- encoding = pdf_dict_get(ctx, dict, PDF_NAME_Encoding);
+ encoding = pdf_dict_get(ctx, dict, PDF_NAME(Encoding));
if (encoding)
{
if (pdf_is_name(ctx, encoding))
@@ -730,13 +730,13 @@ pdf_load_simple_font_by_name(fz_context *ctx, pdf_document *doc, pdf_obj *dict,
{
pdf_obj *base, *diff, *item;
- base = pdf_dict_get(ctx, encoding, PDF_NAME_BaseEncoding);
+ base = pdf_dict_get(ctx, encoding, PDF_NAME(BaseEncoding));
if (pdf_is_name(ctx, base))
pdf_load_encoding(estrings, pdf_to_name(ctx, base));
else if (!fontdesc->is_embedded && !symbolic)
pdf_load_encoding(estrings, "StandardEncoding");
- diff = pdf_dict_get(ctx, encoding, PDF_NAME_Differences);
+ diff = pdf_dict_get(ctx, encoding, PDF_NAME(Differences));
if (pdf_is_array(ctx, diff))
{
n = pdf_array_len(ctx, diff);
@@ -763,16 +763,16 @@ pdf_load_simple_font_by_name(fz_context *ctx, pdf_document *doc, pdf_obj *dict,
has_lock = 1;
/* built-in and substitute fonts may be a different type than what the document expects */
- subtype = pdf_dict_get(ctx, dict, PDF_NAME_Subtype);
- if (pdf_name_eq(ctx, subtype, PDF_NAME_Type1))
+ subtype = pdf_dict_get(ctx, dict, PDF_NAME(Subtype));
+ if (pdf_name_eq(ctx, subtype, PDF_NAME(Type1)))
kind = TYPE1;
- else if (pdf_name_eq(ctx, subtype, PDF_NAME_MMType1))
+ else if (pdf_name_eq(ctx, subtype, PDF_NAME(MMType1)))
kind = TYPE1;
- else if (pdf_name_eq(ctx, subtype, PDF_NAME_TrueType))
+ else if (pdf_name_eq(ctx, subtype, PDF_NAME(TrueType)))
kind = TRUETYPE;
- else if (pdf_name_eq(ctx, subtype, PDF_NAME_CIDFontType0))
+ else if (pdf_name_eq(ctx, subtype, PDF_NAME(CIDFontType0)))
kind = TYPE1;
- else if (pdf_name_eq(ctx, subtype, PDF_NAME_CIDFontType2))
+ else if (pdf_name_eq(ctx, subtype, PDF_NAME(CIDFontType2)))
kind = TRUETYPE;
/* encode by glyph name where we can */
@@ -881,7 +881,7 @@ pdf_load_simple_font_by_name(fz_context *ctx, pdf_document *doc, pdf_obj *dict,
fz_try(ctx)
{
- pdf_load_to_unicode(ctx, doc, fontdesc, estrings, NULL, pdf_dict_get(ctx, dict, PDF_NAME_ToUnicode));
+ pdf_load_to_unicode(ctx, doc, fontdesc, estrings, NULL, pdf_dict_get(ctx, dict, PDF_NAME(ToUnicode)));
}
fz_catch(ctx)
{
@@ -895,13 +895,13 @@ pdf_load_simple_font_by_name(fz_context *ctx, pdf_document *doc, pdf_obj *dict,
pdf_set_default_hmtx(ctx, fontdesc, fontdesc->missing_width);
- widths = pdf_dict_get(ctx, dict, PDF_NAME_Widths);
+ widths = pdf_dict_get(ctx, dict, PDF_NAME(Widths));
if (widths)
{
int first, last;
- first = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_FirstChar));
- last = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_LastChar));
+ first = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(FirstChar)));
+ last = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(LastChar)));
if (first < 0 || last > 255 || first > last)
first = last = 0;
@@ -935,7 +935,7 @@ pdf_load_simple_font_by_name(fz_context *ctx, pdf_document *doc, pdf_obj *dict,
static pdf_font_desc *
pdf_load_simple_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
{
- const char *basefont = pdf_to_name(ctx, pdf_dict_get(ctx, dict, PDF_NAME_BaseFont));
+ const char *basefont = pdf_to_name(ctx, pdf_dict_get(ctx, dict, PDF_NAME(BaseFont)));
return pdf_load_simple_font_by_name(ctx, doc, dict, basefont);
}
@@ -1028,18 +1028,18 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
{
/* Get font name and CID collection */
- basefont = pdf_to_name(ctx, pdf_dict_get(ctx, dict, PDF_NAME_BaseFont));
+ basefont = pdf_to_name(ctx, pdf_dict_get(ctx, dict, PDF_NAME(BaseFont)));
{
pdf_obj *cidinfo;
char tmpstr[64];
int tmplen;
- cidinfo = pdf_dict_get(ctx, dict, PDF_NAME_CIDSystemInfo);
+ cidinfo = pdf_dict_get(ctx, dict, PDF_NAME(CIDSystemInfo));
if (!cidinfo)
fz_throw(ctx, FZ_ERROR_SYNTAX, "cid font is missing info");
- obj = pdf_dict_get(ctx, cidinfo, PDF_NAME_Registry);
+ obj = pdf_dict_get(ctx, cidinfo, PDF_NAME(Registry));
tmplen = fz_mini(sizeof tmpstr - 1, pdf_to_str_len(ctx, obj));
memcpy(tmpstr, pdf_to_str_buf(ctx, obj), tmplen);
tmpstr[tmplen] = '\0';
@@ -1047,7 +1047,7 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
fz_strlcat(collection, "-", sizeof collection);
- obj = pdf_dict_get(ctx, cidinfo, PDF_NAME_Ordering);
+ obj = pdf_dict_get(ctx, cidinfo, PDF_NAME(Ordering));
tmplen = fz_mini(sizeof tmpstr - 1, pdf_to_str_len(ctx, obj));
memcpy(tmpstr, pdf_to_str_buf(ctx, obj), tmplen);
tmpstr[tmplen] = '\0';
@@ -1058,9 +1058,9 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
if (pdf_is_name(ctx, encoding))
{
- if (pdf_name_eq(ctx, encoding, PDF_NAME_Identity_H))
+ if (pdf_name_eq(ctx, encoding, PDF_NAME(Identity_H)))
cmap = pdf_new_identity_cmap(ctx, 0, 2);
- else if (pdf_name_eq(ctx, encoding, PDF_NAME_Identity_V))
+ else if (pdf_name_eq(ctx, encoding, PDF_NAME(Identity_V)))
cmap = pdf_new_identity_cmap(ctx, 1, 2);
else
cmap = pdf_load_system_cmap(ctx, pdf_to_name(ctx, encoding));
@@ -1083,7 +1083,7 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
pdf_set_font_wmode(ctx, fontdesc, pdf_cmap_wmode(ctx, fontdesc->encoding));
- descriptor = pdf_dict_get(ctx, dict, PDF_NAME_FontDescriptor);
+ descriptor = pdf_dict_get(ctx, dict, PDF_NAME(FontDescriptor));
if (!descriptor)
fz_throw(ctx, FZ_ERROR_SYNTAX, "missing font descriptor");
pdf_load_font_descriptor(ctx, doc, fontdesc, descriptor, collection, basefont, 1);
@@ -1092,7 +1092,7 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
/* Apply encoding */
- cidtogidmap = pdf_dict_get(ctx, dict, PDF_NAME_CIDToGIDMap);
+ cidtogidmap = pdf_dict_get(ctx, dict, PDF_NAME(CIDToGIDMap));
if (pdf_is_indirect(ctx, cidtogidmap))
{
fz_buffer *buf;
@@ -1148,12 +1148,12 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
/* Horizontal */
dw = 1000;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_DW);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(DW));
if (obj)
dw = pdf_to_int(ctx, obj);
pdf_set_default_hmtx(ctx, fontdesc, dw);
- widths = pdf_dict_get(ctx, dict, PDF_NAME_W);
+ widths = pdf_dict_get(ctx, dict, PDF_NAME(W));
if (widths)
{
int c0, c1, w, n, m;
@@ -1192,7 +1192,7 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
int dw2y = 880;
int dw2w = -1000;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_DW2);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(DW2));
if (obj)
{
dw2y = pdf_to_int(ctx, pdf_array_get(ctx, obj, 0));
@@ -1201,7 +1201,7 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
pdf_set_default_vmtx(ctx, fontdesc, dw2y, dw2w);
- widths = pdf_dict_get(ctx, dict, PDF_NAME_W2);
+ widths = pdf_dict_get(ctx, dict, PDF_NAME(W2));
if (widths)
{
int c0, c1, w, x, y, n;
@@ -1256,19 +1256,19 @@ pdf_load_type0_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
pdf_obj *encoding;
pdf_obj *to_unicode;
- dfonts = pdf_dict_get(ctx, dict, PDF_NAME_DescendantFonts);
+ dfonts = pdf_dict_get(ctx, dict, PDF_NAME(DescendantFonts));
if (!dfonts)
fz_throw(ctx, FZ_ERROR_SYNTAX, "cid font is missing descendant fonts");
dfont = pdf_array_get(ctx, dfonts, 0);
- subtype = pdf_dict_get(ctx, dfont, PDF_NAME_Subtype);
- encoding = pdf_dict_get(ctx, dict, PDF_NAME_Encoding);
- to_unicode = pdf_dict_get(ctx, dict, PDF_NAME_ToUnicode);
+ subtype = pdf_dict_get(ctx, dfont, PDF_NAME(Subtype));
+ encoding = pdf_dict_get(ctx, dict, PDF_NAME(Encoding));
+ to_unicode = pdf_dict_get(ctx, dict, PDF_NAME(ToUnicode));
- if (pdf_is_name(ctx, subtype) && pdf_name_eq(ctx, subtype, PDF_NAME_CIDFontType0))
+ if (pdf_is_name(ctx, subtype) && pdf_name_eq(ctx, subtype, PDF_NAME(CIDFontType0)))
return load_cid_font(ctx, doc, dfont, encoding, to_unicode);
- if (pdf_is_name(ctx, subtype) && pdf_name_eq(ctx, subtype, PDF_NAME_CIDFontType2))
+ if (pdf_is_name(ctx, subtype) && pdf_name_eq(ctx, subtype, PDF_NAME(CIDFontType2)))
return load_cid_font(ctx, doc, dfont, encoding, to_unicode);
fz_throw(ctx, FZ_ERROR_SYNTAX, "unknown cid font type");
}
@@ -1288,17 +1288,17 @@ pdf_load_font_descriptor(fz_context *ctx, pdf_document *doc, pdf_font_desc *font
/* Prefer BaseFont; don't bother with FontName */
fontname = basefont;
- fontdesc->flags = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_Flags));
- fontdesc->italic_angle = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME_ItalicAngle));
- fontdesc->ascent = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME_Ascent));
- fontdesc->descent = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME_Descent));
- fontdesc->cap_height = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME_CapHeight));
- fontdesc->x_height = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME_XHeight));
- fontdesc->missing_width = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME_MissingWidth));
-
- obj1 = pdf_dict_get(ctx, dict, PDF_NAME_FontFile);
- obj2 = pdf_dict_get(ctx, dict, PDF_NAME_FontFile2);
- obj3 = pdf_dict_get(ctx, dict, PDF_NAME_FontFile3);
+ fontdesc->flags = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Flags)));
+ fontdesc->italic_angle = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(ItalicAngle)));
+ fontdesc->ascent = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Ascent)));
+ fontdesc->descent = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Descent)));
+ fontdesc->cap_height = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(CapHeight)));
+ fontdesc->x_height = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(XHeight)));
+ fontdesc->missing_width = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(MissingWidth)));
+
+ obj1 = pdf_dict_get(ctx, dict, PDF_NAME(FontFile));
+ obj2 = pdf_dict_get(ctx, dict, PDF_NAME(FontFile2));
+ obj3 = pdf_dict_get(ctx, dict, PDF_NAME(FontFile3));
obj = obj1 ? obj1 : obj2 ? obj2 : obj3;
if (pdf_is_indirect(ctx, obj))
@@ -1398,19 +1398,19 @@ pdf_load_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *dict, i
return fontdesc;
}
- subtype = pdf_dict_get(ctx, dict, PDF_NAME_Subtype);
- dfonts = pdf_dict_get(ctx, dict, PDF_NAME_DescendantFonts);
- charprocs = pdf_dict_get(ctx, dict, PDF_NAME_CharProcs);
+ subtype = pdf_dict_get(ctx, dict, PDF_NAME(Subtype));
+ dfonts = pdf_dict_get(ctx, dict, PDF_NAME(DescendantFonts));
+ charprocs = pdf_dict_get(ctx, dict, PDF_NAME(CharProcs));
- if (pdf_name_eq(ctx, subtype, PDF_NAME_Type0))
+ if (pdf_name_eq(ctx, subtype, PDF_NAME(Type0)))
fontdesc = pdf_load_type0_font(ctx, doc, dict);
- else if (pdf_name_eq(ctx, subtype, PDF_NAME_Type1))
+ else if (pdf_name_eq(ctx, subtype, PDF_NAME(Type1)))
fontdesc = pdf_load_simple_font(ctx, doc, dict);
- else if (pdf_name_eq(ctx, subtype, PDF_NAME_MMType1))
+ else if (pdf_name_eq(ctx, subtype, PDF_NAME(MMType1)))
fontdesc = pdf_load_simple_font(ctx, doc, dict);
- else if (pdf_name_eq(ctx, subtype, PDF_NAME_TrueType))
+ else if (pdf_name_eq(ctx, subtype, PDF_NAME(TrueType)))
fontdesc = pdf_load_simple_font(ctx, doc, dict);
- else if (pdf_name_eq(ctx, subtype, PDF_NAME_Type3))
+ else if (pdf_name_eq(ctx, subtype, PDF_NAME(Type3)))
{
fontdesc = pdf_load_type3_font(ctx, doc, rdb, dict);
type3 = 1;
@@ -1547,21 +1547,21 @@ pdf_add_font_file(fz_context *ctx, pdf_document *doc, fz_font *font)
{
size_t len = fz_buffer_storage(ctx, buf, NULL);
obj = pdf_new_dict(ctx, doc, 3);
- pdf_dict_put_int(ctx, obj, PDF_NAME_Length1, (int)len);
+ pdf_dict_put_int(ctx, obj, PDF_NAME(Length1), (int)len);
switch (ft_font_file_kind(font->ft_face))
{
case 1:
/* TODO: these may not be the correct values, but I doubt it matters */
- pdf_dict_put_int(ctx, obj, PDF_NAME_Length2, len);
- pdf_dict_put_int(ctx, obj, PDF_NAME_Length3, 0);
+ pdf_dict_put_int(ctx, obj, PDF_NAME(Length2), len);
+ pdf_dict_put_int(ctx, obj, PDF_NAME(Length3), 0);
break;
case 2:
break;
case 3:
if (FT_Get_Sfnt_Table(font->ft_face, FT_SFNT_HEAD))
- pdf_dict_put(ctx, obj, PDF_NAME_Subtype, PDF_NAME_OpenType);
+ pdf_dict_put(ctx, obj, PDF_NAME(Subtype), PDF_NAME(OpenType));
else
- pdf_dict_put(ctx, obj, PDF_NAME_Subtype, PDF_NAME_Type1C);
+ pdf_dict_put(ctx, obj, PDF_NAME(Subtype), PDF_NAME(Type1C));
break;
}
ref = pdf_add_object(ctx, doc, obj);
@@ -1590,20 +1590,20 @@ pdf_add_font_descriptor(fz_context *ctx, pdf_document *doc, pdf_obj *fobj, fz_fo
fdobj = pdf_new_dict(ctx, doc, 10);
fz_try(ctx)
{
- pdf_dict_put(ctx, fdobj, PDF_NAME_Type, PDF_NAME_FontDescriptor);
- pdf_dict_put_name(ctx, fdobj, PDF_NAME_FontName, font->name);
+ pdf_dict_put(ctx, fdobj, PDF_NAME(Type), PDF_NAME(FontDescriptor));
+ pdf_dict_put_name(ctx, fdobj, PDF_NAME(FontName), font->name);
bbox.x0 = font->bbox.x0 * 1000;
bbox.y0 = font->bbox.y0 * 1000;
bbox.x1 = font->bbox.x1 * 1000;
bbox.y1 = font->bbox.y1 * 1000;
- pdf_dict_put_rect(ctx, fdobj, PDF_NAME_FontBBox, &bbox);
+ pdf_dict_put_rect(ctx, fdobj, PDF_NAME(FontBBox), &bbox);
- pdf_dict_put_int(ctx, fdobj, PDF_NAME_ItalicAngle, 0);
- pdf_dict_put_int(ctx, fdobj, PDF_NAME_Ascent, face->ascender * 1000.0f / face->units_per_EM);
- pdf_dict_put_int(ctx, fdobj, PDF_NAME_Descent, face->descender * 1000.0f / face->units_per_EM);
- pdf_dict_put_int(ctx, fdobj, PDF_NAME_StemV, 80);
- pdf_dict_put_int(ctx, fdobj, PDF_NAME_Flags, PDF_FD_NONSYMBOLIC);
+ pdf_dict_put_int(ctx, fdobj, PDF_NAME(ItalicAngle), 0);
+ pdf_dict_put_int(ctx, fdobj, PDF_NAME(Ascent), face->ascender * 1000.0f / face->units_per_EM);
+ pdf_dict_put_int(ctx, fdobj, PDF_NAME(Descent), face->descender * 1000.0f / face->units_per_EM);
+ pdf_dict_put_int(ctx, fdobj, PDF_NAME(StemV), 80);
+ pdf_dict_put_int(ctx, fdobj, PDF_NAME(Flags), PDF_FD_NONSYMBOLIC);
fileref = pdf_add_font_file(ctx, doc, font);
if (fileref)
@@ -1611,13 +1611,13 @@ pdf_add_font_descriptor(fz_context *ctx, pdf_document *doc, pdf_obj *fobj, fz_fo
switch (ft_font_file_kind(face))
{
default:
- case 1: pdf_dict_put_drop(ctx, fdobj, PDF_NAME_FontFile, fileref); break;
- case 2: pdf_dict_put_drop(ctx, fdobj, PDF_NAME_FontFile2, fileref); break;
- case 3: pdf_dict_put_drop(ctx, fdobj, PDF_NAME_FontFile3, fileref); break;
+ case 1: pdf_dict_put_drop(ctx, fdobj, PDF_NAME(FontFile), fileref); break;
+ case 2: pdf_dict_put_drop(ctx, fdobj, PDF_NAME(FontFile2), fileref); break;
+ case 3: pdf_dict_put_drop(ctx, fdobj, PDF_NAME(FontFile3), fileref); break;
}
}
- pdf_dict_put_drop(ctx, fobj, PDF_NAME_FontDescriptor, pdf_add_object(ctx, doc, fdobj));
+ pdf_dict_put_drop(ctx, fobj, PDF_NAME(FontDescriptor), pdf_add_object(ctx, doc, fdobj));
}
fz_always(ctx)
pdf_drop_obj(ctx, fdobj);
@@ -1656,20 +1656,20 @@ pdf_add_simple_font_widths(fz_context *ctx, pdf_document *doc, pdf_obj *fobj, fz
}
widths = pdf_new_array(ctx, doc, last - first + 1);
- pdf_dict_put_drop(ctx, fobj, PDF_NAME_Widths, widths);
+ pdf_dict_put_drop(ctx, fobj, PDF_NAME(Widths), widths);
for (i = first; i <= last; ++i)
pdf_array_push_int(ctx, widths, width_table[i]);
- pdf_dict_put_int(ctx, fobj, PDF_NAME_FirstChar, first);
- pdf_dict_put_int(ctx, fobj, PDF_NAME_LastChar, last);
+ pdf_dict_put_int(ctx, fobj, PDF_NAME(FirstChar), first);
+ pdf_dict_put_int(ctx, fobj, PDF_NAME(LastChar), last);
}
static void
pdf_add_cid_system_info(fz_context *ctx, pdf_document *doc, pdf_obj *fobj, const char *reg, const char *ord, int supp)
{
- pdf_obj *csi = pdf_dict_put_dict(ctx, fobj, PDF_NAME_CIDSystemInfo, 3);
- pdf_dict_put_string(ctx, csi, PDF_NAME_Registry, reg, strlen(reg));
- pdf_dict_put_string(ctx, csi, PDF_NAME_Ordering, ord, strlen(ord));
- pdf_dict_put_int(ctx, csi, PDF_NAME_Supplement, supp);
+ pdf_obj *csi = pdf_dict_put_dict(ctx, fobj, PDF_NAME(CIDSystemInfo), 3);
+ pdf_dict_put_string(ctx, csi, PDF_NAME(Registry), reg, strlen(reg));
+ pdf_dict_put_string(ctx, csi, PDF_NAME(Ordering), ord, strlen(ord));
+ pdf_dict_put_int(ctx, csi, PDF_NAME(Supplement), supp);
}
/* Different states of starting, same width as last, or consecutive glyph */
@@ -1793,9 +1793,9 @@ pdf_add_cid_font_widths(fz_context *ctx, pdf_document *doc, pdf_obj *fobj, fz_fo
}
if (font->width_table != NULL)
- pdf_dict_put_int(ctx, fobj, PDF_NAME_DW, font->width_default);
+ pdf_dict_put_int(ctx, fobj, PDF_NAME(DW), font->width_default);
if (pdf_array_len(ctx, fw) > 0)
- pdf_dict_put(ctx, fobj, PDF_NAME_W, fw);
+ pdf_dict_put(ctx, fobj, PDF_NAME(W), fw);
}
fz_always(ctx)
pdf_drop_obj(ctx, fw);
@@ -1814,20 +1814,20 @@ pdf_add_descendant_cid_font(fz_context *ctx, pdf_document *doc, fz_font *font)
fobj = pdf_new_dict(ctx, doc, 3);
fz_try(ctx)
{
- pdf_dict_put(ctx, fobj, PDF_NAME_Type, PDF_NAME_Font);
+ pdf_dict_put(ctx, fobj, PDF_NAME(Type), PDF_NAME(Font));
switch (ft_kind(face))
{
- case TYPE1: pdf_dict_put(ctx, fobj, PDF_NAME_Subtype, PDF_NAME_CIDFontType0); break;
- case TRUETYPE: pdf_dict_put(ctx, fobj, PDF_NAME_Subtype, PDF_NAME_CIDFontType2); break;
+ case TYPE1: pdf_dict_put(ctx, fobj, PDF_NAME(Subtype), PDF_NAME(CIDFontType0)); break;
+ case TRUETYPE: pdf_dict_put(ctx, fobj, PDF_NAME(Subtype), PDF_NAME(CIDFontType2)); break;
}
pdf_add_cid_system_info(ctx, doc, fobj, "Adobe", "Identity", 0);
ps_name = FT_Get_Postscript_Name(face);
if (ps_name)
- pdf_dict_put_name(ctx, fobj, PDF_NAME_BaseFont, ps_name);
+ pdf_dict_put_name(ctx, fobj, PDF_NAME(BaseFont), ps_name);
else
- pdf_dict_put_name(ctx, fobj, PDF_NAME_BaseFont, font->name);
+ pdf_dict_put_name(ctx, fobj, PDF_NAME(BaseFont), font->name);
pdf_add_font_descriptor(ctx, doc, fobj, font);
@@ -1997,7 +1997,7 @@ pdf_add_to_unicode(fz_context *ctx, pdf_document *doc, pdf_obj *fobj, fz_font *f
fz_append_string(ctx, buf, "CMapName currentdict /CMap defineresource pop\n");
fz_append_string(ctx, buf, "end\nend\n");
- pdf_dict_put_drop(ctx, fobj, PDF_NAME_ToUnicode, pdf_add_stream(ctx, doc, buf, NULL, 0));
+ pdf_dict_put_drop(ctx, fobj, PDF_NAME(ToUnicode), pdf_add_stream(ctx, doc, buf, NULL, 0));
}
fz_always(ctx)
{
@@ -2027,13 +2027,13 @@ pdf_add_cid_font(fz_context *ctx, pdf_document *doc, fz_font *font)
fobj = pdf_add_new_dict(ctx, doc, 10);
fz_try(ctx)
{
- pdf_dict_put(ctx, fobj, PDF_NAME_Type, PDF_NAME_Font);
- pdf_dict_put(ctx, fobj, PDF_NAME_Subtype, PDF_NAME_Type0);
- pdf_dict_put_name(ctx, fobj, PDF_NAME_BaseFont, font->name);
- pdf_dict_put(ctx, fobj, PDF_NAME_Encoding, PDF_NAME_Identity_H);
+ pdf_dict_put(ctx, fobj, PDF_NAME(Type), PDF_NAME(Font));
+ pdf_dict_put(ctx, fobj, PDF_NAME(Subtype), PDF_NAME(Type0));
+ pdf_dict_put_name(ctx, fobj, PDF_NAME(BaseFont), font->name);
+ pdf_dict_put(ctx, fobj, PDF_NAME(Encoding), PDF_NAME(Identity_H));
pdf_add_to_unicode(ctx, doc, fobj, font);
- dfonts = pdf_dict_put_array(ctx, fobj, PDF_NAME_DescendantFonts, 1);
+ dfonts = pdf_dict_put_array(ctx, fobj, PDF_NAME(DescendantFonts), 1);
pdf_array_push_drop(ctx, dfonts, pdf_add_descendant_cid_font(ctx, doc, font));
fref = pdf_insert_font_resource(ctx, doc, digest, fobj);
@@ -2053,9 +2053,9 @@ pdf_add_simple_font_encoding_imp(fz_context *ctx, pdf_document *doc, pdf_obj *fo
pdf_obj *enc, *diff;
int i, last;
- enc = pdf_dict_put_dict(ctx, font, PDF_NAME_Encoding, 2);
- pdf_dict_put(ctx, enc, PDF_NAME_BaseEncoding, PDF_NAME_WinAnsiEncoding);
- diff = pdf_dict_put_array(ctx, enc, PDF_NAME_Differences, 129);
+ enc = pdf_dict_put_dict(ctx, font, PDF_NAME(Encoding), 2);
+ pdf_dict_put(ctx, enc, PDF_NAME(BaseEncoding), PDF_NAME(WinAnsiEncoding));
+ diff = pdf_dict_put_array(ctx, enc, PDF_NAME(Differences), 129);
last = 0;
for (i = 128; i < 256; ++i)
{
@@ -2077,7 +2077,7 @@ pdf_add_simple_font_encoding(fz_context *ctx, pdf_document *doc, pdf_obj *fobj,
{
default:
case PDF_SIMPLE_ENCODING_LATIN:
- pdf_dict_put(ctx, fobj, PDF_NAME_Encoding, PDF_NAME_WinAnsiEncoding);
+ pdf_dict_put(ctx, fobj, PDF_NAME(Encoding), PDF_NAME(WinAnsiEncoding));
break;
case PDF_SIMPLE_ENCODING_GREEK:
pdf_add_simple_font_encoding_imp(ctx, doc, fobj, pdf_glyph_name_from_iso8859_7);
@@ -2112,11 +2112,11 @@ pdf_add_simple_font(fz_context *ctx, pdf_document *doc, fz_font *font, int encod
fobj = pdf_add_new_dict(ctx, doc, 10);
fz_try(ctx)
{
- pdf_dict_put(ctx, fobj, PDF_NAME_Type, PDF_NAME_Font);
+ pdf_dict_put(ctx, fobj, PDF_NAME(Type), PDF_NAME(Font));
switch (ft_kind(face))
{
- case TYPE1: pdf_dict_put(ctx, fobj, PDF_NAME_Subtype, PDF_NAME_Type1); break;
- case TRUETYPE: pdf_dict_put(ctx, fobj, PDF_NAME_Subtype, PDF_NAME_TrueType); break;
+ case TYPE1: pdf_dict_put(ctx, fobj, PDF_NAME(Subtype), PDF_NAME(Type1)); break;
+ case TRUETYPE: pdf_dict_put(ctx, fobj, PDF_NAME(Subtype), PDF_NAME(TrueType)); break;
}
if (!is_builtin_font(ctx, font))
@@ -2124,14 +2124,14 @@ pdf_add_simple_font(fz_context *ctx, pdf_document *doc, fz_font *font, int encod
const char *ps_name = FT_Get_Postscript_Name(face);
if (!ps_name)
ps_name = font->name;
- pdf_dict_put_name(ctx, fobj, PDF_NAME_BaseFont, ps_name);
+ pdf_dict_put_name(ctx, fobj, PDF_NAME(BaseFont), ps_name);
pdf_add_simple_font_encoding(ctx, doc, fobj, encoding);
pdf_add_simple_font_widths(ctx, doc, fobj, font, enc);
pdf_add_font_descriptor(ctx, doc, fobj, font);
}
else
{
- pdf_dict_put_name(ctx, fobj, PDF_NAME_BaseFont, clean_font_name(font->name));
+ pdf_dict_put_name(ctx, fobj, PDF_NAME(BaseFont), clean_font_name(font->name));
pdf_add_simple_font_encoding(ctx, doc, fobj, encoding);
if (encoding != PDF_SIMPLE_ENCODING_LATIN)
pdf_add_simple_font_widths(ctx, doc, fobj, font, enc);
@@ -2211,28 +2211,28 @@ pdf_add_cjk_font(fz_context *ctx, pdf_document *doc, fz_font *fzfont, int script
font = pdf_add_new_dict(ctx, doc, 5);
fz_try(ctx)
{
- pdf_dict_put(ctx, font, PDF_NAME_Type, PDF_NAME_Font);
- pdf_dict_put(ctx, font, PDF_NAME_Subtype, PDF_NAME_Type0);
- pdf_dict_put_name(ctx, font, PDF_NAME_BaseFont, basefont);
- pdf_dict_put_name(ctx, font, PDF_NAME_Encoding, encoding);
- dfonts = pdf_dict_put_array(ctx, font, PDF_NAME_DescendantFonts, 1);
+ pdf_dict_put(ctx, font, PDF_NAME(Type), PDF_NAME(Font));
+ pdf_dict_put(ctx, font, PDF_NAME(Subtype), PDF_NAME(Type0));
+ pdf_dict_put_name(ctx, font, PDF_NAME(BaseFont), basefont);
+ pdf_dict_put_name(ctx, font, PDF_NAME(Encoding), encoding);
+ dfonts = pdf_dict_put_array(ctx, font, PDF_NAME(DescendantFonts), 1);
pdf_array_push_drop(ctx, dfonts, subfont = pdf_add_new_dict(ctx, doc, 5));
{
- pdf_dict_put(ctx, subfont, PDF_NAME_Type, PDF_NAME_Font);
- pdf_dict_put(ctx, subfont, PDF_NAME_Subtype, PDF_NAME_CIDFontType0);
- pdf_dict_put_name(ctx, subfont, PDF_NAME_BaseFont, basefont);
+ pdf_dict_put(ctx, subfont, PDF_NAME(Type), PDF_NAME(Font));
+ pdf_dict_put(ctx, subfont, PDF_NAME(Subtype), PDF_NAME(CIDFontType0));
+ pdf_dict_put_name(ctx, subfont, PDF_NAME(BaseFont), basefont);
pdf_add_cid_system_info(ctx, doc, subfont, "Adobe", ordering, supplement);
fontdesc = pdf_add_new_dict(ctx, doc, 8);
- pdf_dict_put_drop(ctx, subfont, PDF_NAME_FontDescriptor, fontdesc);
+ pdf_dict_put_drop(ctx, subfont, PDF_NAME(FontDescriptor), fontdesc);
{
- pdf_dict_put(ctx, fontdesc, PDF_NAME_Type, PDF_NAME_FontDescriptor);
- pdf_dict_put_text_string(ctx, fontdesc, PDF_NAME_FontName, basefont);
- pdf_dict_put_int(ctx, fontdesc, PDF_NAME_Flags, 0);
- pdf_dict_put_rect(ctx, fontdesc, PDF_NAME_FontBBox, &bbox);
- pdf_dict_put_int(ctx, fontdesc, PDF_NAME_ItalicAngle, 0);
- pdf_dict_put_int(ctx, fontdesc, PDF_NAME_Ascent, 1000);
- pdf_dict_put_int(ctx, fontdesc, PDF_NAME_Descent, -200);
- pdf_dict_put_int(ctx, fontdesc, PDF_NAME_StemV, 80);
+ pdf_dict_put(ctx, fontdesc, PDF_NAME(Type), PDF_NAME(FontDescriptor));
+ pdf_dict_put_text_string(ctx, fontdesc, PDF_NAME(FontName), basefont);
+ pdf_dict_put_int(ctx, fontdesc, PDF_NAME(Flags), 0);
+ pdf_dict_put_rect(ctx, fontdesc, PDF_NAME(FontBBox), &bbox);
+ pdf_dict_put_int(ctx, fontdesc, PDF_NAME(ItalicAngle), 0);
+ pdf_dict_put_int(ctx, fontdesc, PDF_NAME(Ascent), 1000);
+ pdf_dict_put_int(ctx, fontdesc, PDF_NAME(Descent), -200);
+ pdf_dict_put_int(ctx, fontdesc, PDF_NAME(StemV), 80);
}
}
diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c
index 6c2e0434..fa20949d 100644
--- a/source/pdf/pdf-form.c
+++ b/source/pdf/pdf-form.c
@@ -30,15 +30,15 @@ static int pdf_field_dirties_document(fz_context *ctx, pdf_document *doc, pdf_ob
* share the same name */
static pdf_obj *find_head_of_field_group(fz_context *ctx, pdf_obj *obj)
{
- if (obj == NULL || pdf_dict_get(ctx, obj, PDF_NAME_T))
+ if (obj == NULL || pdf_dict_get(ctx, obj, PDF_NAME(T)))
return obj;
else
- return find_head_of_field_group(ctx, pdf_dict_get(ctx, obj, PDF_NAME_Parent));
+ return find_head_of_field_group(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Parent)));
}
static void pdf_field_mark_dirty(fz_context *ctx, pdf_document *doc, pdf_obj *field)
{
- pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME_Kids);
+ pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME(Kids));
if (kids)
{
int i, n = pdf_array_len(ctx, kids);
@@ -65,7 +65,7 @@ static void update_field_value(fz_context *ctx, pdf_document *doc, pdf_obj *obj,
if (grp)
obj = grp;
- pdf_dict_put_text_string(ctx, obj, PDF_NAME_V, text);
+ pdf_dict_put_text_string(ctx, obj, PDF_NAME(V), text);
pdf_field_mark_dirty(ctx, doc, obj);
}
@@ -81,7 +81,7 @@ static pdf_obj *find_field(fz_context *ctx, pdf_obj *dict, char *name, int len)
char *part;
field = pdf_array_get(ctx, dict, i);
- part = pdf_to_str_buf(ctx, pdf_dict_get(ctx, field, PDF_NAME_T));
+ part = pdf_to_str_buf(ctx, pdf_dict_get(ctx, field, PDF_NAME(T)));
if (strlen(part) == (size_t)len && !memcmp(part, name, len))
return field;
}
@@ -108,7 +108,7 @@ pdf_obj *pdf_lookup_field(fz_context *ctx, pdf_obj *form, char *name)
len = dot ? dot - namep : (int)strlen(namep);
dict = find_field(ctx, form, namep, len);
if (dot)
- form = pdf_dict_get(ctx, dict, PDF_NAME_Kids);
+ form = pdf_dict_get(ctx, dict, PDF_NAME(Kids));
}
return dict;
@@ -123,13 +123,13 @@ static void reset_form_field(fz_context *ctx, pdf_document *doc, pdf_obj *field)
* At the bottom of the hierarchy we may find widget annotations
* that aren't also fields, but DV and V will not be present in their
* dictionaries, and attempts to remove V will be harmless. */
- pdf_obj *dv = pdf_dict_get(ctx, field, PDF_NAME_DV);
- pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME_Kids);
+ pdf_obj *dv = pdf_dict_get(ctx, field, PDF_NAME(DV));
+ pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME(Kids));
if (dv)
- pdf_dict_put(ctx, field, PDF_NAME_V, dv);
+ pdf_dict_put(ctx, field, PDF_NAME(V), dv);
else
- pdf_dict_del(ctx, field, PDF_NAME_V);
+ pdf_dict_del(ctx, field, PDF_NAME(V));
if (kids == NULL)
{
@@ -142,14 +142,14 @@ static void reset_form_field(fz_context *ctx, pdf_document *doc, pdf_obj *field)
case PDF_WIDGET_TYPE_RADIOBUTTON:
case PDF_WIDGET_TYPE_CHECKBOX:
{
- pdf_obj *leafv = pdf_get_inheritable(ctx, doc, field, PDF_NAME_V);
+ pdf_obj *leafv = pdf_get_inheritable(ctx, doc, field, PDF_NAME(V));
if (leafv)
pdf_keep_obj(ctx, leafv);
else
- leafv = PDF_NAME_Off;
+ leafv = PDF_NAME(Off);
- pdf_dict_put_drop(ctx, field, PDF_NAME_AS, leafv);
+ pdf_dict_put_drop(ctx, field, PDF_NAME(AS), leafv);
}
break;
@@ -168,7 +168,7 @@ static void reset_form_field(fz_context *ctx, pdf_document *doc, pdf_obj *field)
void pdf_field_reset(fz_context *ctx, pdf_document *doc, pdf_obj *field)
{
- pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME_Kids);
+ pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME(Kids));
reset_form_field(ctx, doc, field);
@@ -183,8 +183,8 @@ void pdf_field_reset(fz_context *ctx, pdf_document *doc, pdf_obj *field)
static void add_field_hierarchy_to_array(fz_context *ctx, pdf_obj *array, pdf_obj *field)
{
- pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME_Kids);
- pdf_obj *exclude = pdf_dict_get(ctx, field, PDF_NAME_Exclude);
+ pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME(Kids));
+ pdf_obj *exclude = pdf_dict_get(ctx, field, PDF_NAME(Exclude));
if (exclude)
return;
@@ -209,7 +209,7 @@ static void add_field_hierarchy_to_array(fz_context *ctx, pdf_obj *array, pdf_ob
*/
static pdf_obj *specified_fields(fz_context *ctx, pdf_document *doc, pdf_obj *fields, int exclude)
{
- pdf_obj *form = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_AcroForm, PDF_NAME_Fields, NULL);
+ pdf_obj *form = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), PDF_NAME(AcroForm), PDF_NAME(Fields), NULL);
int i, n;
pdf_obj *result = pdf_new_array(ctx, doc, 0);
pdf_obj *nil = NULL;
@@ -234,7 +234,7 @@ static pdf_obj *specified_fields(fz_context *ctx, pdf_document *doc, pdf_obj *fi
field = pdf_lookup_field(ctx, form, pdf_to_str_buf(ctx, field));
if (field)
- pdf_dict_put(ctx, field, PDF_NAME_Exclude, nil);
+ pdf_dict_put(ctx, field, PDF_NAME(Exclude), nil);
}
/* Act upon all unmarked fields */
@@ -254,7 +254,7 @@ static pdf_obj *specified_fields(fz_context *ctx, pdf_document *doc, pdf_obj *fi
field = pdf_lookup_field(ctx, form, pdf_to_str_buf(ctx, field));
if (field)
- pdf_dict_del(ctx, field, PDF_NAME_Exclude);
+ pdf_dict_del(ctx, field, PDF_NAME(Exclude));
}
}
else
@@ -311,11 +311,11 @@ static void execute_action(fz_context *ctx, pdf_document *doc, pdf_obj *obj, pdf
{
if (a)
{
- pdf_obj *type = pdf_dict_get(ctx, a, PDF_NAME_S);
+ pdf_obj *type = pdf_dict_get(ctx, a, PDF_NAME(S));
- if (pdf_name_eq(ctx, type, PDF_NAME_JavaScript))
+ if (pdf_name_eq(ctx, type, PDF_NAME(JavaScript)))
{
- pdf_obj *js = pdf_dict_get(ctx, a, PDF_NAME_JS);
+ pdf_obj *js = pdf_dict_get(ctx, a, PDF_NAME(JS));
if (js)
{
char *code = pdf_load_stream_or_string_as_utf8(ctx, js);
@@ -333,15 +333,15 @@ static void execute_action(fz_context *ctx, pdf_document *doc, pdf_obj *obj, pdf
}
}
}
- else if (pdf_name_eq(ctx, type, PDF_NAME_ResetForm))
+ else if (pdf_name_eq(ctx, type, PDF_NAME(ResetForm)))
{
- reset_form(ctx, doc, pdf_dict_get(ctx, a, PDF_NAME_Fields), pdf_to_int(ctx, pdf_dict_get(ctx, a, PDF_NAME_Flags)) & 1);
+ reset_form(ctx, doc, pdf_dict_get(ctx, a, PDF_NAME(Fields)), pdf_to_int(ctx, pdf_dict_get(ctx, a, PDF_NAME(Flags))) & 1);
}
- else if (pdf_name_eq(ctx, type, PDF_NAME_Named))
+ else if (pdf_name_eq(ctx, type, PDF_NAME(Named)))
{
- pdf_obj *name = pdf_dict_get(ctx, a, PDF_NAME_N);
+ pdf_obj *name = pdf_dict_get(ctx, a, PDF_NAME(N));
- if (pdf_name_eq(ctx, name, PDF_NAME_Print))
+ if (pdf_name_eq(ctx, name, PDF_NAME(Print)))
pdf_event_issue_print(ctx, doc);
}
}
@@ -349,7 +349,7 @@ static void execute_action(fz_context *ctx, pdf_document *doc, pdf_obj *obj, pdf
static void execute_action_chain(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
{
- pdf_obj *a = pdf_dict_get(ctx, obj, PDF_NAME_A);
+ pdf_obj *a = pdf_dict_get(ctx, obj, PDF_NAME(A));
pdf_js_event e;
e.target = obj;
@@ -359,7 +359,7 @@ static void execute_action_chain(fz_context *ctx, pdf_document *doc, pdf_obj *ob
while (a)
{
execute_action(ctx, doc, obj, a);
- a = pdf_dict_get(ctx, a, PDF_NAME_Next);
+ a = pdf_dict_get(ctx, a, PDF_NAME(Next));
}
}
@@ -380,7 +380,7 @@ static void execute_additional_action(fz_context *ctx, pdf_document *doc, pdf_ob
static void check_off(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
{
- pdf_dict_put(ctx, obj, PDF_NAME_AS, PDF_NAME_Off);
+ pdf_dict_put(ctx, obj, PDF_NAME(AS), PDF_NAME(Off));
}
static void set_check(fz_context *ctx, pdf_document *doc, pdf_obj *chk, pdf_obj *name)
@@ -393,16 +393,16 @@ static void set_check(fz_context *ctx, pdf_document *doc, pdf_obj *chk, pdf_obj
if (pdf_dict_get(ctx, n, name))
val = name;
else
- val = PDF_NAME_Off;
+ val = PDF_NAME(Off);
- pdf_dict_put(ctx, chk, PDF_NAME_AS, val);
+ pdf_dict_put(ctx, chk, PDF_NAME(AS), val);
}
/* Set the values of all fields in a group defined by a node
* in the hierarchy */
static void set_check_grp(fz_context *ctx, pdf_document *doc, pdf_obj *grp, pdf_obj *val)
{
- pdf_obj *kids = pdf_dict_get(ctx, grp, PDF_NAME_Kids);
+ pdf_obj *kids = pdf_dict_get(ctx, grp, PDF_NAME(Kids));
if (kids == NULL)
{
@@ -463,16 +463,16 @@ static void recalculate(fz_context *ctx, pdf_document *doc)
static void toggle_check_box(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
{
- pdf_obj *as = pdf_dict_get(ctx, obj, PDF_NAME_AS);
+ pdf_obj *as = pdf_dict_get(ctx, obj, PDF_NAME(AS));
int ff = pdf_get_field_flags(ctx, doc, obj);
int radio = ((ff & (Ff_Pushbutton|Ff_Radio)) == Ff_Radio);
char *val = NULL;
- pdf_obj *grp = radio ? pdf_dict_get(ctx, obj, PDF_NAME_Parent) : find_head_of_field_group(ctx, obj);
+ pdf_obj *grp = radio ? pdf_dict_get(ctx, obj, PDF_NAME(Parent)) : find_head_of_field_group(ctx, obj);
if (!grp)
grp = obj;
- if (as && !pdf_name_eq(ctx, as, PDF_NAME_Off))
+ if (as && !pdf_name_eq(ctx, as, PDF_NAME(Off)))
{
/* "as" neither missing nor set to Off. Set it to Off, unless
* this is a non-toggle-off radio button. */
@@ -494,7 +494,7 @@ static void toggle_check_box(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
for (i = 0; i < len; i++)
{
key = pdf_dict_get_key(ctx, n, i);
- if (pdf_is_name(ctx, key) && !pdf_name_eq(ctx, key, PDF_NAME_Off))
+ if (pdf_is_name(ctx, key) && !pdf_name_eq(ctx, key, PDF_NAME(Off)))
break;
}
@@ -506,13 +506,13 @@ static void toggle_check_box(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
{
/* For radio buttons, first turn off all buttons in the group and
* then set the one that was clicked */
- pdf_obj *kids = pdf_dict_get(ctx, grp, PDF_NAME_Kids);
+ pdf_obj *kids = pdf_dict_get(ctx, grp, PDF_NAME(Kids));
len = pdf_array_len(ctx, kids);
for (i = 0; i < len; i++)
check_off(ctx, doc, pdf_array_get(ctx, kids, i));
- pdf_dict_put(ctx, obj, PDF_NAME_AS, key);
+ pdf_dict_put(ctx, obj, PDF_NAME(AS), key);
}
else
{
@@ -530,7 +530,7 @@ static void toggle_check_box(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
if (val && grp)
{
pdf_obj *v = pdf_new_text_string(ctx, doc, val);
- pdf_dict_put_drop(ctx, grp, PDF_NAME_V, v);
+ pdf_dict_put_drop(ctx, grp, PDF_NAME(V), v);
recalculate(ctx, doc);
}
}
@@ -562,7 +562,7 @@ int pdf_pass_event(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_ui_ev
/* Skip hidden annotations. */
if (annot)
{
- int f = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_F));
+ int f = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(F)));
if (f & (PDF_ANNOT_IS_HIDDEN|PDF_ANNOT_IS_NO_VIEW))
annot = NULL;
}
@@ -570,7 +570,7 @@ int pdf_pass_event(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_ui_ev
/* Skip Link annotations. */
if (annot)
{
- if (pdf_name_eq(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Subtype), PDF_NAME_Link))
+ if (pdf_name_eq(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Subtype)), PDF_NAME(Link)))
annot = NULL;
}
@@ -684,12 +684,12 @@ pdf_widget *pdf_create_widget(fz_context *ctx, pdf_document *doc, pdf_page *page
fz_try(ctx)
{
pdf_set_field_type(ctx, doc, annot->obj, type);
- pdf_dict_put_string(ctx, annot->obj, PDF_NAME_T, fieldname, strlen(fieldname));
+ pdf_dict_put_string(ctx, annot->obj, PDF_NAME(T), fieldname, strlen(fieldname));
if (type == PDF_WIDGET_TYPE_SIGNATURE)
{
int sigflags = (old_sigflags | (SigFlag_SignaturesExist|SigFlag_AppendOnly));
- pdf_dict_putl_drop(ctx, pdf_trailer(ctx, doc), pdf_new_int(ctx, doc, sigflags), PDF_NAME_Root, PDF_NAME_AcroForm, PDF_NAME_SigFlags, NULL);
+ pdf_dict_putl_drop(ctx, pdf_trailer(ctx, doc), pdf_new_int(ctx, doc, sigflags), PDF_NAME(Root), PDF_NAME(AcroForm), PDF_NAME(SigFlags), NULL);
}
/*
@@ -700,7 +700,7 @@ pdf_widget *pdf_create_widget(fz_context *ctx, pdf_document *doc, pdf_page *page
if (!form)
{
form = pdf_new_array(ctx, doc, 1);
- pdf_dict_putl_drop(ctx, pdf_trailer(ctx, doc), form, PDF_NAME_Root, PDF_NAME_AcroForm, PDF_NAME_Fields, NULL);
+ pdf_dict_putl_drop(ctx, pdf_trailer(ctx, doc), form, PDF_NAME(Root), PDF_NAME(AcroForm), PDF_NAME(Fields), NULL);
}
pdf_array_push(ctx, form, annot->obj); /* Cleanup relies on this statement being last */
@@ -712,7 +712,7 @@ pdf_widget *pdf_create_widget(fz_context *ctx, pdf_document *doc, pdf_page *page
/* An empty Fields array may have been created, but that is harmless */
if (type == PDF_WIDGET_TYPE_SIGNATURE)
- pdf_dict_putl_drop(ctx, pdf_trailer(ctx, doc), pdf_new_int(ctx, doc, old_sigflags), PDF_NAME_Root, PDF_NAME_AcroForm, PDF_NAME_SigFlags, NULL);
+ pdf_dict_putl_drop(ctx, pdf_trailer(ctx, doc), pdf_new_int(ctx, doc, old_sigflags), PDF_NAME(Root), PDF_NAME(AcroForm), PDF_NAME(SigFlags), NULL);
fz_rethrow(ctx);
}
@@ -756,7 +756,7 @@ static int set_text_field_value(fz_context *ctx, pdf_document *doc, pdf_obj *fie
static void update_checkbox_selector(fz_context *ctx, pdf_document *doc, pdf_obj *field, const char *val)
{
- pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME_Kids);
+ pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME(Kids));
if (kids)
{
@@ -773,8 +773,8 @@ static void update_checkbox_selector(fz_context *ctx, pdf_document *doc, pdf_obj
if (pdf_dict_gets(ctx, n, val))
oval = pdf_new_name(ctx, doc, val);
else
- oval = PDF_NAME_Off;
- pdf_dict_put_drop(ctx, field, PDF_NAME_AS, oval);
+ oval = PDF_NAME(Off);
+ pdf_dict_put_drop(ctx, field, PDF_NAME(AS), oval);
}
}
@@ -814,7 +814,7 @@ int pdf_field_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, cons
char *pdf_field_border_style(fz_context *ctx, pdf_document *doc, pdf_obj *field)
{
- const char *bs = pdf_to_name(ctx, pdf_dict_getl(ctx, field, PDF_NAME_BS, PDF_NAME_S, NULL));
+ const char *bs = pdf_to_name(ctx, pdf_dict_getl(ctx, field, PDF_NAME(BS), PDF_NAME(S), NULL));
switch (*bs)
{
case 'S': return "Solid";
@@ -831,19 +831,19 @@ void pdf_field_set_border_style(fz_context *ctx, pdf_document *doc, pdf_obj *fie
pdf_obj *val;
if (!strcmp(text, "Solid"))
- val = PDF_NAME_S;
+ val = PDF_NAME(S);
else if (!strcmp(text, "Dashed"))
- val = PDF_NAME_D;
+ val = PDF_NAME(D);
else if (!strcmp(text, "Beveled"))
- val = PDF_NAME_B;
+ val = PDF_NAME(B);
else if (!strcmp(text, "Inset"))
- val = PDF_NAME_I;
+ val = PDF_NAME(I);
else if (!strcmp(text, "Underline"))
- val = PDF_NAME_U;
+ val = PDF_NAME(U);
else
return;
- pdf_dict_putl_drop(ctx, field, val, PDF_NAME_BS, PDF_NAME_S, NULL);
+ pdf_dict_putl_drop(ctx, field, val, PDF_NAME(BS), PDF_NAME(S), NULL);
pdf_field_mark_dirty(ctx, doc, field);
}
@@ -852,7 +852,7 @@ void pdf_field_set_button_caption(fz_context *ctx, pdf_document *doc, pdf_obj *f
if (pdf_field_type(ctx, doc, field) == PDF_WIDGET_TYPE_PUSHBUTTON)
{
pdf_obj *val = pdf_new_text_string(ctx, doc, text);
- pdf_dict_putl_drop(ctx, field, val, PDF_NAME_MK, PDF_NAME_CA, NULL);
+ pdf_dict_putl_drop(ctx, field, val, PDF_NAME(MK), PDF_NAME(CA), NULL);
pdf_field_mark_dirty(ctx, doc, field);
}
}
@@ -865,10 +865,10 @@ int pdf_field_display(fz_context *ctx, pdf_document *doc, pdf_obj *field)
/* Base response on first of children. Not ideal,
* but not clear how to handle children with
* differing values */
- while ((kids = pdf_dict_get(ctx, field, PDF_NAME_Kids)) != NULL)
+ while ((kids = pdf_dict_get(ctx, field, PDF_NAME(Kids))) != NULL)
field = pdf_array_get(ctx, kids, 0);
- f = pdf_to_int(ctx, pdf_dict_get(ctx, field, PDF_NAME_F));
+ f = pdf_to_int(ctx, pdf_dict_get(ctx, field, PDF_NAME(F)));
if (f & PDF_ANNOT_IS_HIDDEN)
{
@@ -897,8 +897,8 @@ int pdf_field_display(fz_context *ctx, pdf_document *doc, pdf_obj *field)
static char *get_field_name(fz_context *ctx, pdf_document *doc, pdf_obj *field, int spare)
{
char *res = NULL;
- pdf_obj *parent = pdf_dict_get(ctx, field, PDF_NAME_Parent);
- char *lname = pdf_to_str_buf(ctx, pdf_dict_get(ctx, field, PDF_NAME_T));
+ pdf_obj *parent = pdf_dict_get(ctx, field, PDF_NAME(Parent));
+ char *lname = pdf_to_str_buf(ctx, pdf_dict_get(ctx, field, PDF_NAME(T)));
int llen = (int)strlen(lname);
/*
@@ -936,12 +936,12 @@ char *pdf_field_name(fz_context *ctx, pdf_document *doc, pdf_obj *field)
void pdf_field_set_display(fz_context *ctx, pdf_document *doc, pdf_obj *field, int d)
{
- pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME_Kids);
+ pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME(Kids));
if (!kids)
{
int mask = (PDF_ANNOT_IS_HIDDEN|PDF_ANNOT_IS_PRINT|PDF_ANNOT_IS_NO_VIEW);
- int f = pdf_to_int(ctx, pdf_dict_get(ctx, field, PDF_NAME_F)) & ~mask;
+ int f = pdf_to_int(ctx, pdf_dict_get(ctx, field, PDF_NAME(F))) & ~mask;
pdf_obj *fo;
switch (d)
@@ -960,7 +960,7 @@ void pdf_field_set_display(fz_context *ctx, pdf_document *doc, pdf_obj *field, i
}
fo = pdf_new_int(ctx, doc, f);
- pdf_dict_put_drop(ctx, field, PDF_NAME_F, fo);
+ pdf_dict_put_drop(ctx, field, PDF_NAME(F), fo);
}
else
{
@@ -976,7 +976,7 @@ void pdf_field_set_fill_color(fz_context *ctx, pdf_document *doc, pdf_obj *field
/* col == NULL mean transparent, but we can simply pass it on as with
* non-NULL values because pdf_dict_putp interprets a NULL value as
* delete */
- pdf_dict_putl(ctx, field, col, PDF_NAME_MK, PDF_NAME_BG, NULL);
+ pdf_dict_putl(ctx, field, col, PDF_NAME(MK), PDF_NAME(BG), NULL);
pdf_field_mark_dirty(ctx, doc, field);
}
@@ -984,7 +984,7 @@ void pdf_field_set_text_color(fz_context *ctx, pdf_document *doc, pdf_obj *field
{
pdf_da_info di;
fz_buffer *fzbuf = NULL;
- char *da = pdf_to_str_buf(ctx, pdf_get_inheritable(ctx, doc, field, PDF_NAME_DA));
+ char *da = pdf_to_str_buf(ctx, pdf_get_inheritable(ctx, doc, field, PDF_NAME(DA)));
unsigned char *buf;
int ilen;
size_t len;
@@ -1009,7 +1009,7 @@ void pdf_field_set_text_color(fz_context *ctx, pdf_document *doc, pdf_obj *field
pdf_fzbuf_print_da(ctx, fzbuf, &di);
len = fz_buffer_storage(ctx, fzbuf, &buf);
daobj = pdf_new_string(ctx, doc, (char *)buf, len);
- pdf_dict_put_drop(ctx, field, PDF_NAME_DA, daobj);
+ pdf_dict_put_drop(ctx, field, PDF_NAME(DA), daobj);
pdf_field_mark_dirty(ctx, doc, field);
}
fz_always(ctx)
@@ -1050,7 +1050,7 @@ int pdf_text_widget_max_len(fz_context *ctx, pdf_document *doc, pdf_widget *tw)
{
pdf_annot *annot = (pdf_annot *)tw;
- return pdf_to_int(ctx, pdf_get_inheritable(ctx, doc, annot->obj, PDF_NAME_MaxLen));
+ return pdf_to_int(ctx, pdf_get_inheritable(ctx, doc, annot->obj, PDF_NAME(MaxLen)));
}
int pdf_text_widget_content_type(fz_context *ctx, pdf_document *doc, pdf_widget *tw)
@@ -1062,7 +1062,7 @@ int pdf_text_widget_content_type(fz_context *ctx, pdf_document *doc, pdf_widget
fz_var(code);
fz_try(ctx)
{
- code = pdf_get_string_or_stream(ctx, doc, pdf_dict_getl(ctx, annot->obj, PDF_NAME_AA, PDF_NAME_F, PDF_NAME_JS, NULL));
+ code = pdf_get_string_or_stream(ctx, doc, pdf_dict_getl(ctx, annot->obj, PDF_NAME(AA), PDF_NAME(F), PDF_NAME(JS), NULL));
if (code)
{
if (strstr(code, "AFNumber_Format"))
@@ -1089,7 +1089,7 @@ int pdf_text_widget_content_type(fz_context *ctx, pdf_document *doc, pdf_widget
static int run_keystroke(fz_context *ctx, pdf_document *doc, pdf_obj *field, char **text)
{
- pdf_obj *k = pdf_dict_getl(ctx, field, PDF_NAME_AA, PDF_NAME_K, NULL);
+ pdf_obj *k = pdf_dict_getl(ctx, field, PDF_NAME(AA), PDF_NAME(K), NULL);
if (k && doc->js)
{
@@ -1138,7 +1138,7 @@ int pdf_choice_widget_options(fz_context *ctx, pdf_document *doc, pdf_widget *tw
if (!annot)
return 0;
- optarr = pdf_dict_get(ctx, annot->obj, PDF_NAME_Opt);
+ optarr = pdf_dict_get(ctx, annot->obj, PDF_NAME(Opt));
n = pdf_array_len(ctx, optarr);
if (opts)
@@ -1184,7 +1184,7 @@ int pdf_choice_widget_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw,
if (!annot)
return 0;
- optarr = pdf_dict_get(ctx, annot->obj, PDF_NAME_V);
+ optarr = pdf_dict_get(ctx, annot->obj, PDF_NAME(V));
if (pdf_is_string(ctx, optarr))
{
@@ -1236,16 +1236,16 @@ void pdf_choice_widget_set_value(fz_context *ctx, pdf_document *doc, pdf_widget
pdf_array_push_drop(ctx, optarr, opt);
}
- pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_V, optarr);
+ pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(V), optarr);
}
else
{
opt = pdf_new_text_string(ctx, doc, opts[0]);
- pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_V, opt);
+ pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(V), opt);
}
/* FIXME: when n > 1, we should be regenerating the indexes */
- pdf_dict_del(ctx, annot->obj, PDF_NAME_I);
+ pdf_dict_del(ctx, annot->obj, PDF_NAME(I));
pdf_field_mark_dirty(ctx, doc, annot->obj);
if (pdf_field_dirties_document(ctx, doc, annot->obj))
@@ -1261,7 +1261,7 @@ void pdf_choice_widget_set_value(fz_context *ctx, pdf_document *doc, pdf_widget
int pdf_signature_widget_byte_range(fz_context *ctx, pdf_document *doc, pdf_widget *widget, fz_range *byte_range)
{
pdf_annot *annot = (pdf_annot *)widget;
- pdf_obj *br = pdf_dict_getl(ctx, annot->obj, PDF_NAME_V, PDF_NAME_ByteRange, NULL);
+ pdf_obj *br = pdf_dict_getl(ctx, annot->obj, PDF_NAME(V), PDF_NAME(ByteRange), NULL);
int i, n = pdf_array_len(ctx, br)/2;
if (byte_range)
@@ -1309,7 +1309,7 @@ fz_stream *pdf_signature_widget_hash_bytes(fz_context *ctx, pdf_document *doc, p
int pdf_signature_widget_contents(fz_context *ctx, pdf_document *doc, pdf_widget *widget, char **contents)
{
pdf_annot *annot = (pdf_annot *)widget;
- pdf_obj *c = pdf_dict_getl(ctx, annot->obj, PDF_NAME_V, PDF_NAME_Contents, NULL);
+ pdf_obj *c = pdf_dict_getl(ctx, annot->obj, PDF_NAME(V), PDF_NAME(Contents), NULL);
if (contents)
*contents = pdf_to_str_buf(ctx, c);
return pdf_to_str_len(ctx, c);
@@ -1328,7 +1328,7 @@ void pdf_signature_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field,
vnum = pdf_create_object(ctx, doc);
indv = pdf_new_indirect(ctx, doc, vnum, 0);
- pdf_dict_put_drop(ctx, field, PDF_NAME_V, indv);
+ pdf_dict_put_drop(ctx, field, PDF_NAME(V), indv);
fz_var(v);
fz_try(ctx)
@@ -1346,13 +1346,13 @@ void pdf_signature_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field,
}
byte_range = pdf_new_array(ctx, doc, 4);
- pdf_dict_put_drop(ctx, v, PDF_NAME_ByteRange, byte_range);
+ pdf_dict_put_drop(ctx, v, PDF_NAME(ByteRange), byte_range);
contents = pdf_new_string(ctx, doc, buf, sizeof(buf));
- pdf_dict_put_drop(ctx, v, PDF_NAME_Contents, contents);
+ pdf_dict_put_drop(ctx, v, PDF_NAME(Contents), contents);
- pdf_dict_put(ctx, v, PDF_NAME_Filter, PDF_NAME_Adobe_PPKLite);
- pdf_dict_put(ctx, v, PDF_NAME_SubFilter, PDF_NAME_adbe_pkcs7_detached);
+ pdf_dict_put(ctx, v, PDF_NAME(Filter), PDF_NAME(Adobe_PPKLite));
+ pdf_dict_put(ctx, v, PDF_NAME(SubFilter), PDF_NAME(adbe_pkcs7_detached));
/* Record details within the document structure so that contents
* and byte_range can be updated with their correct values at
diff --git a/source/pdf/pdf-function.c b/source/pdf/pdf-function.c
index 9577dccc..76173196 100644
--- a/source/pdf/pdf-function.c
+++ b/source/pdf/pdf-function.c
@@ -949,7 +949,7 @@ load_sample_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
func->u.sa.samples = NULL;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Size);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Size));
if (pdf_array_len(ctx, obj) < func->m)
fz_throw(ctx, FZ_ERROR_SYNTAX, "too few sample function dimension sizes");
if (pdf_array_len(ctx, obj) > func->m)
@@ -964,7 +964,7 @@ load_sample_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
}
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_BitsPerSample);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(BitsPerSample));
func->u.sa.bps = bps = pdf_to_int(ctx, obj);
for (i = 0; i < func->m; i++)
@@ -972,7 +972,7 @@ load_sample_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
func->u.sa.encode[i][0] = 0;
func->u.sa.encode[i][1] = func->u.sa.size[i] - 1;
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Encode);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Encode));
if (pdf_is_array(ctx, obj))
{
int ranges = fz_mini(func->m, pdf_array_len(ctx, obj) / 2);
@@ -992,7 +992,7 @@ load_sample_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
func->u.sa.decode[i][1] = func->range[i][1];
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Decode);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Decode));
if (pdf_is_array(ctx, obj))
{
int ranges = fz_mini(func->n, pdf_array_len(ctx, obj) / 2);
@@ -1154,7 +1154,7 @@ load_exponential_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
fz_warn(ctx, "exponential functions have at most one input");
func->m = 1;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_N);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(N));
func->u.e.n = pdf_to_real(ctx, obj);
/* See exponential functions (PDF 1.7 section 3.9.2) */
@@ -1180,7 +1180,7 @@ load_exponential_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
func->u.e.c1[i] = 1;
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_C0);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(C0));
if (pdf_is_array(ctx, obj))
{
int ranges = fz_mini(func->n, pdf_array_len(ctx, obj));
@@ -1191,7 +1191,7 @@ load_exponential_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
func->u.e.c0[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i));
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_C1);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(C1));
if (pdf_is_array(ctx, obj))
{
int ranges = fz_mini(func->n, pdf_array_len(ctx, obj));
@@ -1245,7 +1245,7 @@ load_stitching_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
fz_warn(ctx, "stitching functions have at most one input");
func->m = 1;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Functions);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Functions));
if (!pdf_is_array(ctx, obj))
fz_throw(ctx, FZ_ERROR_SYNTAX, "stitching function has no input functions");
@@ -1283,7 +1283,7 @@ load_stitching_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
fz_rethrow(ctx);
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Bounds);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Bounds));
if (!pdf_is_array(ctx, obj))
fz_throw(ctx, FZ_ERROR_SYNTAX, "stitching function has no bounds");
{
@@ -1311,7 +1311,7 @@ load_stitching_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
func->u.st.encode[i * 2 + 1] = 0;
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Encode);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Encode));
if (pdf_is_array(ctx, obj))
{
int ranges = fz_mini(k, pdf_array_len(ctx, obj) / 2);
@@ -1458,11 +1458,11 @@ pdf_load_function(fz_context *ctx, pdf_obj *dict, int in, int out)
FZ_INIT_STORABLE(func, 1, pdf_drop_function_imp);
func->size = sizeof(*func);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_FunctionType);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(FunctionType));
func->type = pdf_to_int(ctx, obj);
/* required for all */
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Domain);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Domain));
func->m = fz_clampi(pdf_array_len(ctx, obj) / 2, 1, MAX_M);
for (i = 0; i < func->m; i++)
{
@@ -1471,7 +1471,7 @@ pdf_load_function(fz_context *ctx, pdf_obj *dict, int in, int out)
}
/* required for type0 and type4, optional otherwise */
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Range);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Range));
if (pdf_is_array(ctx, obj))
{
func->has_range = 1;
diff --git a/source/pdf/pdf-image.c b/source/pdf/pdf-image.c
index 02e7ddf7..be708e34 100644
--- a/source/pdf/pdf-image.c
+++ b/source/pdf/pdf-image.c
@@ -55,13 +55,13 @@ pdf_load_image_imp(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *di
if (pdf_is_jpx_image(ctx, dict))
return pdf_load_jpx_imp(ctx, doc, rdb, dict, cstm, forcemask);
- w = pdf_to_int(ctx, pdf_dict_geta(ctx, dict, PDF_NAME_Width, PDF_NAME_W));
- h = pdf_to_int(ctx, pdf_dict_geta(ctx, dict, PDF_NAME_Height, PDF_NAME_H));
- bpc = pdf_to_int(ctx, pdf_dict_geta(ctx, dict, PDF_NAME_BitsPerComponent, PDF_NAME_BPC));
+ w = pdf_to_int(ctx, pdf_dict_geta(ctx, dict, PDF_NAME(Width), PDF_NAME(W)));
+ h = pdf_to_int(ctx, pdf_dict_geta(ctx, dict, PDF_NAME(Height), PDF_NAME(H)));
+ bpc = pdf_to_int(ctx, pdf_dict_geta(ctx, dict, PDF_NAME(BitsPerComponent), PDF_NAME(BPC)));
if (bpc == 0)
bpc = 8;
- imagemask = pdf_to_bool(ctx, pdf_dict_geta(ctx, dict, PDF_NAME_ImageMask, PDF_NAME_IM));
- interpolate = pdf_to_bool(ctx, pdf_dict_geta(ctx, dict, PDF_NAME_Interpolate, PDF_NAME_I));
+ imagemask = pdf_to_bool(ctx, pdf_dict_geta(ctx, dict, PDF_NAME(ImageMask), PDF_NAME(IM)));
+ interpolate = pdf_to_bool(ctx, pdf_dict_geta(ctx, dict, PDF_NAME(Interpolate), PDF_NAME(I)));
indexed = 0;
use_colorkey = 0;
@@ -88,13 +88,13 @@ pdf_load_image_imp(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *di
fz_try(ctx)
{
- obj = pdf_dict_geta(ctx, dict, PDF_NAME_ColorSpace, PDF_NAME_CS);
+ obj = pdf_dict_geta(ctx, dict, PDF_NAME(ColorSpace), PDF_NAME(CS));
if (obj && !imagemask && !forcemask)
{
/* colorspace resource lookup is only done for inline images */
if (pdf_is_name(ctx, obj))
{
- res = pdf_dict_get(ctx, pdf_dict_get(ctx, rdb, PDF_NAME_ColorSpace), obj);
+ res = pdf_dict_get(ctx, pdf_dict_get(ctx, rdb, PDF_NAME(ColorSpace)), obj);
if (res)
obj = res;
}
@@ -109,7 +109,7 @@ pdf_load_image_imp(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *di
n = 1;
}
- obj = pdf_dict_geta(ctx, dict, PDF_NAME_Decode, PDF_NAME_D);
+ obj = pdf_dict_geta(ctx, dict, PDF_NAME(Decode), PDF_NAME(D));
if (obj)
{
for (i = 0; i < n * 2; i++)
@@ -131,7 +131,7 @@ pdf_load_image_imp(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *di
decode[i] = i & 1 ? maxval : 0;
}
- obj = pdf_dict_geta(ctx, dict, PDF_NAME_SMask, PDF_NAME_Mask);
+ obj = pdf_dict_geta(ctx, dict, PDF_NAME(SMask), PDF_NAME(Mask));
if (pdf_is_dict(ctx, obj))
{
/* Not allowed for inline images or soft masks */
@@ -142,7 +142,7 @@ pdf_load_image_imp(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *di
else
{
mask = pdf_load_image_imp(ctx, doc, rdb, obj, NULL, 1);
- obj = pdf_dict_get(ctx, obj, PDF_NAME_Matte);
+ obj = pdf_dict_get(ctx, obj, PDF_NAME(Matte));
if (pdf_is_array(ctx, obj))
{
use_colorkey = 1;
@@ -207,12 +207,12 @@ pdf_is_jpx_image(fz_context *ctx, pdf_obj *dict)
pdf_obj *filter;
int i, n;
- filter = pdf_dict_get(ctx, dict, PDF_NAME_Filter);
- if (pdf_name_eq(ctx, filter, PDF_NAME_JPXDecode))
+ filter = pdf_dict_get(ctx, dict, PDF_NAME(Filter));
+ if (pdf_name_eq(ctx, filter, PDF_NAME(JPXDecode)))
return 1;
n = pdf_array_len(ctx, filter);
for (i = 0; i < n; i++)
- if (pdf_name_eq(ctx, pdf_array_get(ctx, filter, i), PDF_NAME_JPXDecode))
+ if (pdf_name_eq(ctx, pdf_array_get(ctx, filter, i), PDF_NAME(JPXDecode)))
return 1;
return 0;
}
@@ -240,14 +240,14 @@ pdf_load_jpx(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int forcemask)
unsigned char *data;
size_t len;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_ColorSpace);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(ColorSpace));
if (obj)
colorspace = pdf_load_colorspace(ctx, obj);
len = fz_buffer_storage(ctx, buf, &data);
pix = fz_load_jpx(ctx, data, len, colorspace);
- obj = pdf_dict_geta(ctx, dict, PDF_NAME_SMask, PDF_NAME_Mask);
+ obj = pdf_dict_geta(ctx, dict, PDF_NAME(SMask), PDF_NAME(Mask));
if (pdf_is_dict(ctx, obj))
{
if (forcemask)
@@ -256,7 +256,7 @@ pdf_load_jpx(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int forcemask)
mask = pdf_load_image_imp(ctx, doc, NULL, obj, NULL, 1);
}
- obj = pdf_dict_geta(ctx, dict, PDF_NAME_Decode, PDF_NAME_D);
+ obj = pdf_dict_geta(ctx, dict, PDF_NAME(Decode), PDF_NAME(D));
if (obj && !fz_colorspace_is_indexed(ctx, colorspace))
{
float decode[FZ_MAX_COLORS * 2];
@@ -326,9 +326,9 @@ pdf_add_image(fz_context *ctx, pdf_document *doc, fz_image *image, int mask)
imobj = pdf_add_new_dict(ctx, doc, 3);
fz_try(ctx)
{
- dp = pdf_dict_put_dict(ctx, imobj, PDF_NAME_DecodeParms, 3);
- pdf_dict_put(ctx, imobj, PDF_NAME_Type, PDF_NAME_XObject);
- pdf_dict_put(ctx, imobj, PDF_NAME_Subtype, PDF_NAME_Image);
+ dp = pdf_dict_put_dict(ctx, imobj, PDF_NAME(DecodeParms), 3);
+ pdf_dict_put(ctx, imobj, PDF_NAME(Type), PDF_NAME(XObject));
+ pdf_dict_put(ctx, imobj, PDF_NAME(Subtype), PDF_NAME(Image));
if (cbuffer)
{
@@ -339,65 +339,65 @@ pdf_add_image(fz_context *ctx, pdf_document *doc, fz_image *image, int mask)
goto raw_or_unknown_compression;
case FZ_IMAGE_JPEG:
if (cp->u.jpeg.color_transform != -1)
- pdf_dict_put_int(ctx, dp, PDF_NAME_ColorTransform, cp->u.jpeg.color_transform);
- pdf_dict_put(ctx, imobj, PDF_NAME_Filter, PDF_NAME_DCTDecode);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(ColorTransform), cp->u.jpeg.color_transform);
+ pdf_dict_put(ctx, imobj, PDF_NAME(Filter), PDF_NAME(DCTDecode));
break;
case FZ_IMAGE_JPX:
if (cp->u.jpx.smask_in_data)
- pdf_dict_put_int(ctx, dp, PDF_NAME_SMaskInData, cp->u.jpx.smask_in_data);
- pdf_dict_put(ctx, imobj, PDF_NAME_Filter, PDF_NAME_JPXDecode);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(SMaskInData), cp->u.jpx.smask_in_data);
+ pdf_dict_put(ctx, imobj, PDF_NAME(Filter), PDF_NAME(JPXDecode));
break;
case FZ_IMAGE_FAX:
if (cp->u.fax.columns)
- pdf_dict_put_int(ctx, dp, PDF_NAME_Columns, cp->u.fax.columns);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(Columns), cp->u.fax.columns);
if (cp->u.fax.rows)
- pdf_dict_put_int(ctx, dp, PDF_NAME_Rows, cp->u.fax.rows);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(Rows), cp->u.fax.rows);
if (cp->u.fax.k)
- pdf_dict_put_int(ctx, dp, PDF_NAME_K, cp->u.fax.k);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(K), cp->u.fax.k);
if (cp->u.fax.end_of_line)
- pdf_dict_put_int(ctx, dp, PDF_NAME_EndOfLine, cp->u.fax.end_of_line);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(EndOfLine), cp->u.fax.end_of_line);
if (cp->u.fax.encoded_byte_align)
- pdf_dict_put_int(ctx, dp, PDF_NAME_EncodedByteAlign, cp->u.fax.encoded_byte_align);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(EncodedByteAlign), cp->u.fax.encoded_byte_align);
if (cp->u.fax.end_of_block)
- pdf_dict_put_int(ctx, dp, PDF_NAME_EndOfBlock, cp->u.fax.end_of_block);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(EndOfBlock), cp->u.fax.end_of_block);
if (cp->u.fax.black_is_1)
- pdf_dict_put_int(ctx, dp, PDF_NAME_BlackIs1, cp->u.fax.black_is_1);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(BlackIs1), cp->u.fax.black_is_1);
if (cp->u.fax.damaged_rows_before_error)
- pdf_dict_put_int(ctx, dp, PDF_NAME_DamagedRowsBeforeError, cp->u.fax.damaged_rows_before_error);
- pdf_dict_put(ctx, imobj, PDF_NAME_Filter, PDF_NAME_CCITTFaxDecode);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(DamagedRowsBeforeError), cp->u.fax.damaged_rows_before_error);
+ pdf_dict_put(ctx, imobj, PDF_NAME(Filter), PDF_NAME(CCITTFaxDecode));
break;
case FZ_IMAGE_FLATE:
if (cp->u.flate.columns)
- pdf_dict_put_int(ctx, dp, PDF_NAME_Columns, cp->u.flate.columns);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(Columns), cp->u.flate.columns);
if (cp->u.flate.colors)
- pdf_dict_put_int(ctx, dp, PDF_NAME_Colors, cp->u.flate.colors);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(Colors), cp->u.flate.colors);
if (cp->u.flate.predictor)
- pdf_dict_put_int(ctx, dp, PDF_NAME_Predictor, cp->u.flate.predictor);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(Predictor), cp->u.flate.predictor);
if (cp->u.flate.bpc)
- pdf_dict_put_int(ctx, dp, PDF_NAME_BitsPerComponent, cp->u.flate.bpc);
- pdf_dict_put(ctx, imobj, PDF_NAME_Filter, PDF_NAME_FlateDecode);
- pdf_dict_put_int(ctx, imobj, PDF_NAME_BitsPerComponent, image->bpc);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(BitsPerComponent), cp->u.flate.bpc);
+ pdf_dict_put(ctx, imobj, PDF_NAME(Filter), PDF_NAME(FlateDecode));
+ pdf_dict_put_int(ctx, imobj, PDF_NAME(BitsPerComponent), image->bpc);
break;
case FZ_IMAGE_LZW:
if (cp->u.lzw.columns)
- pdf_dict_put_int(ctx, dp, PDF_NAME_Columns, cp->u.lzw.columns);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(Columns), cp->u.lzw.columns);
if (cp->u.lzw.colors)
- pdf_dict_put_int(ctx, dp, PDF_NAME_Colors, cp->u.lzw.colors);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(Colors), cp->u.lzw.colors);
if (cp->u.lzw.predictor)
- pdf_dict_put_int(ctx, dp, PDF_NAME_Predictor, cp->u.lzw.predictor);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(Predictor), cp->u.lzw.predictor);
if (cp->u.lzw.early_change)
- pdf_dict_put_int(ctx, dp, PDF_NAME_EarlyChange, cp->u.lzw.early_change);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(EarlyChange), cp->u.lzw.early_change);
if (cp->u.lzw.bpc)
- pdf_dict_put_int(ctx, dp, PDF_NAME_BitsPerComponent, cp->u.lzw.bpc);
- pdf_dict_put(ctx, imobj, PDF_NAME_Filter, PDF_NAME_LZWDecode);
+ pdf_dict_put_int(ctx, dp, PDF_NAME(BitsPerComponent), cp->u.lzw.bpc);
+ pdf_dict_put(ctx, imobj, PDF_NAME(Filter), PDF_NAME(LZWDecode));
break;
case FZ_IMAGE_RLD:
- pdf_dict_put(ctx, imobj, PDF_NAME_Filter, PDF_NAME_RunLengthDecode);
+ pdf_dict_put(ctx, imobj, PDF_NAME(Filter), PDF_NAME(RunLengthDecode));
break;
}
if (!pdf_dict_len(ctx, dp))
- pdf_dict_del(ctx, imobj, PDF_NAME_DecodeParms);
+ pdf_dict_del(ctx, imobj, PDF_NAME(DecodeParms));
buffer = fz_keep_buffer(ctx, cbuffer->buffer);
}
@@ -454,18 +454,18 @@ raw_or_unknown_compression:
}
}
- pdf_dict_put_int(ctx, imobj, PDF_NAME_Width, pixmap ? pixmap->w : image->w);
- pdf_dict_put_int(ctx, imobj, PDF_NAME_Height, pixmap ? pixmap->h : image->h);
+ pdf_dict_put_int(ctx, imobj, PDF_NAME(Width), pixmap ? pixmap->w : image->w);
+ pdf_dict_put_int(ctx, imobj, PDF_NAME(Height), pixmap ? pixmap->h : image->h);
if (mask)
{
- pdf_dict_put_bool(ctx, imobj, PDF_NAME_ImageMask, 1);
+ pdf_dict_put_bool(ctx, imobj, PDF_NAME(ImageMask), 1);
}
else
{
fz_colorspace *cs;
- pdf_dict_put_int(ctx, imobj, PDF_NAME_BitsPerComponent, image->bpc);
+ pdf_dict_put_int(ctx, imobj, PDF_NAME(BitsPerComponent), image->bpc);
cs = pixmap ? pixmap->colorspace : image->colorspace;
switch (fz_colorspace_type(ctx, cs))
@@ -482,19 +482,19 @@ raw_or_unknown_compression:
basecs = fz_colorspace_base(ctx, cs);
basen = fz_colorspace_n(ctx, basecs);
- arr = pdf_dict_put_array(ctx, imobj, PDF_NAME_ColorSpace, 4);
+ arr = pdf_dict_put_array(ctx, imobj, PDF_NAME(ColorSpace), 4);
- pdf_array_push(ctx, arr, PDF_NAME_Indexed);
+ pdf_array_push(ctx, arr, PDF_NAME(Indexed));
switch (fz_colorspace_type(ctx, basecs))
{
case FZ_COLORSPACE_GRAY:
- pdf_array_push(ctx, arr, PDF_NAME_DeviceGray);
+ pdf_array_push(ctx, arr, PDF_NAME(DeviceGray));
break;
case FZ_COLORSPACE_RGB:
- pdf_array_push(ctx, arr, PDF_NAME_DeviceRGB);
+ pdf_array_push(ctx, arr, PDF_NAME(DeviceRGB));
break;
case FZ_COLORSPACE_CMYK:
- pdf_array_push(ctx, arr, PDF_NAME_DeviceCMYK);
+ pdf_array_push(ctx, arr, PDF_NAME(DeviceCMYK));
break;
default:
// TODO: convert to RGB!
@@ -507,13 +507,13 @@ raw_or_unknown_compression:
}
break;
case FZ_COLORSPACE_GRAY:
- pdf_dict_put(ctx, imobj, PDF_NAME_ColorSpace, PDF_NAME_DeviceGray);
+ pdf_dict_put(ctx, imobj, PDF_NAME(ColorSpace), PDF_NAME(DeviceGray));
break;
case FZ_COLORSPACE_RGB:
- pdf_dict_put(ctx, imobj, PDF_NAME_ColorSpace, PDF_NAME_DeviceRGB);
+ pdf_dict_put(ctx, imobj, PDF_NAME(ColorSpace), PDF_NAME(DeviceRGB));
break;
case FZ_COLORSPACE_CMYK:
- pdf_dict_put(ctx, imobj, PDF_NAME_ColorSpace, PDF_NAME_DeviceCMYK);
+ pdf_dict_put(ctx, imobj, PDF_NAME(ColorSpace), PDF_NAME(DeviceCMYK));
break;
default:
// TODO: convert to RGB!
@@ -524,7 +524,7 @@ raw_or_unknown_compression:
if (image->mask)
{
- pdf_dict_put_drop(ctx, imobj, PDF_NAME_SMask, pdf_add_image(ctx, doc, image->mask, 0));
+ pdf_dict_put_drop(ctx, imobj, PDF_NAME(SMask), pdf_add_image(ctx, doc, image->mask, 0));
}
pdf_update_stream(ctx, doc, imobj, buffer, 1);
diff --git a/source/pdf/pdf-interpret.c b/source/pdf/pdf-interpret.c
index c6833878..8f8d051f 100644
--- a/source/pdf/pdf-interpret.c
+++ b/source/pdf/pdf-interpret.c
@@ -155,23 +155,23 @@ pdf_process_extgstate(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, pdf_ob
{
pdf_obj *obj;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_LW);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(LW));
if (pdf_is_number(ctx, obj) && proc->op_w)
proc->op_w(ctx, proc, pdf_to_real(ctx, obj));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_LC);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(LC));
if (pdf_is_int(ctx, obj) && proc->op_J)
proc->op_J(ctx, proc, fz_clampi(pdf_to_int(ctx, obj), 0, 2));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_LJ);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(LJ));
if (pdf_is_int(ctx, obj) && proc->op_j)
proc->op_j(ctx, proc, fz_clampi(pdf_to_int(ctx, obj), 0, 2));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_ML);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(ML));
if (pdf_is_number(ctx, obj) && proc->op_M)
proc->op_M(ctx, proc, pdf_to_real(ctx, obj));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_D);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(D));
if (pdf_is_array(ctx, obj) && proc->op_d)
{
pdf_obj *dash_array = pdf_array_get(ctx, obj, 0);
@@ -179,15 +179,15 @@ pdf_process_extgstate(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, pdf_ob
proc->op_d(ctx, proc, dash_array, pdf_to_real(ctx, dash_phase));
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_RI);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(RI));
if (pdf_is_name(ctx, obj) && proc->op_ri)
proc->op_ri(ctx, proc, pdf_to_name(ctx, obj));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_FL);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(FL));
if (pdf_is_number(ctx, obj) && proc->op_i)
proc->op_i(ctx, proc, pdf_to_real(ctx, obj));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Font);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Font));
if (pdf_is_array(ctx, obj) && proc->op_Tf)
{
pdf_obj *font_ref = pdf_array_get(ctx, obj, 0);
@@ -203,53 +203,53 @@ pdf_process_extgstate(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, pdf_ob
/* overprint and color management */
- obj = pdf_dict_get(ctx, dict, PDF_NAME_OP);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(OP));
if (pdf_is_bool(ctx, obj) && proc->op_gs_OP)
proc->op_gs_OP(ctx, proc, pdf_to_bool(ctx, obj));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_op);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(op));
if (pdf_is_bool(ctx, obj) && proc->op_gs_op)
proc->op_gs_op(ctx, proc, pdf_to_bool(ctx, obj));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_OPM);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(OPM));
if (pdf_is_int(ctx, obj) && proc->op_gs_OPM)
proc->op_gs_OPM(ctx, proc, pdf_to_int(ctx, obj));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_UseBlackPtComp);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(UseBlackPtComp));
if (pdf_is_name(ctx, obj) && proc->op_gs_UseBlackPtComp)
proc->op_gs_UseBlackPtComp(ctx, proc, obj);
/* transfer functions */
- obj = pdf_dict_get(ctx, dict, PDF_NAME_TR2);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(TR2));
if (pdf_is_name(ctx, obj))
- if (!pdf_name_eq(ctx, obj, PDF_NAME_Identity) && !pdf_name_eq(ctx, obj, PDF_NAME_Default))
+ if (!pdf_name_eq(ctx, obj, PDF_NAME(Identity)) && !pdf_name_eq(ctx, obj, PDF_NAME(Default)))
fz_warn(ctx, "ignoring transfer function");
if (!obj) /* TR is ignored in the presence of TR2 */
{
- pdf_obj *tr = pdf_dict_get(ctx, dict, PDF_NAME_TR);
+ pdf_obj *tr = pdf_dict_get(ctx, dict, PDF_NAME(TR));
if (pdf_is_name(ctx, tr))
- if (!pdf_name_eq(ctx, tr, PDF_NAME_Identity))
+ if (!pdf_name_eq(ctx, tr, PDF_NAME(Identity)))
fz_warn(ctx, "ignoring transfer function");
}
/* transparency state */
- obj = pdf_dict_get(ctx, dict, PDF_NAME_CA);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(CA));
if (pdf_is_number(ctx, obj) && proc->op_gs_CA)
proc->op_gs_CA(ctx, proc, pdf_to_real(ctx, obj));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_ca);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(ca));
if (pdf_is_number(ctx, obj) && proc->op_gs_ca)
proc->op_gs_ca(ctx, proc, pdf_to_real(ctx, obj));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_BM);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(BM));
if (pdf_is_array(ctx, obj))
obj = pdf_array_get(ctx, obj, 0);
if (pdf_is_name(ctx, obj) && proc->op_gs_BM)
proc->op_gs_BM(ctx, proc, pdf_to_name(ctx, obj));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_SMask);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(SMask));
if (proc->op_gs_SMask)
{
if (pdf_is_dict(ctx, obj))
@@ -260,7 +260,7 @@ pdf_process_extgstate(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, pdf_ob
int colorspace_n = 1;
int k, luminosity;
- xobj = pdf_dict_get(ctx, obj, PDF_NAME_G);
+ xobj = pdf_dict_get(ctx, obj, PDF_NAME(G));
colorspace = pdf_xobject_colorspace(ctx, xobj);
if (colorspace)
@@ -276,26 +276,26 @@ pdf_process_extgstate(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, pdf_ob
softmask_bc[3] = 1.0f;
fz_drop_colorspace(ctx, colorspace);
- bc = pdf_dict_get(ctx, obj, PDF_NAME_BC);
+ bc = pdf_dict_get(ctx, obj, PDF_NAME(BC));
if (pdf_is_array(ctx, bc))
{
for (k = 0; k < colorspace_n; k++)
softmask_bc[k] = pdf_to_real(ctx, pdf_array_get(ctx, bc, k));
}
- s = pdf_dict_get(ctx, obj, PDF_NAME_S);
- if (pdf_name_eq(ctx, s, PDF_NAME_Luminosity))
+ s = pdf_dict_get(ctx, obj, PDF_NAME(S));
+ if (pdf_name_eq(ctx, s, PDF_NAME(Luminosity)))
luminosity = 1;
else
luminosity = 0;
- tr = pdf_dict_get(ctx, obj, PDF_NAME_TR);
- if (tr && !pdf_name_eq(ctx, tr, PDF_NAME_Identity))
+ tr = pdf_dict_get(ctx, obj, PDF_NAME(TR));
+ if (tr && !pdf_name_eq(ctx, tr, PDF_NAME(Identity)))
fz_warn(ctx, "ignoring transfer function");
proc->op_gs_SMask(ctx, proc, xobj, csi->rdb, softmask_bc, luminosity);
}
- else if (pdf_is_name(ctx, obj) && pdf_name_eq(ctx, obj, PDF_NAME_None))
+ else if (pdf_is_name(ctx, obj) && pdf_name_eq(ctx, obj, PDF_NAME(None)))
{
proc->op_gs_SMask(ctx, proc, NULL, NULL, NULL, 0);
}
@@ -307,32 +307,32 @@ pdf_process_Do(fz_context *ctx, pdf_processor *proc, pdf_csi *csi)
{
pdf_obj *xres, *xobj, *subtype;
- xres = pdf_dict_get(ctx, csi->rdb, PDF_NAME_XObject);
+ xres = pdf_dict_get(ctx, csi->rdb, PDF_NAME(XObject));
if (!xres)
fz_throw(ctx, FZ_ERROR_SYNTAX, "cannot find XObject dictionary");
xobj = pdf_dict_gets(ctx, xres, csi->name);
if (!xobj)
fz_throw(ctx, FZ_ERROR_SYNTAX, "cannot find XObject resource '%s'", csi->name);
- subtype = pdf_dict_get(ctx, xobj, PDF_NAME_Subtype);
- if (pdf_name_eq(ctx, subtype, PDF_NAME_Form))
+ subtype = pdf_dict_get(ctx, xobj, PDF_NAME(Subtype));
+ if (pdf_name_eq(ctx, subtype, PDF_NAME(Form)))
{
- pdf_obj *st = pdf_dict_get(ctx, xobj, PDF_NAME_Subtype2);
+ pdf_obj *st = pdf_dict_get(ctx, xobj, PDF_NAME(Subtype2));
if (st)
subtype = st;
}
if (!pdf_is_name(ctx, subtype))
fz_throw(ctx, FZ_ERROR_SYNTAX, "no XObject subtype specified");
- if (pdf_is_hidden_ocg(ctx, csi->doc->ocg, csi->rdb, proc->usage, pdf_dict_get(ctx, xobj, PDF_NAME_OC)))
+ if (pdf_is_hidden_ocg(ctx, csi->doc->ocg, csi->rdb, proc->usage, pdf_dict_get(ctx, xobj, PDF_NAME(OC))))
return;
- if (pdf_name_eq(ctx, subtype, PDF_NAME_Form))
+ if (pdf_name_eq(ctx, subtype, PDF_NAME(Form)))
{
if (proc->op_Do_form)
proc->op_Do_form(ctx, proc, csi->name, xobj, csi->rdb);
}
- else if (pdf_name_eq(ctx, subtype, PDF_NAME_Image))
+ else if (pdf_name_eq(ctx, subtype, PDF_NAME(Image)))
{
if (proc->op_Do_image)
{
@@ -378,7 +378,7 @@ pdf_process_CS(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, int stroke)
else
{
pdf_obj *csres, *csobj;
- csres = pdf_dict_get(ctx, csi->rdb, PDF_NAME_ColorSpace);
+ csres = pdf_dict_get(ctx, csi->rdb, PDF_NAME(ColorSpace));
if (!csres)
fz_throw(ctx, FZ_ERROR_SYNTAX, "cannot find ColorSpace dictionary");
csobj = pdf_dict_gets(ctx, csres, csi->name);
@@ -408,14 +408,14 @@ pdf_process_SC(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, int stroke)
{
pdf_obj *patres, *patobj, *type;
- patres = pdf_dict_get(ctx, csi->rdb, PDF_NAME_Pattern);
+ patres = pdf_dict_get(ctx, csi->rdb, PDF_NAME(Pattern));
if (!patres)
fz_throw(ctx, FZ_ERROR_SYNTAX, "cannot find Pattern dictionary");
patobj = pdf_dict_gets(ctx, patres, csi->name);
if (!patobj)
fz_throw(ctx, FZ_ERROR_SYNTAX, "cannot find Pattern resource '%s'", csi->name);
- type = pdf_dict_get(ctx, patobj, PDF_NAME_PatternType);
+ type = pdf_dict_get(ctx, patobj, PDF_NAME(PatternType));
if (pdf_to_int(ctx, type) == 1)
{
@@ -477,7 +477,7 @@ static pdf_obj *
resolve_properties(fz_context *ctx, pdf_csi *csi, pdf_obj *obj)
{
if (pdf_is_name(ctx, obj))
- return pdf_dict_get(ctx, pdf_dict_get(ctx, csi->rdb, PDF_NAME_Properties), obj);
+ return pdf_dict_get(ctx, pdf_dict_get(ctx, csi->rdb, PDF_NAME(Properties)), obj);
else
return obj;
}
@@ -590,7 +590,7 @@ pdf_process_keyword(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, fz_strea
case B('g','s'):
{
pdf_obj *gsres, *gsobj;
- gsres = pdf_dict_get(ctx, csi->rdb, PDF_NAME_ExtGState);
+ gsres = pdf_dict_get(ctx, csi->rdb, PDF_NAME(ExtGState));
if (!gsres)
fz_throw(ctx, FZ_ERROR_SYNTAX, "cannot find ExtGState dictionary");
gsobj = pdf_dict_gets(ctx, gsres, csi->name);
@@ -651,7 +651,7 @@ pdf_process_keyword(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, fz_strea
{
pdf_obj *fontres, *fontobj;
pdf_font_desc *font;
- fontres = pdf_dict_get(ctx, csi->rdb, PDF_NAME_Font);
+ fontres = pdf_dict_get(ctx, csi->rdb, PDF_NAME(Font));
if (!fontres)
fz_throw(ctx, FZ_ERROR_SYNTAX, "cannot find Font dictionary");
fontobj = pdf_dict_gets(ctx, fontres, csi->name);
@@ -743,7 +743,7 @@ pdf_process_keyword(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, fz_strea
{
pdf_obj *shaderes, *shadeobj;
fz_shade *shade;
- shaderes = pdf_dict_get(ctx, csi->rdb, PDF_NAME_Shading);
+ shaderes = pdf_dict_get(ctx, csi->rdb, PDF_NAME(Shading));
if (!shaderes)
fz_throw(ctx, FZ_ERROR_SYNTAX, "cannot find Shading dictionary");
shadeobj = pdf_dict_gets(ctx, shaderes, csi->name);
@@ -1047,7 +1047,7 @@ pdf_process_contents(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pd
void
pdf_process_annot(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pdf_page *page, pdf_annot *annot, fz_cookie *cookie)
{
- int flags = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_F));
+ int flags = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(F)));
if (flags & (PDF_ANNOT_IS_INVISIBLE | PDF_ANNOT_IS_HIDDEN))
return;
@@ -1067,7 +1067,7 @@ pdf_process_annot(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pdf_p
/* TODO: NoZoom and NoRotate */
/* XXX what resources, if any, to use for this check? */
- if (pdf_is_hidden_ocg(ctx, doc->ocg, NULL, proc->usage, pdf_dict_get(ctx, annot->obj, PDF_NAME_OC)))
+ if (pdf_is_hidden_ocg(ctx, doc->ocg, NULL, proc->usage, pdf_dict_get(ctx, annot->obj, PDF_NAME(OC))))
return;
if (proc->op_q && proc->op_cm && proc->op_Do_form && proc->op_Q && annot->ap)
diff --git a/source/pdf/pdf-js.c b/source/pdf/pdf-js.c
index 0024670a..d5fb1e4b 100644
--- a/source/pdf/pdf-js.c
+++ b/source/pdf/pdf-js.c
@@ -618,9 +618,9 @@ static pdf_js *pdf_new_js(fz_context *ctx, pdf_document *doc)
pdf_obj *root, *acroform;
/* Find the form array */
- root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
- acroform = pdf_dict_get(ctx, root, PDF_NAME_AcroForm);
- js->form = pdf_dict_get(ctx, acroform, PDF_NAME_Fields);
+ root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
+ acroform = pdf_dict_get(ctx, root, PDF_NAME(AcroForm));
+ js->form = pdf_dict_get(ctx, acroform, PDF_NAME(Fields));
/* Initialise the javascript engine, passing the fz_context for use in memory allocation. */
js->imp = js_newstate(pdf_js_alloc, ctx, 0);
@@ -649,7 +649,7 @@ static void pdf_js_load_document_level(pdf_js *js)
pdf_obj *javascript;
int len, i;
- javascript = pdf_load_name_tree(ctx, doc, PDF_NAME_JavaScript);
+ javascript = pdf_load_name_tree(ctx, doc, PDF_NAME(JavaScript));
len = pdf_dict_len(ctx, javascript);
fz_try(ctx)
@@ -657,7 +657,7 @@ static void pdf_js_load_document_level(pdf_js *js)
for (i = 0; i < len; i++)
{
pdf_obj *fragment = pdf_dict_get_val(ctx, javascript, i);
- pdf_obj *code = pdf_dict_get(ctx, fragment, PDF_NAME_JS);
+ pdf_obj *code = pdf_dict_get(ctx, fragment, PDF_NAME(JS));
char *codebuf = pdf_load_stream_or_string_as_utf8(ctx, code);
pdf_js_execute(js, codebuf);
fz_free(ctx, codebuf);
diff --git a/source/pdf/pdf-layer.c b/source/pdf/pdf-layer.c
index acbe6b9a..821e9c4c 100644
--- a/source/pdf/pdf-layer.c
+++ b/source/pdf/pdf-layer.c
@@ -146,7 +146,7 @@ populate_ui(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_ocg_ui *ui, pdf_obj *
if (j == desc->len)
continue; /* OCG not found in main list! Just ignore it */
ui->ocg = j;
- ui->name = pdf_to_str_buf(ctx, pdf_dict_get(ctx, o, PDF_NAME_Name));
+ ui->name = pdf_to_str_buf(ctx, pdf_dict_get(ctx, o, PDF_NAME(Name)));
ui->button_flags = pdf_array_contains(ctx, o, rbgroups) ? PDF_LAYER_UI_RADIOBOX : PDF_LAYER_UI_CHECKBOX;
ui->locked = pdf_array_contains(ctx, o, locked);
ui++;
@@ -173,14 +173,14 @@ load_ui(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_obj *ocprops, pdf_obj *oc
int count;
/* Count the number of entries */
- order = pdf_dict_get(ctx, occg, PDF_NAME_Order);
+ order = pdf_dict_get(ctx, occg, PDF_NAME(Order));
if (!order)
order = pdf_dict_getp(ctx, ocprops, "D/Order");
count = count_entries(ctx, order);
- rbgroups = pdf_dict_get(ctx, occg, PDF_NAME_RBGroups);
+ rbgroups = pdf_dict_get(ctx, occg, PDF_NAME(RBGroups));
if (!rbgroups)
rbgroups = pdf_dict_getp(ctx, ocprops, "D/RBGroups");
- locked = pdf_dict_get(ctx, occg, PDF_NAME_Locked);
+ locked = pdf_dict_get(ctx, occg, PDF_NAME(Locked));
desc->num_ui_entries = count;
desc->ui = Memento_label(fz_calloc(ctx, count, sizeof(pdf_ocg_ui)), "pdf_ocg_ui");
@@ -203,7 +203,7 @@ pdf_select_layer_config(fz_context *ctx, pdf_document *doc, int config)
pdf_obj *obj, *cobj;
pdf_obj *name;
- obj = pdf_dict_get(ctx, pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root), PDF_NAME_OCProperties);
+ obj = pdf_dict_get(ctx, pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root)), PDF_NAME(OCProperties));
if (!obj)
{
if (config == 0)
@@ -212,26 +212,26 @@ pdf_select_layer_config(fz_context *ctx, pdf_document *doc, int config)
fz_throw(ctx, FZ_ERROR_GENERIC, "Unknown Layer config (None known!)");
}
- cobj = pdf_array_get(ctx, pdf_dict_get(ctx, obj, PDF_NAME_Configs), config);
+ cobj = pdf_array_get(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Configs)), config);
if (!cobj)
{
if (config != 0)
fz_throw(ctx, FZ_ERROR_GENERIC, "Illegal Layer config");
- cobj = pdf_dict_get(ctx, obj, PDF_NAME_D);
+ cobj = pdf_dict_get(ctx, obj, PDF_NAME(D));
if (!cobj)
fz_throw(ctx, FZ_ERROR_GENERIC, "No default Layer config");
}
pdf_drop_obj(ctx, desc->intent);
- desc->intent = pdf_keep_obj(ctx, pdf_dict_get(ctx, cobj, PDF_NAME_Intent));
+ desc->intent = pdf_keep_obj(ctx, pdf_dict_get(ctx, cobj, PDF_NAME(Intent)));
len = desc->len;
- name = pdf_dict_get(ctx, cobj, PDF_NAME_BaseState);
- if (pdf_name_eq(ctx, name, PDF_NAME_Unchanged))
+ name = pdf_dict_get(ctx, cobj, PDF_NAME(BaseState));
+ if (pdf_name_eq(ctx, name, PDF_NAME(Unchanged)))
{
/* Do nothing */
}
- else if (pdf_name_eq(ctx, name, PDF_NAME_OFF))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(OFF)))
{
for (i = 0; i < len; i++)
{
@@ -246,7 +246,7 @@ pdf_select_layer_config(fz_context *ctx, pdf_document *doc, int config)
}
}
- obj = pdf_dict_get(ctx, cobj, PDF_NAME_ON);
+ obj = pdf_dict_get(ctx, cobj, PDF_NAME(ON));
len2 = pdf_array_len(ctx, obj);
for (i = 0; i < len2; i++)
{
@@ -261,7 +261,7 @@ pdf_select_layer_config(fz_context *ctx, pdf_document *doc, int config)
}
}
- obj = pdf_dict_get(ctx, cobj, PDF_NAME_OFF);
+ obj = pdf_dict_get(ctx, cobj, PDF_NAME(OFF));
len2 = pdf_array_len(ctx, obj);
for (i = 0; i < len2; i++)
{
@@ -303,16 +303,16 @@ pdf_layer_config_info(fz_context *ctx, pdf_document *doc, int config_num, pdf_la
if (!ocprops)
return;
- obj = pdf_dict_get(ctx, ocprops, PDF_NAME_Configs);
+ obj = pdf_dict_get(ctx, ocprops, PDF_NAME(Configs));
if (pdf_is_array(ctx, obj))
obj = pdf_array_get(ctx, obj, config_num);
else if (config_num == 0)
- obj = pdf_dict_get(ctx, ocprops, PDF_NAME_D);
+ obj = pdf_dict_get(ctx, ocprops, PDF_NAME(D));
else
fz_throw(ctx, FZ_ERROR_GENERIC, "Invalid layer config number");
- info->creator = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME_Creator));
- info->name = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME_Name));
+ info->creator = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Creator)));
+ info->name = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Name)));
}
void
@@ -527,7 +527,7 @@ pdf_is_hidden_ocg(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_obj *rdb, const
/* If we've been handed a name, look it up in the properties. */
if (pdf_is_name(ctx, ocg))
{
- ocg = pdf_dict_get(ctx, pdf_dict_get(ctx, rdb, PDF_NAME_Properties), ocg);
+ ocg = pdf_dict_get(ctx, pdf_dict_get(ctx, rdb, PDF_NAME(Properties)), ocg);
}
/* If we haven't been given an ocg at all, then we're visible */
if (!ocg)
@@ -536,9 +536,9 @@ pdf_is_hidden_ocg(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_obj *rdb, const
fz_strlcpy(event_state, usage, sizeof event_state);
fz_strlcat(event_state, "State", sizeof event_state);
- type = pdf_dict_get(ctx, ocg, PDF_NAME_Type);
+ type = pdf_dict_get(ctx, ocg, PDF_NAME(Type));
- if (pdf_name_eq(ctx, type, PDF_NAME_OCG))
+ if (pdf_name_eq(ctx, type, PDF_NAME(OCG)))
{
/* An Optional Content Group */
int default_value = 0;
@@ -558,7 +558,7 @@ pdf_is_hidden_ocg(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_obj *rdb, const
/* Check Intents; if our intent is not part of the set given
* by the current config, we should ignore it. */
- obj = pdf_dict_get(ctx, ocg, PDF_NAME_Intent);
+ obj = pdf_dict_get(ctx, ocg, PDF_NAME(Intent));
if (pdf_is_name(ctx, obj))
{
/* If it doesn't match, it's hidden */
@@ -594,7 +594,7 @@ pdf_is_hidden_ocg(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_obj *rdb, const
* 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 = pdf_dict_get(ctx, ocg, PDF_NAME_Usage);
+ obj = pdf_dict_get(ctx, ocg, PDF_NAME(Usage));
if (!pdf_is_dict(ctx, obj))
return default_value;
/* FIXME: Should look at Zoom (and return hidden if out of
@@ -603,39 +603,39 @@ pdf_is_hidden_ocg(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_obj *rdb, const
* User is appropriate - if not return hidden. */
obj2 = pdf_dict_gets(ctx, obj, usage);
es = pdf_dict_gets(ctx, obj2, event_state);
- if (pdf_name_eq(ctx, es, PDF_NAME_OFF))
+ if (pdf_name_eq(ctx, es, PDF_NAME(OFF)))
{
return 1;
}
- if (pdf_name_eq(ctx, es, PDF_NAME_ON))
+ if (pdf_name_eq(ctx, es, PDF_NAME(ON)))
{
return 0;
}
return default_value;
}
- else if (pdf_name_eq(ctx, type, PDF_NAME_OCMD))
+ else if (pdf_name_eq(ctx, type, PDF_NAME(OCMD)))
{
/* An Optional Content Membership Dictionary */
pdf_obj *name;
int combine, on = 0;
- obj = pdf_dict_get(ctx, ocg, PDF_NAME_VE);
+ obj = pdf_dict_get(ctx, ocg, PDF_NAME(VE));
if (pdf_is_array(ctx, obj)) {
/* FIXME: Calculate visibility from array */
return 0;
}
- name = pdf_dict_get(ctx, ocg, PDF_NAME_P);
+ name = pdf_dict_get(ctx, ocg, PDF_NAME(P));
/* Set combine; Bit 0 set => AND, Bit 1 set => true means
* Off, otherwise true means On */
- if (pdf_name_eq(ctx, name, PDF_NAME_AllOn))
+ if (pdf_name_eq(ctx, name, PDF_NAME(AllOn)))
{
combine = 1;
}
- else if (pdf_name_eq(ctx, name, PDF_NAME_AnyOff))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(AnyOff)))
{
combine = 2;
}
- else if (pdf_name_eq(ctx, name, PDF_NAME_AllOff))
+ else if (pdf_name_eq(ctx, name, PDF_NAME(AllOff)))
{
combine = 3;
}
@@ -648,7 +648,7 @@ pdf_is_hidden_ocg(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_obj *rdb, const
return 0; /* Should never happen */
fz_try(ctx)
{
- obj = pdf_dict_get(ctx, ocg, PDF_NAME_OCGs);
+ obj = pdf_dict_get(ctx, ocg, PDF_NAME(OCGs));
on = combine & 1;
if (pdf_is_array(ctx, obj)) {
int i, len;
@@ -694,11 +694,11 @@ pdf_read_ocg(fz_context *ctx, pdf_document *doc)
fz_var(desc);
- obj = pdf_dict_get(ctx, pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root), PDF_NAME_OCProperties);
+ obj = pdf_dict_get(ctx, pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root)), PDF_NAME(OCProperties));
if (!obj)
return;
- configs = pdf_dict_get(ctx, obj, PDF_NAME_Configs);
+ configs = pdf_dict_get(ctx, obj, PDF_NAME(Configs));
if (configs == NULL)
num_configs = 1;
else if (!pdf_is_array(ctx, configs))
@@ -706,7 +706,7 @@ pdf_read_ocg(fz_context *ctx, pdf_document *doc)
else
num_configs = pdf_array_len(ctx, configs);
- ocg = pdf_dict_get(ctx, obj, PDF_NAME_OCGs);
+ ocg = pdf_dict_get(ctx, obj, PDF_NAME(OCGs));
if (!ocg || !pdf_is_array(ctx, ocg))
/* Not ever supposed to happen, but live with it. */
return;
@@ -753,19 +753,19 @@ pdf_set_layer_config_as_default(fz_context *ctx, pdf_document *doc)
return;
/* All files with OCGs are required to have a D entry */
- d = pdf_dict_get(ctx, ocprops, PDF_NAME_D);
+ d = pdf_dict_get(ctx, ocprops, PDF_NAME(D));
if (d == NULL)
return;
- pdf_dict_put(ctx, d, PDF_NAME_BaseState, PDF_NAME_OFF);
+ pdf_dict_put(ctx, d, PDF_NAME(BaseState), PDF_NAME(OFF));
/* We are about to delete RBGroups and Order, from D. These are
* both the underlying defaults for other configs, so copy the
* current values out to any config that doesn't have one
* already. */
- order = pdf_dict_get(ctx, d, PDF_NAME_Order);
- rbgroups = pdf_dict_get(ctx, d, PDF_NAME_RBGroups);
- configs = pdf_dict_get(ctx, ocprops, PDF_NAME_Configs);
+ order = pdf_dict_get(ctx, d, PDF_NAME(Order));
+ rbgroups = pdf_dict_get(ctx, d, PDF_NAME(RBGroups));
+ configs = pdf_dict_get(ctx, ocprops, PDF_NAME(Configs));
if (configs)
{
int len = pdf_array_len(ctx, configs);
@@ -773,10 +773,10 @@ pdf_set_layer_config_as_default(fz_context *ctx, pdf_document *doc)
{
pdf_obj *config = pdf_array_get(ctx, configs, k);
- if (order && !pdf_dict_get(ctx, config, PDF_NAME_Order))
- pdf_dict_put(ctx, config, PDF_NAME_Order, order);
- if (rbgroups && !pdf_dict_get(ctx, config, PDF_NAME_RBGroups))
- pdf_dict_put(ctx, config, PDF_NAME_RBGroups, rbgroups);
+ if (order && !pdf_dict_get(ctx, config, PDF_NAME(Order)))
+ pdf_dict_put(ctx, config, PDF_NAME(Order), order);
+ if (rbgroups && !pdf_dict_get(ctx, config, PDF_NAME(RBGroups)))
+ pdf_dict_put(ctx, config, PDF_NAME(RBGroups), rbgroups);
}
}
@@ -791,15 +791,15 @@ pdf_set_layer_config_as_default(fz_context *ctx, pdf_document *doc)
if (s->state)
pdf_array_push(ctx, on, s->obj);
}
- pdf_dict_put(ctx, d, PDF_NAME_Order, order);
- pdf_dict_put(ctx, d, PDF_NAME_ON, on);
- pdf_dict_del(ctx, d, PDF_NAME_OFF);
- pdf_dict_del(ctx, d, PDF_NAME_AS);
- pdf_dict_put(ctx, d, PDF_NAME_Intent, PDF_NAME_View);
- pdf_dict_del(ctx, d, PDF_NAME_Name);
- pdf_dict_del(ctx, d, PDF_NAME_Creator);
- pdf_dict_del(ctx, d, PDF_NAME_RBGroups);
- pdf_dict_del(ctx, d, PDF_NAME_Locked);
-
- pdf_dict_del(ctx, ocprops, PDF_NAME_Configs);
+ pdf_dict_put(ctx, d, PDF_NAME(Order), order);
+ pdf_dict_put(ctx, d, PDF_NAME(ON), on);
+ pdf_dict_del(ctx, d, PDF_NAME(OFF));
+ pdf_dict_del(ctx, d, PDF_NAME(AS));
+ pdf_dict_put(ctx, d, PDF_NAME(Intent), PDF_NAME(View));
+ pdf_dict_del(ctx, d, PDF_NAME(Name));
+ pdf_dict_del(ctx, d, PDF_NAME(Creator));
+ pdf_dict_del(ctx, d, PDF_NAME(RBGroups));
+ pdf_dict_del(ctx, d, PDF_NAME(Locked));
+
+ pdf_dict_del(ctx, ocprops, PDF_NAME(Configs));
}
diff --git a/source/pdf/pdf-nametree.c b/source/pdf/pdf-nametree.c
index 71ee4ba7..375b9fd5 100644
--- a/source/pdf/pdf-nametree.c
+++ b/source/pdf/pdf-nametree.c
@@ -4,8 +4,8 @@
static pdf_obj *
pdf_lookup_name_imp(fz_context *ctx, pdf_obj *node, pdf_obj *needle)
{
- pdf_obj *kids = pdf_dict_get(ctx, node, PDF_NAME_Kids);
- pdf_obj *names = pdf_dict_get(ctx, node, PDF_NAME_Names);
+ pdf_obj *kids = pdf_dict_get(ctx, node, PDF_NAME(Kids));
+ pdf_obj *names = pdf_dict_get(ctx, node, PDF_NAME(Names));
if (pdf_is_array(ctx, kids))
{
@@ -16,7 +16,7 @@ pdf_lookup_name_imp(fz_context *ctx, pdf_obj *node, pdf_obj *needle)
{
int m = (l + r) >> 1;
pdf_obj *kid = pdf_array_get(ctx, kids, m);
- pdf_obj *limits = pdf_dict_get(ctx, kid, PDF_NAME_Limits);
+ pdf_obj *limits = pdf_dict_get(ctx, kid, PDF_NAME(Limits));
pdf_obj *first = pdf_array_get(ctx, limits, 0);
pdf_obj *last = pdf_array_get(ctx, limits, 1);
@@ -77,8 +77,8 @@ pdf_lookup_name_imp(fz_context *ctx, pdf_obj *node, pdf_obj *needle)
pdf_obj *
pdf_lookup_name(fz_context *ctx, pdf_document *doc, pdf_obj *which, pdf_obj *needle)
{
- pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
- pdf_obj *names = pdf_dict_get(ctx, root, PDF_NAME_Names);
+ pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
+ pdf_obj *names = pdf_dict_get(ctx, root, PDF_NAME(Names));
pdf_obj *tree = pdf_dict_get(ctx, names, which);
return pdf_lookup_name_imp(ctx, tree, needle);
}
@@ -86,9 +86,9 @@ pdf_lookup_name(fz_context *ctx, pdf_document *doc, pdf_obj *which, pdf_obj *nee
pdf_obj *
pdf_lookup_dest(fz_context *ctx, pdf_document *doc, pdf_obj *needle)
{
- pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
- pdf_obj *dests = pdf_dict_get(ctx, root, PDF_NAME_Dests);
- pdf_obj *names = pdf_dict_get(ctx, root, PDF_NAME_Names);
+ pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
+ pdf_obj *dests = pdf_dict_get(ctx, root, PDF_NAME(Dests));
+ pdf_obj *names = pdf_dict_get(ctx, root, PDF_NAME(Names));
pdf_obj *dest = NULL;
/* PDF 1.1 has destinations in a dictionary */
@@ -103,7 +103,7 @@ pdf_lookup_dest(fz_context *ctx, pdf_document *doc, pdf_obj *needle)
/* PDF 1.2 has destinations in a name tree */
if (names && !dest)
{
- pdf_obj *tree = pdf_dict_get(ctx, names, PDF_NAME_Dests);
+ pdf_obj *tree = pdf_dict_get(ctx, names, PDF_NAME(Dests));
return pdf_lookup_name_imp(ctx, tree, needle);
}
@@ -113,8 +113,8 @@ pdf_lookup_dest(fz_context *ctx, pdf_document *doc, pdf_obj *needle)
static void
pdf_load_name_tree_imp(fz_context *ctx, pdf_obj *dict, pdf_document *doc, pdf_obj *node)
{
- pdf_obj *kids = pdf_dict_get(ctx, node, PDF_NAME_Kids);
- pdf_obj *names = pdf_dict_get(ctx, node, PDF_NAME_Names);
+ pdf_obj *kids = pdf_dict_get(ctx, node, PDF_NAME(Kids));
+ pdf_obj *names = pdf_dict_get(ctx, node, PDF_NAME(Names));
int i;
if (kids && !pdf_mark_obj(ctx, node))
@@ -155,8 +155,8 @@ pdf_load_name_tree_imp(fz_context *ctx, pdf_obj *dict, pdf_document *doc, pdf_ob
pdf_obj *
pdf_load_name_tree(fz_context *ctx, pdf_document *doc, pdf_obj *which)
{
- pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
- pdf_obj *names = pdf_dict_get(ctx, root, PDF_NAME_Names);
+ pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
+ pdf_obj *names = pdf_dict_get(ctx, root, PDF_NAME(Names));
pdf_obj *tree = pdf_dict_get(ctx, names, which);
if (pdf_is_dict(ctx, tree))
{
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c
index bd68b761..0d43e056 100644
--- a/source/pdf/pdf-object.c
+++ b/source/pdf/pdf-object.c
@@ -2,12 +2,17 @@
#include "mupdf/pdf.h"
#include "../fitz/fitz-imp.h"
-#include "pdf-name-table.h"
-
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
+#define PDF_MAKE_NAME(STRING,NAME) STRING,
+static const char *PDF_NAME_LIST[] = {
+ "", /* dummy */
+#include "mupdf/pdf/name-table.h"
+};
+#undef PDF_MAKE_NAME
+
typedef enum pdf_objkind_e
{
PDF_INT = 'i',
@@ -102,13 +107,13 @@ typedef struct pdf_obj_ref_s
pdf_obj *
pdf_new_null(fz_context *ctx, pdf_document *doc)
{
- return PDF_OBJ_NULL;
+ return PDF_NULL;
}
pdf_obj *
pdf_new_bool(fz_context *ctx, pdf_document *doc, int b)
{
- return b ? PDF_OBJ_TRUE : PDF_OBJ_FALSE;
+ return b ? PDF_TRUE : PDF_FALSE;
}
pdf_obj *
@@ -166,9 +171,9 @@ pdf_new_name(fz_context *ctx, pdf_document *doc, const char *str)
pdf_obj_name *obj;
const char **stdname;
- stdname = bsearch(str, &PDF_NAMES[1], PDF_OBJ_ENUM_NAME__LIMIT-1, sizeof(char *), namecmp);
+ stdname = bsearch(str, &PDF_NAME_LIST[1], PDF_ENUM_LIMIT_NAME-1, sizeof(char *), namecmp);
if (stdname != NULL)
- return (pdf_obj *)(intptr_t)(stdname - &PDF_NAMES[0]);
+ return (pdf_obj *)(intptr_t)(stdname - &PDF_NAME_LIST[0]);
obj = Memento_label(fz_malloc(ctx, offsetof(pdf_obj_name, n) + strlen(str) + 1), "pdf_obj(name)");
obj->super.refs = 1;
@@ -195,33 +200,31 @@ pdf_new_indirect(fz_context *ctx, pdf_document *doc, int num, int gen)
pdf_obj *
pdf_keep_obj(fz_context *ctx, pdf_obj *obj)
{
- if (obj >= PDF_OBJ__LIMIT)
+ if (obj >= PDF_OBJ_LIMIT)
{
(void)fz_keep_imp16(ctx, obj, &obj->refs);
}
return obj;
}
-#define OBJ_IS_NULL(obj) \
- (obj == PDF_OBJ_NULL)
-#define OBJ_IS_BOOL(obj) \
- (obj == PDF_OBJ_TRUE || obj == PDF_OBJ_FALSE)
+#define OBJ_IS_NULL(obj) (obj == PDF_NULL)
+#define OBJ_IS_BOOL(obj) (obj == PDF_TRUE || obj == PDF_FALSE)
#define OBJ_IS_INT(obj) \
- (obj >= PDF_OBJ__LIMIT ? obj->kind == PDF_INT : 0)
+ (obj >= PDF_OBJ_LIMIT ? obj->kind == PDF_INT : 0)
#define OBJ_IS_REAL(obj) \
- (obj >= PDF_OBJ__LIMIT ? obj->kind == PDF_REAL : 0)
+ (obj >= PDF_OBJ_LIMIT ? obj->kind == PDF_REAL : 0)
#define OBJ_IS_NUMBER(obj) \
- (obj >= PDF_OBJ__LIMIT ? (obj->kind == PDF_REAL || obj->kind == PDF_INT) : 0)
+ (obj >= PDF_OBJ_LIMIT ? (obj->kind == PDF_REAL || obj->kind == PDF_INT) : 0)
#define OBJ_IS_STRING(obj) \
- (obj >= PDF_OBJ__LIMIT ? obj->kind == PDF_STRING : 0)
+ (obj >= PDF_OBJ_LIMIT ? obj->kind == PDF_STRING : 0)
#define OBJ_IS_NAME(obj) \
- ((obj >= PDF_OBJ__LIMIT) ? (obj->kind == PDF_NAME) : (obj != NULL && obj < PDF_OBJ_NAME__LIMIT))
+ ((obj >= PDF_OBJ_LIMIT) ? (obj->kind == PDF_NAME) : (obj != NULL && obj < PDF_NAME_LIMIT))
#define OBJ_IS_ARRAY(obj) \
- (obj >= PDF_OBJ__LIMIT ? obj->kind == PDF_ARRAY : 0)
+ (obj >= PDF_OBJ_LIMIT ? obj->kind == PDF_ARRAY : 0)
#define OBJ_IS_DICT(obj) \
- (obj >= PDF_OBJ__LIMIT ? obj->kind == PDF_DICT : 0)
+ (obj >= PDF_OBJ_LIMIT ? obj->kind == PDF_DICT : 0)
#define OBJ_IS_INDIRECT(obj) \
- (obj >= PDF_OBJ__LIMIT ? obj->kind == PDF_INDIRECT : 0)
+ (obj >= PDF_OBJ_LIMIT ? obj->kind == PDF_INDIRECT : 0)
#define RESOLVE(obj) \
if (OBJ_IS_INDIRECT(obj)) \
@@ -289,13 +292,13 @@ int pdf_is_dict(fz_context *ctx, pdf_obj *obj)
int pdf_to_bool(fz_context *ctx, pdf_obj *obj)
{
RESOLVE(obj);
- return obj == PDF_OBJ_TRUE;
+ return obj == PDF_TRUE;
}
int pdf_to_int(fz_context *ctx, pdf_obj *obj)
{
RESOLVE(obj);
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return 0;
if (obj->kind == PDF_INT)
return (int)NUM(obj)->u.i;
@@ -307,7 +310,7 @@ int pdf_to_int(fz_context *ctx, pdf_obj *obj)
int64_t pdf_to_int64(fz_context *ctx, pdf_obj *obj)
{
RESOLVE(obj);
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return 0;
if (obj->kind == PDF_INT)
return NUM(obj)->u.i;
@@ -319,7 +322,7 @@ int64_t pdf_to_int64(fz_context *ctx, pdf_obj *obj)
float pdf_to_real(fz_context *ctx, pdf_obj *obj)
{
RESOLVE(obj);
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return 0;
if (obj->kind == PDF_REAL)
return NUM(obj)->u.f;
@@ -333,8 +336,8 @@ const char *pdf_to_name(fz_context *ctx, pdf_obj *obj)
RESOLVE(obj);
if (!OBJ_IS_NAME(obj))
return "";
- if (obj < PDF_OBJ_NAME__LIMIT)
- return PDF_NAMES[(intptr_t)obj];
+ if (obj < PDF_NAME_LIMIT)
+ return PDF_NAME_LIST[(intptr_t)obj];
return NAME(obj)->n;
}
@@ -395,7 +398,7 @@ pdf_document *pdf_get_indirect_document(fz_context *ctx, pdf_obj *obj)
pdf_document *pdf_get_bound_document(fz_context *ctx, pdf_obj *obj)
{
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return NULL;
if (obj->kind == PDF_INDIRECT)
return REF(obj)->doc;
@@ -424,27 +427,27 @@ pdf_objcmp(fz_context *ctx, pdf_obj *a, pdf_obj *b)
if (!a || !b)
return 1;
- if (a < PDF_OBJ_NAME__LIMIT)
+ if (a < PDF_NAME_LIMIT)
{
- if (b < PDF_OBJ_NAME__LIMIT)
+ if (b < PDF_NAME_LIMIT)
return a != b;
- if (b < PDF_OBJ__LIMIT)
+ if (b < PDF_OBJ_LIMIT)
return 1;
if (b->kind != PDF_NAME)
return 1;
- return strcmp(NAME(b)->n, PDF_NAMES[(intptr_t)a]);
+ return strcmp(NAME(b)->n, PDF_NAME_LIST[(intptr_t)a]);
}
- if (b < PDF_OBJ_NAME__LIMIT)
+ if (b < PDF_NAME_LIMIT)
{
- if (a < PDF_OBJ__LIMIT)
+ if (a < PDF_OBJ_LIMIT)
return 1;
if (a->kind != PDF_NAME)
return 1;
- return strcmp(NAME(a)->n, PDF_NAMES[(intptr_t)b]);
+ return strcmp(NAME(a)->n, PDF_NAME_LIST[(intptr_t)b]);
}
- if (a < PDF_OBJ__LIMIT || b < PDF_OBJ__LIMIT)
+ if (a < PDF_OBJ_LIMIT || b < PDF_OBJ_LIMIT)
return a != b;
if (a->kind != b->kind)
@@ -508,18 +511,25 @@ pdf_objcmp(fz_context *ctx, pdf_obj *a, pdf_obj *b)
return 1;
}
+int pdf_name_eq(fz_context *ctx, pdf_obj *a, pdf_obj *b)
+{
+ /* A quick check in case they are constants */
+ if (a < PDF_NAME_LIMIT)
+ return a == b;
+ return !pdf_objcmp_resolve(ctx, a, b);
+}
+
static char *
pdf_objkindstr(pdf_obj *obj)
{
if (!obj)
return "<NULL>";
- if (obj < PDF_OBJ_NAME__LIMIT)
+ if (obj < PDF_NAME_LIMIT)
return "name";
- if (obj == PDF_OBJ_TRUE || obj == PDF_OBJ_FALSE)
+ if (obj == PDF_TRUE || obj == PDF_FALSE)
return "boolean";
- if (obj == PDF_OBJ_NULL)
+ if (obj == PDF_NULL)
return "null";
-
switch (obj->kind)
{
case PDF_INT: return "integer";
@@ -634,7 +644,7 @@ static void prepare_object_for_alteration(fz_context *ctx, pdf_obj *obj, pdf_obj
obj should be a dict or an array. We don't care about
any other types, as they aren't 'containers'.
*/
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return;
switch (obj->kind)
@@ -689,7 +699,7 @@ pdf_array_put(fz_context *ctx, pdf_obj *obj, int i, pdf_obj *item)
fz_throw(ctx, FZ_ERROR_GENERIC, "index out of bounds");
if (!item)
- item = PDF_OBJ_NULL;
+ item = PDF_NULL;
prepare_object_for_alteration(ctx, obj, item);
pdf_drop_obj(ctx, ARRAY(obj)->items[i]);
@@ -715,7 +725,7 @@ pdf_array_push(fz_context *ctx, pdf_obj *obj, pdf_obj *item)
fz_throw(ctx, FZ_ERROR_GENERIC, "not an array (%s)", pdf_objkindstr(obj));
if (!item)
- item = PDF_OBJ_NULL;
+ item = PDF_NULL;
prepare_object_for_alteration(ctx, obj, item);
if (ARRAY(obj)->len + 1 > ARRAY(obj)->cap)
@@ -728,7 +738,7 @@ void
pdf_array_push_drop(fz_context *ctx, pdf_obj *obj, pdf_obj *item)
{
RESOLVE(obj);
- if (obj >= PDF_OBJ__LIMIT)
+ if (obj >= PDF_OBJ_LIMIT)
{
fz_try(ctx)
pdf_array_push(ctx, obj, item);
@@ -749,7 +759,7 @@ pdf_array_insert(fz_context *ctx, pdf_obj *obj, pdf_obj *item, int i)
fz_throw(ctx, FZ_ERROR_GENERIC, "index out of bounds");
if (!item)
- item = PDF_OBJ_NULL;
+ item = PDF_NULL;
prepare_object_for_alteration(ctx, obj, item);
if (ARRAY(obj)->len + 1 > ARRAY(obj)->cap)
@@ -763,7 +773,7 @@ void
pdf_array_insert_drop(fz_context *ctx, pdf_obj *obj, pdf_obj *item, int i)
{
RESOLVE(obj);
- if (obj >= PDF_OBJ__LIMIT)
+ if (obj >= PDF_OBJ_LIMIT)
{
fz_try(ctx)
pdf_array_insert(ctx, obj, item, i);
@@ -865,16 +875,16 @@ static int keyvalcmp(const void *ap, const void *bp)
/* We should never get a->k == NULL or b->k == NULL. If we
* do, then they match. */
- if (a->k < PDF_OBJ_NAME__LIMIT)
- an = PDF_NAMES[(intptr_t)a->k];
- else if (a->k >= PDF_OBJ__LIMIT && a->k->kind == PDF_NAME)
+ if (a->k < PDF_NAME_LIMIT)
+ an = PDF_NAME_LIST[(intptr_t)a->k];
+ else if (a->k >= PDF_OBJ_LIMIT && a->k->kind == PDF_NAME)
an = NAME(a->k)->n;
else
return 0;
- if (b->k < PDF_OBJ_NAME__LIMIT)
- bn = PDF_NAMES[(intptr_t)b->k];
- else if (b->k >= PDF_OBJ__LIMIT && b->k->kind == PDF_NAME)
+ if (b->k < PDF_NAME_LIMIT)
+ bn = PDF_NAME_LIST[(intptr_t)b->k];
+ else if (b->k >= PDF_OBJ_LIMIT && b->k->kind == PDF_NAME)
bn = NAME(b->k)->n;
else
return 0;
@@ -1000,7 +1010,7 @@ pdf_dict_put_val_null(fz_context *ctx, pdf_obj *obj, int idx)
prepare_object_for_alteration(ctx, obj, NULL);
pdf_drop_obj(ctx, DICT(obj)->items[idx].v);
- DICT(obj)->items[idx].v = PDF_OBJ_NULL;
+ DICT(obj)->items[idx].v = PDF_NULL;
}
/* Returns 0 <= i < len for key found. Returns -1-len < i <= -1 for key
@@ -1054,7 +1064,7 @@ pdf_dict_find(fz_context *ctx, pdf_obj *obj, pdf_obj *key)
int r = len - 1;
pdf_obj *k = DICT(obj)->items[r].k;
- if (k == key || (k >= PDF_OBJ__LIMIT && strcmp(NAME(k)->n, PDF_NAMES[(intptr_t)key]) < 0))
+ if (k == key || (k >= PDF_OBJ_LIMIT && strcmp(NAME(k)->n, PDF_NAME_LIST[(intptr_t)key]) < 0))
{
return -1 - (r+1);
}
@@ -1065,7 +1075,7 @@ pdf_dict_find(fz_context *ctx, pdf_obj *obj, pdf_obj *key)
int c;
k = DICT(obj)->items[m].k;
- c = (k < PDF_OBJ__LIMIT ? (char *)key-(char *)k : -strcmp(NAME(k)->n, PDF_NAMES[(intptr_t)key]));
+ c = (k < PDF_OBJ_LIMIT ? (char *)key-(char *)k : -strcmp(NAME(k)->n, PDF_NAME_LIST[(intptr_t)key]));
if (c < 0)
r = m - 1;
else if (c > 0)
@@ -1081,14 +1091,14 @@ pdf_dict_find(fz_context *ctx, pdf_obj *obj, pdf_obj *key)
for (i = 0; i < len; i++)
{
pdf_obj *k = DICT(obj)->items[i].k;
- if (k < PDF_OBJ__LIMIT)
+ if (k < PDF_OBJ_LIMIT)
{
if (k == key)
return i;
}
else
{
- if (!strcmp(PDF_NAMES[(intptr_t)key], NAME(k)->n))
+ if (!strcmp(PDF_NAME_LIST[(intptr_t)key], NAME(k)->n))
return i;
}
}
@@ -1175,7 +1185,7 @@ pdf_dict_get(fz_context *ctx, pdf_obj *obj, pdf_obj *key)
if (!OBJ_IS_NAME(key))
return NULL;
- if (key < PDF_OBJ_NAME__LIMIT)
+ if (key < PDF_NAME_LIMIT)
i = pdf_dict_find(ctx, obj, key);
else
i = pdf_dict_finds(ctx, obj, pdf_to_name(ctx, key));
@@ -1219,12 +1229,12 @@ pdf_dict_get_put(fz_context *ctx, pdf_obj *obj, pdf_obj *key, pdf_obj *val, pdf_
fz_throw(ctx, FZ_ERROR_GENERIC, "key is not a name (%s)", pdf_objkindstr(obj));
if (!val)
- val = PDF_OBJ_NULL;
+ val = PDF_NULL;
if (DICT(obj)->len > 100 && !(obj->flags & PDF_FLAGS_SORTED))
pdf_sort_dict(ctx, obj);
- if (key < PDF_OBJ_NAME__LIMIT)
+ if (key < PDF_NAME_LIMIT)
i = pdf_dict_find(ctx, obj, key);
else
i = pdf_dict_finds(ctx, obj, pdf_to_name(ctx, key));
@@ -1512,8 +1522,8 @@ pdf_dict_del(fz_context *ctx, pdf_obj *obj, pdf_obj *key)
if (!OBJ_IS_NAME(key))
fz_throw(ctx, FZ_ERROR_GENERIC, "key is not a name (%s)", pdf_objkindstr(key));
- if (key < PDF_OBJ_NAME__LIMIT)
- pdf_dict_dels(ctx, obj, PDF_NAMES[(intptr_t)key]);
+ if (key < PDF_NAME_LIMIT)
+ pdf_dict_dels(ctx, obj, PDF_NAME_LIST[(intptr_t)key]);
else
pdf_dict_dels(ctx, obj, NAME(key)->n);
}
@@ -1534,7 +1544,7 @@ pdf_sort_dict(fz_context *ctx, pdf_obj *obj)
pdf_obj *
pdf_deep_copy_obj(fz_context *ctx, pdf_obj *obj)
{
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
{
return pdf_keep_obj(ctx, obj);
}
@@ -1590,7 +1600,7 @@ int
pdf_obj_marked(fz_context *ctx, pdf_obj *obj)
{
RESOLVE(obj);
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return 0;
return !!(obj->flags & PDF_FLAGS_MARKED);
}
@@ -1600,7 +1610,7 @@ pdf_mark_obj(fz_context *ctx, pdf_obj *obj)
{
int marked;
RESOLVE(obj);
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return 0;
marked = !!(obj->flags & PDF_FLAGS_MARKED);
obj->flags |= PDF_FLAGS_MARKED;
@@ -1611,7 +1621,7 @@ void
pdf_unmark_obj(fz_context *ctx, pdf_obj *obj)
{
RESOLVE(obj);
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return;
obj->flags &= ~PDF_FLAGS_MARKED;
}
@@ -1619,7 +1629,7 @@ pdf_unmark_obj(fz_context *ctx, pdf_obj *obj)
void
pdf_set_obj_memo(fz_context *ctx, pdf_obj *obj, int bit, int memo)
{
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return;
bit <<= 1;
@@ -1633,7 +1643,7 @@ pdf_set_obj_memo(fz_context *ctx, pdf_obj *obj, int bit, int memo)
int
pdf_obj_memo(fz_context *ctx, pdf_obj *obj, int bit, int *memo)
{
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return 0;
bit <<= 1;
if (!(obj->flags & (PDF_FLAGS_MEMO_BASE<<bit)))
@@ -1645,7 +1655,7 @@ pdf_obj_memo(fz_context *ctx, pdf_obj *obj, int bit, int *memo)
int pdf_obj_is_dirty(fz_context *ctx, pdf_obj *obj)
{
RESOLVE(obj);
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return 0;
return !!(obj->flags & PDF_FLAGS_DIRTY);
}
@@ -1653,14 +1663,14 @@ int pdf_obj_is_dirty(fz_context *ctx, pdf_obj *obj)
void pdf_dirty_obj(fz_context *ctx, pdf_obj *obj)
{
RESOLVE(obj);
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return;
obj->flags |= PDF_FLAGS_DIRTY;
}
void pdf_clean_obj(fz_context *ctx, pdf_obj *obj)
{
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return;
obj->flags &= ~PDF_FLAGS_DIRTY;
}
@@ -1694,7 +1704,7 @@ pdf_drop_dict(fz_context *ctx, pdf_obj *obj)
void
pdf_drop_obj(fz_context *ctx, pdf_obj *obj)
{
- if (obj >= PDF_OBJ__LIMIT)
+ if (obj >= PDF_OBJ_LIMIT)
{
if (fz_drop_imp16(ctx, obj, &obj->refs))
{
@@ -1713,7 +1723,7 @@ pdf_set_obj_parent(fz_context *ctx, pdf_obj *obj, int num)
{
int n, i;
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return;
switch(obj->kind)
@@ -1735,7 +1745,7 @@ pdf_set_obj_parent(fz_context *ctx, pdf_obj *obj, int num)
int pdf_obj_parent_num(fz_context *ctx, pdf_obj *obj)
{
- if (obj < PDF_OBJ__LIMIT)
+ if (obj < PDF_OBJ_LIMIT)
return 0;
switch(obj->kind)
@@ -2172,7 +2182,7 @@ void pdf_debug_obj(fz_context *ctx, pdf_obj *obj)
int pdf_obj_refs(fz_context *ctx, pdf_obj *ref)
{
- return (ref >= PDF_OBJ__LIMIT ? ref->refs : 0);
+ return (ref >= PDF_OBJ_LIMIT ? ref->refs : 0);
}
/* Convenience functions */
diff --git a/source/pdf/pdf-op-filter.c b/source/pdf/pdf-op-filter.c
index 58fd129f..b848816d 100644
--- a/source/pdf/pdf-op-filter.c
+++ b/source/pdf/pdf-op-filter.c
@@ -757,7 +757,7 @@ pdf_filter_gs_begin(fz_context *ctx, pdf_processor *proc, const char *name, pdf_
filter_flush(ctx, p, FLUSH_ALL);
if (p->chain->op_gs_begin)
p->chain->op_gs_begin(ctx, p->chain, name, extgstate);
- copy_resource(ctx, p, PDF_NAME_ExtGState, name);
+ copy_resource(ctx, p, PDF_NAME(ExtGState), name);
}
static void
@@ -1093,7 +1093,7 @@ pdf_filter_Tf(fz_context *ctx, pdf_processor *proc, const char *name, pdf_font_d
pdf_drop_font(ctx, p->gstate->pending.text.font);
p->gstate->pending.text.font = pdf_keep_font(ctx, font);
p->gstate->pending.text.size = size;
- copy_resource(ctx, p, PDF_NAME_Font, name);
+ copy_resource(ctx, p, PDF_NAME(Font), name);
}
static void
@@ -1225,7 +1225,7 @@ pdf_filter_CS(fz_context *ctx, pdf_processor *proc, const char *name, fz_colorsp
filter_gstate *gstate = gstate_to_update(ctx, p);
fz_strlcpy(gstate->pending.CS.name, name, sizeof gstate->pending.CS.name);
gstate->pending.CS.cs = cs;
- copy_resource(ctx, p, PDF_NAME_ColorSpace, name);
+ copy_resource(ctx, p, PDF_NAME(ColorSpace), name);
}
static void
@@ -1235,7 +1235,7 @@ pdf_filter_cs(fz_context *ctx, pdf_processor *proc, const char *name, fz_colorsp
filter_gstate *gstate = gstate_to_update(ctx, p);
fz_strlcpy(gstate->pending.cs.name, name, sizeof gstate->pending.cs.name);
gstate->pending.cs.cs = cs;
- copy_resource(ctx, p, PDF_NAME_ColorSpace, name);
+ copy_resource(ctx, p, PDF_NAME(ColorSpace), name);
}
static void
@@ -1250,7 +1250,7 @@ pdf_filter_SC_pattern(fz_context *ctx, pdf_processor *proc, const char *name, pd
gstate->pending.SC.n = n;
for (i = 0; i < n; ++i)
gstate->pending.SC.c[i] = color[i];
- copy_resource(ctx, p, PDF_NAME_Pattern, name);
+ copy_resource(ctx, p, PDF_NAME(Pattern), name);
}
static void
@@ -1265,7 +1265,7 @@ pdf_filter_sc_pattern(fz_context *ctx, pdf_processor *proc, const char *name, pd
gstate->pending.sc.n = n;
for (i = 0; i < n; ++i)
gstate->pending.sc.c[i] = color[i];
- copy_resource(ctx, p, PDF_NAME_Pattern, name);
+ copy_resource(ctx, p, PDF_NAME(Pattern), name);
}
static void
@@ -1277,7 +1277,7 @@ pdf_filter_SC_shade(fz_context *ctx, pdf_processor *proc, const char *name, fz_s
gstate->pending.SC.pat = NULL;
gstate->pending.SC.shd = shade;
gstate->pending.SC.n = 0;
- copy_resource(ctx, p, PDF_NAME_Pattern, name);
+ copy_resource(ctx, p, PDF_NAME(Pattern), name);
}
static void
@@ -1289,7 +1289,7 @@ pdf_filter_sc_shade(fz_context *ctx, pdf_processor *proc, const char *name, fz_s
gstate->pending.sc.pat = NULL;
gstate->pending.sc.shd = shade;
gstate->pending.sc.n = 0;
- copy_resource(ctx, p, PDF_NAME_Pattern, name);
+ copy_resource(ctx, p, PDF_NAME(Pattern), name);
}
static void
@@ -1386,7 +1386,7 @@ pdf_filter_sh(fz_context *ctx, pdf_processor *proc, const char *name, fz_shade *
filter_flush(ctx, p, FLUSH_ALL);
if (p->chain->op_sh)
p->chain->op_sh(ctx, p->chain, name, shade);
- copy_resource(ctx, p, PDF_NAME_Shading, name);
+ copy_resource(ctx, p, PDF_NAME(Shading), name);
}
static void
@@ -1396,7 +1396,7 @@ pdf_filter_Do_image(fz_context *ctx, pdf_processor *proc, const char *name, fz_i
filter_flush(ctx, p, FLUSH_ALL);
if (p->chain->op_Do_image)
p->chain->op_Do_image(ctx, p->chain, name, image);
- copy_resource(ctx, p, PDF_NAME_XObject, name);
+ copy_resource(ctx, p, PDF_NAME(XObject), name);
}
static void
@@ -1406,7 +1406,7 @@ pdf_filter_Do_form(fz_context *ctx, pdf_processor *proc, const char *name, pdf_o
filter_flush(ctx, p, FLUSH_ALL);
if (p->chain->op_Do_form)
p->chain->op_Do_form(ctx, p->chain, name, xobj, page_resources);
- copy_resource(ctx, p, PDF_NAME_XObject, name);
+ copy_resource(ctx, p, PDF_NAME(XObject), name);
}
/* marked content */
diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c
index 305cd774..9b52ce17 100644
--- a/source/pdf/pdf-op-run.c
+++ b/source/pdf/pdf-op-run.c
@@ -1483,7 +1483,7 @@ static void pdf_run_gs_UseBlackPtComp(fz_context *ctx, pdf_processor *proc, pdf_
{
pdf_run_processor *pr = (pdf_run_processor *)proc;
pdf_gstate *gstate = pdf_flush_text(ctx, pr);
- int on = pdf_name_eq(ctx, obj, PDF_NAME_ON);
+ int on = pdf_name_eq(ctx, obj, PDF_NAME(ON));
/* The spec says that "ON" means on, "OFF" means "Off", and
* "Default" or anything else means "Meh, do what you want." */
gstate->stroke.color_params.bp = on;
@@ -2033,7 +2033,7 @@ static void pdf_run_BDC(fz_context *ctx, pdf_processor *proc, const char *tag, p
if (!tag || strcmp(tag, "OC"))
return;
- str = pdf_to_str_buf(ctx, pdf_dict_get(ctx, cooked, PDF_NAME_Name));
+ str = pdf_to_str_buf(ctx, pdf_dict_get(ctx, cooked, PDF_NAME(Name)));
if (str == NULL)
str = "UnnamedLayer";
diff --git a/source/pdf/pdf-outline.c b/source/pdf/pdf-outline.c
index 77f04ffc..ea8ecbeb 100644
--- a/source/pdf/pdf-outline.c
+++ b/source/pdf/pdf-outline.c
@@ -22,13 +22,13 @@ pdf_load_outline_imp(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
*prev = node;
prev = &node->next;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Title);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Title));
if (obj)
node->title = pdf_to_utf8(ctx, obj);
- if ((obj = pdf_dict_get(ctx, dict, PDF_NAME_Dest)) != NULL)
+ if ((obj = pdf_dict_get(ctx, dict, PDF_NAME(Dest))) != NULL)
node->uri = pdf_parse_link_dest(ctx, doc, obj);
- else if ((obj = pdf_dict_get(ctx, dict, PDF_NAME_A)) != NULL)
+ else if ((obj = pdf_dict_get(ctx, dict, PDF_NAME(A))) != NULL)
node->uri = pdf_parse_link_action(ctx, doc, obj, -1);
else
node->uri = NULL;
@@ -38,22 +38,22 @@ pdf_load_outline_imp(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
else
node->page = -1;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_First);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(First));
if (obj)
{
node->down = pdf_load_outline_imp(ctx, doc, obj);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Count);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Count));
if (pdf_to_int(ctx, obj) > 0)
node->is_open = 1;
}
- dict = pdf_dict_get(ctx, dict, PDF_NAME_Next);
+ dict = pdf_dict_get(ctx, dict, PDF_NAME(Next));
}
}
fz_always(ctx)
{
- for (dict = odict; dict && pdf_obj_marked(ctx, dict); dict = pdf_dict_get(ctx, dict, PDF_NAME_Next))
+ for (dict = odict; dict && pdf_obj_marked(ctx, dict); dict = pdf_dict_get(ctx, dict, PDF_NAME(Next)))
pdf_unmark_obj(ctx, dict);
}
fz_catch(ctx)
@@ -74,9 +74,9 @@ pdf_load_outline(fz_context *ctx, pdf_document *doc)
pdf_load_page_tree(ctx, doc); /* cache page tree for fast link destination lookups */
fz_try(ctx)
{
- root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
- obj = pdf_dict_get(ctx, root, PDF_NAME_Outlines);
- first = pdf_dict_get(ctx, obj, PDF_NAME_First);
+ root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
+ obj = pdf_dict_get(ctx, root, PDF_NAME(Outlines));
+ first = pdf_dict_get(ctx, obj, PDF_NAME(First));
if (first)
outline = pdf_load_outline_imp(ctx, doc, first);
}
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c
index 9325ce3e..68e2b55e 100644
--- a/source/pdf/pdf-page.c
+++ b/source/pdf/pdf-page.c
@@ -14,11 +14,11 @@ pdf_count_pages(fz_context *ctx, pdf_document *doc)
static int
pdf_load_page_tree_imp(fz_context *ctx, pdf_document *doc, pdf_obj *node, int idx)
{
- pdf_obj *type = pdf_dict_get(ctx, node, PDF_NAME_Type);
- if (pdf_name_eq(ctx, type, PDF_NAME_Pages))
+ pdf_obj *type = pdf_dict_get(ctx, node, PDF_NAME(Type));
+ if (pdf_name_eq(ctx, type, PDF_NAME(Pages)))
{
- pdf_obj *kids = pdf_dict_get(ctx, node, PDF_NAME_Kids);
- int count = pdf_to_int(ctx, pdf_dict_get(ctx, node, PDF_NAME_Count));
+ pdf_obj *kids = pdf_dict_get(ctx, node, PDF_NAME(Kids));
+ int count = pdf_to_int(ctx, pdf_dict_get(ctx, node, PDF_NAME(Count)));
int i, n = pdf_array_len(ctx, kids);
/* if Kids length is same as Count, all children must be page objects */
@@ -48,7 +48,7 @@ pdf_load_page_tree_imp(fz_context *ctx, pdf_document *doc, pdf_obj *node, int id
fz_rethrow(ctx);
}
}
- else if (pdf_name_eq(ctx, type, PDF_NAME_Page))
+ else if (pdf_name_eq(ctx, type, PDF_NAME(Page)))
{
if (idx >= doc->rev_page_count)
fz_throw(ctx, FZ_ERROR_GENERIC, "too many kids in page tree");
@@ -116,7 +116,7 @@ pdf_lookup_page_loc_imp(fz_context *ctx, pdf_document *doc, pdf_obj *node, int *
{
do
{
- kids = pdf_dict_get(ctx, node, PDF_NAME_Kids);
+ kids = pdf_dict_get(ctx, node, PDF_NAME(Kids));
len = pdf_array_len(ctx, kids);
if (len == 0)
@@ -142,10 +142,10 @@ pdf_lookup_page_loc_imp(fz_context *ctx, pdf_document *doc, pdf_obj *node, int *
for (i = 0; i < len; i++)
{
pdf_obj *kid = pdf_array_get(ctx, kids, i);
- pdf_obj *type = pdf_dict_get(ctx, kid, PDF_NAME_Type);
- if (type ? pdf_name_eq(ctx, type, PDF_NAME_Pages) : pdf_dict_get(ctx, kid, PDF_NAME_Kids) && !pdf_dict_get(ctx, kid, PDF_NAME_MediaBox))
+ pdf_obj *type = pdf_dict_get(ctx, kid, PDF_NAME(Type));
+ if (type ? pdf_name_eq(ctx, type, PDF_NAME(Pages)) : pdf_dict_get(ctx, kid, PDF_NAME(Kids)) && !pdf_dict_get(ctx, kid, PDF_NAME(MediaBox)))
{
- int count = pdf_to_int(ctx, pdf_dict_get(ctx, kid, PDF_NAME_Count));
+ int count = pdf_to_int(ctx, pdf_dict_get(ctx, kid, PDF_NAME(Count)));
if (*skip < count)
{
node = kid;
@@ -158,7 +158,7 @@ pdf_lookup_page_loc_imp(fz_context *ctx, pdf_document *doc, pdf_obj *node, int *
}
else
{
- if (type ? !pdf_name_eq(ctx, type, PDF_NAME_Page) : !pdf_dict_get(ctx, kid, PDF_NAME_MediaBox))
+ if (type ? !pdf_name_eq(ctx, type, PDF_NAME(Page)) : !pdf_dict_get(ctx, kid, PDF_NAME(MediaBox)))
fz_warn(ctx, "non-page object in page tree (%s)", pdf_to_name(ctx, type));
if (*skip == 0)
{
@@ -200,8 +200,8 @@ pdf_lookup_page_loc_imp(fz_context *ctx, pdf_document *doc, pdf_obj *node, int *
pdf_obj *
pdf_lookup_page_loc(fz_context *ctx, pdf_document *doc, int needle, pdf_obj **parentp, int *indexp)
{
- pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
- pdf_obj *node = pdf_dict_get(ctx, root, PDF_NAME_Pages);
+ pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
+ pdf_obj *node = pdf_dict_get(ctx, root, PDF_NAME(Pages));
int skip = needle;
pdf_obj *hit;
@@ -223,16 +223,16 @@ pdf_lookup_page_obj(fz_context *ctx, pdf_document *doc, int needle)
static int
pdf_count_pages_before_kid(fz_context *ctx, pdf_document *doc, pdf_obj *parent, int kid_num)
{
- pdf_obj *kids = pdf_dict_get(ctx, parent, PDF_NAME_Kids);
+ pdf_obj *kids = pdf_dict_get(ctx, parent, PDF_NAME(Kids));
int i, total = 0, len = pdf_array_len(ctx, kids);
for (i = 0; i < len; i++)
{
pdf_obj *kid = pdf_array_get(ctx, kids, i);
if (pdf_to_num(ctx, kid) == kid_num)
return total;
- if (pdf_name_eq(ctx, pdf_dict_get(ctx, kid, PDF_NAME_Type), PDF_NAME_Pages))
+ if (pdf_name_eq(ctx, pdf_dict_get(ctx, kid, PDF_NAME(Type)), PDF_NAME(Pages)))
{
- pdf_obj *count = pdf_dict_get(ctx, kid, PDF_NAME_Count);
+ pdf_obj *count = pdf_dict_get(ctx, kid, PDF_NAME(Count));
int n = pdf_to_int(ctx, count);
if (!pdf_is_int(ctx, count) || n < 0)
fz_throw(ctx, FZ_ERROR_GENERIC, "illegal or missing count in pages tree");
@@ -251,10 +251,10 @@ pdf_lookup_page_number_slow(fz_context *ctx, pdf_document *doc, pdf_obj *node)
int total = 0;
pdf_obj *parent, *parent2;
- if (!pdf_name_eq(ctx, pdf_dict_get(ctx, node, PDF_NAME_Type), PDF_NAME_Page))
+ if (!pdf_name_eq(ctx, pdf_dict_get(ctx, node, PDF_NAME(Type)), PDF_NAME(Page)))
fz_throw(ctx, FZ_ERROR_GENERIC, "invalid page object");
- parent2 = parent = pdf_dict_get(ctx, node, PDF_NAME_Parent);
+ parent2 = parent = pdf_dict_get(ctx, node, PDF_NAME(Parent));
fz_var(parent);
fz_try(ctx)
{
@@ -264,7 +264,7 @@ pdf_lookup_page_number_slow(fz_context *ctx, pdf_document *doc, pdf_obj *node)
fz_throw(ctx, FZ_ERROR_GENERIC, "cycle in page tree (parents)");
total += pdf_count_pages_before_kid(ctx, doc, parent, needle);
needle = pdf_to_num(ctx, parent);
- parent = pdf_dict_get(ctx, parent, PDF_NAME_Parent);
+ parent = pdf_dict_get(ctx, parent, PDF_NAME(Parent));
}
}
fz_always(ctx)
@@ -275,7 +275,7 @@ pdf_lookup_page_number_slow(fz_context *ctx, pdf_document *doc, pdf_obj *node)
pdf_unmark_obj(ctx, parent2);
if (parent2 == parent)
break;
- parent2 = pdf_dict_get(ctx, parent2, PDF_NAME_Parent);
+ parent2 = pdf_dict_get(ctx, parent2, PDF_NAME(Parent));
}
}
fz_catch(ctx)
@@ -359,7 +359,7 @@ pdf_lookup_inherited_page_item(fz_context *ctx, pdf_obj *node, pdf_obj *key)
break;
if (pdf_mark_obj(ctx, node))
fz_throw(ctx, FZ_ERROR_GENERIC, "cycle in page tree (parents)");
- node = pdf_dict_get(ctx, node, PDF_NAME_Parent);
+ node = pdf_dict_get(ctx, node, PDF_NAME(Parent));
}
while (node);
}
@@ -370,7 +370,7 @@ pdf_lookup_inherited_page_item(fz_context *ctx, pdf_obj *node, pdf_obj *key)
pdf_unmark_obj(ctx, node2);
if (node2 == node)
break;
- node2 = pdf_dict_get(ctx, node2, PDF_NAME_Parent);
+ node2 = pdf_dict_get(ctx, node2, PDF_NAME(Parent));
}
while (node2);
}
@@ -393,10 +393,10 @@ pdf_flatten_inheritable_page_item(fz_context *ctx, pdf_obj *page, pdf_obj *key)
void
pdf_flatten_inheritable_page_items(fz_context *ctx, pdf_obj *page)
{
- pdf_flatten_inheritable_page_item(ctx, page, PDF_NAME_MediaBox);
- pdf_flatten_inheritable_page_item(ctx, page, PDF_NAME_CropBox);
- pdf_flatten_inheritable_page_item(ctx, page, PDF_NAME_Rotate);
- pdf_flatten_inheritable_page_item(ctx, page, PDF_NAME_Resources);
+ pdf_flatten_inheritable_page_item(ctx, page, PDF_NAME(MediaBox));
+ pdf_flatten_inheritable_page_item(ctx, page, PDF_NAME(CropBox));
+ pdf_flatten_inheritable_page_item(ctx, page, PDF_NAME(Rotate));
+ pdf_flatten_inheritable_page_item(ctx, page, PDF_NAME(Resources));
}
/* We need to know whether to install a page-level transparency group */
@@ -406,8 +406,8 @@ static int pdf_resources_use_blending(fz_context *ctx, pdf_obj *rdb);
static int
pdf_extgstate_uses_blending(fz_context *ctx, pdf_obj *dict)
{
- pdf_obj *obj = pdf_dict_get(ctx, dict, PDF_NAME_BM);
- if (obj && !pdf_name_eq(ctx, obj, PDF_NAME_Normal))
+ pdf_obj *obj = pdf_dict_get(ctx, dict, PDF_NAME(BM));
+ if (obj && !pdf_name_eq(ctx, obj, PDF_NAME(Normal)))
return 1;
return 0;
}
@@ -416,18 +416,18 @@ static int
pdf_pattern_uses_blending(fz_context *ctx, pdf_obj *dict)
{
pdf_obj *obj;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Resources);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Resources));
if (pdf_resources_use_blending(ctx, obj))
return 1;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_ExtGState);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(ExtGState));
return pdf_extgstate_uses_blending(ctx, obj);
}
static int
pdf_xobject_uses_blending(fz_context *ctx, pdf_obj *dict)
{
- pdf_obj *obj = pdf_dict_get(ctx, dict, PDF_NAME_Resources);
- if (pdf_name_eq(ctx, pdf_dict_getp(ctx, dict, "Group/S"), PDF_NAME_Transparency))
+ pdf_obj *obj = pdf_dict_get(ctx, dict, PDF_NAME(Resources));
+ if (pdf_name_eq(ctx, pdf_dict_getp(ctx, dict, "Group/S"), PDF_NAME(Transparency)))
return 1;
return pdf_resources_use_blending(ctx, obj);
}
@@ -451,19 +451,19 @@ pdf_resources_use_blending(fz_context *ctx, pdf_obj *rdb)
fz_try(ctx)
{
- obj = pdf_dict_get(ctx, rdb, PDF_NAME_ExtGState);
+ obj = pdf_dict_get(ctx, rdb, PDF_NAME(ExtGState));
n = pdf_dict_len(ctx, obj);
for (i = 0; i < n; i++)
if (pdf_extgstate_uses_blending(ctx, pdf_dict_get_val(ctx, obj, i)))
goto found;
- obj = pdf_dict_get(ctx, rdb, PDF_NAME_Pattern);
+ obj = pdf_dict_get(ctx, rdb, PDF_NAME(Pattern));
n = pdf_dict_len(ctx, obj);
for (i = 0; i < n; i++)
if (pdf_pattern_uses_blending(ctx, pdf_dict_get_val(ctx, obj, i)))
goto found;
- obj = pdf_dict_get(ctx, rdb, PDF_NAME_XObject);
+ obj = pdf_dict_get(ctx, rdb, PDF_NAME(XObject));
n = pdf_dict_len(ctx, obj);
for (i = 0; i < n; i++)
if (pdf_xobject_uses_blending(ctx, pdf_dict_get_val(ctx, obj, i)))
@@ -492,7 +492,7 @@ static int pdf_resources_use_overprint(fz_context *ctx, pdf_obj *rdb);
static int
pdf_extgstate_uses_overprint(fz_context *ctx, pdf_obj *dict)
{
- pdf_obj *obj = pdf_dict_get(ctx, dict, PDF_NAME_OP);
+ pdf_obj *obj = pdf_dict_get(ctx, dict, PDF_NAME(OP));
if (obj && pdf_to_bool(ctx, obj))
return 1;
return 0;
@@ -502,17 +502,17 @@ static int
pdf_pattern_uses_overprint(fz_context *ctx, pdf_obj *dict)
{
pdf_obj *obj;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Resources);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Resources));
if (pdf_resources_use_overprint(ctx, obj))
return 1;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_ExtGState);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(ExtGState));
return pdf_extgstate_uses_overprint(ctx, obj);
}
static int
pdf_xobject_uses_overprint(fz_context *ctx, pdf_obj *dict)
{
- pdf_obj *obj = pdf_dict_get(ctx, dict, PDF_NAME_Resources);
+ pdf_obj *obj = pdf_dict_get(ctx, dict, PDF_NAME(Resources));
return pdf_resources_use_overprint(ctx, obj);
}
@@ -535,19 +535,19 @@ pdf_resources_use_overprint(fz_context *ctx, pdf_obj *rdb)
fz_try(ctx)
{
- obj = pdf_dict_get(ctx, rdb, PDF_NAME_ExtGState);
+ obj = pdf_dict_get(ctx, rdb, PDF_NAME(ExtGState));
n = pdf_dict_len(ctx, obj);
for (i = 0; i < n; i++)
if (pdf_extgstate_uses_overprint(ctx, pdf_dict_get_val(ctx, obj, i)))
goto found;
- obj = pdf_dict_get(ctx, rdb, PDF_NAME_Pattern);
+ obj = pdf_dict_get(ctx, rdb, PDF_NAME(Pattern));
n = pdf_dict_len(ctx, obj);
for (i = 0; i < n; i++)
if (pdf_pattern_uses_overprint(ctx, pdf_dict_get_val(ctx, obj, i)))
goto found;
- obj = pdf_dict_get(ctx, rdb, PDF_NAME_XObject);
+ obj = pdf_dict_get(ctx, rdb, PDF_NAME(XObject));
n = pdf_dict_len(ctx, obj);
for (i = 0; i < n; i++)
if (pdf_xobject_uses_overprint(ctx, pdf_dict_get_val(ctx, obj, i)))
@@ -576,46 +576,46 @@ pdf_page_presentation(fz_context *ctx, pdf_page *page, fz_transition *transition
{
pdf_obj *obj, *transdict;
- *duration = pdf_to_real(ctx, pdf_dict_get(ctx, page->obj, PDF_NAME_Dur));
+ *duration = pdf_to_real(ctx, pdf_dict_get(ctx, page->obj, PDF_NAME(Dur)));
- transdict = pdf_dict_get(ctx, page->obj, PDF_NAME_Trans);
+ transdict = pdf_dict_get(ctx, page->obj, PDF_NAME(Trans));
if (!transdict)
return NULL;
- obj = pdf_dict_get(ctx, transdict, PDF_NAME_D);
+ obj = pdf_dict_get(ctx, transdict, PDF_NAME(D));
transition->duration = (obj ? pdf_to_real(ctx, obj) : 1);
- transition->vertical = !pdf_name_eq(ctx, pdf_dict_get(ctx, transdict, PDF_NAME_Dm), PDF_NAME_H);
- transition->outwards = !pdf_name_eq(ctx, pdf_dict_get(ctx, transdict, PDF_NAME_M), PDF_NAME_I);
+ transition->vertical = !pdf_name_eq(ctx, pdf_dict_get(ctx, transdict, PDF_NAME(Dm)), PDF_NAME(H));
+ transition->outwards = !pdf_name_eq(ctx, pdf_dict_get(ctx, transdict, PDF_NAME(M)), PDF_NAME(I));
/* FIXME: If 'Di' is None, it should be handled differently, but
* this only affects Fly, and we don't implement that currently. */
- transition->direction = (pdf_to_int(ctx, pdf_dict_get(ctx, transdict, PDF_NAME_Di)));
+ transition->direction = (pdf_to_int(ctx, pdf_dict_get(ctx, transdict, PDF_NAME(Di))));
/* FIXME: Read SS for Fly when we implement it */
/* FIXME: Read B for Fly when we implement it */
- obj = pdf_dict_get(ctx, transdict, PDF_NAME_S);
- if (pdf_name_eq(ctx, obj, PDF_NAME_Split))
+ obj = pdf_dict_get(ctx, transdict, PDF_NAME(S));
+ if (pdf_name_eq(ctx, obj, PDF_NAME(Split)))
transition->type = FZ_TRANSITION_SPLIT;
- else if (pdf_name_eq(ctx, obj, PDF_NAME_Blinds))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(Blinds)))
transition->type = FZ_TRANSITION_BLINDS;
- else if (pdf_name_eq(ctx, obj, PDF_NAME_Box))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(Box)))
transition->type = FZ_TRANSITION_BOX;
- else if (pdf_name_eq(ctx, obj, PDF_NAME_Wipe))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(Wipe)))
transition->type = FZ_TRANSITION_WIPE;
- else if (pdf_name_eq(ctx, obj, PDF_NAME_Dissolve))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(Dissolve)))
transition->type = FZ_TRANSITION_DISSOLVE;
- else if (pdf_name_eq(ctx, obj, PDF_NAME_Glitter))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(Glitter)))
transition->type = FZ_TRANSITION_GLITTER;
- else if (pdf_name_eq(ctx, obj, PDF_NAME_Fly))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(Fly)))
transition->type = FZ_TRANSITION_FLY;
- else if (pdf_name_eq(ctx, obj, PDF_NAME_Push))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(Push)))
transition->type = FZ_TRANSITION_PUSH;
- else if (pdf_name_eq(ctx, obj, PDF_NAME_Cover))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(Cover)))
transition->type = FZ_TRANSITION_COVER;
- else if (pdf_name_eq(ctx, obj, PDF_NAME_Uncover))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(Uncover)))
transition->type = FZ_TRANSITION_UNCOVER;
- else if (pdf_name_eq(ctx, obj, PDF_NAME_Fade))
+ else if (pdf_name_eq(ctx, obj, PDF_NAME(Fade)))
transition->type = FZ_TRANSITION_FADE;
else
transition->type = FZ_TRANSITION_NONE;
@@ -641,19 +641,19 @@ pdf_load_links(fz_context *ctx, pdf_page *page)
pdf_obj *
pdf_page_resources(fz_context *ctx, pdf_page *page)
{
- return pdf_lookup_inherited_page_item(ctx, page->obj, PDF_NAME_Resources);
+ return pdf_lookup_inherited_page_item(ctx, page->obj, PDF_NAME(Resources));
}
pdf_obj *
pdf_page_contents(fz_context *ctx, pdf_page *page)
{
- return pdf_dict_get(ctx, page->obj, PDF_NAME_Contents);
+ return pdf_dict_get(ctx, page->obj, PDF_NAME(Contents));
}
pdf_obj *
pdf_page_group(fz_context *ctx, pdf_page *page)
{
- return pdf_dict_get(ctx, page->obj, PDF_NAME_Group);
+ return pdf_dict_get(ctx, page->obj, PDF_NAME(Group));
}
void
@@ -668,11 +668,11 @@ pdf_page_obj_transform(fz_context *ctx, pdf_obj *pageobj, fz_rect *page_mediabox
if (!page_mediabox)
page_mediabox = &pagebox;
- obj = pdf_dict_get(ctx, pageobj, PDF_NAME_UserUnit);
+ obj = pdf_dict_get(ctx, pageobj, PDF_NAME(UserUnit));
if (pdf_is_real(ctx, obj))
userunit = pdf_to_real(ctx, obj);
- pdf_to_rect(ctx, pdf_lookup_inherited_page_item(ctx, pageobj, PDF_NAME_MediaBox), &mediabox);
+ pdf_to_rect(ctx, pdf_lookup_inherited_page_item(ctx, pageobj, PDF_NAME(MediaBox)), &mediabox);
if (fz_is_empty_rect(&mediabox))
{
mediabox.x0 = 0;
@@ -681,7 +681,7 @@ pdf_page_obj_transform(fz_context *ctx, pdf_obj *pageobj, fz_rect *page_mediabox
mediabox.y1 = 792;
}
- pdf_to_rect(ctx, pdf_lookup_inherited_page_item(ctx, pageobj, PDF_NAME_CropBox), &cropbox);
+ pdf_to_rect(ctx, pdf_lookup_inherited_page_item(ctx, pageobj, PDF_NAME(CropBox)), &cropbox);
if (!fz_is_empty_rect(&cropbox))
fz_intersect_rect(&mediabox, &cropbox);
@@ -693,7 +693,7 @@ pdf_page_obj_transform(fz_context *ctx, pdf_obj *pageobj, fz_rect *page_mediabox
if (page_mediabox->x1 - page_mediabox->x0 < 1 || page_mediabox->y1 - page_mediabox->y0 < 1)
*page_mediabox = fz_unit_rect;
- rotate = pdf_to_int(ctx, pdf_lookup_inherited_page_item(ctx, pageobj, PDF_NAME_Rotate));
+ rotate = pdf_to_int(ctx, pdf_lookup_inherited_page_item(ctx, pageobj, PDF_NAME(Rotate)));
/* Snap page rotation to 0, 90, 180 or 270 */
if (rotate < 0)
@@ -732,7 +732,7 @@ find_seps(fz_context *ctx, fz_separations **seps, pdf_obj *obj)
int i, n;
pdf_obj *nameobj = pdf_array_get(ctx, obj, 0);
- if (pdf_name_eq(ctx, nameobj, PDF_NAME_Separation))
+ if (pdf_name_eq(ctx, nameobj, PDF_NAME(Separation)))
{
fz_colorspace *cs;
const char *name = pdf_to_name(ctx, pdf_array_get(ctx, obj, 1));
@@ -759,15 +759,15 @@ find_seps(fz_context *ctx, fz_separations **seps, pdf_obj *obj)
fz_add_separation(ctx, *seps, name, cs, 0);
fz_drop_colorspace(ctx, cs);
}
- else if (pdf_name_eq(ctx, nameobj, PDF_NAME_Indexed))
+ else if (pdf_name_eq(ctx, nameobj, PDF_NAME(Indexed)))
{
find_seps(ctx, seps, pdf_array_get(ctx, obj, 1));
}
- else if (pdf_name_eq(ctx, nameobj, PDF_NAME_DeviceN))
+ else if (pdf_name_eq(ctx, nameobj, PDF_NAME(DeviceN)))
{
/* If the separation colorants exists for this DeviceN color space
* add those prior to our search for DeviceN color */
- pdf_obj *cols = pdf_dict_get(ctx, pdf_array_get(ctx, obj, 4), PDF_NAME_Colorants);
+ pdf_obj *cols = pdf_dict_get(ctx, pdf_array_get(ctx, obj, 4), PDF_NAME(Colorants));
n = pdf_dict_len(ctx, cols);
for (i = 0; i < n; i++)
find_seps(ctx, seps, pdf_dict_get_val(ctx, cols, i));
@@ -781,7 +781,7 @@ find_devn(fz_context *ctx, fz_separations **seps, pdf_obj *obj)
pdf_obj *arr;
pdf_obj *nameobj = pdf_array_get(ctx, obj, 0);
- if (!pdf_name_eq(ctx, nameobj, PDF_NAME_DeviceN))
+ if (!pdf_name_eq(ctx, nameobj, PDF_NAME(DeviceN)))
return;
arr = pdf_array_get(ctx, obj, 1);
@@ -860,14 +860,14 @@ scan_page_seps(fz_context *ctx, pdf_obj *res, fz_separations **seps, res_finder_
fz_try(ctx)
{
- search_res(ctx, seps, pdf_dict_get(ctx, res, PDF_NAME_ColorSpace), fn);
+ search_res(ctx, seps, pdf_dict_get(ctx, res, PDF_NAME(ColorSpace)), fn);
- sh = pdf_dict_get(ctx, res, PDF_NAME_Shading);
+ sh = pdf_dict_get(ctx, res, PDF_NAME(Shading));
len = pdf_dict_len(ctx, sh);
for (i = 0; i < len; i++)
- fn(ctx, seps, pdf_dict_get(ctx, pdf_dict_get_val(ctx, sh, i), PDF_NAME_ColorSpace));
+ fn(ctx, seps, pdf_dict_get(ctx, pdf_dict_get_val(ctx, sh, i), PDF_NAME(ColorSpace)));
- forms = pdf_dict_get(ctx, res, PDF_NAME_XObject);
+ forms = pdf_dict_get(ctx, res, PDF_NAME(XObject));
len = pdf_dict_len(ctx, forms);
/* Recurse on the forms. Throw if we cycle */
@@ -878,8 +878,8 @@ scan_page_seps(fz_context *ctx, pdf_obj *res, fz_separations **seps, res_finder_
if (pdf_mark_obj(ctx, xo))
fz_throw(ctx, FZ_ERROR_GENERIC, "cycle in forms");
- scan_page_seps(ctx, pdf_dict_get(ctx, xo, PDF_NAME_Resources), seps, fn);
- fn(ctx, seps, pdf_dict_get(ctx, xo, PDF_NAME_ColorSpace));
+ scan_page_seps(ctx, pdf_dict_get(ctx, xo, PDF_NAME(Resources)), seps, fn);
+ fn(ctx, seps, pdf_dict_get(ctx, xo, PDF_NAME(ColorSpace)));
pdf_unmark_obj(ctx, xo);
xo = NULL;
}
@@ -973,7 +973,7 @@ pdf_load_default_colorspaces_imp(fz_context *ctx, fz_default_colorspaces *defaul
/* The spec says to ignore any colors we can't understand */
fz_try(ctx)
{
- cs_obj = pdf_dict_get(ctx, obj, PDF_NAME_DefaultGray);
+ cs_obj = pdf_dict_get(ctx, obj, PDF_NAME(DefaultGray));
if (cs_obj)
{
fz_colorspace *cs = pdf_load_colorspace(ctx, cs_obj);
@@ -989,7 +989,7 @@ pdf_load_default_colorspaces_imp(fz_context *ctx, fz_default_colorspaces *defaul
fz_try(ctx)
{
- cs_obj = pdf_dict_get(ctx, obj, PDF_NAME_DefaultRGB);
+ cs_obj = pdf_dict_get(ctx, obj, PDF_NAME(DefaultRGB));
if (cs_obj)
{
fz_colorspace *cs = pdf_load_colorspace(ctx, cs_obj);
@@ -1005,7 +1005,7 @@ pdf_load_default_colorspaces_imp(fz_context *ctx, fz_default_colorspaces *defaul
fz_try(ctx)
{
- cs_obj = pdf_dict_get(ctx, obj, PDF_NAME_DefaultCMYK);
+ cs_obj = pdf_dict_get(ctx, obj, PDF_NAME(DefaultCMYK));
if (cs_obj)
{
fz_colorspace *cs = pdf_load_colorspace(ctx, cs_obj);
@@ -1030,7 +1030,7 @@ pdf_load_default_colorspaces(fz_context *ctx, pdf_document *doc, pdf_page *page)
default_cs = fz_new_default_colorspaces(ctx);
res = pdf_page_resources(ctx, page);
- obj = pdf_dict_get(ctx, res, PDF_NAME_ColorSpace);
+ obj = pdf_dict_get(ctx, res, PDF_NAME(ColorSpace));
if (obj)
pdf_load_default_colorspaces_imp(ctx, default_cs, obj);
@@ -1047,7 +1047,7 @@ pdf_update_default_colorspaces(fz_context *ctx, fz_default_colorspaces *old_cs,
pdf_obj *obj;
fz_default_colorspaces *new_cs;
- obj = pdf_dict_get(ctx, res, PDF_NAME_ColorSpace);
+ obj = pdf_dict_get(ctx, res, PDF_NAME(ColorSpace));
if (!obj)
return fz_keep_default_colorspaces(ctx, old_cs);
@@ -1079,7 +1079,7 @@ pdf_load_page(fz_context *ctx, pdf_document *doc, int number)
/* Pre-load annotations and links */
fz_try(ctx)
{
- obj = pdf_dict_get(ctx, pageobj, PDF_NAME_Annots);
+ obj = pdf_dict_get(ctx, pageobj, PDF_NAME(Annots));
if (obj)
{
fz_rect page_mediabox;
@@ -1105,7 +1105,7 @@ pdf_load_page(fz_context *ctx, pdf_document *doc, int number)
fz_try(ctx)
{
pdf_obj *resources = pdf_page_resources(ctx, page);
- if (pdf_name_eq(ctx, pdf_dict_getp(ctx, pageobj, "Group/S"), PDF_NAME_Transparency))
+ if (pdf_name_eq(ctx, pdf_dict_getp(ctx, pageobj, "Group/S"), PDF_NAME(Transparency)))
page->transparency = 1;
else if (pdf_resources_use_blending(ctx, resources))
page->transparency = 1;
@@ -1138,14 +1138,14 @@ pdf_delete_page(fz_context *ctx, pdf_document *doc, int at)
int i;
pdf_lookup_page_loc(ctx, doc, at, &parent, &i);
- kids = pdf_dict_get(ctx, parent, PDF_NAME_Kids);
+ kids = pdf_dict_get(ctx, parent, PDF_NAME(Kids));
pdf_array_delete(ctx, kids, i);
while (parent)
{
- int count = pdf_to_int(ctx, pdf_dict_get(ctx, parent, PDF_NAME_Count));
- pdf_dict_put_int(ctx, parent, PDF_NAME_Count, count - 1);
- parent = pdf_dict_get(ctx, parent, PDF_NAME_Parent);
+ int count = pdf_to_int(ctx, pdf_dict_get(ctx, parent, PDF_NAME(Count)));
+ pdf_dict_put_int(ctx, parent, PDF_NAME(Count), count - 1);
+ parent = pdf_dict_get(ctx, parent, PDF_NAME(Parent));
}
}
@@ -1171,19 +1171,19 @@ pdf_add_page(fz_context *ctx, pdf_document *doc, const fz_rect *mediabox, int ro
pdf_obj *page_obj = pdf_new_dict(ctx, doc, 5);
fz_try(ctx)
{
- pdf_dict_put(ctx, page_obj, PDF_NAME_Type, PDF_NAME_Page);
- pdf_dict_put_rect(ctx, page_obj, PDF_NAME_MediaBox, mediabox);
- pdf_dict_put_int(ctx, page_obj, PDF_NAME_Rotate, rotate);
+ pdf_dict_put(ctx, page_obj, PDF_NAME(Type), PDF_NAME(Page));
+ pdf_dict_put_rect(ctx, page_obj, PDF_NAME(MediaBox), mediabox);
+ pdf_dict_put_int(ctx, page_obj, PDF_NAME(Rotate), rotate);
if (pdf_is_indirect(ctx, resources))
- pdf_dict_put(ctx, page_obj, PDF_NAME_Resources, resources);
+ pdf_dict_put(ctx, page_obj, PDF_NAME(Resources), resources);
else if (pdf_is_dict(ctx, resources))
- pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Resources, pdf_add_object(ctx, doc, resources));
+ pdf_dict_put_drop(ctx, page_obj, PDF_NAME(Resources), pdf_add_object(ctx, doc, resources));
else
- pdf_dict_put_dict(ctx, page_obj, PDF_NAME_Resources, 1);
+ pdf_dict_put_dict(ctx, page_obj, PDF_NAME(Resources), 1);
if (contents)
- pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Contents, pdf_add_stream(ctx, doc, contents, NULL, 0));
+ pdf_dict_put_drop(ctx, page_obj, PDF_NAME(Contents), pdf_add_stream(ctx, doc, contents, NULL, 0));
}
fz_catch(ctx)
{
@@ -1209,11 +1209,11 @@ pdf_insert_page(fz_context *ctx, pdf_document *doc, int at, pdf_obj *page_ref)
if (count == 0)
{
- pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
- parent = pdf_dict_get(ctx, root, PDF_NAME_Pages);
+ pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
+ parent = pdf_dict_get(ctx, root, PDF_NAME(Pages));
if (!parent)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find page tree");
- kids = pdf_dict_get(ctx, parent, PDF_NAME_Kids);
+ kids = pdf_dict_get(ctx, parent, PDF_NAME(Kids));
if (!kids)
fz_throw(ctx, FZ_ERROR_GENERIC, "malformed page tree");
pdf_array_insert(ctx, kids, page_ref, 0);
@@ -1222,24 +1222,24 @@ pdf_insert_page(fz_context *ctx, pdf_document *doc, int at, pdf_obj *page_ref)
{
/* append after last page */
pdf_lookup_page_loc(ctx, doc, count - 1, &parent, &i);
- kids = pdf_dict_get(ctx, parent, PDF_NAME_Kids);
+ kids = pdf_dict_get(ctx, parent, PDF_NAME(Kids));
pdf_array_insert(ctx, kids, page_ref, i + 1);
}
else
{
/* insert before found page */
pdf_lookup_page_loc(ctx, doc, at, &parent, &i);
- kids = pdf_dict_get(ctx, parent, PDF_NAME_Kids);
+ kids = pdf_dict_get(ctx, parent, PDF_NAME(Kids));
pdf_array_insert(ctx, kids, page_ref, i);
}
- pdf_dict_put(ctx, page_ref, PDF_NAME_Parent, parent);
+ pdf_dict_put(ctx, page_ref, PDF_NAME(Parent), parent);
/* Adjust page counts */
while (parent)
{
- count = pdf_to_int(ctx, pdf_dict_get(ctx, parent, PDF_NAME_Count));
- pdf_dict_put_int(ctx, parent, PDF_NAME_Count, count + 1);
- parent = pdf_dict_get(ctx, parent, PDF_NAME_Parent);
+ count = pdf_to_int(ctx, pdf_dict_get(ctx, parent, PDF_NAME(Count)));
+ pdf_dict_put_int(ctx, parent, PDF_NAME(Count), count + 1);
+ parent = pdf_dict_get(ctx, parent, PDF_NAME(Parent));
}
}
diff --git a/source/pdf/pdf-parse.c b/source/pdf/pdf-parse.c
index 827fd945..b1d012ef 100644
--- a/source/pdf/pdf-parse.c
+++ b/source/pdf/pdf-parse.c
@@ -442,11 +442,11 @@ pdf_parse_array(fz_context *ctx, pdf_document *doc, fz_stream *file, pdf_lexbuf
pdf_array_push_bool(ctx, ary, 0);
break;
case PDF_TOK_NULL:
- pdf_array_push(ctx, ary, PDF_OBJ_NULL);
+ pdf_array_push(ctx, ary, PDF_NULL);
break;
default:
- pdf_array_push(ctx, ary, PDF_OBJ_NULL);
+ pdf_array_push(ctx, ary, PDF_NULL);
break;
}
}
diff --git a/source/pdf/pdf-pattern.c b/source/pdf/pdf-pattern.c
index 7523c5bc..e1e6f08f 100644
--- a/source/pdf/pdf-pattern.c
+++ b/source/pdf/pdf-pattern.c
@@ -53,20 +53,20 @@ pdf_load_pattern(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
/* Store pattern now, to avoid possible recursion if objects refer back to this one */
pdf_store_item(ctx, dict, pat, pdf_pattern_size(pat));
- pat->ismask = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_PaintType)) == 2;
- pat->xstep = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME_XStep));
- pat->ystep = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME_YStep));
+ pat->ismask = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(PaintType))) == 2;
+ pat->xstep = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(XStep)));
+ pat->ystep = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(YStep)));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_BBox);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(BBox));
pdf_to_rect(ctx, obj, &pat->bbox);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Matrix);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix));
if (obj)
pdf_to_matrix(ctx, obj, &pat->matrix);
else
pat->matrix = fz_identity;
- pat->resources = pdf_dict_get(ctx, dict, PDF_NAME_Resources);
+ pat->resources = pdf_dict_get(ctx, dict, PDF_NAME(Resources));
if (pat->resources)
pdf_keep_obj(ctx, pat->resources);
diff --git a/source/pdf/pdf-portfolio.c b/source/pdf/pdf-portfolio.c
index c0eca9ec..65610013 100644
--- a/source/pdf/pdf-portfolio.c
+++ b/source/pdf/pdf-portfolio.c
@@ -23,20 +23,20 @@ load_portfolio(fz_context *ctx, pdf_document *doc)
int i, n;
pdf_portfolio **pp;
- obj = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Collection, PDF_NAME_Schema, NULL);
+ obj = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), PDF_NAME(Collection), PDF_NAME(Schema), NULL);
n = pdf_dict_len(ctx, obj);
for (i = 0; i < n; i++)
{
pdf_obj *k = pdf_dict_get_key(ctx, obj, i);
pdf_obj *v = pdf_dict_get_val(ctx, obj, i);
- int sort = pdf_to_int(ctx, pdf_dict_get(ctx, v, PDF_NAME_O));
- pdf_obj *eo = pdf_dict_get(ctx, v, PDF_NAME_E);
+ int sort = pdf_to_int(ctx, pdf_dict_get(ctx, v, PDF_NAME(O)));
+ pdf_obj *eo = pdf_dict_get(ctx, v, PDF_NAME(E));
int editable = eo ? pdf_to_bool(ctx, eo) : 0;
- pdf_obj *vo = pdf_dict_get(ctx, v, PDF_NAME_V);
+ pdf_obj *vo = pdf_dict_get(ctx, v, PDF_NAME(V));
int visible = vo ? pdf_to_bool(ctx, vo) : 1;
- const char *subtype = pdf_to_name(ctx, pdf_dict_get(ctx, v, PDF_NAME_Subtype));
- pdf_obj *name = pdf_dict_get(ctx, v, PDF_NAME_N);
+ const char *subtype = pdf_to_name(ctx, pdf_dict_get(ctx, v, PDF_NAME(Subtype)));
+ pdf_obj *name = pdf_dict_get(ctx, v, PDF_NAME(N));
pdf_portfolio *p = fz_malloc_struct(ctx, pdf_portfolio);
p->key = pdf_keep_obj(ctx, k);
p->val = pdf_keep_obj(ctx, v);
@@ -152,7 +152,7 @@ void pdf_reorder_portfolio_schema(fz_context *ctx, pdf_document *doc, int entry,
/* Rewrite the underlying orderings */
for (p = doc->portfolio, entry = 0; p; p = p->next, entry++)
- pdf_dict_put_int(ctx, p->val, PDF_NAME_O, entry);
+ pdf_dict_put_int(ctx, p->val, PDF_NAME(O), entry);
}
void pdf_rename_portfolio_schema(fz_context *ctx, pdf_document *doc, int entry, const char *name, int name_len)
@@ -176,7 +176,7 @@ void pdf_rename_portfolio_schema(fz_context *ctx, pdf_document *doc, int entry,
s = pdf_new_string(ctx, doc, name, name_len);
pdf_drop_obj(ctx, p->entry.name);
p->entry.name = s;
- pdf_dict_put(ctx, p->val, PDF_NAME_N, s);
+ pdf_dict_put(ctx, p->val, PDF_NAME(N), s);
}
typedef int (pdf_name_tree_map_fn)(fz_context *ctx, pdf_obj *container, pdf_obj *key, pdf_obj *val, void *arg);
@@ -196,7 +196,7 @@ do_name_tree_map(fz_context *ctx, pdf_obj *tree, pdf_name_tree_map_fn *fn, void
fz_try(ctx)
{
- pdf_obj *arr = pdf_dict_get(ctx, tree, PDF_NAME_Kids);
+ pdf_obj *arr = pdf_dict_get(ctx, tree, PDF_NAME(Kids));
n = pdf_array_len(ctx, arr);
for (i = n; i > 0;)
@@ -209,7 +209,7 @@ do_name_tree_map(fz_context *ctx, pdf_obj *tree, pdf_name_tree_map_fn *fn, void
}
}
- arr = pdf_dict_get(ctx, tree, PDF_NAME_Names);
+ arr = pdf_dict_get(ctx, tree, PDF_NAME(Names));
m = pdf_array_len(ctx, arr);
if (m & 1)
@@ -243,7 +243,7 @@ static int delete_from_node(fz_context *ctx, pdf_obj *container, pdf_obj *key, p
{
pdf_obj *delete_key = (pdf_obj *)arg;
- pdf_dict_del(ctx, pdf_dict_get(ctx, val, PDF_NAME_CI), delete_key);
+ pdf_dict_del(ctx, pdf_dict_get(ctx, val, PDF_NAME(CI)), delete_key);
return 0;
}
@@ -270,11 +270,11 @@ void pdf_delete_portfolio_schema(fz_context *ctx, pdf_document *doc, int entry)
*pp = p->next;
/* Delete the key from the schema */
- s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Collection, PDF_NAME_Schema, NULL);
+ s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), PDF_NAME(Collection), PDF_NAME(Schema), NULL);
pdf_dict_del(ctx, s, p->key);
/* Delete this entry from all the collection entries */
- s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Names, PDF_NAME_EmbeddedFiles, NULL);
+ s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), PDF_NAME(Names), PDF_NAME(EmbeddedFiles), NULL);
pdf_name_tree_map(ctx, s, delete_from_node, p->key);
pdf_drop_obj(ctx, p->entry.name);
@@ -325,10 +325,10 @@ void pdf_add_portfolio_schema(fz_context *ctx, pdf_document *doc, int entry, con
while (p);
sc = pdf_new_dict(ctx, doc, 4);
- pdf_dict_put_bool(ctx, sc, PDF_NAME_E, !!info->editable);
- pdf_dict_put_bool(ctx, sc, PDF_NAME_V, !!info->visible);
- pdf_dict_put_drop(ctx, sc, PDF_NAME_N, info->name);
- pdf_dict_put(ctx, sc, PDF_NAME_Subtype, PDF_NAME_S);
+ pdf_dict_put_bool(ctx, sc, PDF_NAME(E), !!info->editable);
+ pdf_dict_put_bool(ctx, sc, PDF_NAME(V), !!info->visible);
+ pdf_dict_put_drop(ctx, sc, PDF_NAME(N), info->name);
+ pdf_dict_put(ctx, sc, PDF_NAME(Subtype), PDF_NAME(S));
/* Add to our linked list (in the correct sorted place) */
p = fz_malloc_struct(ctx, pdf_portfolio);
@@ -340,13 +340,13 @@ void pdf_add_portfolio_schema(fz_context *ctx, pdf_document *doc, int entry, con
*pp = p;
/* Add the key to the schema */
- s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Collection, PDF_NAME_Schema, NULL);
+ s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), PDF_NAME(Collection), PDF_NAME(Schema), NULL);
pdf_dict_put(ctx, s, num_name, sc);
/* Renumber the schema entries */
for (num = 0, p = doc->portfolio; p; num++, p = p->next)
{
- pdf_dict_put_int(ctx, p->val, PDF_NAME_O, num);
+ pdf_dict_put_int(ctx, p->val, PDF_NAME(O), num);
p->sort = num;
}
}
@@ -385,7 +385,7 @@ int pdf_count_portfolio_entries(fz_context *ctx, pdf_document *doc)
if (doc->portfolio == NULL)
load_portfolio(ctx, doc);
- s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Names, PDF_NAME_EmbeddedFiles, NULL);
+ s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), PDF_NAME(Names), PDF_NAME(EmbeddedFiles), NULL);
count = 0;
pdf_name_tree_map(ctx, s, count_nodes, &count);
@@ -439,7 +439,7 @@ pdf_obj *pdf_portfolio_entry_obj_name(fz_context *ctx, pdf_document *doc, int en
if (doc->portfolio == NULL)
load_portfolio(ctx, doc);
- s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Names, PDF_NAME_EmbeddedFiles, NULL);
+ s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), PDF_NAME(Names), PDF_NAME(EmbeddedFiles), NULL);
data.count = entry;
data.key = NULL;
data.val = NULL;
@@ -469,7 +469,7 @@ fz_buffer *pdf_portfolio_entry(fz_context *ctx, pdf_document *doc, int entry)
{
pdf_obj *obj = pdf_portfolio_entry_obj(ctx, doc, entry);
- return pdf_load_stream(ctx, pdf_dict_getl(ctx, obj, PDF_NAME_EF, PDF_NAME_F, NULL));
+ return pdf_load_stream(ctx, pdf_dict_getl(ctx, obj, PDF_NAME(EF), PDF_NAME(F), NULL));
}
pdf_obj *pdf_portfolio_entry_info(fz_context *ctx, pdf_document *doc, int entry, int schema_entry)
@@ -496,21 +496,21 @@ pdf_obj *pdf_portfolio_entry_info(fz_context *ctx, pdf_document *doc, int entry,
lookup = NULL;
break;
case PDF_SCHEMA_FILENAME:
- lookup = PDF_NAME_UF;
+ lookup = PDF_NAME(UF);
break;
case PDF_SCHEMA_DESC:
- lookup = PDF_NAME_Desc;
+ lookup = PDF_NAME(Desc);
break;
case PDF_SCHEMA_MODDATE:
- lookup = PDF_NAME_ModDate;
+ lookup = PDF_NAME(ModDate);
ef = 1;
break;
case PDF_SCHEMA_CREATIONDATE:
- lookup = PDF_NAME_CreationDate;
+ lookup = PDF_NAME(CreationDate);
ef = 1;
break;
case PDF_SCHEMA_SIZE:
- lookup = PDF_NAME_Size;
+ lookup = PDF_NAME(Size);
ef = 1;
break;
}
@@ -519,13 +519,13 @@ pdf_obj *pdf_portfolio_entry_info(fz_context *ctx, pdf_document *doc, int entry,
pdf_obj *res;
if (ef)
- obj = pdf_dict_getl(ctx, obj, PDF_NAME_EF, PDF_NAME_F, PDF_NAME_Params, NULL);
+ obj = pdf_dict_getl(ctx, obj, PDF_NAME(EF), PDF_NAME(F), PDF_NAME(Params), NULL);
res = pdf_dict_get(ctx, obj, lookup);
- if (res == NULL && pdf_name_eq(ctx, lookup, PDF_NAME_UF))
- res = pdf_dict_get(ctx, obj, PDF_NAME_F);
+ if (res == NULL && pdf_name_eq(ctx, lookup, PDF_NAME(UF)))
+ res = pdf_dict_get(ctx, obj, PDF_NAME(F));
return res;
}
- return pdf_dict_getl(ctx, obj, PDF_NAME_CI, p->key, NULL);
+ return pdf_dict_getl(ctx, obj, PDF_NAME(CI), p->key, NULL);
}
typedef struct
@@ -583,21 +583,21 @@ pdf_name_tree_insert(fz_context *ctx, pdf_document *doc, pdf_obj *tree, pdf_obj
if (!data.found)
{
/* Completely empty name tree! */
- pdf_dict_put_array(ctx, tree, PDF_NAME_Names, 2);
- pdf_dict_put_array(ctx, tree, PDF_NAME_Limits, 2);
+ pdf_dict_put_array(ctx, tree, PDF_NAME(Names), 2);
+ pdf_dict_put_array(ctx, tree, PDF_NAME(Limits), 2);
data.found = tree;
data.found_index = 0;
}
- names = pdf_dict_get(ctx, data.found, PDF_NAME_Names);
+ names = pdf_dict_get(ctx, data.found, PDF_NAME(Names));
if (names == NULL)
- names = pdf_dict_put_array(ctx, data.found, PDF_NAME_Names, 2);
+ names = pdf_dict_put_array(ctx, data.found, PDF_NAME(Names), 2);
pdf_array_insert(ctx, names, key, 2*data.found_index);
pdf_array_insert(ctx, names, val, 2*data.found_index+1);
- limits = pdf_dict_get(ctx, data.found, PDF_NAME_Limits);
+ limits = pdf_dict_get(ctx, data.found, PDF_NAME(Limits));
if (limits == NULL)
- limits = pdf_dict_put_array(ctx, data.found, PDF_NAME_Limits, 2);
+ limits = pdf_dict_put_array(ctx, data.found, PDF_NAME(Limits), 2);
limit0 = pdf_array_get(ctx, limits, 0);
limit1 = pdf_array_get(ctx, limits, 1);
if (!pdf_is_string(ctx, limit0) || data.found_index == 0)
@@ -631,31 +631,31 @@ int pdf_add_portfolio_entry(fz_context *ctx, pdf_document *doc,
fz_try(ctx)
{
val = pdf_new_dict(ctx, doc, 6);
- pdf_dict_put_dict(ctx, val, PDF_NAME_CI, 4);
- ef = pdf_dict_put_dict(ctx, val, PDF_NAME_EF, 4);
- pdf_dict_put_string(ctx, val, PDF_NAME_F, filename, filename_len);
- pdf_dict_put_string(ctx, val, PDF_NAME_UF, unifile, unifile_len);
- pdf_dict_put_string(ctx, val, PDF_NAME_Desc, desc, desc_len);
- pdf_dict_put(ctx, val, PDF_NAME_Type, PDF_NAME_Filespec);
- pdf_dict_put_drop(ctx, ef, PDF_NAME_F, (f = pdf_add_stream(ctx, doc, buf, NULL, 0)));
+ pdf_dict_put_dict(ctx, val, PDF_NAME(CI), 4);
+ ef = pdf_dict_put_dict(ctx, val, PDF_NAME(EF), 4);
+ pdf_dict_put_string(ctx, val, PDF_NAME(F), filename, filename_len);
+ pdf_dict_put_string(ctx, val, PDF_NAME(UF), unifile, unifile_len);
+ pdf_dict_put_string(ctx, val, PDF_NAME(Desc), desc, desc_len);
+ pdf_dict_put(ctx, val, PDF_NAME(Type), PDF_NAME(Filespec));
+ pdf_dict_put_drop(ctx, ef, PDF_NAME(F), (f = pdf_add_stream(ctx, doc, buf, NULL, 0)));
len = fz_buffer_storage(ctx, buf, NULL);
- pdf_dict_put_int(ctx, f, PDF_NAME_DL, len);
- pdf_dict_put_int(ctx, f, PDF_NAME_Length, len);
- params = pdf_dict_put_dict(ctx, f, PDF_NAME_Params, 4);
- pdf_dict_put_int(ctx, params, PDF_NAME_Size, len);
+ pdf_dict_put_int(ctx, f, PDF_NAME(DL), len);
+ pdf_dict_put_int(ctx, f, PDF_NAME(Length), len);
+ params = pdf_dict_put_dict(ctx, f, PDF_NAME(Params), 4);
+ pdf_dict_put_int(ctx, params, PDF_NAME(Size), len);
- s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Collection, NULL);
+ s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), PDF_NAME(Collection), NULL);
if (s == NULL)
{
s = pdf_new_dict(ctx, doc, 4);
- pdf_dict_putl_drop(ctx, pdf_trailer(ctx, doc), s, PDF_NAME_Root, PDF_NAME_Collection, NULL);
+ pdf_dict_putl_drop(ctx, pdf_trailer(ctx, doc), s, PDF_NAME(Root), PDF_NAME(Collection), NULL);
}
- s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Names, PDF_NAME_EmbeddedFiles, NULL);
+ s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), PDF_NAME(Names), PDF_NAME(EmbeddedFiles), NULL);
if (s == NULL)
{
s = pdf_new_dict(ctx, doc, 4);
- pdf_dict_putl_drop(ctx, pdf_trailer(ctx, doc), s, PDF_NAME_Root, PDF_NAME_Names, PDF_NAME_EmbeddedFiles, NULL);
+ pdf_dict_putl_drop(ctx, pdf_trailer(ctx, doc), s, PDF_NAME(Root), PDF_NAME(Names), PDF_NAME(EmbeddedFiles), NULL);
}
entry = pdf_name_tree_insert(ctx, doc, s, key, val);
}
@@ -700,17 +700,17 @@ void pdf_set_portfolio_entry_info(fz_context *ctx, pdf_document *doc, int entry,
lookup = NULL;
break;
case PDF_SCHEMA_FILENAME:
- lookup = PDF_NAME_UF;
+ lookup = PDF_NAME(UF);
break;
case PDF_SCHEMA_DESC:
- lookup = PDF_NAME_Desc;
+ lookup = PDF_NAME(Desc);
break;
case PDF_SCHEMA_MODDATE:
- lookup = PDF_NAME_ModDate;
+ lookup = PDF_NAME(ModDate);
ef = 1;
break;
case PDF_SCHEMA_CREATIONDATE:
- lookup = PDF_NAME_CreationDate;
+ lookup = PDF_NAME(CreationDate);
ef = 1;
break;
case PDF_SCHEMA_SIZE:
@@ -720,13 +720,13 @@ void pdf_set_portfolio_entry_info(fz_context *ctx, pdf_document *doc, int entry,
if (lookup)
{
if (ef)
- obj = pdf_dict_getl(ctx, obj, PDF_NAME_EF, PDF_NAME_F, PDF_NAME_Params, NULL);
+ obj = pdf_dict_getl(ctx, obj, PDF_NAME(EF), PDF_NAME(F), PDF_NAME(Params), NULL);
pdf_dict_put(ctx, obj, lookup, data);
- if (pdf_name_eq(ctx, lookup, PDF_NAME_UF))
- pdf_dict_put(ctx, obj, PDF_NAME_F, data);
+ if (pdf_name_eq(ctx, lookup, PDF_NAME(UF)))
+ pdf_dict_put(ctx, obj, PDF_NAME(F), data);
return;
}
- pdf_dict_putl(ctx, obj, data, PDF_NAME_CI, p->key, NULL);
+ pdf_dict_putl(ctx, obj, data, PDF_NAME(CI), p->key, NULL);
}
void pdf_drop_portfolio(fz_context *ctx, pdf_document *doc)
diff --git a/source/pdf/pdf-repair.c b/source/pdf/pdf-repair.c
index 5f055ca4..1965a37e 100644
--- a/source/pdf/pdf-repair.c
+++ b/source/pdf/pdf-repair.c
@@ -73,12 +73,12 @@ pdf_repair_obj(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf, int64_t *stm
if (encrypt || id || root)
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Type);
- if (!pdf_is_indirect(ctx, obj) && pdf_name_eq(ctx, obj, PDF_NAME_XRef))
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Type));
+ if (!pdf_is_indirect(ctx, obj) && pdf_name_eq(ctx, obj, PDF_NAME(XRef)))
{
if (encrypt)
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Encrypt);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Encrypt));
if (obj)
{
pdf_drop_obj(ctx, *encrypt);
@@ -88,7 +88,7 @@ pdf_repair_obj(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf, int64_t *stm
if (id)
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_ID);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(ID));
if (obj)
{
pdf_drop_obj(ctx, *id);
@@ -97,18 +97,18 @@ pdf_repair_obj(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf, int64_t *stm
}
if (root)
- *root = pdf_keep_obj(ctx, pdf_dict_get(ctx, dict, PDF_NAME_Root));
+ *root = pdf_keep_obj(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Root)));
}
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Length);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Length));
if (!pdf_is_indirect(ctx, obj) && pdf_is_int(ctx, obj))
stm_len = pdf_to_int(ctx, obj);
if (doc->file_reading_linearly && page)
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Type);
- if (!pdf_is_indirect(ctx, obj) && pdf_name_eq(ctx, obj, PDF_NAME_Page))
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Type));
+ if (!pdf_is_indirect(ctx, obj) && pdf_name_eq(ctx, obj, PDF_NAME(Page)))
{
pdf_drop_obj(ctx, *page);
*page = pdf_keep_obj(ctx, dict);
@@ -210,7 +210,7 @@ pdf_repair_obj_stm(fz_context *ctx, pdf_document *doc, int stm_num)
{
obj = pdf_load_object(ctx, doc, stm_num);
- count = pdf_to_int(ctx, pdf_dict_get(ctx, obj, PDF_NAME_N));
+ count = pdf_to_int(ctx, pdf_dict_get(ctx, obj, PDF_NAME(N)));
pdf_drop_obj(ctx, obj);
@@ -481,25 +481,25 @@ pdf_repair_xref(fz_context *ctx, pdf_document *doc)
fz_try(ctx)
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Encrypt);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Encrypt));
if (obj)
{
pdf_drop_obj(ctx, encrypt);
encrypt = pdf_keep_obj(ctx, obj);
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_ID);
- if (obj && (!id || !encrypt || pdf_dict_get(ctx, dict, PDF_NAME_Encrypt)))
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(ID));
+ if (obj && (!id || !encrypt || pdf_dict_get(ctx, dict, PDF_NAME(Encrypt))))
{
pdf_drop_obj(ctx, id);
id = pdf_keep_obj(ctx, obj);
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Root);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Root));
if (obj)
add_root(ctx, obj, &roots, &num_roots, &max_roots);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Info);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Info));
if (obj)
{
pdf_drop_obj(ctx, info);
@@ -571,7 +571,7 @@ pdf_repair_xref(fz_context *ctx, pdf_document *doc)
fz_try(ctx)
{
length = pdf_new_int(ctx, doc, list[i].stm_len);
- pdf_dict_get_put_drop(ctx, dict, PDF_NAME_Length, length, &old_obj);
+ pdf_dict_get_put_drop(ctx, dict, PDF_NAME(Length), length, &old_obj);
if (old_obj)
orphan_object(ctx, doc, old_obj);
}
@@ -611,7 +611,7 @@ pdf_repair_xref(fz_context *ctx, pdf_document *doc)
obj = NULL;
obj = pdf_new_int(ctx, doc, maxnum + 1);
- pdf_dict_put(ctx, pdf_trailer(ctx, doc), PDF_NAME_Size, obj);
+ pdf_dict_put(ctx, pdf_trailer(ctx, doc), PDF_NAME(Size), obj);
pdf_drop_obj(ctx, obj);
obj = NULL;
@@ -624,12 +624,12 @@ pdf_repair_xref(fz_context *ctx, pdf_document *doc)
}
if (i >= 0)
{
- pdf_dict_put(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, roots[i]);
+ pdf_dict_put(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), roots[i]);
}
}
if (info)
{
- pdf_dict_put(ctx, pdf_trailer(ctx, doc), PDF_NAME_Info, info);
+ pdf_dict_put(ctx, pdf_trailer(ctx, doc), PDF_NAME(Info), info);
pdf_drop_obj(ctx, info);
info = NULL;
}
@@ -644,7 +644,7 @@ pdf_repair_xref(fz_context *ctx, pdf_document *doc)
encrypt = obj;
obj = NULL;
}
- pdf_dict_put(ctx, pdf_trailer(ctx, doc), PDF_NAME_Encrypt, encrypt);
+ pdf_dict_put(ctx, pdf_trailer(ctx, doc), PDF_NAME(Encrypt), encrypt);
pdf_drop_obj(ctx, encrypt);
encrypt = NULL;
}
@@ -659,7 +659,7 @@ pdf_repair_xref(fz_context *ctx, pdf_document *doc)
id = obj;
obj = NULL;
}
- pdf_dict_put(ctx, pdf_trailer(ctx, doc), PDF_NAME_ID, id);
+ pdf_dict_put(ctx, pdf_trailer(ctx, doc), PDF_NAME(ID), id);
pdf_drop_obj(ctx, id);
id = NULL;
}
@@ -699,7 +699,7 @@ pdf_repair_obj_stms(fz_context *ctx, pdf_document *doc)
dict = pdf_load_object(ctx, doc, i);
fz_try(ctx)
{
- if (pdf_name_eq(ctx, pdf_dict_get(ctx, dict, PDF_NAME_Type), PDF_NAME_ObjStm))
+ if (pdf_name_eq(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Type)), PDF_NAME(ObjStm)))
pdf_repair_obj_stm(ctx, doc, i);
}
fz_catch(ctx)
diff --git a/source/pdf/pdf-resources.c b/source/pdf/pdf-resources.c
index be97a0ba..55d6603e 100644
--- a/source/pdf/pdf-resources.c
+++ b/source/pdf/pdf-resources.c
@@ -41,8 +41,8 @@ pdf_preload_image_resources(fz_context *ctx, pdf_document *doc)
for (k = 1; k < len; k++)
{
obj = pdf_new_indirect(ctx, doc, k, 0);
- type = pdf_dict_get(ctx, obj, PDF_NAME_Subtype);
- if (pdf_name_eq(ctx, type, PDF_NAME_Image))
+ type = pdf_dict_get(ctx, obj, PDF_NAME(Subtype));
+ if (pdf_name_eq(ctx, type, PDF_NAME(Image)))
{
image = pdf_load_image(ctx, doc, obj);
fz_md5_image(ctx, image, digest);
diff --git a/source/pdf/pdf-run.c b/source/pdf/pdf-run.c
index 22ee32c7..2cc56edb 100644
--- a/source/pdf/pdf-run.c
+++ b/source/pdf/pdf-run.c
@@ -66,7 +66,7 @@ pdf_run_page_contents_with_usage(fz_context *ctx, pdf_document *doc, pdf_page *p
if (group)
{
- pdf_obj *cs = pdf_dict_get(ctx, group, PDF_NAME_CS);
+ pdf_obj *cs = pdf_dict_get(ctx, group, PDF_NAME(CS));
if (cs)
{
fz_try(ctx)
diff --git a/source/pdf/pdf-shade.c b/source/pdf/pdf-shade.c
index 3cf3db52..f0124913 100644
--- a/source/pdf/pdf-shade.c
+++ b/source/pdf/pdf-shade.c
@@ -61,7 +61,7 @@ pdf_load_function_based_shading(fz_context *ctx, pdf_document *doc, fz_shade *sh
x0 = y0 = 0;
x1 = y1 = 1;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Domain);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Domain));
if (obj)
{
x0 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
@@ -70,7 +70,7 @@ pdf_load_function_based_shading(fz_context *ctx, pdf_document *doc, fz_shade *sh
y1 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 3));
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Matrix);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix));
if (obj)
pdf_to_matrix(ctx, obj, &matrix);
else
@@ -106,7 +106,7 @@ pdf_load_linear_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf
float d0, d1;
int e0, e1;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Coords);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Coords));
shade->u.l_or_r.coords[0][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
shade->u.l_or_r.coords[0][1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1));
shade->u.l_or_r.coords[1][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 2));
@@ -114,7 +114,7 @@ pdf_load_linear_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf
d0 = 0;
d1 = 1;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Domain);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Domain));
if (obj)
{
d0 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
@@ -122,7 +122,7 @@ pdf_load_linear_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf
}
e0 = e1 = 0;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Extend);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Extend));
if (obj)
{
e0 = pdf_to_bool(ctx, pdf_array_get(ctx, obj, 0));
@@ -142,7 +142,7 @@ pdf_load_radial_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf
float d0, d1;
int e0, e1;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Coords);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Coords));
shade->u.l_or_r.coords[0][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
shade->u.l_or_r.coords[0][1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1));
shade->u.l_or_r.coords[0][2] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 2));
@@ -152,7 +152,7 @@ pdf_load_radial_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf
d0 = 0;
d1 = 1;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Domain);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Domain));
if (obj)
{
d0 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
@@ -160,7 +160,7 @@ pdf_load_radial_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf
}
e0 = e1 = 0;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Extend);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Extend));
if (obj)
{
e0 = pdf_to_bool(ctx, pdf_array_get(ctx, obj, 0));
@@ -201,12 +201,12 @@ pdf_load_mesh_params(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf_ob
shade->u.m.c1[i] = 1;
}
- shade->u.m.vprow = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_VerticesPerRow));
- shade->u.m.bpflag = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_BitsPerFlag));
- shade->u.m.bpcoord = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_BitsPerCoordinate));
- shade->u.m.bpcomp = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_BitsPerComponent));
+ shade->u.m.vprow = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(VerticesPerRow)));
+ shade->u.m.bpflag = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(BitsPerFlag)));
+ shade->u.m.bpcoord = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(BitsPerCoordinate)));
+ shade->u.m.bpcomp = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(BitsPerComponent)));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Decode);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Decode));
if (pdf_array_len(ctx, obj) >= 6)
{
n = fz_mini(FZ_MAX_COLORS, (pdf_array_len(ctx, obj) - 4) / 2);
@@ -327,16 +327,16 @@ pdf_load_shading_dict(fz_context *ctx, pdf_document *doc, pdf_obj *dict, const f
funcs = 0;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_ShadingType);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(ShadingType));
type = pdf_to_int(ctx, obj);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_ColorSpace);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(ColorSpace));
if (!obj)
fz_throw(ctx, FZ_ERROR_SYNTAX, "shading colorspace is missing");
shade->colorspace = pdf_load_colorspace(ctx, obj);
n = fz_colorspace_n(ctx, shade->colorspace);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Background);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Background));
if (obj)
{
shade->use_background = 1;
@@ -344,11 +344,11 @@ pdf_load_shading_dict(fz_context *ctx, pdf_document *doc, pdf_obj *dict, const f
shade->background[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i));
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_BBox);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(BBox));
if (pdf_is_array(ctx, obj))
pdf_to_rect(ctx, obj, &shade->bbox);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Function);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Function));
if (pdf_is_dict(ctx, obj))
{
funcs = 1;
@@ -446,24 +446,24 @@ pdf_load_shading(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
}
/* Type 2 pattern dictionary */
- if (pdf_dict_get(ctx, dict, PDF_NAME_PatternType))
+ if (pdf_dict_get(ctx, dict, PDF_NAME(PatternType)))
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Matrix);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix));
if (obj)
pdf_to_matrix(ctx, obj, &mat);
else
mat = fz_identity;
- obj = pdf_dict_get(ctx, dict, PDF_NAME_ExtGState);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(ExtGState));
if (obj)
{
- if (pdf_dict_get(ctx, obj, PDF_NAME_CA) || pdf_dict_get(ctx, obj, PDF_NAME_ca))
+ if (pdf_dict_get(ctx, obj, PDF_NAME(CA)) || pdf_dict_get(ctx, obj, PDF_NAME(ca)))
{
fz_warn(ctx, "shading with alpha not supported");
}
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Shading);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Shading));
if (!obj)
fz_throw(ctx, FZ_ERROR_SYNTAX, "missing shading dictionary");
diff --git a/source/pdf/pdf-signature.c b/source/pdf/pdf-signature.c
index 3c882f54..ef39a50e 100644
--- a/source/pdf/pdf-signature.c
+++ b/source/pdf/pdf-signature.c
@@ -71,7 +71,7 @@ void pdf_sign_signature(fz_context *ctx, pdf_document *doc, pdf_widget *widget,
pdf_signature_set_value(ctx, doc, wobj, signer);
- pdf_to_rect(ctx, pdf_dict_get(ctx, wobj, PDF_NAME_Rect), &rect);
+ pdf_to_rect(ctx, pdf_dict_get(ctx, wobj, PDF_NAME(Rect)), &rect);
/* Create an appearance stream only if the signature is intended to be visible */
if (!fz_is_empty_rect(&rect))
{
diff --git a/source/pdf/pdf-stream.c b/source/pdf/pdf-stream.c
index e8ce2fab..2cb10d12 100644
--- a/source/pdf/pdf-stream.c
+++ b/source/pdf/pdf-stream.c
@@ -38,10 +38,10 @@ pdf_stream_has_crypt(fz_context *ctx, pdf_obj *stm)
pdf_obj *obj;
int i;
- filters = pdf_dict_geta(ctx, stm, PDF_NAME_Filter, PDF_NAME_F);
+ filters = pdf_dict_geta(ctx, stm, PDF_NAME(Filter), PDF_NAME(F));
if (filters)
{
- if (pdf_name_eq(ctx, filters, PDF_NAME_Crypt))
+ if (pdf_name_eq(ctx, filters, PDF_NAME(Crypt)))
return 1;
if (pdf_is_array(ctx, filters))
{
@@ -49,7 +49,7 @@ pdf_stream_has_crypt(fz_context *ctx, pdf_obj *stm)
for (i = 0; i < n; i++)
{
obj = pdf_array_get(ctx, filters, i);
- if (pdf_name_eq(ctx, obj, PDF_NAME_Crypt))
+ if (pdf_name_eq(ctx, obj, PDF_NAME(Crypt)))
return 1;
}
}
@@ -93,22 +93,22 @@ pdf_load_jbig2_globals(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
static void
build_compression_params(fz_context *ctx, pdf_obj *f, pdf_obj *p, fz_compression_params *params)
{
- int predictor = pdf_to_int(ctx, pdf_dict_get(ctx, p, PDF_NAME_Predictor));
- pdf_obj *columns_obj = pdf_dict_get(ctx, p, PDF_NAME_Columns);
+ int predictor = pdf_to_int(ctx, pdf_dict_get(ctx, p, PDF_NAME(Predictor)));
+ pdf_obj *columns_obj = pdf_dict_get(ctx, p, PDF_NAME(Columns));
int columns = pdf_to_int(ctx, columns_obj);
- int colors = pdf_to_int(ctx, pdf_dict_get(ctx, p, PDF_NAME_Colors));
- int bpc = pdf_to_int(ctx, pdf_dict_get(ctx, p, PDF_NAME_BitsPerComponent));
+ int colors = pdf_to_int(ctx, pdf_dict_get(ctx, p, PDF_NAME(Colors)));
+ int bpc = pdf_to_int(ctx, pdf_dict_get(ctx, p, PDF_NAME(BitsPerComponent)));
params->type = FZ_IMAGE_RAW;
- if (pdf_name_eq(ctx, f, PDF_NAME_CCITTFaxDecode) || pdf_name_eq(ctx, f, PDF_NAME_CCF))
+ if (pdf_name_eq(ctx, f, PDF_NAME(CCITTFaxDecode)) || pdf_name_eq(ctx, f, PDF_NAME(CCF)))
{
- pdf_obj *k = pdf_dict_get(ctx, p, PDF_NAME_K);
- pdf_obj *eol = pdf_dict_get(ctx, p, PDF_NAME_EndOfLine);
- pdf_obj *eba = pdf_dict_get(ctx, p, PDF_NAME_EncodedByteAlign);
- pdf_obj *rows = pdf_dict_get(ctx, p, PDF_NAME_Rows);
- pdf_obj *eob = pdf_dict_get(ctx, p, PDF_NAME_EndOfBlock);
- pdf_obj *bi1 = pdf_dict_get(ctx, p, PDF_NAME_BlackIs1);
+ pdf_obj *k = pdf_dict_get(ctx, p, PDF_NAME(K));
+ pdf_obj *eol = pdf_dict_get(ctx, p, PDF_NAME(EndOfLine));
+ pdf_obj *eba = pdf_dict_get(ctx, p, PDF_NAME(EncodedByteAlign));
+ pdf_obj *rows = pdf_dict_get(ctx, p, PDF_NAME(Rows));
+ pdf_obj *eob = pdf_dict_get(ctx, p, PDF_NAME(EndOfBlock));
+ pdf_obj *bi1 = pdf_dict_get(ctx, p, PDF_NAME(BlackIs1));
params->type = FZ_IMAGE_FAX;
params->u.fax.k = (k ? pdf_to_int(ctx, k) : 0);
@@ -119,18 +119,18 @@ build_compression_params(fz_context *ctx, pdf_obj *f, pdf_obj *p, fz_compression
params->u.fax.end_of_block = (eob ? pdf_to_bool(ctx, eob) : 1);
params->u.fax.black_is_1 = (bi1 ? pdf_to_bool(ctx, bi1) : 0);
}
- else if (pdf_name_eq(ctx, f, PDF_NAME_DCTDecode) || pdf_name_eq(ctx, f, PDF_NAME_DCT))
+ else if (pdf_name_eq(ctx, f, PDF_NAME(DCTDecode)) || pdf_name_eq(ctx, f, PDF_NAME(DCT)))
{
- pdf_obj *ct = pdf_dict_get(ctx, p, PDF_NAME_ColorTransform);
+ pdf_obj *ct = pdf_dict_get(ctx, p, PDF_NAME(ColorTransform));
params->type = FZ_IMAGE_JPEG;
params->u.jpeg.color_transform = (ct ? pdf_to_int(ctx, ct) : -1);
}
- else if (pdf_name_eq(ctx, f, PDF_NAME_RunLengthDecode) || pdf_name_eq(ctx, f, PDF_NAME_RL))
+ else if (pdf_name_eq(ctx, f, PDF_NAME(RunLengthDecode)) || pdf_name_eq(ctx, f, PDF_NAME(RL)))
{
params->type = FZ_IMAGE_RLD;
}
- else if (pdf_name_eq(ctx, f, PDF_NAME_FlateDecode) || pdf_name_eq(ctx, f, PDF_NAME_Fl))
+ else if (pdf_name_eq(ctx, f, PDF_NAME(FlateDecode)) || pdf_name_eq(ctx, f, PDF_NAME(Fl)))
{
params->type = FZ_IMAGE_FLATE;
params->u.flate.predictor = predictor;
@@ -138,9 +138,9 @@ build_compression_params(fz_context *ctx, pdf_obj *f, pdf_obj *p, fz_compression
params->u.flate.colors = colors;
params->u.flate.bpc = bpc;
}
- else if (pdf_name_eq(ctx, f, PDF_NAME_LZWDecode) || pdf_name_eq(ctx, f, PDF_NAME_LZW))
+ else if (pdf_name_eq(ctx, f, PDF_NAME(LZWDecode)) || pdf_name_eq(ctx, f, PDF_NAME(LZW)))
{
- pdf_obj *ec = pdf_dict_get(ctx, p, PDF_NAME_EarlyChange);
+ pdf_obj *ec = pdf_dict_get(ctx, p, PDF_NAME(EarlyChange));
params->type = FZ_IMAGE_LZW;
params->u.lzw.predictor = predictor;
@@ -173,16 +173,16 @@ build_filter(fz_context *ctx, fz_stream *chain, pdf_document *doc, pdf_obj *f, p
else if (params->type != FZ_IMAGE_RAW)
return fz_open_image_decomp_stream(ctx, chain, params, NULL);
- else if (pdf_name_eq(ctx, f, PDF_NAME_ASCIIHexDecode) || pdf_name_eq(ctx, f, PDF_NAME_AHx))
+ else if (pdf_name_eq(ctx, f, PDF_NAME(ASCIIHexDecode)) || pdf_name_eq(ctx, f, PDF_NAME(AHx)))
return fz_open_ahxd(ctx, chain);
- else if (pdf_name_eq(ctx, f, PDF_NAME_ASCII85Decode) || pdf_name_eq(ctx, f, PDF_NAME_A85))
+ else if (pdf_name_eq(ctx, f, PDF_NAME(ASCII85Decode)) || pdf_name_eq(ctx, f, PDF_NAME(A85)))
return fz_open_a85d(ctx, chain);
- else if (pdf_name_eq(ctx, f, PDF_NAME_JBIG2Decode))
+ else if (pdf_name_eq(ctx, f, PDF_NAME(JBIG2Decode)))
{
fz_jbig2_globals *globals = NULL;
- pdf_obj *obj = pdf_dict_get(ctx, p, PDF_NAME_JBIG2Globals);
+ pdf_obj *obj = pdf_dict_get(ctx, p, PDF_NAME(JBIG2Globals));
if (obj)
{
if (!pdf_is_stream(ctx, obj))
@@ -193,16 +193,16 @@ build_filter(fz_context *ctx, fz_stream *chain, pdf_document *doc, pdf_obj *f, p
return fz_open_jbig2d(ctx, chain, globals); /* takes ownership of jbig2_globals */
}
- else if (pdf_name_eq(ctx, f, PDF_NAME_JPXDecode))
+ else if (pdf_name_eq(ctx, f, PDF_NAME(JPXDecode)))
return fz_keep_stream(ctx, chain); /* JPX decoding is special cased in the image loading code */
- else if (pdf_name_eq(ctx, f, PDF_NAME_Crypt))
+ else if (pdf_name_eq(ctx, f, PDF_NAME(Crypt)))
{
if (!doc->crypt)
fz_warn(ctx, "crypt filter in unencrypted document");
else
{
- pdf_obj *name = pdf_dict_get(ctx, p, PDF_NAME_Name);
+ pdf_obj *name = pdf_dict_get(ctx, p, PDF_NAME(Name));
if (pdf_is_name(ctx, name))
return pdf_open_crypt_with_filter(ctx, chain, doc->crypt, name, num, gen);
}
@@ -294,7 +294,7 @@ pdf_open_raw_filter(fz_context *ctx, fz_stream *file_stm, pdf_document *doc, pdf
}
hascrypt = pdf_stream_has_crypt(ctx, stmobj);
- len = pdf_to_int(ctx, pdf_dict_get(ctx, stmobj, PDF_NAME_Length));
+ len = pdf_to_int(ctx, pdf_dict_get(ctx, stmobj, PDF_NAME(Length)));
null_stm = fz_open_null(ctx, file_stm, len, offset);
if (doc->crypt && !hascrypt)
{
@@ -316,8 +316,8 @@ pdf_open_raw_filter(fz_context *ctx, fz_stream *file_stm, pdf_document *doc, pdf
static fz_stream *
pdf_open_filter(fz_context *ctx, pdf_document *doc, fz_stream *file_stm, pdf_obj *stmobj, int num, int64_t offset, fz_compression_params *imparams)
{
- pdf_obj *filters = pdf_dict_geta(ctx, stmobj, PDF_NAME_Filter, PDF_NAME_F);
- pdf_obj *params = pdf_dict_geta(ctx, stmobj, PDF_NAME_DecodeParms, PDF_NAME_DP);
+ pdf_obj *filters = pdf_dict_geta(ctx, stmobj, PDF_NAME(Filter), PDF_NAME(F));
+ pdf_obj *params = pdf_dict_geta(ctx, stmobj, PDF_NAME(DecodeParms), PDF_NAME(DP));
int orig_num, orig_gen;
fz_stream *rstm, *fstm;
@@ -346,8 +346,8 @@ pdf_open_filter(fz_context *ctx, pdf_document *doc, fz_stream *file_stm, pdf_obj
fz_stream *
pdf_open_inline_stream(fz_context *ctx, pdf_document *doc, pdf_obj *stmobj, int length, fz_stream *file_stm, fz_compression_params *imparams)
{
- pdf_obj *filters = pdf_dict_geta(ctx, stmobj, PDF_NAME_Filter, PDF_NAME_F);
- pdf_obj *params = pdf_dict_geta(ctx, stmobj, PDF_NAME_DecodeParms, PDF_NAME_DP);
+ pdf_obj *filters = pdf_dict_geta(ctx, stmobj, PDF_NAME(Filter), PDF_NAME(F));
+ pdf_obj *params = pdf_dict_geta(ctx, stmobj, PDF_NAME(DecodeParms), PDF_NAME(DP));
if (pdf_is_name(ctx, filters))
return build_filter(ctx, file_stm, doc, filters, params, 0, 0, imparams);
@@ -471,7 +471,7 @@ pdf_load_raw_stream_number(fz_context *ctx, pdf_document *doc, int num)
dict = pdf_load_object(ctx, doc, num);
- len = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_Length));
+ len = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Length)));
pdf_drop_obj(ctx, dict);
@@ -522,12 +522,12 @@ can_reuse_buffer(fz_context *ctx, pdf_xref_entry *entry, fz_compression_params *
if (params)
params->type = FZ_IMAGE_RAW;
- f = pdf_dict_geta(ctx, entry->obj, PDF_NAME_Filter, PDF_NAME_F);
+ f = pdf_dict_geta(ctx, entry->obj, PDF_NAME(Filter), PDF_NAME(F));
/* If there are no filters, it's uncompressed, and we can use it */
if (!f)
return 1;
- p = pdf_dict_geta(ctx, entry->obj, PDF_NAME_DecodeParms, PDF_NAME_DP);
+ p = pdf_dict_geta(ctx, entry->obj, PDF_NAME(DecodeParms), PDF_NAME(DP));
if (pdf_is_array(ctx, f))
{
int len = pdf_array_len(ctx, f);
@@ -576,8 +576,8 @@ pdf_load_image_stream(fz_context *ctx, pdf_document *doc, int num, fz_compressio
dict = pdf_load_object(ctx, doc, num);
- len = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_Length));
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Filter);
+ len = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Length)));
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Filter));
len = pdf_guess_filter_length(len, pdf_to_name(ctx, obj));
n = pdf_array_len(ctx, obj);
for (i = 0; i < n; i++)
diff --git a/source/pdf/pdf-type3.c b/source/pdf/pdf-type3.c
index f82bb2f0..ad222fbe 100644
--- a/source/pdf/pdf-type3.c
+++ b/source/pdf/pdf-type3.c
@@ -47,7 +47,7 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d
fz_try(ctx)
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Name);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Name));
if (pdf_is_name(ctx, obj))
fz_strlcpy(buf, pdf_to_name(ctx, obj), sizeof buf);
else
@@ -55,10 +55,10 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d
fontdesc = pdf_new_font_desc(ctx);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_FontMatrix);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(FontMatrix));
pdf_to_matrix(ctx, obj, &matrix);
- obj = pdf_dict_get(ctx, dict, PDF_NAME_FontBBox);
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(FontBBox));
fz_transform_rect(pdf_to_rect(ctx, obj, &bbox), &matrix);
font = fz_new_type3_font(ctx, buf, &matrix);
@@ -72,7 +72,7 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d
for (i = 0; i < 256; i++)
estrings[i] = NULL;
- encoding = pdf_dict_get(ctx, dict, PDF_NAME_Encoding);
+ encoding = pdf_dict_get(ctx, dict, PDF_NAME(Encoding));
if (!encoding)
{
fz_throw(ctx, FZ_ERROR_SYNTAX, "Type3 font missing Encoding");
@@ -85,11 +85,11 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d
{
pdf_obj *base, *diff, *item;
- base = pdf_dict_get(ctx, encoding, PDF_NAME_BaseEncoding);
+ base = pdf_dict_get(ctx, encoding, PDF_NAME(BaseEncoding));
if (pdf_is_name(ctx, base))
pdf_load_encoding(estrings, pdf_to_name(ctx, base));
- diff = pdf_dict_get(ctx, encoding, PDF_NAME_Differences);
+ diff = pdf_dict_get(ctx, encoding, PDF_NAME(Differences));
if (pdf_is_array(ctx, diff))
{
n = pdf_array_len(ctx, diff);
@@ -108,7 +108,7 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d
fontdesc->encoding = pdf_new_identity_cmap(ctx, 0, 1);
fontdesc->size += pdf_cmap_size(ctx, fontdesc->encoding);
- pdf_load_to_unicode(ctx, doc, fontdesc, estrings, NULL, pdf_dict_get(ctx, dict, PDF_NAME_ToUnicode));
+ pdf_load_to_unicode(ctx, doc, fontdesc, estrings, NULL, pdf_dict_get(ctx, dict, PDF_NAME(ToUnicode)));
/* Use the glyph index as ASCII when we can't figure out a proper encoding */
if (fontdesc->cid_to_ucs_len == 256)
@@ -122,13 +122,13 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d
pdf_set_default_hmtx(ctx, fontdesc, 0);
- first = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_FirstChar));
- last = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_LastChar));
+ first = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(FirstChar)));
+ last = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(LastChar)));
if (first < 0 || last > 255 || first > last)
first = last = 0;
- widths = pdf_dict_get(ctx, dict, PDF_NAME_Widths);
+ widths = pdf_dict_get(ctx, dict, PDF_NAME(Widths));
if (!widths)
{
fz_throw(ctx, FZ_ERROR_SYNTAX, "Type3 font missing Widths");
@@ -147,7 +147,7 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d
/* Resources -- inherit page resources if the font doesn't have its own */
font->t3freeres = pdf_t3_free_resources;
- font->t3resources = pdf_dict_get(ctx, dict, PDF_NAME_Resources);
+ font->t3resources = pdf_dict_get(ctx, dict, PDF_NAME(Resources));
if (!font->t3resources)
font->t3resources = rdb;
if (font->t3resources)
@@ -160,7 +160,7 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d
/* CharProcs */
- charprocs = pdf_dict_get(ctx, dict, PDF_NAME_CharProcs);
+ charprocs = pdf_dict_get(ctx, dict, PDF_NAME(CharProcs));
if (!charprocs)
{
fz_throw(ctx, FZ_ERROR_SYNTAX, "Type3 font missing CharProcs");
diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c
index b4d51949..24e6d9e4 100644
--- a/source/pdf/pdf-write.c
+++ b/source/pdf/pdf-write.c
@@ -538,12 +538,12 @@ static pdf_obj *markref(fz_context *ctx, pdf_document *doc, pdf_write_state *opt
{
if (pdf_obj_num_is_stream(ctx, doc, num))
{
- pdf_obj *len = pdf_dict_get(ctx, obj, PDF_NAME_Length);
+ pdf_obj *len = pdf_dict_get(ctx, obj, PDF_NAME(Length));
if (pdf_is_indirect(ctx, len))
{
opts->use_list[pdf_to_num(ctx, len)] = 0;
len = pdf_resolve_indirect(ctx, len);
- pdf_dict_put(ctx, obj, PDF_NAME_Length, len);
+ pdf_dict_put(ctx, obj, PDF_NAME(Length), len);
}
}
}
@@ -621,7 +621,7 @@ static int markobj(fz_context *ctx, pdf_document *doc, pdf_write_state *opts, pd
{
DEBUGGING_MARKING(indent(); printf("ARRAY[%d/%d]\n", i, n));
if (markobj(ctx, doc, opts, pdf_array_get(ctx, obj, i)))
- pdf_array_put(ctx, obj, i, PDF_OBJ_NULL);
+ pdf_array_put(ctx, obj, i, PDF_NULL);
}
}
@@ -1021,7 +1021,7 @@ mark_pages(fz_context *ctx, pdf_document *doc, pdf_write_state *opts, pdf_obj *v
{
if (pdf_is_dict(ctx, val))
{
- if (pdf_name_eq(ctx, PDF_NAME_Page, pdf_dict_get(ctx, val, PDF_NAME_Type)))
+ if (pdf_name_eq(ctx, PDF_NAME(Page), pdf_dict_get(ctx, val, PDF_NAME(Type))))
{
int num = pdf_to_num(ctx, val);
pdf_unmark_obj(ctx, val);
@@ -1039,7 +1039,7 @@ mark_pages(fz_context *ctx, pdf_document *doc, pdf_write_state *opts, pdf_obj *v
pdf_obj *key = pdf_dict_get_key(ctx, val, i);
pdf_obj *obj = pdf_dict_get_val(ctx, val, i);
- if (pdf_name_eq(ctx, PDF_NAME_Kids, key))
+ if (pdf_name_eq(ctx, PDF_NAME(Kids), key))
pagenum = mark_pages(ctx, doc, opts, obj, pagenum);
else
mark_all(ctx, doc, opts, obj, USE_CATALOGUE, -1);
@@ -1099,18 +1099,18 @@ mark_root(fz_context *ctx, pdf_document *doc, pdf_write_state *opts, pdf_obj *di
pdf_obj *key = pdf_dict_get_key(ctx, dict, i);
pdf_obj *val = pdf_dict_get_val(ctx, dict, i);
- if (pdf_name_eq(ctx, PDF_NAME_Pages, key))
+ if (pdf_name_eq(ctx, PDF_NAME(Pages), key))
opts->page_count = mark_pages(ctx, doc, opts, val, 0);
- else if (pdf_name_eq(ctx, PDF_NAME_Names, key))
+ else if (pdf_name_eq(ctx, PDF_NAME(Names), key))
mark_all(ctx, doc, opts, val, USE_OTHER_OBJECTS, -1);
- else if (pdf_name_eq(ctx, PDF_NAME_Dests, key))
+ else if (pdf_name_eq(ctx, PDF_NAME(Dests), key))
mark_all(ctx, doc, opts, val, USE_OTHER_OBJECTS, -1);
- else if (pdf_name_eq(ctx, PDF_NAME_Outlines, key))
+ else if (pdf_name_eq(ctx, PDF_NAME(Outlines), key))
{
int section;
/* Look at PageMode to decide whether to
* USE_OTHER_OBJECTS or USE_PAGE1 here. */
- if (pdf_name_eq(ctx, pdf_dict_get(ctx, dict, PDF_NAME_PageMode), PDF_NAME_UseOutlines))
+ if (pdf_name_eq(ctx, pdf_dict_get(ctx, dict, PDF_NAME(PageMode)), PDF_NAME(UseOutlines)))
section = USE_PAGE1;
else
section = USE_OTHER_OBJECTS;
@@ -1145,7 +1145,7 @@ mark_trailer(fz_context *ctx, pdf_document *doc, pdf_write_state *opts, pdf_obj
pdf_obj *key = pdf_dict_get_key(ctx, dict, i);
pdf_obj *val = pdf_dict_get_val(ctx, dict, i);
- if (pdf_name_eq(ctx, PDF_NAME_Root, key))
+ if (pdf_name_eq(ctx, PDF_NAME(Root), key))
mark_root(ctx, doc, opts, val);
else
mark_all(ctx, doc, opts, val, USE_CATALOGUE, -1);
@@ -1187,23 +1187,23 @@ add_linearization_objs(fz_context *ctx, pdf_document *doc, pdf_write_state *opts
opts->renumber_map[params_num] = params_num;
opts->rev_renumber_map[params_num] = params_num;
opts->gen_list[params_num] = 0;
- pdf_dict_put_real(ctx, params_obj, PDF_NAME_Linearized, 1.0f);
+ pdf_dict_put_real(ctx, params_obj, PDF_NAME(Linearized), 1.0f);
opts->linear_l = pdf_new_int(ctx, doc, INT_MIN);
- pdf_dict_put(ctx, params_obj, PDF_NAME_L, opts->linear_l);
+ pdf_dict_put(ctx, params_obj, PDF_NAME(L), opts->linear_l);
opts->linear_h0 = pdf_new_int(ctx, doc, INT_MIN);
o = pdf_new_array(ctx, doc, 2);
- pdf_dict_put_drop(ctx, params_obj, PDF_NAME_H, o);
+ pdf_dict_put_drop(ctx, params_obj, PDF_NAME(H), o);
pdf_array_push(ctx, o, opts->linear_h0);
opts->linear_h1 = pdf_new_int(ctx, doc, INT_MIN);
pdf_array_push(ctx, o, opts->linear_h1);
opts->linear_o = pdf_new_int(ctx, doc, INT_MIN);
- pdf_dict_put(ctx, params_obj, PDF_NAME_O, opts->linear_o);
+ pdf_dict_put(ctx, params_obj, PDF_NAME(O), opts->linear_o);
opts->linear_e = pdf_new_int(ctx, doc, INT_MIN);
- pdf_dict_put(ctx, params_obj, PDF_NAME_E, opts->linear_e);
+ pdf_dict_put(ctx, params_obj, PDF_NAME(E), opts->linear_e);
opts->linear_n = pdf_new_int(ctx, doc, INT_MIN);
- pdf_dict_put(ctx, params_obj, PDF_NAME_N, opts->linear_n);
+ pdf_dict_put(ctx, params_obj, PDF_NAME(N), opts->linear_n);
opts->linear_t = pdf_new_int(ctx, doc, INT_MIN);
- pdf_dict_put(ctx, params_obj, PDF_NAME_T, opts->linear_t);
+ pdf_dict_put(ctx, params_obj, PDF_NAME(T), opts->linear_t);
/* Primary hint stream */
hint_obj = pdf_new_dict(ctx, doc, 10);
@@ -1214,9 +1214,9 @@ add_linearization_objs(fz_context *ctx, pdf_document *doc, pdf_write_state *opts
opts->renumber_map[hint_num] = hint_num;
opts->rev_renumber_map[hint_num] = hint_num;
opts->gen_list[hint_num] = 0;
- pdf_dict_put_int(ctx, hint_obj, PDF_NAME_P, 0);
+ pdf_dict_put_int(ctx, hint_obj, PDF_NAME(P), 0);
opts->hints_s = pdf_new_int(ctx, doc, INT_MIN);
- pdf_dict_put(ctx, hint_obj, PDF_NAME_S, opts->hints_s);
+ pdf_dict_put(ctx, hint_obj, PDF_NAME(S), opts->hints_s);
/* FIXME: Do we have thumbnails? Do a T entry */
/* FIXME: Do we have outlines? Do an O entry */
/* FIXME: Do we have article threads? Do an A entry */
@@ -1225,9 +1225,9 @@ add_linearization_objs(fz_context *ctx, pdf_document *doc, pdf_write_state *opts
/* FIXME: Do we have document information? Do an I entry */
/* FIXME: Do we have logical structure hierarchy? Do a C entry */
/* FIXME: Do L, Page Label hint table */
- pdf_dict_put(ctx, hint_obj, PDF_NAME_Filter, PDF_NAME_FlateDecode);
+ pdf_dict_put(ctx, hint_obj, PDF_NAME(Filter), PDF_NAME(FlateDecode));
opts->hints_length = pdf_new_int(ctx, doc, INT_MIN);
- pdf_dict_put(ctx, hint_obj, PDF_NAME_Length, opts->hints_length);
+ pdf_dict_put(ctx, hint_obj, PDF_NAME(Length), opts->hints_length);
pdf_get_xref_entry(ctx, doc, hint_num)->stm_ofs = -1;
}
fz_always(ctx)
@@ -1294,22 +1294,22 @@ lpr_inherit_res(fz_context *ctx, pdf_obj *node, int depth, pdf_obj *dict)
{
pdf_obj *o;
- node = pdf_dict_get(ctx, node, PDF_NAME_Parent);
+ node = pdf_dict_get(ctx, node, PDF_NAME(Parent));
depth--;
if (!node || depth < 0)
break;
- o = pdf_dict_get(ctx, node, PDF_NAME_Resources);
+ o = pdf_dict_get(ctx, node, PDF_NAME(Resources));
if (o)
{
- lpr_inherit_res_contents(ctx, dict, o, PDF_NAME_ExtGState);
- lpr_inherit_res_contents(ctx, dict, o, PDF_NAME_ColorSpace);
- lpr_inherit_res_contents(ctx, dict, o, PDF_NAME_Pattern);
- lpr_inherit_res_contents(ctx, dict, o, PDF_NAME_Shading);
- lpr_inherit_res_contents(ctx, dict, o, PDF_NAME_XObject);
- lpr_inherit_res_contents(ctx, dict, o, PDF_NAME_Font);
- lpr_inherit_res_contents(ctx, dict, o, PDF_NAME_ProcSet);
- lpr_inherit_res_contents(ctx, dict, o, PDF_NAME_Properties);
+ lpr_inherit_res_contents(ctx, dict, o, PDF_NAME(ExtGState));
+ lpr_inherit_res_contents(ctx, dict, o, PDF_NAME(ColorSpace));
+ lpr_inherit_res_contents(ctx, dict, o, PDF_NAME(Pattern));
+ lpr_inherit_res_contents(ctx, dict, o, PDF_NAME(Shading));
+ lpr_inherit_res_contents(ctx, dict, o, PDF_NAME(XObject));
+ lpr_inherit_res_contents(ctx, dict, o, PDF_NAME(Font));
+ lpr_inherit_res_contents(ctx, dict, o, PDF_NAME(ProcSet));
+ lpr_inherit_res_contents(ctx, dict, o, PDF_NAME(Properties));
}
}
}
@@ -1323,7 +1323,7 @@ lpr_inherit(fz_context *ctx, pdf_obj *node, char *text, int depth)
if (o)
return pdf_resolve_indirect(ctx, o);
- node = pdf_dict_get(ctx, node, PDF_NAME_Parent);
+ node = pdf_dict_get(ctx, node, PDF_NAME(Parent));
depth--;
}
while (depth >= 0 && node);
@@ -1345,53 +1345,53 @@ lpr(fz_context *ctx, pdf_document *doc, pdf_obj *node, int depth, int page)
fz_try(ctx)
{
- if (pdf_name_eq(ctx, PDF_NAME_Page, pdf_dict_get(ctx, node, PDF_NAME_Type)))
+ if (pdf_name_eq(ctx, PDF_NAME(Page), pdf_dict_get(ctx, node, PDF_NAME(Type))))
{
pdf_obj *r; /* r is deliberately not cleaned up */
/* Copy resources down to the child */
- o = pdf_keep_obj(ctx, pdf_dict_get(ctx, node, PDF_NAME_Resources));
+ o = pdf_keep_obj(ctx, pdf_dict_get(ctx, node, PDF_NAME(Resources)));
if (!o)
{
o = pdf_keep_obj(ctx, pdf_new_dict(ctx, doc, 2));
- pdf_dict_put(ctx, node, PDF_NAME_Resources, o);
+ pdf_dict_put(ctx, node, PDF_NAME(Resources), o);
}
lpr_inherit_res(ctx, node, depth, o);
r = lpr_inherit(ctx, node, "MediaBox", depth);
if (r)
- pdf_dict_put(ctx, node, PDF_NAME_MediaBox, r);
+ pdf_dict_put(ctx, node, PDF_NAME(MediaBox), r);
r = lpr_inherit(ctx, node, "CropBox", depth);
if (r)
- pdf_dict_put(ctx, node, PDF_NAME_CropBox, r);
+ pdf_dict_put(ctx, node, PDF_NAME(CropBox), r);
r = lpr_inherit(ctx, node, "BleedBox", depth);
if (r)
- pdf_dict_put(ctx, node, PDF_NAME_BleedBox, r);
+ pdf_dict_put(ctx, node, PDF_NAME(BleedBox), r);
r = lpr_inherit(ctx, node, "TrimBox", depth);
if (r)
- pdf_dict_put(ctx, node, PDF_NAME_TrimBox, r);
+ pdf_dict_put(ctx, node, PDF_NAME(TrimBox), r);
r = lpr_inherit(ctx, node, "ArtBox", depth);
if (r)
- pdf_dict_put(ctx, node, PDF_NAME_ArtBox, r);
+ pdf_dict_put(ctx, node, PDF_NAME(ArtBox), r);
r = lpr_inherit(ctx, node, "Rotate", depth);
if (r)
- pdf_dict_put(ctx, node, PDF_NAME_Rotate, r);
+ pdf_dict_put(ctx, node, PDF_NAME(Rotate), r);
page++;
}
else
{
- kids = pdf_dict_get(ctx, node, PDF_NAME_Kids);
+ kids = pdf_dict_get(ctx, node, PDF_NAME(Kids));
n = pdf_array_len(ctx, kids);
for(i = 0; i < n; i++)
{
page = lpr(ctx, doc, pdf_array_get(ctx, kids, i), depth+1, page);
}
- pdf_dict_del(ctx, node, PDF_NAME_Resources);
- pdf_dict_del(ctx, node, PDF_NAME_MediaBox);
- pdf_dict_del(ctx, node, PDF_NAME_CropBox);
- pdf_dict_del(ctx, node, PDF_NAME_BleedBox);
- pdf_dict_del(ctx, node, PDF_NAME_TrimBox);
- pdf_dict_del(ctx, node, PDF_NAME_ArtBox);
- pdf_dict_del(ctx, node, PDF_NAME_Rotate);
+ pdf_dict_del(ctx, node, PDF_NAME(Resources));
+ pdf_dict_del(ctx, node, PDF_NAME(MediaBox));
+ pdf_dict_del(ctx, node, PDF_NAME(CropBox));
+ pdf_dict_del(ctx, node, PDF_NAME(BleedBox));
+ pdf_dict_del(ctx, node, PDF_NAME(TrimBox));
+ pdf_dict_del(ctx, node, PDF_NAME(ArtBox));
+ pdf_dict_del(ctx, node, PDF_NAME(Rotate));
}
}
fz_always(ctx)
@@ -1414,7 +1414,7 @@ pdf_localise_page_resources(fz_context *ctx, pdf_document *doc)
if (doc->resources_localised)
return;
- lpr(ctx, doc, pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Pages, NULL), 0, 0);
+ lpr(ctx, doc, pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), PDF_NAME(Pages), NULL), 0, 0);
doc->resources_localised = 1;
}
@@ -1590,8 +1590,8 @@ static void addhexfilter(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
pdf_obj *f, *dp, *newf, *newdp;
newf = newdp = NULL;
- f = pdf_dict_get(ctx, dict, PDF_NAME_Filter);
- dp = pdf_dict_get(ctx, dict, PDF_NAME_DecodeParms);
+ f = pdf_dict_get(ctx, dict, PDF_NAME(Filter));
+ dp = pdf_dict_get(ctx, dict, PDF_NAME(DecodeParms));
fz_var(newf);
fz_var(newdp);
@@ -1601,29 +1601,29 @@ static void addhexfilter(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
if (pdf_is_name(ctx, f))
{
newf = pdf_new_array(ctx, doc, 2);
- pdf_array_push(ctx, newf, PDF_NAME_ASCIIHexDecode);
+ pdf_array_push(ctx, newf, PDF_NAME(ASCIIHexDecode));
pdf_array_push(ctx, newf, f);
f = newf;
if (pdf_is_dict(ctx, dp))
{
newdp = pdf_new_array(ctx, doc, 2);
- pdf_array_push(ctx, newdp, PDF_OBJ_NULL);
+ pdf_array_push(ctx, newdp, PDF_NULL);
pdf_array_push(ctx, newdp, dp);
dp = newdp;
}
}
else if (pdf_is_array(ctx, f))
{
- pdf_array_insert(ctx, f, PDF_NAME_ASCIIHexDecode, 0);
+ pdf_array_insert(ctx, f, PDF_NAME(ASCIIHexDecode), 0);
if (pdf_is_array(ctx, dp))
- pdf_array_insert(ctx, dp, PDF_OBJ_NULL, 0);
+ pdf_array_insert(ctx, dp, PDF_NULL, 0);
}
else
- f = PDF_NAME_ASCIIHexDecode;
+ f = PDF_NAME(ASCIIHexDecode);
- pdf_dict_put(ctx, dict, PDF_NAME_Filter, f);
+ pdf_dict_put(ctx, dict, PDF_NAME(Filter), f);
if (dp)
- pdf_dict_put(ctx, dict, PDF_NAME_DecodeParms, dp);
+ pdf_dict_put(ctx, dict, PDF_NAME(DecodeParms), dp);
}
fz_always(ctx)
{
@@ -1678,7 +1678,7 @@ static void copystream(fz_context *ctx, pdf_document *doc, pdf_write_state *opts
obj = pdf_copy_dict(ctx, obj_orig);
len = fz_buffer_storage(ctx, buf, &data);
- if (do_deflate && !pdf_dict_get(ctx, obj, PDF_NAME_Filter))
+ if (do_deflate && !pdf_dict_get(ctx, obj, PDF_NAME(Filter)))
{
size_t clen;
unsigned char *cdata;
@@ -1693,7 +1693,7 @@ static void copystream(fz_context *ctx, pdf_document *doc, pdf_write_state *opts
{
len = clen;
data = cdata;
- pdf_dict_put(ctx, obj, PDF_NAME_Filter, PDF_NAME_FlateDecode);
+ pdf_dict_put(ctx, obj, PDF_NAME(Filter), PDF_NAME(FlateDecode));
fz_drop_buffer(ctx, buf);
buf = tmp;
}
@@ -1710,7 +1710,7 @@ static void copystream(fz_context *ctx, pdf_document *doc, pdf_write_state *opts
}
newlen = pdf_new_int(ctx, doc, pdf_encrypted_len(ctx, doc->crypt, num, gen, (int)len));
- pdf_dict_put_drop(ctx, obj, PDF_NAME_Length, newlen);
+ pdf_dict_put_drop(ctx, obj, PDF_NAME(Length), newlen);
fz_write_printf(ctx, opts->out, "%d %d obj\n", num, gen);
pdf_print_encrypted_obj(ctx, opts->out, obj, opts->do_tight, doc->crypt, num, gen);
@@ -1735,8 +1735,8 @@ static void expandstream(fz_context *ctx, pdf_document *doc, pdf_write_state *op
(*opts->errors)++;
obj = pdf_copy_dict(ctx, obj_orig);
- pdf_dict_del(ctx, obj, PDF_NAME_Filter);
- pdf_dict_del(ctx, obj, PDF_NAME_DecodeParms);
+ pdf_dict_del(ctx, obj, PDF_NAME(Filter));
+ pdf_dict_del(ctx, obj, PDF_NAME(DecodeParms));
len = fz_buffer_storage(ctx, buf, &data);
if (do_deflate)
@@ -1754,7 +1754,7 @@ static void expandstream(fz_context *ctx, pdf_document *doc, pdf_write_state *op
{
len = clen;
data = cdata;
- pdf_dict_put(ctx, obj, PDF_NAME_Filter, PDF_NAME_FlateDecode);
+ pdf_dict_put(ctx, obj, PDF_NAME(Filter), PDF_NAME(FlateDecode));
fz_drop_buffer(ctx, buf);
buf = tmp;
}
@@ -1770,7 +1770,7 @@ static void expandstream(fz_context *ctx, pdf_document *doc, pdf_write_state *op
addhexfilter(ctx, doc, obj);
}
- pdf_dict_put_int(ctx, obj, PDF_NAME_Length, len);
+ pdf_dict_put_int(ctx, obj, PDF_NAME(Length), len);
fz_write_printf(ctx, opts->out, "%d %d obj\n", num, gen);
pdf_print_encrypted_obj(ctx, opts->out, obj, opts->do_tight, doc->crypt, num, gen);
@@ -1813,12 +1813,12 @@ static int filter_implies_image(fz_context *ctx, pdf_obj *o)
static int is_image_stream(fz_context *ctx, pdf_obj *obj)
{
pdf_obj *o;
- if ((o = pdf_dict_get(ctx, obj, PDF_NAME_Type), pdf_name_eq(ctx, o, PDF_NAME_XObject)))
- if ((o = pdf_dict_get(ctx, obj, PDF_NAME_Subtype), pdf_name_eq(ctx, o, PDF_NAME_Image)))
+ if ((o = pdf_dict_get(ctx, obj, PDF_NAME(Type)), pdf_name_eq(ctx, o, PDF_NAME(XObject))))
+ if ((o = pdf_dict_get(ctx, obj, PDF_NAME(Subtype)), pdf_name_eq(ctx, o, PDF_NAME(Image))))
return 1;
- if (o = pdf_dict_get(ctx, obj, PDF_NAME_Filter), filter_implies_image(ctx, o))
+ if (o = pdf_dict_get(ctx, obj, PDF_NAME(Filter)), filter_implies_image(ctx, o))
return 1;
- if (pdf_dict_get(ctx, obj, PDF_NAME_Width) != NULL && pdf_dict_get(ctx, obj, PDF_NAME_Height) != NULL)
+ if (pdf_dict_get(ctx, obj, PDF_NAME(Width)) != NULL && pdf_dict_get(ctx, obj, PDF_NAME(Height)) != NULL)
return 1;
return 0;
}
@@ -1826,27 +1826,27 @@ static int is_image_stream(fz_context *ctx, pdf_obj *obj)
static int is_font_stream(fz_context *ctx, pdf_obj *obj)
{
pdf_obj *o;
- if (o = pdf_dict_get(ctx, obj, PDF_NAME_Type), pdf_name_eq(ctx, o, PDF_NAME_Font))
+ if (o = pdf_dict_get(ctx, obj, PDF_NAME(Type)), pdf_name_eq(ctx, o, PDF_NAME(Font)))
return 1;
- if (o = pdf_dict_get(ctx, obj, PDF_NAME_Type), pdf_name_eq(ctx, o, PDF_NAME_FontDescriptor))
+ if (o = pdf_dict_get(ctx, obj, PDF_NAME(Type)), pdf_name_eq(ctx, o, PDF_NAME(FontDescriptor)))
return 1;
- if (pdf_dict_get(ctx, obj, PDF_NAME_Length1) != NULL)
+ if (pdf_dict_get(ctx, obj, PDF_NAME(Length1)) != NULL)
return 1;
- if (pdf_dict_get(ctx, obj, PDF_NAME_Length2) != NULL)
+ if (pdf_dict_get(ctx, obj, PDF_NAME(Length2)) != NULL)
return 1;
- if (pdf_dict_get(ctx, obj, PDF_NAME_Length3) != NULL)
+ if (pdf_dict_get(ctx, obj, PDF_NAME(Length3)) != NULL)
return 1;
- if (o = pdf_dict_get(ctx, obj, PDF_NAME_Subtype), pdf_name_eq(ctx, o, PDF_NAME_Type1C))
+ if (o = pdf_dict_get(ctx, obj, PDF_NAME(Subtype)), pdf_name_eq(ctx, o, PDF_NAME(Type1C)))
return 1;
- if (o = pdf_dict_get(ctx, obj, PDF_NAME_Subtype), pdf_name_eq(ctx, o, PDF_NAME_CIDFontType0C))
+ if (o = pdf_dict_get(ctx, obj, PDF_NAME(Subtype)), pdf_name_eq(ctx, o, PDF_NAME(CIDFontType0C)))
return 1;
return 0;
}
static int is_xml_metadata(fz_context *ctx, pdf_obj *obj)
{
- if (pdf_name_eq(ctx, pdf_dict_get(ctx, obj, PDF_NAME_Type), PDF_NAME_Metadata))
- if (pdf_name_eq(ctx, pdf_dict_get(ctx, obj, PDF_NAME_Subtype), PDF_NAME_XML))
+ if (pdf_name_eq(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Type)), PDF_NAME(Metadata)))
+ if (pdf_name_eq(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Subtype)), PDF_NAME(XML)))
return 1;
return 0;
}
@@ -1879,14 +1879,14 @@ static void writeobject(fz_context *ctx, pdf_document *doc, pdf_write_state *opt
/* skip ObjStm and XRef objects */
if (pdf_is_dict(ctx, obj))
{
- type = pdf_dict_get(ctx, obj, PDF_NAME_Type);
- if (pdf_name_eq(ctx, type, PDF_NAME_ObjStm))
+ type = pdf_dict_get(ctx, obj, PDF_NAME(Type));
+ if (pdf_name_eq(ctx, type, PDF_NAME(ObjStm)))
{
opts->use_list[num] = 0;
pdf_drop_obj(ctx, obj);
return;
}
- if (skip_xrefs && pdf_name_eq(ctx, type, PDF_NAME_XRef))
+ if (skip_xrefs && pdf_name_eq(ctx, type, PDF_NAME(XRef)))
{
opts->use_list[num] = 0;
pdf_drop_obj(ctx, obj);
@@ -2000,8 +2000,8 @@ static void writexref(fz_context *ctx, pdf_document *doc, pdf_write_state *opts,
if (opts->do_incremental)
{
trailer = pdf_keep_obj(ctx, pdf_trailer(ctx, doc));
- pdf_dict_put_int(ctx, trailer, PDF_NAME_Size, pdf_xref_len(ctx, doc));
- pdf_dict_put_int(ctx, trailer, PDF_NAME_Prev, doc->startxref);
+ pdf_dict_put_int(ctx, trailer, PDF_NAME(Size), pdf_xref_len(ctx, doc));
+ pdf_dict_put_int(ctx, trailer, PDF_NAME(Prev), doc->startxref);
doc->startxref = startxref;
}
else
@@ -2009,30 +2009,30 @@ static void writexref(fz_context *ctx, pdf_document *doc, pdf_write_state *opts,
trailer = pdf_new_dict(ctx, doc, 5);
nobj = pdf_new_int(ctx, doc, to);
- pdf_dict_put_drop(ctx, trailer, PDF_NAME_Size, nobj);
+ pdf_dict_put_drop(ctx, trailer, PDF_NAME(Size), nobj);
if (first)
{
- obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Info);
+ obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Info));
if (obj)
- pdf_dict_put(ctx, trailer, PDF_NAME_Info, obj);
+ pdf_dict_put(ctx, trailer, PDF_NAME(Info), obj);
- obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
+ obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
if (obj)
- pdf_dict_put(ctx, trailer, PDF_NAME_Root, obj);
+ pdf_dict_put(ctx, trailer, PDF_NAME(Root), obj);
- obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_ID);
+ obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(ID));
if (obj)
- pdf_dict_put(ctx, trailer, PDF_NAME_ID, obj);
+ pdf_dict_put(ctx, trailer, PDF_NAME(ID), obj);
- obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Encrypt);
+ obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Encrypt));
if (obj)
- pdf_dict_put(ctx, trailer, PDF_NAME_Encrypt, obj);
+ pdf_dict_put(ctx, trailer, PDF_NAME(Encrypt), obj);
}
if (main_xref_offset != 0)
{
nobj = pdf_new_int(ctx, doc, main_xref_offset);
- pdf_dict_put_drop(ctx, trailer, PDF_NAME_Prev, nobj);
+ pdf_dict_put_drop(ctx, trailer, PDF_NAME(Prev), nobj);
}
}
@@ -2089,49 +2089,49 @@ static void writexrefstream(fz_context *ctx, pdf_document *doc, pdf_write_state
if (first)
{
- obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Info);
+ obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Info));
if (obj)
- pdf_dict_put(ctx, dict, PDF_NAME_Info, obj);
+ pdf_dict_put(ctx, dict, PDF_NAME(Info), obj);
- obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
+ obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
if (obj)
- pdf_dict_put(ctx, dict, PDF_NAME_Root, obj);
+ pdf_dict_put(ctx, dict, PDF_NAME(Root), obj);
- obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_ID);
+ obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(ID));
if (obj)
- pdf_dict_put(ctx, dict, PDF_NAME_ID, obj);
+ pdf_dict_put(ctx, dict, PDF_NAME(ID), obj);
if (opts->do_incremental)
{
- obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Encrypt);
+ obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Encrypt));
if (obj)
- pdf_dict_put(ctx, dict, PDF_NAME_Encrypt, obj);
+ pdf_dict_put(ctx, dict, PDF_NAME(Encrypt), obj);
}
}
- pdf_dict_put_int(ctx, dict, PDF_NAME_Size, to);
+ pdf_dict_put_int(ctx, dict, PDF_NAME(Size), to);
if (opts->do_incremental)
{
- pdf_dict_put_int(ctx, dict, PDF_NAME_Prev, doc->startxref);
+ pdf_dict_put_int(ctx, dict, PDF_NAME(Prev), doc->startxref);
doc->startxref = startxref;
}
else
{
if (main_xref_offset != 0)
- pdf_dict_put_int(ctx, dict, PDF_NAME_Prev, main_xref_offset);
+ pdf_dict_put_int(ctx, dict, PDF_NAME(Prev), main_xref_offset);
}
- pdf_dict_put(ctx, dict, PDF_NAME_Type, PDF_NAME_XRef);
+ pdf_dict_put(ctx, dict, PDF_NAME(Type), PDF_NAME(XRef));
w = pdf_new_array(ctx, doc, 3);
- pdf_dict_put(ctx, dict, PDF_NAME_W, w);
+ pdf_dict_put(ctx, dict, PDF_NAME(W), w);
pdf_array_push_int(ctx, w, 1);
pdf_array_push_int(ctx, w, 4);
pdf_array_push_int(ctx, w, 1);
index = pdf_new_array(ctx, doc, 2);
- pdf_dict_put_drop(ctx, dict, PDF_NAME_Index, index);
+ pdf_dict_put_drop(ctx, dict, PDF_NAME(Index), index);
/* opts->gen_list[num] is already initialized by fz_calloc. */
opts->use_list[num] = 1;
@@ -2612,7 +2612,7 @@ static void presize_unsaved_signature_byteranges(fz_context *ctx, pdf_document *
* the end and between each consecutive pair of signatures,
* hence n + 1 */
int i;
- pdf_obj *byte_range = pdf_dict_getl(ctx, usig->field, PDF_NAME_V, PDF_NAME_ByteRange, NULL);
+ pdf_obj *byte_range = pdf_dict_getl(ctx, usig->field, PDF_NAME(V), PDF_NAME(ByteRange), NULL);
for (i = 0; i < n+1; i++)
{
@@ -2649,7 +2649,7 @@ static void complete_signatures(fz_context *ctx, pdf_document *doc, pdf_write_st
for (usig = xref->unsaved_sigs; usig; usig = usig->next)
{
char *bstr, *cstr, *fstr;
- int pnum = pdf_obj_parent_num(ctx, pdf_dict_getl(ctx, usig->field, PDF_NAME_V, PDF_NAME_ByteRange, NULL));
+ int pnum = pdf_obj_parent_num(ctx, pdf_dict_getl(ctx, usig->field, PDF_NAME(V), PDF_NAME(ByteRange), NULL));
fz_seek(ctx, stm, opts->ofs_list[pnum], SEEK_SET);
(void)fz_read(ctx, stm, (unsigned char *)buf, sizeof(buf));
buf[sizeof(buf)-1] = 0;
@@ -2673,7 +2673,7 @@ static void complete_signatures(fz_context *ctx, pdf_document *doc, pdf_write_st
/* Recreate ByteRange with correct values. Initially store the
* recreated object in the first of the unsaved signatures */
byte_range = pdf_new_array(ctx, doc, 4);
- pdf_dict_putl_drop(ctx, xref->unsaved_sigs->field, byte_range, PDF_NAME_V, PDF_NAME_ByteRange, NULL);
+ pdf_dict_putl_drop(ctx, xref->unsaved_sigs->field, byte_range, PDF_NAME(V), PDF_NAME(ByteRange), NULL);
last_end = 0;
for (usig = xref->unsaved_sigs; usig; usig = usig->next)
@@ -2687,7 +2687,7 @@ static void complete_signatures(fz_context *ctx, pdf_document *doc, pdf_write_st
/* Copy the new ByteRange to the other unsaved signatures */
for (usig = xref->unsaved_sigs->next; usig; usig = usig->next)
- pdf_dict_putl_drop(ctx, usig->field, pdf_copy_array(ctx, byte_range), PDF_NAME_V, PDF_NAME_ByteRange, NULL);
+ pdf_dict_putl_drop(ctx, usig->field, pdf_copy_array(ctx, byte_range), PDF_NAME(V), PDF_NAME(ByteRange), NULL);
/* Write the byte range into buf, padding with spaces*/
i = pdf_sprint_obj(ctx, buf, sizeof(buf), byte_range, 1);
@@ -2884,7 +2884,7 @@ prepare_for_save(fz_context *ctx, pdf_document *doc, pdf_write_options *in_opts)
static void
change_identity(fz_context *ctx, pdf_document *doc)
{
- pdf_obj *identity = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_ID);
+ pdf_obj *identity = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(ID));
pdf_obj *str;
unsigned char rnd[16];
@@ -2955,7 +2955,7 @@ do_pdf_save_document(fz_context *ctx, pdf_document *doc, pdf_write_state *opts,
opts->crypt_object_number = 0;
if (doc->crypt)
{
- pdf_obj *crypt = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Encrypt);
+ pdf_obj *crypt = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Encrypt));
int crypt_num = pdf_to_num(ctx, crypt);
opts->crypt_object_number = opts->renumber_map[crypt_num];
}
@@ -3200,10 +3200,10 @@ make_page_tree_node(fz_context *ctx, pdf_document *doc, int l, int r, pdf_obj *p
fz_try(ctx)
{
me = pdf_new_dict(ctx, doc, 2);
- pdf_dict_put(ctx, me, PDF_NAME_Type, PDF_NAME_Pages);
- pdf_dict_put_int(ctx, me, PDF_NAME_Count, r-l);
+ pdf_dict_put(ctx, me, PDF_NAME(Type), PDF_NAME(Pages));
+ pdf_dict_put_int(ctx, me, PDF_NAME(Count), r-l);
if (!root)
- pdf_dict_put(ctx, me, PDF_NAME_Parent, parent_ref);
+ pdf_dict_put(ctx, me, PDF_NAME(Parent), parent_ref);
a = pdf_new_array(ctx, doc, KIDS_PER_LEVEL);
me_ref = pdf_add_object(ctx, doc, me);
@@ -3212,7 +3212,7 @@ make_page_tree_node(fz_context *ctx, pdf_document *doc, int l, int r, pdf_obj *p
if (spaces >= r-l)
{
o = pdf_keep_obj(ctx, doc->page_refs[l++]);
- pdf_dict_put(ctx, o, PDF_NAME_Parent, me_ref);
+ pdf_dict_put(ctx, o, PDF_NAME(Parent), me_ref);
}
else
{
@@ -3226,7 +3226,7 @@ make_page_tree_node(fz_context *ctx, pdf_document *doc, int l, int r, pdf_obj *p
pdf_drop_obj(ctx, o);
o = NULL;
}
- pdf_dict_put_drop(ctx, me, PDF_NAME_Kids, a);
+ pdf_dict_put_drop(ctx, me, PDF_NAME(Kids), a);
a = NULL;
}
fz_always(ctx)
@@ -3252,9 +3252,9 @@ pdf_rebalance_page_tree(fz_context *ctx, pdf_document *doc)
if (!doc || !doc->needs_page_tree_rebuild)
return;
- catalog = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
+ catalog = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
pages = make_page_tree_node(ctx, doc, 0, doc->page_len, catalog, 1);
- pdf_dict_put_drop(ctx, catalog, PDF_NAME_Pages, pages);
+ pdf_dict_put_drop(ctx, catalog, PDF_NAME(Pages), pages);
doc->needs_page_tree_rebuild = 0;
}
diff --git a/source/pdf/pdf-xobject.c b/source/pdf/pdf-xobject.c
index 975b3e76..87221737 100644
--- a/source/pdf/pdf-xobject.c
+++ b/source/pdf/pdf-xobject.c
@@ -4,42 +4,42 @@
pdf_obj *
pdf_xobject_resources(fz_context *ctx, pdf_obj *xobj)
{
- return pdf_dict_get(ctx, xobj, PDF_NAME_Resources);
+ return pdf_dict_get(ctx, xobj, PDF_NAME(Resources));
}
fz_rect *
pdf_xobject_bbox(fz_context *ctx, pdf_obj *xobj, fz_rect *bbox)
{
- return pdf_to_rect(ctx, pdf_dict_get(ctx, xobj, PDF_NAME_BBox), bbox);
+ return pdf_to_rect(ctx, pdf_dict_get(ctx, xobj, PDF_NAME(BBox)), bbox);
}
fz_matrix *
pdf_xobject_matrix(fz_context *ctx, pdf_obj *xobj, fz_matrix *matrix)
{
- return pdf_to_matrix(ctx, pdf_dict_get(ctx, xobj, PDF_NAME_Matrix), matrix);
+ return pdf_to_matrix(ctx, pdf_dict_get(ctx, xobj, PDF_NAME(Matrix)), matrix);
}
int pdf_xobject_isolated(fz_context *ctx, pdf_obj *xobj)
{
- pdf_obj *group = pdf_dict_get(ctx, xobj, PDF_NAME_Group);
+ pdf_obj *group = pdf_dict_get(ctx, xobj, PDF_NAME(Group));
if (group)
- return pdf_to_bool(ctx, pdf_dict_get(ctx, group, PDF_NAME_I));
+ return pdf_to_bool(ctx, pdf_dict_get(ctx, group, PDF_NAME(I)));
return 0;
}
int pdf_xobject_knockout(fz_context *ctx, pdf_obj *xobj)
{
- pdf_obj *group = pdf_dict_get(ctx, xobj, PDF_NAME_Group);
+ pdf_obj *group = pdf_dict_get(ctx, xobj, PDF_NAME(Group));
if (group)
- return pdf_to_bool(ctx, pdf_dict_get(ctx, group, PDF_NAME_K));
+ return pdf_to_bool(ctx, pdf_dict_get(ctx, group, PDF_NAME(K)));
return 0;
}
int pdf_xobject_transparency(fz_context *ctx, pdf_obj *xobj)
{
- pdf_obj *group = pdf_dict_get(ctx, xobj, PDF_NAME_Group);
+ pdf_obj *group = pdf_dict_get(ctx, xobj, PDF_NAME(Group));
if (group)
- if (pdf_name_eq(ctx, pdf_dict_get(ctx, group, PDF_NAME_S), PDF_NAME_Transparency))
+ if (pdf_name_eq(ctx, pdf_dict_get(ctx, group, PDF_NAME(S)), PDF_NAME(Transparency)))
return 1;
return 0;
}
@@ -47,10 +47,10 @@ int pdf_xobject_transparency(fz_context *ctx, pdf_obj *xobj)
fz_colorspace *
pdf_xobject_colorspace(fz_context *ctx, pdf_obj *xobj)
{
- pdf_obj *group = pdf_dict_get(ctx, xobj, PDF_NAME_Group);
+ pdf_obj *group = pdf_dict_get(ctx, xobj, PDF_NAME(Group));
if (group)
{
- pdf_obj *cs = pdf_dict_get(ctx, group, PDF_NAME_CS);
+ pdf_obj *cs = pdf_dict_get(ctx, group, PDF_NAME(CS));
if (cs)
{
fz_colorspace *colorspace = NULL;
@@ -78,21 +78,21 @@ pdf_new_xobject(fz_context *ctx, pdf_document *doc, const fz_rect *bbox, const f
fz_try(ctx)
{
dict = pdf_new_dict(ctx, doc, 0);
- pdf_dict_put_rect(ctx, dict, PDF_NAME_BBox, bbox);
- pdf_dict_put_int(ctx, dict, PDF_NAME_FormType, 1);
- pdf_dict_put_int(ctx, dict, PDF_NAME_Length, 0);
- pdf_dict_put_matrix(ctx, dict, PDF_NAME_Matrix, mat);
+ pdf_dict_put_rect(ctx, dict, PDF_NAME(BBox), bbox);
+ pdf_dict_put_int(ctx, dict, PDF_NAME(FormType), 1);
+ pdf_dict_put_int(ctx, dict, PDF_NAME(Length), 0);
+ pdf_dict_put_matrix(ctx, dict, PDF_NAME(Matrix), mat);
res = pdf_new_dict(ctx, doc, 0);
- pdf_dict_put(ctx, dict, PDF_NAME_Resources, res);
+ pdf_dict_put(ctx, dict, PDF_NAME(Resources), res);
procset = pdf_new_array(ctx, doc, 2);
- pdf_dict_put_drop(ctx, res, PDF_NAME_ProcSet, procset);
- pdf_array_push(ctx, procset, PDF_NAME_PDF);
- pdf_array_push(ctx, procset, PDF_NAME_Text);
+ pdf_dict_put_drop(ctx, res, PDF_NAME(ProcSet), procset);
+ pdf_array_push(ctx, procset, PDF_NAME(PDF));
+ pdf_array_push(ctx, procset, PDF_NAME(Text));
- pdf_dict_put(ctx, dict, PDF_NAME_Subtype, PDF_NAME_Form);
- pdf_dict_put(ctx, dict, PDF_NAME_Type, PDF_NAME_XObject);
+ pdf_dict_put(ctx, dict, PDF_NAME(Subtype), PDF_NAME(Form));
+ pdf_dict_put(ctx, dict, PDF_NAME(Type), PDF_NAME(XObject));
form = pdf_add_object(ctx, doc, dict);
}
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index 158ffbf5..a9dada66 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -749,7 +749,7 @@ pdf_xref_size_from_old_trailer(fz_context *ctx, pdf_document *doc, pdf_lexbuf *b
trailer = pdf_parse_dict(ctx, doc, doc->file, buf);
- size = pdf_to_int(ctx, pdf_dict_get(ctx, trailer, PDF_NAME_Size));
+ size = pdf_to_int(ctx, pdf_dict_get(ctx, trailer, PDF_NAME(Size)));
if (size < 0 || size > PDF_MAX_OBJECT_NUMBER + 1)
fz_throw(ctx, FZ_ERROR_GENERIC, "trailer Size entry out of range");
}
@@ -1007,13 +1007,13 @@ pdf_read_new_xref(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf)
{
pdf_xref_entry *entry;
- obj = pdf_dict_get(ctx, trailer, PDF_NAME_Size);
+ obj = pdf_dict_get(ctx, trailer, PDF_NAME(Size));
if (!obj)
fz_throw(ctx, FZ_ERROR_GENERIC, "xref stream missing Size entry (%d 0 R)", num);
size = pdf_to_int(ctx, obj);
- obj = pdf_dict_get(ctx, trailer, PDF_NAME_W);
+ obj = pdf_dict_get(ctx, trailer, PDF_NAME(W));
if (!obj)
fz_throw(ctx, FZ_ERROR_GENERIC, "xref stream missing W entry (%d R)", num);
w0 = pdf_to_int(ctx, pdf_array_get(ctx, obj, 0));
@@ -1031,7 +1031,7 @@ pdf_read_new_xref(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf)
w1 = w1 < 0 ? 0 : w1;
w2 = w2 < 0 ? 0 : w2;
- index = pdf_dict_get(ctx, trailer, PDF_NAME_Index);
+ index = pdf_dict_get(ctx, trailer, PDF_NAME(Index));
stm = pdf_open_stream_with_offset(ctx, doc, num, trailer, stm_ofs);
@@ -1110,7 +1110,7 @@ read_xref_section(fz_context *ctx, pdf_document *doc, int64_t ofs, pdf_lexbuf *b
/* FIXME: do we overwrite free entries properly? */
/* FIXME: Does this work properly with progression? */
- xrefstmofs = pdf_to_int64(ctx, pdf_dict_get(ctx, trailer, PDF_NAME_XRefStm));
+ xrefstmofs = pdf_to_int64(ctx, pdf_dict_get(ctx, trailer, PDF_NAME(XRefStm)));
if (xrefstmofs)
{
if (xrefstmofs < 0)
@@ -1124,7 +1124,7 @@ read_xref_section(fz_context *ctx, pdf_document *doc, int64_t ofs, pdf_lexbuf *b
pdf_drop_obj(ctx, pdf_read_xref(ctx, doc, xrefstmofs, buf));
}
- prevofs = pdf_to_int64(ctx, pdf_dict_get(ctx, trailer, PDF_NAME_Prev));
+ prevofs = pdf_to_int64(ctx, pdf_dict_get(ctx, trailer, PDF_NAME(Prev)));
if (prevofs < 0)
fz_throw(ctx, FZ_ERROR_GENERIC, "negative xref stream offset for previous xref stream");
}
@@ -1292,27 +1292,27 @@ pdf_load_linear(fz_context *ctx, pdf_document *doc)
dict = pdf_parse_ind_obj(ctx, doc, doc->file, &doc->lexbuf.base, &num, &gen, &stmofs, NULL);
if (!pdf_is_dict(ctx, dict))
fz_throw(ctx, FZ_ERROR_GENERIC, "Failed to read linearized dictionary");
- o = pdf_dict_get(ctx, dict, PDF_NAME_Linearized);
+ o = pdf_dict_get(ctx, dict, PDF_NAME(Linearized));
if (o == NULL)
fz_throw(ctx, FZ_ERROR_GENERIC, "Failed to read linearized dictionary");
lin = pdf_to_int(ctx, o);
if (lin != 1)
fz_throw(ctx, FZ_ERROR_GENERIC, "Unexpected version of Linearized tag (%d)", lin);
- len = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_L));
+ len = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(L)));
if (len != doc->file_length)
fz_throw(ctx, FZ_ERROR_GENERIC, "File has been updated since linearization");
pdf_read_xref_sections(ctx, doc, fz_tell(ctx, doc->file), &doc->lexbuf.base, 0);
- doc->linear_page_count = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_N));
+ doc->linear_page_count = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(N)));
doc->linear_page_refs = fz_resize_array(ctx, doc->linear_page_refs, doc->linear_page_count, sizeof(pdf_obj *));
memset(doc->linear_page_refs, 0, doc->linear_page_count * sizeof(pdf_obj*));
doc->linear_obj = dict;
doc->linear_pos = fz_tell(ctx, doc->file);
- doc->linear_page1_obj_num = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_O));
+ doc->linear_page1_obj_num = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(O)));
doc->linear_page_refs[0] = pdf_new_indirect(ctx, doc, doc->linear_page1_obj_num, 0);
doc->linear_page_num = 0;
- hint = pdf_dict_get(ctx, dict, PDF_NAME_H);
+ hint = pdf_dict_get(ctx, dict, PDF_NAME(H));
doc->hint_object_offset = pdf_to_int(ctx, pdf_array_get(ctx, hint, 0));
doc->hint_object_length = pdf_to_int(ctx, pdf_array_get(ctx, hint, 1));
@@ -1388,8 +1388,8 @@ pdf_init_document(fz_context *ctx, pdf_document *doc)
pdf_prime_xref_index(ctx, doc);
}
- encrypt = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Encrypt);
- id = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_ID);
+ encrypt = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Encrypt));
+ id = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(ID));
if (pdf_is_dict(ctx, encrypt))
doc->crypt = pdf_new_crypt(ctx, encrypt, id);
@@ -1401,8 +1401,8 @@ pdf_init_document(fz_context *ctx, pdf_document *doc)
int xref_len = pdf_xref_len(ctx, doc);
pdf_repair_obj_stms(ctx, doc);
- hasroot = (pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root) != NULL);
- hasinfo = (pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Info) != NULL);
+ hasroot = (pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root)) != NULL);
+ hasinfo = (pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Info)) != NULL);
for (i = 1; i < xref_len; i++)
{
@@ -1423,20 +1423,20 @@ pdf_init_document(fz_context *ctx, pdf_document *doc)
if (!hasroot)
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME_Type);
- if (pdf_name_eq(ctx, obj, PDF_NAME_Catalog))
+ obj = pdf_dict_get(ctx, dict, PDF_NAME(Type));
+ if (pdf_name_eq(ctx, obj, PDF_NAME(Catalog)))
{
nobj = pdf_new_indirect(ctx, doc, i, 0);
- pdf_dict_put_drop(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, nobj);
+ pdf_dict_put_drop(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), nobj);
}
}
if (!hasinfo)
{
- if (pdf_dict_get(ctx, dict, PDF_NAME_Creator) || pdf_dict_get(ctx, dict, PDF_NAME_Producer))
+ if (pdf_dict_get(ctx, dict, PDF_NAME(Creator)) || pdf_dict_get(ctx, dict, PDF_NAME(Producer)))
{
nobj = pdf_new_indirect(ctx, doc, i, 0);
- pdf_dict_put_drop(ctx, pdf_trailer(ctx, doc), PDF_NAME_Info, nobj);
+ pdf_dict_put_drop(ctx, pdf_trailer(ctx, doc), PDF_NAME(Info), nobj);
}
}
@@ -1467,7 +1467,7 @@ pdf_init_document(fz_context *ctx, pdf_document *doc)
fz_try(ctx)
{
const char *version_str;
- obj = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Version, NULL);
+ obj = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root), PDF_NAME(Version), NULL);
version_str = pdf_to_name(ctx, obj);
if (*version_str)
{
@@ -1609,8 +1609,8 @@ pdf_load_obj_stm(fz_context *ctx, pdf_document *doc, int num, pdf_lexbuf *buf, i
{
pdf_mark_obj(ctx, objstm);
- count = pdf_to_int(ctx, pdf_dict_get(ctx, objstm, PDF_NAME_N));
- first = pdf_to_int(ctx, pdf_dict_get(ctx, objstm, PDF_NAME_First));
+ count = pdf_to_int(ctx, pdf_dict_get(ctx, objstm, PDF_NAME(N)));
+ first = pdf_to_int(ctx, pdf_dict_get(ctx, objstm, PDF_NAME(First)));
if (count < 0 || count > PDF_MAX_OBJECT_NUMBER)
fz_throw(ctx, FZ_ERROR_GENERIC, "number of objects in object stream out of range");
@@ -1846,7 +1846,7 @@ pdf_load_hinted_page(fz_context *ctx, pdf_document *doc, int pagenum)
{
int num = doc->hint_page[pagenum].number;
pdf_obj *page = pdf_load_object(ctx, doc, num);
- if (pdf_name_eq(ctx, PDF_NAME_Page, pdf_dict_get(ctx, page, PDF_NAME_Type)))
+ if (pdf_name_eq(ctx, PDF_NAME(Page), pdf_dict_get(ctx, page, PDF_NAME(Type))))
{
/* We have found the page object! */
DEBUGMESS((ctx, "LoadHintedPage pagenum=%d num=%d", pagenum, num));
@@ -2192,11 +2192,11 @@ pdf_update_stream(fz_context *ctx, pdf_document *doc, pdf_obj *obj, fz_buffer *n
fz_drop_buffer(ctx, x->stm_buf);
x->stm_buf = fz_keep_buffer(ctx, newbuf);
- pdf_dict_put_int(ctx, obj, PDF_NAME_Length, (int)fz_buffer_storage(ctx, newbuf, NULL));
+ pdf_dict_put_int(ctx, obj, PDF_NAME(Length), (int)fz_buffer_storage(ctx, newbuf, NULL));
if (!compressed)
{
- pdf_dict_del(ctx, obj, PDF_NAME_Filter);
- pdf_dict_del(ctx, obj, PDF_NAME_DecodeParms);
+ pdf_dict_del(ctx, obj, PDF_NAME(Filter));
+ pdf_dict_del(ctx, obj, PDF_NAME(DecodeParms));
}
}
@@ -2224,7 +2224,7 @@ pdf_lookup_metadata(fz_context *ctx, pdf_document *doc, const char *key, char *b
char *s;
int n;
- info = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Info);
+ info = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Info));
if (!info)
return -1;
@@ -2344,7 +2344,7 @@ pdf_load_hints(fz_context *ctx, pdf_document *doc, int objnum)
if (dict == NULL || !pdf_is_dict(ctx, dict))
fz_throw(ctx, FZ_ERROR_GENERIC, "malformed hint object");
- shared_hint_offset = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_S));
+ shared_hint_offset = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(S)));
/* Malloc the structures (use realloc to cope with the fact we
* may try this several times before enough data is loaded) */
@@ -2616,8 +2616,8 @@ pdf_obj *pdf_progressive_advance(fz_context *ctx, pdf_document *doc, int pagenum
pdf_obj *pages;
doc->linear_pos = doc->file_length;
pdf_load_xref(ctx, doc, buf);
- catalog = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
- pages = pdf_dict_get(ctx, catalog, PDF_NAME_Pages);
+ catalog = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME(Root));
+ pages = pdf_dict_get(ctx, catalog, PDF_NAME(Pages));
if (!pdf_is_dict(ctx, pages))
fz_throw(ctx, FZ_ERROR_GENERIC, "missing page tree");
@@ -2747,13 +2747,13 @@ pdf_document *pdf_create_document(fz_context *ctx)
pdf_get_populating_xref_entry(ctx, doc, 0);
trailer = pdf_new_dict(ctx, doc, 2);
- pdf_dict_put_int(ctx, trailer, PDF_NAME_Size, 3);
- pdf_dict_put_drop(ctx, trailer, PDF_NAME_Root, root = pdf_add_new_dict(ctx, doc, 2));
- pdf_dict_put(ctx, root, PDF_NAME_Type, PDF_NAME_Catalog);
- pdf_dict_put_drop(ctx, root, PDF_NAME_Pages, pages = pdf_add_new_dict(ctx, doc, 3));
- pdf_dict_put(ctx, pages, PDF_NAME_Type, PDF_NAME_Pages);
- pdf_dict_put_int(ctx, pages, PDF_NAME_Count, 0);
- pdf_dict_put_array(ctx, pages, PDF_NAME_Kids, 1);
+ pdf_dict_put_int(ctx, trailer, PDF_NAME(Size), 3);
+ pdf_dict_put_drop(ctx, trailer, PDF_NAME(Root), root = pdf_add_new_dict(ctx, doc, 2));
+ pdf_dict_put(ctx, root, PDF_NAME(Type), PDF_NAME(Catalog));
+ pdf_dict_put_drop(ctx, root, PDF_NAME(Pages), pages = pdf_add_new_dict(ctx, doc, 3));
+ pdf_dict_put(ctx, pages, PDF_NAME(Type), PDF_NAME(Pages));
+ pdf_dict_put_int(ctx, pages, PDF_NAME(Count), 0);
+ pdf_dict_put_array(ctx, pages, PDF_NAME(Kids), 1);
/* Set the trailer of the final xref section. */
doc->xref_sections[0].trailer = trailer;