diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2012-02-03 14:30:57 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2012-02-03 14:30:57 +0100 |
commit | e2fe317a9e4649cebd88896cfc3fb790e75bfe6c (patch) | |
tree | 18fd5cb530dafb824293715af892f028c2432d55 /xps/xps_zip.c | |
parent | 977ad5326276de29f0b2ae212a1cb4c09d8d94e0 (diff) | |
download | mupdf-e2fe317a9e4649cebd88896cfc3fb790e75bfe6c.tar.xz |
Add document interface.
Diffstat (limited to 'xps/xps_zip.c')
-rw-r--r-- | xps/xps_zip.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/xps/xps_zip.c b/xps/xps_zip.c index 38f0cb60..b3772138 100644 --- a/xps/xps_zip.c +++ b/xps/xps_zip.c @@ -3,6 +3,8 @@ #include <zlib.h> +static void xps_init_document(xps_document *doc); + xps_part * xps_new_part(xps_document *doc, char *name, int size) { @@ -456,6 +458,7 @@ xps_open_document_with_directory(fz_context *ctx, char *directory) xps_document *doc; doc = fz_malloc_struct(ctx, xps_document); + xps_init_document(doc); doc->ctx = ctx; doc->directory = fz_strdup(ctx, directory); @@ -479,6 +482,7 @@ xps_open_document_with_stream(fz_stream *file) xps_document *doc; doc = fz_malloc_struct(ctx, xps_document); + xps_init_document(doc); doc->ctx = ctx; doc->file = fz_keep_stream(file); @@ -563,3 +567,60 @@ xps_close_document(xps_document *doc) fz_free(doc->ctx, doc->directory); fz_free(doc->ctx, doc); } + +/* Document interface wrappers */ + +static void xps_close_document_shim(fz_document *doc) +{ + xps_close_document((xps_document*)doc); +} + +static fz_outline *xps_load_outline_shim(fz_document *doc) +{ + return xps_load_outline((xps_document*)doc); +} + +static int xps_count_pages_shim(fz_document *doc) +{ + return xps_count_pages((xps_document*)doc); +} + +static fz_page *xps_load_page_shim(fz_document *doc, int number) +{ + return (fz_page*) xps_load_page((xps_document*)doc, number); +} + +static fz_link *xps_load_links_shim(fz_document *doc, fz_page *page) +{ + return xps_load_links((xps_document*)doc, (xps_page*)page); +} + +static fz_rect xps_bound_page_shim(fz_document *doc, fz_page *page) +{ + return xps_bound_page((xps_document*)doc, (xps_page*)page); +} + +static void xps_run_page_shim(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix transform, fz_cookie *cookie) +{ + xps_run_page((xps_document*)doc, (xps_page*)page, dev, transform, cookie); +} + +static void xps_free_page_shim(fz_document *doc, fz_page *page) +{ + xps_free_page((xps_document*)doc, (xps_page*)page); +} + +static void +xps_init_document(xps_document *doc) +{ + doc->super.close = xps_close_document_shim; + doc->super.needs_password = NULL; + doc->super.authenticate_password = NULL; + doc->super.load_outline = xps_load_outline_shim; + doc->super.count_pages = xps_count_pages_shim; + doc->super.load_page = xps_load_page_shim; + doc->super.load_links = xps_load_links_shim; + doc->super.bound_page = xps_bound_page_shim; + doc->super.run_page = xps_run_page_shim; + doc->super.free_page = xps_free_page_shim; +} |