summaryrefslogtreecommitdiff
path: root/fitz
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 /fitz
parent977ad5326276de29f0b2ae212a1cb4c09d8d94e0 (diff)
downloadmupdf-e2fe317a9e4649cebd88896cfc3fb790e75bfe6c.tar.xz
Add document interface.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/doc_document.c78
-rw-r--r--fitz/fitz.h39
2 files changed, 114 insertions, 3 deletions
diff --git a/fitz/doc_document.c b/fitz/doc_document.c
new file mode 100644
index 00000000..36f43ee2
--- /dev/null
+++ b/fitz/doc_document.c
@@ -0,0 +1,78 @@
+#include "fitz.h"
+
+void
+fz_close_document(fz_document *doc)
+{
+ if (doc && doc->close)
+ doc->close(doc);
+}
+
+int
+fz_needs_password(fz_document *doc)
+{
+ if (doc && doc->needs_password)
+ return doc->needs_password(doc);
+ return 0;
+}
+
+int
+fz_authenticate_password(fz_document *doc, char *password)
+{
+ if (doc && doc->authenticate_password)
+ return doc->authenticate_password(doc, password);
+ return 1;
+}
+
+fz_outline *
+fz_load_outline(fz_document *doc)
+{
+ if (doc && doc->load_outline)
+ return doc->load_outline(doc);
+ return NULL;
+}
+
+int
+fz_count_pages(fz_document *doc)
+{
+ if (doc && doc->count_pages)
+ return doc->count_pages(doc);
+ return 0;
+}
+
+fz_page *
+fz_load_page(fz_document *doc, int number)
+{
+ if (doc && doc->load_page)
+ return doc->load_page(doc, number);
+ return NULL;
+}
+
+fz_link *
+fz_load_links(fz_document *doc, fz_page *page)
+{
+ if (doc && doc->load_links && page)
+ return doc->load_links(doc, page);
+ return NULL;
+}
+
+fz_rect
+fz_bound_page(fz_document *doc, fz_page *page)
+{
+ if (doc && doc->bound_page && page)
+ return doc->bound_page(doc, page);
+ return fz_empty_rect;
+}
+
+void
+fz_run_page(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix transform, fz_cookie *cookie)
+{
+ if (doc && doc->run_page && page)
+ doc->run_page(doc, page, dev, transform, cookie);
+}
+
+void
+fz_free_page(fz_document *doc, fz_page *page)
+{
+ if (doc && doc->free_page && page)
+ doc->free_page(doc, page);
+}
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 8483817d..9628e505 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -1580,9 +1580,7 @@ fz_link *fz_new_link(fz_context *ctx, fz_rect bbox, fz_link_dest dest);
void fz_free_link(fz_context *ctx, fz_link *link);
void fz_free_link_dest(fz_context *ctx, fz_link_dest *dest);
-/*
- * Document interface.
- */
+/* Outline */
typedef struct fz_outline_s fz_outline;
@@ -1598,4 +1596,39 @@ void fz_debug_outline_xml(fz_outline *outline, int level);
void fz_debug_outline(fz_outline *outline, int level);
void fz_free_outline(fz_context *ctx, fz_outline *outline);
+/* Document interface */
+
+typedef struct fz_document_s fz_document;
+typedef struct fz_page_s fz_page; /* doesn't have a definition -- always cast to *_page */
+
+struct fz_document_s
+{
+ void (*close)(fz_document *);
+ int (*needs_password)(fz_document *doc);
+ int (*authenticate_password)(fz_document *doc, char *password);
+ fz_outline *(*load_outline)(fz_document *doc);
+ int (*count_pages)(fz_document *doc);
+ fz_page *(*load_page)(fz_document *doc, int number);
+ fz_link *(*load_links)(fz_document *doc, fz_page *page);
+ fz_rect (*bound_page)(fz_document *doc, fz_page *page);
+ void (*run_page)(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix transform, fz_cookie *cookie);
+ void (*free_page)(fz_document *doc, fz_page *page);
+};
+
+fz_document *fz_open_document(fz_context *ctx, char *filename);
+
+void fz_close_document(fz_document *doc);
+
+int fz_needs_password(fz_document *doc);
+int fz_authenticate_password(fz_document *doc, char *password);
+
+fz_outline *fz_load_outline(fz_document *doc);
+
+int fz_count_pages(fz_document *doc);
+fz_page *fz_load_page(fz_document *doc, int number);
+fz_link *fz_load_links(fz_document *doc, fz_page *page);
+fz_rect fz_bound_page(fz_document *doc, fz_page *page);
+void fz_run_page(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix transform, fz_cookie *cookie);
+void fz_free_page(fz_document *doc, fz_page *page);
+
#endif