summaryrefslogtreecommitdiff
path: root/xps
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2012-02-03 14:30:57 +0100
committerTor Andersson <tor.andersson@artifex.com>2012-02-03 14:30:57 +0100
commite2fe317a9e4649cebd88896cfc3fb790e75bfe6c (patch)
tree18fd5cb530dafb824293715af892f028c2432d55 /xps
parent977ad5326276de29f0b2ae212a1cb4c09d8d94e0 (diff)
downloadmupdf-e2fe317a9e4649cebd88896cfc3fb790e75bfe6c.tar.xz
Add document interface.
Diffstat (limited to 'xps')
-rw-r--r--xps/muxps.h2
-rw-r--r--xps/xps_doc.c7
-rw-r--r--xps/xps_zip.c61
3 files changed, 70 insertions, 0 deletions
diff --git a/xps/muxps.h b/xps/muxps.h
index 2e5c4206..6a6f345f 100644
--- a/xps/muxps.h
+++ b/xps/muxps.h
@@ -215,6 +215,8 @@ struct xps_entry_s
struct xps_document_s
{
+ fz_document super;
+
fz_context *ctx;
char *directory;
fz_stream *file;
diff --git a/xps/xps_doc.c b/xps/xps_doc.c
index 0bc7e443..3a4738dd 100644
--- a/xps/xps_doc.c
+++ b/xps/xps_doc.c
@@ -141,6 +141,13 @@ xps_add_link(xps_document *doc, fz_rect area, char *base_uri, char *target_uri)
}
}
+fz_link *
+xps_load_links(xps_document *doc, xps_page *page)
+{
+ if (!page->links_resolved)
+ fz_warn(doc->ctx, "xps_load_links before page has been executed!");
+ return page->links;
+}
static void
xps_add_fixed_page(xps_document *doc, char *name, int width, int height)
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;
+}