diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2017-04-27 12:43:00 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-04-27 15:12:03 +0200 |
commit | c586d072fd786e66851173f5ddd31241ad28f3e6 (patch) | |
tree | d6db1b68dc122f8349513633ae76a73ed353b69b | |
parent | ce680b96e207c90429eb702c5ee4b9bec177fdfd (diff) | |
download | mupdf-c586d072fd786e66851173f5ddd31241ad28f3e6.tar.xz |
Avoid typecasting function pointers in subclasses.
Do the typecasting in the functions instead, reducing the risk
of function prototype mismatches.
-rw-r--r-- | source/cbz/mucbz.c | 45 | ||||
-rw-r--r-- | source/cbz/muimg.c | 39 | ||||
-rw-r--r-- | source/cbz/mutiff.c | 42 | ||||
-rw-r--r-- | source/pdf/pdf-resources.c | 9 | ||||
-rw-r--r-- | source/xps/xps-doc.c | 35 | ||||
-rw-r--r-- | source/xps/xps-imp.h | 41 | ||||
-rw-r--r-- | source/xps/xps-link.c | 3 | ||||
-rw-r--r-- | source/xps/xps-outline.c | 5 | ||||
-rw-r--r-- | source/xps/xps-tile.c | 3 | ||||
-rw-r--r-- | source/xps/xps-zip.c | 31 |
10 files changed, 132 insertions, 121 deletions
diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c index e75823a6..7000dc8f 100644 --- a/source/cbz/mucbz.c +++ b/source/cbz/mucbz.c @@ -121,21 +121,24 @@ cbz_create_page_list(fz_context *ctx, cbz_document *doc) } static void -cbz_drop_document(fz_context *ctx, cbz_document *doc) +cbz_drop_document(fz_context *ctx, fz_document *doc_) { + cbz_document *doc = (cbz_document*)doc_; fz_drop_archive(ctx, doc->arch); fz_free(ctx, (char **)doc->page); } static int -cbz_count_pages(fz_context *ctx, cbz_document *doc) +cbz_count_pages(fz_context *ctx, fz_document *doc_) { + cbz_document *doc = (cbz_document*)doc_; return doc->page_count; } static fz_rect * -cbz_bound_page(fz_context *ctx, cbz_page *page, fz_rect *bbox) +cbz_bound_page(fz_context *ctx, fz_page *page_, fz_rect *bbox) { + cbz_page *page = (cbz_page*)page_; fz_image *image = page->image; int xres, yres; @@ -147,8 +150,9 @@ cbz_bound_page(fz_context *ctx, cbz_page *page, fz_rect *bbox) } static void -cbz_run_page(fz_context *ctx, cbz_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie) +cbz_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie) { + cbz_page *page = (cbz_page*)page_; fz_matrix local_ctm = *ctm; fz_image *image = page->image; int xres, yres; @@ -162,14 +166,16 @@ cbz_run_page(fz_context *ctx, cbz_page *page, fz_device *dev, const fz_matrix *c } static void -cbz_drop_page(fz_context *ctx, cbz_page *page) +cbz_drop_page(fz_context *ctx, fz_page *page_) { + cbz_page *page = (cbz_page*)page_; fz_drop_image(ctx, page->image); } -static cbz_page * -cbz_load_page(fz_context *ctx, cbz_document *doc, int number) +static fz_page * +cbz_load_page(fz_context *ctx, fz_document *doc_, int number) { + cbz_document *doc = (cbz_document*)doc_; cbz_page *page = NULL; fz_buffer *buf = NULL; @@ -186,9 +192,9 @@ cbz_load_page(fz_context *ctx, cbz_document *doc, int number) fz_try(ctx) { page = fz_new_derived_page(ctx, cbz_page); - page->super.bound_page = (fz_page_bound_page_fn*)cbz_bound_page; - page->super.run_page_contents = (fz_page_run_page_contents_fn*)cbz_run_page; - page->super.drop_page = (fz_page_drop_page_fn*)cbz_drop_page; + page->super.bound_page = cbz_bound_page; + page->super.run_page_contents = cbz_run_page; + page->super.drop_page = cbz_drop_page; page->image = fz_new_image_from_buffer(ctx, buf); } fz_always(ctx) @@ -197,16 +203,17 @@ cbz_load_page(fz_context *ctx, cbz_document *doc, int number) } fz_catch(ctx) { - fz_drop_page(ctx, &page->super); + fz_drop_page(ctx, (fz_page*)page); fz_rethrow(ctx); } - return page; + return (fz_page*)page; } static int -cbz_lookup_metadata(fz_context *ctx, cbz_document *doc, const char *key, char *buf, int size) +cbz_lookup_metadata(fz_context *ctx, fz_document *doc_, const char *key, char *buf, int size) { + cbz_document *doc = (cbz_document*)doc_; if (!strcmp(key, "format")) return (int) fz_strlcpy(buf, fz_archive_format(ctx, doc->arch), size); return -1; @@ -219,10 +226,10 @@ cbz_open_document_with_stream(fz_context *ctx, fz_stream *file) doc = fz_new_derived_document(ctx, cbz_document); - doc->super.drop_document = (fz_document_drop_fn*)cbz_drop_document; - doc->super.count_pages = (fz_document_count_pages_fn*)cbz_count_pages; - doc->super.load_page = (fz_document_load_page_fn*)cbz_load_page; - doc->super.lookup_metadata = (fz_document_lookup_metadata_fn*)cbz_lookup_metadata; + doc->super.drop_document = cbz_drop_document; + doc->super.count_pages = cbz_count_pages; + doc->super.load_page = cbz_load_page; + doc->super.lookup_metadata = cbz_lookup_metadata; fz_try(ctx) { @@ -231,10 +238,10 @@ cbz_open_document_with_stream(fz_context *ctx, fz_stream *file) } fz_catch(ctx) { - fz_drop_document(ctx, &doc->super); + fz_drop_document(ctx, (fz_document*)doc); fz_rethrow(ctx); } - return &doc->super; + return (fz_document*)doc; } static const char *cbz_extensions[] = diff --git a/source/cbz/muimg.c b/source/cbz/muimg.c index d2dd7d19..6fe0687d 100644 --- a/source/cbz/muimg.c +++ b/source/cbz/muimg.c @@ -20,20 +20,22 @@ struct img_document_s }; static void -img_drop_document(fz_context *ctx, img_document *doc) +img_drop_document(fz_context *ctx, fz_document *doc_) { + img_document *doc = (img_document*)doc_; fz_drop_image(ctx, doc->image); } static int -img_count_pages(fz_context *ctx, img_document *doc) +img_count_pages(fz_context *ctx, fz_document *doc_) { return 1; } static fz_rect * -img_bound_page(fz_context *ctx, img_page *page, fz_rect *bbox) +img_bound_page(fz_context *ctx, fz_page *page_, fz_rect *bbox) { + img_page *page = (img_page*)page_; fz_image *image = page->image; int xres, yres; fz_image_resolution(image, &xres, &yres); @@ -44,8 +46,9 @@ img_bound_page(fz_context *ctx, img_page *page, fz_rect *bbox) } static void -img_run_page(fz_context *ctx, img_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie) +img_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie) { + img_page *page = (img_page*)page_; fz_matrix local_ctm = *ctm; fz_image *image = page->image; int xres, yres; @@ -58,14 +61,16 @@ img_run_page(fz_context *ctx, img_page *page, fz_device *dev, const fz_matrix *c } static void -img_drop_page(fz_context *ctx, img_page *page) +img_drop_page(fz_context *ctx, fz_page *page_) { + img_page *page = (img_page*)page_; fz_drop_image(ctx, page->image); } -static img_page * -img_load_page(fz_context *ctx, img_document *doc, int number) +static fz_page * +img_load_page(fz_context *ctx, fz_document *doc_, int number) { + img_document *doc = (img_document*)doc_; img_page *page; if (number != 0) @@ -73,17 +78,17 @@ img_load_page(fz_context *ctx, img_document *doc, int number) page = fz_new_derived_page(ctx, img_page); - page->super.bound_page = (fz_page_bound_page_fn*)img_bound_page; - page->super.run_page_contents = (fz_page_run_page_contents_fn*)img_run_page; - page->super.drop_page = (fz_page_drop_page_fn*)img_drop_page; + page->super.bound_page = img_bound_page; + page->super.run_page_contents = img_run_page; + page->super.drop_page = img_drop_page; page->image = fz_keep_image(ctx, doc->image); - return page; + return (fz_page*)page; } static int -img_lookup_metadata(fz_context *ctx, img_document *doc, const char *key, char *buf, int size) +img_lookup_metadata(fz_context *ctx, fz_document *doc_, const char *key, char *buf, int size) { if (!strcmp(key, "format")) return (int)fz_strlcpy(buf, "Image", size); @@ -95,10 +100,10 @@ img_new_document(fz_context *ctx, fz_image *image) { img_document *doc = fz_new_derived_document(ctx, img_document); - doc->super.drop_document = (fz_document_drop_fn*)img_drop_document; - doc->super.count_pages = (fz_document_count_pages_fn*)img_count_pages; - doc->super.load_page = (fz_document_load_page_fn*)img_load_page; - doc->super.lookup_metadata = (fz_document_lookup_metadata_fn*)img_lookup_metadata; + doc->super.drop_document = img_drop_document; + doc->super.count_pages = img_count_pages; + doc->super.load_page = img_load_page; + doc->super.lookup_metadata = img_lookup_metadata; doc->image = fz_keep_image(ctx, image); @@ -129,7 +134,7 @@ img_open_document_with_stream(fz_context *ctx, fz_stream *stm) fz_catch(ctx) fz_rethrow(ctx); - return &doc->super; + return (fz_document*)doc; } static const char *img_extensions[] = diff --git a/source/cbz/mutiff.c b/source/cbz/mutiff.c index c9dd2fb1..9cd306f2 100644 --- a/source/cbz/mutiff.c +++ b/source/cbz/mutiff.c @@ -21,8 +21,9 @@ struct tiff_document_s }; static fz_rect * -tiff_bound_page(fz_context *ctx, tiff_page *page, fz_rect *bbox) +tiff_bound_page(fz_context *ctx, fz_page *page_, fz_rect *bbox) { + tiff_page *page = (tiff_page*)page_; fz_image *image = page->image; int xres, yres; @@ -34,8 +35,9 @@ tiff_bound_page(fz_context *ctx, tiff_page *page, fz_rect *bbox) } static void -tiff_run_page(fz_context *ctx, tiff_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie) +tiff_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie) { + tiff_page *page = (tiff_page*)page_; fz_matrix local_ctm = *ctm; fz_image *image = page->image; int xres, yres; @@ -49,14 +51,16 @@ tiff_run_page(fz_context *ctx, tiff_page *page, fz_device *dev, const fz_matrix } static void -tiff_drop_page(fz_context *ctx, tiff_page *page) +tiff_drop_page(fz_context *ctx, fz_page *page_) { + tiff_page *page = (tiff_page*)page_; fz_drop_image(ctx, page->image); } -static tiff_page * -tiff_load_page(fz_context *ctx, tiff_document *doc, int number) +static fz_page * +tiff_load_page(fz_context *ctx, fz_document *doc_, int number) { + tiff_document *doc = (tiff_document*)doc_; fz_pixmap *pixmap = NULL; fz_image *image = NULL; tiff_page *page = NULL; @@ -77,9 +81,9 @@ tiff_load_page(fz_context *ctx, tiff_document *doc, int number) image = fz_new_image_from_pixmap(ctx, pixmap, NULL); page = fz_new_derived_page(ctx, tiff_page); - page->super.bound_page = (fz_page_bound_page_fn*)tiff_bound_page; - page->super.run_page_contents = (fz_page_run_page_contents_fn*)tiff_run_page; - page->super.drop_page = (fz_page_drop_page_fn*)tiff_drop_page; + page->super.bound_page = tiff_bound_page; + page->super.run_page_contents = tiff_run_page; + page->super.drop_page = tiff_drop_page; page->image = fz_keep_image(ctx, image); } fz_always(ctx) @@ -93,17 +97,18 @@ tiff_load_page(fz_context *ctx, tiff_document *doc, int number) fz_rethrow(ctx); } - return page; + return (fz_page*)page; } static int -tiff_count_pages(fz_context *ctx, tiff_document *doc) +tiff_count_pages(fz_context *ctx, fz_document *doc_) { + tiff_document *doc = (tiff_document*)doc_; return doc->page_count; } static int -tiff_lookup_metadata(fz_context *ctx, tiff_document *doc, const char *key, char *buf, int size) +tiff_lookup_metadata(fz_context *ctx, fz_document *doc_, const char *key, char *buf, int size) { if (!strcmp(key, "format")) return (int)fz_strlcpy(buf, "TIFF", size); @@ -111,8 +116,9 @@ tiff_lookup_metadata(fz_context *ctx, tiff_document *doc, const char *key, char } static void -tiff_drop_document(fz_context *ctx, tiff_document *doc) +tiff_drop_document(fz_context *ctx, fz_document *doc_) { + tiff_document *doc = (tiff_document*)doc_; fz_drop_buffer(ctx, doc->buffer); } @@ -123,10 +129,10 @@ tiff_open_document_with_stream(fz_context *ctx, fz_stream *file) doc = fz_new_derived_document(ctx, tiff_document); - doc->super.drop_document = (fz_document_drop_fn*)tiff_drop_document; - doc->super.count_pages = (fz_document_count_pages_fn*)tiff_count_pages; - doc->super.load_page = (fz_document_load_page_fn*)tiff_load_page; - doc->super.lookup_metadata = (fz_document_lookup_metadata_fn*)tiff_lookup_metadata; + doc->super.drop_document = tiff_drop_document; + doc->super.count_pages = tiff_count_pages; + doc->super.load_page = tiff_load_page; + doc->super.lookup_metadata = tiff_lookup_metadata; fz_try(ctx) { @@ -138,11 +144,11 @@ tiff_open_document_with_stream(fz_context *ctx, fz_stream *file) } fz_catch(ctx) { - fz_drop_document(ctx, &doc->super); + fz_drop_document(ctx, (fz_document*)doc); fz_rethrow(ctx); } - return &doc->super; + return (fz_document*)doc; } static const char *tiff_extensions[] = diff --git a/source/pdf/pdf-resources.c b/source/pdf/pdf-resources.c index f3b71e23..67008159 100644 --- a/source/pdf/pdf-resources.c +++ b/source/pdf/pdf-resources.c @@ -70,6 +70,11 @@ pdf_preload_image_resources(fz_context *ctx, pdf_document *doc) } } +static void pdf_drop_obj_as_void(fz_context *ctx, void *obj) +{ + pdf_drop_obj(ctx, obj); +} + pdf_obj * pdf_find_image_resource(fz_context *ctx, pdf_document *doc, fz_image *item, unsigned char digest[16]) { @@ -77,7 +82,7 @@ pdf_find_image_resource(fz_context *ctx, pdf_document *doc, fz_image *item, unsi if (!doc->resources.images) { - doc->resources.images = fz_new_hash_table(ctx, 4096, 16, -1, (fz_hash_table_drop_fn*)pdf_drop_obj); + doc->resources.images = fz_new_hash_table(ctx, 4096, 16, -1, pdf_drop_obj_as_void); pdf_preload_image_resources(ctx, doc); } @@ -111,7 +116,7 @@ pdf_find_font_resource(fz_context *ctx, pdf_document *doc, fz_buffer *item, unsi pdf_obj *res; if (!doc->resources.fonts) - doc->resources.fonts = fz_new_hash_table(ctx, 4096, 16, -1, (fz_hash_table_drop_fn*)pdf_drop_obj); + doc->resources.fonts = fz_new_hash_table(ctx, 4096, 16, -1, pdf_drop_obj_as_void); /* Create md5 and see if we have the item in our table */ fz_md5_buffer(ctx, item, digest); diff --git a/source/xps/xps-doc.c b/source/xps/xps-doc.c index c4034d48..611e5903 100644 --- a/source/xps/xps-doc.c +++ b/source/xps/xps-doc.c @@ -105,10 +105,11 @@ xps_add_link_target(fz_context *ctx, xps_document *doc, char *name) } int -xps_lookup_link_target(fz_context *ctx, xps_document *doc, char *target_uri, float *xp, float *yp) +xps_lookup_link_target(fz_context *ctx, fz_document *doc_, const char *target_uri, float *xp, float *yp) { + xps_document *doc = (xps_document*)doc_; xps_target *target; - char *needle = strrchr(target_uri, '#'); + const char *needle = strrchr(target_uri, '#'); needle = needle ? needle + 1 : target_uri; for (target = doc->target; target; target = target->next) if (!strcmp(target->name, needle)) @@ -318,8 +319,9 @@ xps_read_page_list(fz_context *ctx, xps_document *doc) } int -xps_count_pages(fz_context *ctx, xps_document *doc) +xps_count_pages(fz_context *ctx, fz_document *doc_) { + xps_document *doc = (xps_document*)doc_; return doc->page_count; } @@ -388,8 +390,9 @@ xps_load_fixed_page(fz_context *ctx, xps_document *doc, xps_fixpage *page) } static fz_rect * -xps_bound_page(fz_context *ctx, xps_page *page, fz_rect *bounds) +xps_bound_page(fz_context *ctx, fz_page *page_, fz_rect *bounds) { + xps_page *page = (xps_page*)page_; bounds->x0 = bounds->y0 = 0; bounds->x1 = page->fix->width * 72.0f / 96.0f; bounds->y1 = page->fix->height * 72.0f / 96.0f; @@ -397,15 +400,17 @@ xps_bound_page(fz_context *ctx, xps_page *page, fz_rect *bounds) } static void -xps_drop_page_imp(fz_context *ctx, xps_page *page) +xps_drop_page_imp(fz_context *ctx, fz_page *page_) { + xps_page *page = (xps_page*)page_; fz_drop_document(ctx, &page->doc->super); fz_drop_xml(ctx, page->root); } -xps_page * -xps_load_page(fz_context *ctx, xps_document *doc, int number) +fz_page * +xps_load_page(fz_context *ctx, fz_document *doc_, int number) { + xps_document *doc = (xps_document*)doc_; xps_page *page = NULL; xps_fixpage *fix; fz_xml *root; @@ -421,12 +426,12 @@ xps_load_page(fz_context *ctx, xps_document *doc, int number) fz_try(ctx) { page = fz_new_derived_page(ctx, xps_page); - page->super.load_links = (fz_page_load_links_fn*)xps_load_links; - page->super.bound_page = (fz_page_bound_page_fn*)xps_bound_page; - page->super.run_page_contents = (fz_page_run_page_contents_fn*)xps_run_page; - page->super.drop_page = (fz_page_drop_page_fn*)xps_drop_page_imp; + page->super.load_links = xps_load_links; + page->super.bound_page = xps_bound_page; + page->super.run_page_contents = xps_run_page; + page->super.drop_page = xps_drop_page_imp; - page->doc = (xps_document*) fz_keep_document(ctx, &doc->super); + page->doc = (xps_document*) fz_keep_document(ctx, (fz_document*)doc); page->fix = fix; page->root = root; } @@ -435,7 +440,7 @@ xps_load_page(fz_context *ctx, xps_document *doc, int number) fz_drop_xml(ctx, root); fz_rethrow(ctx); } - return page; + return (fz_page*)page; } n ++; } @@ -469,8 +474,8 @@ static const char *xps_mimetypes[] = fz_document_handler xps_document_handler = { xps_recognize, - (fz_document_open_fn*)xps_open_document, - (fz_document_open_with_stream_fn*)xps_open_document_with_stream, + xps_open_document, + xps_open_document_with_stream, xps_extensions, xps_mimetypes }; diff --git a/source/xps/xps-imp.h b/source/xps/xps-imp.h index f86f16f1..cac5494a 100644 --- a/source/xps/xps-imp.h +++ b/source/xps/xps-imp.h @@ -5,36 +5,16 @@ typedef struct xps_document_s xps_document; typedef struct xps_page_s xps_page; /* - xps_open_document: Open a document. - - Open a document for reading so the library is able to locate - objects and pages inside the file. - - The returned xps_document should be used when calling most - other functions. Note that it wraps the context, so those - functions implicitly get access to the global state in - context. - - filename: a path to a file as it would be given to open(2). -*/ -xps_document *xps_open_document(fz_context *ctx, const char *filename); - -/* - xps_open_document_with_stream: Opens a document. - - Same as xps_open_document, but takes a stream instead of a - filename to locate the document to open. Increments the - reference count of the stream. See fz_open_file, - fz_open_file_w or fz_open_fd for opening a stream, and - fz_drop_stream for closing an open stream. -*/ -xps_document *xps_open_document_with_stream(fz_context *ctx, fz_stream *file); - -int xps_count_pages(fz_context *ctx, xps_document *doc); -xps_page *xps_load_page(fz_context *ctx, xps_document *doc, int number); -fz_outline *xps_load_outline(fz_context *ctx, xps_document *doc); -void xps_run_page(fz_context *ctx, xps_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie); -fz_link *xps_load_links(fz_context *ctx, xps_page *page); + * fz_document api functions + */ +fz_document *xps_open_document(fz_context *ctx, const char *filename); +fz_document *xps_open_document_with_stream(fz_context *ctx, fz_stream *file); +int xps_count_pages(fz_context *ctx, fz_document *doc); +fz_page *xps_load_page(fz_context *ctx, fz_document *doc, int number); +fz_outline *xps_load_outline(fz_context *ctx, fz_document *doc); +void xps_run_page(fz_context *ctx, fz_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie); +fz_link *xps_load_links(fz_context *ctx, fz_page *page); +int xps_lookup_link_target(fz_context *ctx, fz_document *doc, const char *target_uri, float *xp, float *yp); /* * Memory, and string functions. @@ -103,7 +83,6 @@ void xps_read_page_list(fz_context *ctx, xps_document *doc); void xps_print_page_list(fz_context *ctx, xps_document *doc); void xps_drop_page_list(fz_context *ctx, xps_document *doc); -int xps_lookup_link_target(fz_context *ctx, xps_document *doc, char *target_uri, float *xp, float *yp); /* * Images, fonts, and colorspaces. diff --git a/source/xps/xps-link.c b/source/xps/xps-link.c index c574fe35..c07e0d76 100644 --- a/source/xps/xps-link.c +++ b/source/xps/xps-link.c @@ -184,8 +184,9 @@ xps_load_links_in_fixed_page(fz_context *ctx, xps_document *doc, const fz_matrix } fz_link * -xps_load_links(fz_context *ctx, xps_page *page) +xps_load_links(fz_context *ctx, fz_page *page_) { + xps_page *page = (xps_page*)page_; fz_matrix ctm; fz_link *link = NULL; fz_scale(&ctm, 72.0f / 96.0f, 72.0f / 96.0f); diff --git a/source/xps/xps-outline.c b/source/xps/xps-outline.c index 6244a83d..63b6326b 100644 --- a/source/xps/xps-outline.c +++ b/source/xps/xps-outline.c @@ -37,7 +37,7 @@ xps_parse_document_outline(fz_context *ctx, xps_document *doc, fz_xml *root) entry = fz_new_outline(ctx); entry->title = fz_strdup(ctx, description); entry->uri = fz_strdup(ctx, target); - entry->page = xps_lookup_link_target(ctx, doc, target, NULL, NULL); + entry->page = xps_lookup_link_target(ctx, (fz_document*)doc, target, NULL, NULL); entry->down = NULL; entry->next = NULL; @@ -119,8 +119,9 @@ xps_load_document_structure(fz_context *ctx, xps_document *doc, xps_fixdoc *fixd } fz_outline * -xps_load_outline(fz_context *ctx, xps_document *doc) +xps_load_outline(fz_context *ctx, fz_document *doc_) { + xps_document *doc = (xps_document*)doc_; xps_fixdoc *fixdoc; fz_outline *head = NULL, *tail, *outline; diff --git a/source/xps/xps-tile.c b/source/xps/xps-tile.c index 53e223ee..e5b3bed7 100644 --- a/source/xps/xps-tile.c +++ b/source/xps/xps-tile.c @@ -366,8 +366,9 @@ xps_parse_fixed_page(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, x } void -xps_run_page(fz_context *ctx, xps_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie) +xps_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie) { + xps_page *page = (xps_page*)page_; xps_document *doc = page->doc; fz_matrix page_ctm = *ctm; diff --git a/source/xps/xps-zip.c b/source/xps/xps-zip.c index 5efccab4..a17894ea 100644 --- a/source/xps/xps-zip.c +++ b/source/xps/xps-zip.c @@ -110,7 +110,7 @@ xps_has_part(fz_context *ctx, xps_document *doc, char *name) return 0; } -static xps_document * +static fz_document * xps_open_document_with_directory(fz_context *ctx, const char *directory) { xps_document *doc; @@ -129,10 +129,10 @@ xps_open_document_with_directory(fz_context *ctx, const char *directory) fz_rethrow(ctx); } - return doc; + return (fz_document*)doc; } -xps_document * +fz_document * xps_open_document_with_stream(fz_context *ctx, fz_stream *file) { xps_document *doc; @@ -151,16 +151,16 @@ xps_open_document_with_stream(fz_context *ctx, fz_stream *file) fz_rethrow(ctx); } - return doc; + return (fz_document*)doc; } -xps_document * +fz_document * xps_open_document(fz_context *ctx, const char *filename) { char buf[2048]; fz_stream *file; char *p; - xps_document *doc; + fz_document *doc; if (strstr(filename, "/_rels/.rels") || strstr(filename, "\\_rels\\.rels")) { @@ -181,12 +181,13 @@ xps_open_document(fz_context *ctx, const char *filename) fz_catch(ctx) fz_rethrow(ctx); - return doc; + return (fz_document*)doc; } static void -xps_drop_document(fz_context *ctx, xps_document *doc) +xps_drop_document(fz_context *ctx, fz_document *doc_) { + xps_document *doc = (xps_document*)doc_; xps_font_cache *font, *next; if (doc->zip) @@ -208,7 +209,7 @@ xps_drop_document(fz_context *ctx, xps_document *doc) } static int -xps_lookup_metadata(fz_context *ctx, xps_document *doc, const char *key, char *buf, int size) +xps_lookup_metadata(fz_context *ctx, fz_document *doc_, const char *key, char *buf, int size) { if (!strcmp(key, "format")) return (int)fz_strlcpy(buf, "XPS", size); @@ -219,10 +220,10 @@ static void xps_init_document(fz_context *ctx, xps_document *doc) { doc->super.refs = 1; - doc->super.drop_document = (fz_document_drop_fn*)xps_drop_document; - doc->super.load_outline = (fz_document_load_outline_fn*)xps_load_outline; - doc->super.resolve_link = (fz_document_resolve_link_fn*)xps_lookup_link_target; - doc->super.count_pages = (fz_document_count_pages_fn*)xps_count_pages; - doc->super.load_page = (fz_document_load_page_fn*)xps_load_page; - doc->super.lookup_metadata = (fz_document_lookup_metadata_fn*)xps_lookup_metadata; + doc->super.drop_document = xps_drop_document; + doc->super.load_outline = xps_load_outline; + doc->super.resolve_link = xps_lookup_link_target; + doc->super.count_pages = xps_count_pages; + doc->super.load_page = xps_load_page; + doc->super.lookup_metadata = xps_lookup_metadata; } |