summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-03-20 16:12:26 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-03-22 14:58:18 +0100
commit6d433a5702bda01f17407be6c272eae8653d1800 (patch)
tree0ae255a1488b2da1f729b256f33845f4ddd4b5c9 /source/pdf
parent8d6283fd202e650e80470a544442d384d10a0b7e (diff)
downloadmupdf-6d433a5702bda01f17407be6c272eae8653d1800.tar.xz
Use pdf_dict_put_dict family of functions.
Diffstat (limited to 'source/pdf')
-rw-r--r--source/pdf/pdf-annot-edit.c3
-rw-r--r--source/pdf/pdf-font.c11
-rw-r--r--source/pdf/pdf-image.c4
-rw-r--r--source/pdf/pdf-page.c2
-rw-r--r--source/pdf/pdf-portfolio.c14
-rw-r--r--source/pdf/pdf-xref.c2
6 files changed, 17 insertions, 19 deletions
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c
index 7708f9d7..8ca64198 100644
--- a/source/pdf/pdf-annot-edit.c
+++ b/source/pdf/pdf-annot-edit.c
@@ -496,10 +496,9 @@ pdf_annot_border(fz_context *ctx, pdf_annot *annot)
void
pdf_set_annot_border(fz_context *ctx, pdf_annot *annot, float w)
{
- pdf_document *doc = annot->page->doc;
pdf_obj *bs = pdf_dict_get(ctx, annot->obj, PDF_NAME_BS);
if (!pdf_is_dict(ctx, bs))
- pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_BS, bs = pdf_new_dict(ctx, doc, 1));
+ 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);
}
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index 7caf9e3a..ebefde78 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -1667,8 +1667,7 @@ pdf_add_simple_font_widths(fz_context *ctx, pdf_document *doc, pdf_obj *fobj, fz
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_drop(ctx, fobj, PDF_NAME_CIDSystemInfo, csi = pdf_new_dict(ctx, doc, 3));
+ 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);
@@ -2035,7 +2034,7 @@ pdf_add_cid_font(fz_context *ctx, pdf_document *doc, fz_font *font)
pdf_dict_put(ctx, fobj, PDF_NAME_Encoding, PDF_NAME_Identity_H);
pdf_add_to_unicode(ctx, doc, fobj, font);
- pdf_dict_put_drop(ctx, fobj, PDF_NAME_DescendantFonts, dfonts = pdf_new_array(ctx, doc, 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);
@@ -2055,9 +2054,9 @@ pdf_add_simple_font_encoding_imp(fz_context *ctx, pdf_document *doc, pdf_obj *fo
pdf_obj *enc, *diff;
int i, last;
- pdf_dict_put_drop(ctx, font, PDF_NAME_Encoding, enc = pdf_new_dict(ctx, doc, 3));
+ enc = pdf_dict_put_dict(ctx, font, PDF_NAME_Encoding, 2);
pdf_dict_put(ctx, enc, PDF_NAME_BaseEncoding, PDF_NAME_WinAnsiEncoding);
- pdf_dict_put_drop(ctx, enc, PDF_NAME_Differences, diff = pdf_new_array(ctx, doc, 129));
+ diff = pdf_dict_put_array(ctx, enc, PDF_NAME_Differences, 129);
last = 0;
for (i = 128; i < 256; ++i)
{
@@ -2217,7 +2216,7 @@ pdf_add_cjk_font(fz_context *ctx, pdf_document *doc, fz_font *fzfont, int script
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);
- pdf_dict_put_drop(ctx, font, PDF_NAME_DescendantFonts, dfonts = pdf_new_array(ctx, doc, 1));
+ dfonts = pdf_dict_put_array(ctx, font, PDF_NAME_DescendantFonts, 1);
pdf_array_push_drop(ctx, dfonts, pdf_add_object_drop(ctx, doc, subfont = pdf_new_dict(ctx, doc, 5)));
{
pdf_dict_put(ctx, subfont, PDF_NAME_Type, PDF_NAME_Font);
diff --git a/source/pdf/pdf-image.c b/source/pdf/pdf-image.c
index 2b274e62..35eff099 100644
--- a/source/pdf/pdf-image.c
+++ b/source/pdf/pdf-image.c
@@ -326,7 +326,7 @@ pdf_add_image(fz_context *ctx, pdf_document *doc, fz_image *image, int mask)
imobj = pdf_add_object_drop(ctx, doc, pdf_new_dict(ctx, doc, 3));
fz_try(ctx)
{
- pdf_dict_put_drop(ctx, imobj, PDF_NAME_DecodeParms, dp = pdf_new_dict(ctx, doc, 3));
+ 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);
@@ -482,7 +482,7 @@ raw_or_unknown_compression:
basecs = fz_colorspace_base(ctx, cs);
basen = fz_colorspace_n(ctx, basecs);
- pdf_dict_put_drop(ctx, imobj, PDF_NAME_ColorSpace, arr = pdf_new_array(ctx, doc, 4));
+ arr = pdf_dict_put_array(ctx, imobj, PDF_NAME_ColorSpace, 4);
pdf_array_push(ctx, arr, PDF_NAME_Indexed);
switch (fz_colorspace_type(ctx, basecs))
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c
index f5ab501b..9325ce3e 100644
--- a/source/pdf/pdf-page.c
+++ b/source/pdf/pdf-page.c
@@ -1180,7 +1180,7 @@ pdf_add_page(fz_context *ctx, pdf_document *doc, const fz_rect *mediabox, int ro
else if (pdf_is_dict(ctx, resources))
pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Resources, pdf_add_object(ctx, doc, resources));
else
- pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Resources, pdf_new_dict(ctx, doc, 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));
diff --git a/source/pdf/pdf-portfolio.c b/source/pdf/pdf-portfolio.c
index 4821e8be..c0eca9ec 100644
--- a/source/pdf/pdf-portfolio.c
+++ b/source/pdf/pdf-portfolio.c
@@ -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_drop(ctx, tree, PDF_NAME_Names, pdf_new_array(ctx, doc, 2));
- pdf_dict_put_drop(ctx, tree, PDF_NAME_Limits, pdf_new_array(ctx, doc, 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);
if (names == NULL)
- pdf_dict_put_drop(ctx, data.found, PDF_NAME_Names, (names = pdf_new_array(ctx, doc, 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);
if (limits == NULL)
- pdf_dict_put_drop(ctx, data.found, PDF_NAME_Limits, (limits = pdf_new_array(ctx, doc, 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,8 +631,8 @@ int pdf_add_portfolio_entry(fz_context *ctx, pdf_document *doc,
fz_try(ctx)
{
val = pdf_new_dict(ctx, doc, 6);
- pdf_dict_put_drop(ctx, val, PDF_NAME_CI, pdf_new_dict(ctx, doc, 4));
- pdf_dict_put_drop(ctx, val, PDF_NAME_EF, (ef = pdf_new_dict(ctx, doc, 4)));
+ 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);
@@ -641,7 +641,7 @@ int pdf_add_portfolio_entry(fz_context *ctx, pdf_document *doc,
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);
- pdf_dict_put_drop(ctx, f, PDF_NAME_Params, (params = pdf_new_dict(ctx, doc, 4)));
+ 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);
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index 72e0dc43..133ac570 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -2725,7 +2725,7 @@ pdf_document *pdf_create_document(fz_context *ctx)
pdf_dict_put_drop(ctx, root, PDF_NAME_Pages, pdf_add_object_drop(ctx, doc, pages));
pdf_dict_put(ctx, pages, PDF_NAME_Type, PDF_NAME_Pages);
pdf_dict_put_int(ctx, pages, PDF_NAME_Count, 0);
- pdf_dict_put_drop(ctx, pages, PDF_NAME_Kids, pdf_new_array(ctx, doc, 1));
+ pdf_dict_put_array(ctx, pages, PDF_NAME_Kids, 1);
/* Set the trailer of the final xref section. */
doc->xref_sections[0].trailer = trailer;