summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/pdf/object.h4
-rw-r--r--source/pdf/pdf-annot.c12
-rw-r--r--source/pdf/pdf-appearance.c4
-rw-r--r--source/pdf/pdf-object.c20
-rw-r--r--source/pdf/pdf-pattern.c9
-rw-r--r--source/pdf/pdf-shade.c5
-rw-r--r--source/pdf/pdf-signature.c4
-rw-r--r--source/pdf/pdf-type3.c8
-rw-r--r--source/pdf/pdf-xobject.c4
9 files changed, 43 insertions, 27 deletions
diff --git a/include/mupdf/pdf/object.h b/include/mupdf/pdf/object.h
index e4a9b313..bc81a9b3 100644
--- a/include/mupdf/pdf/object.h
+++ b/include/mupdf/pdf/object.h
@@ -138,6 +138,8 @@ float pdf_dict_get_real(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
const char *pdf_dict_get_name(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
const char *pdf_dict_get_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key, size_t *sizep);
const char *pdf_dict_get_text_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
+fz_rect pdf_dict_get_rect(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
+fz_matrix pdf_dict_get_matrix(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
void pdf_array_push_bool(fz_context *ctx, pdf_obj *array, int x);
void pdf_array_push_int(fz_context *ctx, pdf_obj *array, int64_t x);
@@ -153,6 +155,8 @@ int pdf_array_get_int(fz_context *ctx, pdf_obj *array, int index);
float pdf_array_get_real(fz_context *ctx, pdf_obj *array, int index);
const char *pdf_array_get_string(fz_context *ctx, pdf_obj *array, int index, size_t *sizep);
const char *pdf_array_get_text_string(fz_context *ctx, pdf_obj *array, int index);
+fz_rect pdf_array_get_rect(fz_context *ctx, pdf_obj *array, int index);
+fz_matrix pdf_array_get_matrix(fz_context *ctx, pdf_obj *array, int index);
/*
Recurse through the object structure setting the node's parent_num to num.
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c
index e2e2392f..1c17882c 100644
--- a/source/pdf/pdf-annot.c
+++ b/source/pdf/pdf-annot.c
@@ -38,7 +38,7 @@ pdf_annot_transform(fz_context *ctx, pdf_annot *annot)
fz_matrix matrix;
float w, h, x, y;
- rect = pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)));
+ rect = pdf_dict_get_rect(ctx, annot->obj, PDF_NAME(Rect));
bbox = pdf_xobject_bbox(ctx, annot->ap);
matrix = pdf_xobject_matrix(ctx, annot->ap);
@@ -127,9 +127,10 @@ pdf_next_annot(fz_context *ctx, pdf_annot *annot)
fz_rect
pdf_bound_annot(fz_context *ctx, pdf_annot *annot)
{
- fz_rect annot_rect = pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)));
fz_matrix page_ctm;
+ fz_rect annot_rect;
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
+ annot_rect = pdf_dict_get_rect(ctx, annot->obj, PDF_NAME(Rect));
return fz_transform_rect(annot_rect, page_ctm);
}
@@ -370,11 +371,10 @@ fz_rect
pdf_annot_rect(fz_context *ctx, pdf_annot *annot)
{
fz_matrix page_ctm;
- fz_rect rect;
+ fz_rect annot_rect;
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- rect = pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)));
- fz_transform_rect(rect, page_ctm);
- return rect;
+ annot_rect = pdf_dict_get_rect(ctx, annot->obj, PDF_NAME(Rect));
+ return fz_transform_rect(annot_rect, page_ctm);
}
void
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index 1bf0fd33..a23bbaf1 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -1213,7 +1213,7 @@ void pdf_update_signature_appearance(fz_context *ctx, pdf_annot *annot, const ch
fz_rect rect;
float w, h, size, name_w;
- rect = pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)));
+ rect = pdf_dict_get_rect(ctx, annot->obj, PDF_NAME(Rect));
fz_var(helv);
fz_var(zadb);
@@ -1334,7 +1334,7 @@ void pdf_update_appearance(fz_context *ctx, pdf_annot *annot)
fz_try(ctx)
{
- rect = pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)));
+ rect = pdf_dict_get_rect(ctx, annot->obj, PDF_NAME(Rect));
pdf_write_appearance(ctx, annot, buf, &rect, &bbox, &matrix, &res);
pdf_dict_put_rect(ctx, annot->obj, PDF_NAME(Rect), rect);
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c
index 32a02b9b..7452cefa 100644
--- a/source/pdf/pdf-object.c
+++ b/source/pdf/pdf-object.c
@@ -2296,6 +2296,16 @@ const char *pdf_dict_get_text_string(fz_context *ctx, pdf_obj *dict, pdf_obj *ke
return pdf_to_text_string(ctx, pdf_dict_get(ctx, dict, key));
}
+fz_rect pdf_dict_get_rect(fz_context *ctx, pdf_obj *dict, pdf_obj *key)
+{
+ return pdf_to_rect(ctx, pdf_dict_get(ctx, dict, key));
+}
+
+fz_matrix pdf_dict_get_matrix(fz_context *ctx, pdf_obj *dict, pdf_obj *key)
+{
+ return pdf_to_matrix(ctx, pdf_dict_get(ctx, dict, key));
+}
+
int pdf_array_get_bool(fz_context *ctx, pdf_obj *array, int index)
{
return pdf_to_bool(ctx, pdf_array_get(ctx, array, index));
@@ -2320,3 +2330,13 @@ const char *pdf_array_get_text_string(fz_context *ctx, pdf_obj *array, int index
{
return pdf_to_text_string(ctx, pdf_array_get(ctx, array, index));
}
+
+fz_rect pdf_array_get_rect(fz_context *ctx, pdf_obj *array, int index)
+{
+ return pdf_to_rect(ctx, pdf_array_get(ctx, array, index));
+}
+
+fz_matrix pdf_array_get_matrix(fz_context *ctx, pdf_obj *array, int index)
+{
+ return pdf_to_matrix(ctx, pdf_array_get(ctx, array, index));
+}
diff --git a/source/pdf/pdf-pattern.c b/source/pdf/pdf-pattern.c
index 5574a565..5a01bbcd 100644
--- a/source/pdf/pdf-pattern.c
+++ b/source/pdf/pdf-pattern.c
@@ -34,7 +34,6 @@ pdf_pattern *
pdf_load_pattern(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
{
pdf_pattern *pat;
- pdf_obj *obj;
if ((pat = pdf_find_item(ctx, pdf_drop_pattern_imp, dict)) != NULL)
{
@@ -56,12 +55,8 @@ pdf_load_pattern(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
pat->ismask = pdf_dict_get_int(ctx, dict, PDF_NAME(PaintType)) == 2;
pat->xstep = pdf_dict_get_real(ctx, dict, PDF_NAME(XStep));
pat->ystep = pdf_dict_get_real(ctx, dict, PDF_NAME(YStep));
-
- obj = pdf_dict_get(ctx, dict, PDF_NAME(BBox));
- pat->bbox = pdf_to_rect(ctx, obj);
-
- obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix));
- pat->matrix = pdf_to_matrix(ctx, obj);
+ pat->bbox = pdf_dict_get_rect(ctx, dict, PDF_NAME(BBox));
+ pat->matrix = pdf_dict_get_matrix(ctx, dict, PDF_NAME(Matrix));
pat->resources = pdf_dict_get(ctx, dict, PDF_NAME(Resources));
if (pat->resources)
diff --git a/source/pdf/pdf-shade.c b/source/pdf/pdf-shade.c
index 13c1ebc8..970a2ed1 100644
--- a/source/pdf/pdf-shade.c
+++ b/source/pdf/pdf-shade.c
@@ -69,7 +69,7 @@ pdf_load_function_based_shading(fz_context *ctx, pdf_document *doc, fz_shade *sh
y1 = pdf_array_get_real(ctx, obj, 3);
}
- shade->u.f.matrix = pdf_to_matrix(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Matrix)));
+ shade->u.f.matrix = pdf_dict_get_matrix(ctx, dict, PDF_NAME(Matrix));
shade->u.f.xdivs = FUNSEGS;
shade->u.f.ydivs = FUNSEGS;
shade->u.f.fn_vals = fz_malloc(ctx, (FUNSEGS+1)*(FUNSEGS+1)*n*sizeof(float));
@@ -442,8 +442,7 @@ 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)))
{
- obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix));
- mat = pdf_to_matrix(ctx, obj);
+ mat = pdf_dict_get_matrix(ctx, dict, PDF_NAME(Matrix));
obj = pdf_dict_get(ctx, dict, PDF_NAME(ExtGState));
if (obj)
diff --git a/source/pdf/pdf-signature.c b/source/pdf/pdf-signature.c
index aaa2c5e1..213c33e1 100644
--- a/source/pdf/pdf-signature.c
+++ b/source/pdf/pdf-signature.c
@@ -67,9 +67,9 @@ void pdf_sign_signature(fz_context *ctx, pdf_document *doc, pdf_widget *widget,
{
const char *dn_str;
pdf_obj *wobj = ((pdf_annot *)widget)->obj;
- fz_rect rect = fz_empty_rect;
+ fz_rect rect;
- rect = pdf_to_rect(ctx, pdf_dict_get(ctx, wobj, PDF_NAME(Rect)));
+ rect = pdf_dict_get_rect(ctx, wobj, PDF_NAME(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-type3.c b/source/pdf/pdf-type3.c
index d88d687a..d94cfb5b 100644
--- a/source/pdf/pdf-type3.c
+++ b/source/pdf/pdf-type3.c
@@ -55,11 +55,9 @@ 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));
- matrix = pdf_to_matrix(ctx, obj);
-
- obj = pdf_dict_get(ctx, dict, PDF_NAME(FontBBox));
- bbox = fz_transform_rect(pdf_to_rect(ctx, obj), matrix);
+ matrix = pdf_dict_get_matrix(ctx, dict, PDF_NAME(FontMatrix));
+ bbox = pdf_dict_get_rect(ctx, dict, PDF_NAME(FontBBox));
+ bbox = fz_transform_rect(bbox, matrix);
font = fz_new_type3_font(ctx, buf, matrix);
fontdesc->font = font;
diff --git a/source/pdf/pdf-xobject.c b/source/pdf/pdf-xobject.c
index 2cfe1f8f..8219c762 100644
--- a/source/pdf/pdf-xobject.c
+++ b/source/pdf/pdf-xobject.c
@@ -10,13 +10,13 @@ pdf_xobject_resources(fz_context *ctx, pdf_obj *xobj)
fz_rect
pdf_xobject_bbox(fz_context *ctx, pdf_obj *xobj)
{
- return pdf_to_rect(ctx, pdf_dict_get(ctx, xobj, PDF_NAME(BBox)));
+ return pdf_dict_get_rect(ctx, xobj, PDF_NAME(BBox));
}
fz_matrix
pdf_xobject_matrix(fz_context *ctx, pdf_obj *xobj)
{
- return pdf_to_matrix(ctx, pdf_dict_get(ctx, xobj, PDF_NAME(Matrix)));
+ return pdf_dict_get_matrix(ctx, xobj, PDF_NAME(Matrix));
}
int pdf_xobject_isolated(fz_context *ctx, pdf_obj *xobj)