summaryrefslogtreecommitdiff
path: root/pdf/pdf_pagetree.c
diff options
context:
space:
mode:
Diffstat (limited to 'pdf/pdf_pagetree.c')
-rw-r--r--pdf/pdf_pagetree.c128
1 files changed, 64 insertions, 64 deletions
diff --git a/pdf/pdf_pagetree.c b/pdf/pdf_pagetree.c
index df3c8b8a..9320bb9c 100644
--- a/pdf/pdf_pagetree.c
+++ b/pdf/pdf_pagetree.c
@@ -10,132 +10,132 @@ struct info
};
int
-pdf_getpagecount(pdf_xref *xref)
+pdf_get_page_count(pdf_xref *xref)
{
- return xref->pagelen;
+ return xref->page_len;
}
fz_obj *
-pdf_getpageobject(pdf_xref *xref, int number)
+pdf_get_page_object(pdf_xref *xref, int number)
{
- if (number > 0 && number <= xref->pagelen)
- return xref->pageobjs[number - 1];
- return nil;
+ if (number > 0 && number <= xref->page_len)
+ return xref->page_objs[number - 1];
+ return NULL;
}
fz_obj *
-pdf_getpageref(pdf_xref *xref, int number)
+pdf_get_page_ref(pdf_xref *xref, int number)
{
- if (number > 0 && number <= xref->pagelen)
- return xref->pagerefs[number - 1];
- return nil;
+ if (number > 0 && number <= xref->page_len)
+ return xref->page_refs[number - 1];
+ return NULL;
}
int
-pdf_findpageobject(pdf_xref *xref, fz_obj *page)
+pdf_find_page_object(pdf_xref *xref, fz_obj *page)
{
- int num = fz_tonum(page);
- int gen = fz_togen(page);
+ int num = fz_to_num(page);
+ int gen = fz_to_gen(page);
int i;
- for (i = 0; i < xref->pagelen; i++)
- if (num == fz_tonum(xref->pagerefs[i]) && gen == fz_togen(xref->pagerefs[i]))
+ for (i = 0; i < xref->page_len; i++)
+ if (num == fz_to_num(xref->page_refs[i]) && gen == fz_to_gen(xref->page_refs[i]))
return i + 1;
return 0;
}
static void
-pdf_loadpagetreenode(pdf_xref *xref, fz_obj *node, struct info info)
+pdf_load_page_tree_node(pdf_xref *xref, fz_obj *node, struct info info)
{
fz_obj *dict, *kids, *count;
fz_obj *obj, *tmp;
int i, n;
/* prevent infinite recursion */
- if (fz_dictgets(node, ".seen"))
+ if (fz_dict_gets(node, ".seen"))
return;
- kids = fz_dictgets(node, "Kids");
- count = fz_dictgets(node, "Count");
+ kids = fz_dict_gets(node, "Kids");
+ count = fz_dict_gets(node, "Count");
- if (fz_isarray(kids) && fz_isint(count))
+ if (fz_is_array(kids) && fz_is_int(count))
{
- obj = fz_dictgets(node, "Resources");
+ obj = fz_dict_gets(node, "Resources");
if (obj)
info.resources = obj;
- obj = fz_dictgets(node, "MediaBox");
+ obj = fz_dict_gets(node, "MediaBox");
if (obj)
info.mediabox = obj;
- obj = fz_dictgets(node, "CropBox");
+ obj = fz_dict_gets(node, "CropBox");
if (obj)
info.cropbox = obj;
- obj = fz_dictgets(node, "Rotate");
+ obj = fz_dict_gets(node, "Rotate");
if (obj)
info.rotate = obj;
- tmp = fz_newnull();
- fz_dictputs(node, ".seen", tmp);
- fz_dropobj(tmp);
+ tmp = fz_new_null();
+ fz_dict_puts(node, ".seen", tmp);
+ fz_drop_obj(tmp);
- n = fz_arraylen(kids);
+ n = fz_array_len(kids);
for (i = 0; i < n; i++)
{
- obj = fz_arrayget(kids, i);
- pdf_loadpagetreenode(xref, obj, info);
+ obj = fz_array_get(kids, i);
+ pdf_load_page_tree_node(xref, obj, info);
}
- fz_dictdels(node, ".seen");
+ fz_dict_dels(node, ".seen");
}
else
{
- dict = fz_resolveindirect(node);
-
- if (info.resources && !fz_dictgets(dict, "Resources"))
- fz_dictputs(dict, "Resources", info.resources);
- if (info.mediabox && !fz_dictgets(dict, "MediaBox"))
- fz_dictputs(dict, "MediaBox", info.mediabox);
- if (info.cropbox && !fz_dictgets(dict, "CropBox"))
- fz_dictputs(dict, "CropBox", info.cropbox);
- if (info.rotate && !fz_dictgets(dict, "Rotate"))
- fz_dictputs(dict, "Rotate", info.rotate);
-
- if (xref->pagelen == xref->pagecap)
+ dict = fz_resolve_indirect(node);
+
+ if (info.resources && !fz_dict_gets(dict, "Resources"))
+ fz_dict_puts(dict, "Resources", info.resources);
+ if (info.mediabox && !fz_dict_gets(dict, "MediaBox"))
+ fz_dict_puts(dict, "MediaBox", info.mediabox);
+ if (info.cropbox && !fz_dict_gets(dict, "CropBox"))
+ fz_dict_puts(dict, "CropBox", info.cropbox);
+ if (info.rotate && !fz_dict_gets(dict, "Rotate"))
+ fz_dict_puts(dict, "Rotate", info.rotate);
+
+ if (xref->page_len == xref->page_cap)
{
fz_warn("found more pages than expected");
- xref->pagecap ++;
- xref->pagerefs = fz_realloc(xref->pagerefs, xref->pagecap, sizeof(fz_obj*));
- xref->pageobjs = fz_realloc(xref->pageobjs, xref->pagecap, sizeof(fz_obj*));
+ xref->page_cap ++;
+ xref->page_refs = fz_realloc(xref->page_refs, xref->page_cap, sizeof(fz_obj*));
+ xref->page_objs = fz_realloc(xref->page_objs, xref->page_cap, sizeof(fz_obj*));
}
- xref->pagerefs[xref->pagelen] = fz_keepobj(node);
- xref->pageobjs[xref->pagelen] = fz_keepobj(dict);
- xref->pagelen ++;
+ xref->page_refs[xref->page_len] = fz_keep_obj(node);
+ xref->page_objs[xref->page_len] = fz_keep_obj(dict);
+ xref->page_len ++;
}
}
fz_error
-pdf_loadpagetree(pdf_xref *xref)
+pdf_load_page_tree(pdf_xref *xref)
{
struct info info;
- fz_obj *catalog = fz_dictgets(xref->trailer, "Root");
- fz_obj *pages = fz_dictgets(catalog, "Pages");
- fz_obj *count = fz_dictgets(pages, "Count");
+ fz_obj *catalog = fz_dict_gets(xref->trailer, "Root");
+ fz_obj *pages = fz_dict_gets(catalog, "Pages");
+ fz_obj *count = fz_dict_gets(pages, "Count");
- if (!fz_isdict(pages))
+ if (!fz_is_dict(pages))
return fz_throw("missing page tree");
- if (!fz_isint(count))
+ if (!fz_is_int(count))
return fz_throw("missing page count");
- xref->pagecap = fz_toint(count);
- xref->pagelen = 0;
- xref->pagerefs = fz_calloc(xref->pagecap, sizeof(fz_obj*));
- xref->pageobjs = fz_calloc(xref->pagecap, sizeof(fz_obj*));
+ xref->page_cap = fz_to_int(count);
+ xref->page_len = 0;
+ xref->page_refs = fz_calloc(xref->page_cap, sizeof(fz_obj*));
+ xref->page_objs = fz_calloc(xref->page_cap, sizeof(fz_obj*));
- info.resources = nil;
- info.mediabox = nil;
- info.cropbox = nil;
- info.rotate = nil;
+ info.resources = NULL;
+ info.mediabox = NULL;
+ info.cropbox = NULL;
+ info.rotate = NULL;
- pdf_loadpagetreenode(xref, pages, info);
+ pdf_load_page_tree_node(xref, pages, info);
return fz_okay;
}