From 4069e52998d2cb2b54e65e8a8b418868ffa73bee Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Tue, 17 Apr 2012 00:40:43 +0100 Subject: Add Meta interface to fz_document. Use this to reintroduce "Document Properties..." in mupdf viewer. --- fitz/doc_document.c | 8 ++++++ fitz/fitz-internal.h | 1 + fitz/fitz.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) (limited to 'fitz') diff --git a/fitz/doc_document.c b/fitz/doc_document.c index 2da7a110..095a7fb5 100644 --- a/fitz/doc_document.c +++ b/fitz/doc_document.c @@ -113,3 +113,11 @@ fz_free_page(fz_document *doc, fz_page *page) if (doc && doc->free_page && page) doc->free_page(doc, page); } + +int +fz_meta(fz_document *doc, int key, void *ptr, int size) +{ + if (doc && doc->meta) + return doc->meta(doc, key, ptr, size); + return FZ_META_UNKNOWN_KEY; +} diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h index b47d984a..bd19886c 100644 --- a/fitz/fitz-internal.h +++ b/fitz/fitz-internal.h @@ -1079,6 +1079,7 @@ struct fz_document_s 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); + int (*meta)(fz_document *doc, int key, void *ptr, int size); }; #endif diff --git a/fitz/fitz.h b/fitz/fitz.h index 1355c740..472b5ac9 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -2154,4 +2154,74 @@ void fz_run_page(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix tran */ void fz_free_page(fz_document *doc, fz_page *page); +/* + fz_meta: Perform a meta operation on a document. + + Meta operations provide a way to perform format specific + operations on a document. The meta operation scheme is + designed to be extensible so that new features can be + transparently added in later versions of the library. + + doc: The document on which to perform the meta operation. + + key: The meta operation to try. If a particular operation + is unsupported on a given document, the function will return + FZ_META_UNKNOWN_KEY. + + ptr: An operation dependent (possibly NULL) pointer. + + size: An operation dependent integer. Often this will + be the size of the block pointed to by ptr, but not always. + + Returns an operation dependent value; FZ_META_UNKNOWN_KEY + always means "unknown operation for this document". In general + FZ_META_OK should be used to indicate successful operation. +*/ +int fz_meta(fz_document *doc, int key, void *ptr, int size); + +enum +{ + FZ_META_UNKNOWN_KEY = -1, + FZ_META_OK = 0, + + /* + ptr: Pointer to block (uninitialised on entry) + size: Size of block (at least 64 bytes) + Returns: Document format as a brief text string. + All formats should support this. + */ + FZ_META_FORMAT_INFO = 1, + + /* + ptr: Pointer to block (uninitialised on entry) + size: Size of block (at least 64 bytes) + Returns: Encryption info as a brief text string. + */ + FZ_META_CRYPT_INFO = 2, + + /* + ptr: NULL + size: Which permission to check + Returns: 1 if permitted, 0 otherwise. + */ + FZ_META_HAS_PERMISSION = 3, + + FZ_PERMISSION_PRINT = 0, + FZ_PERMISSION_CHANGE = 1, + FZ_PERMISSION_COPY = 2, + FZ_PERMISSION_NOTES = 3, + + /* + ptr: Pointer to block. First entry in the block is + a pointer to a UCS string to lookup. The rest of the + block is uninitialised on entry. + size: size of the block in bytes. + Returns: 0 if not found. 1 if found. The string + result is copied into the block (truncated to size + and NULL terminated) + + */ + FZ_META_INFO = 4, +}; + #endif -- cgit v1.2.3