diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-03 15:58:56 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-03 16:01:29 +0200 |
commit | 8e0110dcba95b991fc397a8c1b70c97953b1b8d5 (patch) | |
tree | 139ff9ee932090765579fd1c8a0275c507d8f455 /xps | |
parent | f2eeb7778b262dffe2fc3bc81b9c942b07c12a25 (diff) | |
download | mupdf-8e0110dcba95b991fc397a8c1b70c97953b1b8d5.tar.xz |
xps: Rearrange files, part three.
Diffstat (limited to 'xps')
-rw-r--r-- | xps/muxps.h | 26 | ||||
-rw-r--r-- | xps/xps_doc.c | 191 | ||||
-rw-r--r-- | xps/xps_page.c | 154 | ||||
-rw-r--r-- | xps/xps_path.c | 34 | ||||
-rw-r--r-- | xps/xps_tile.c | 116 | ||||
-rw-r--r-- | xps/xps_zip.c | 122 |
6 files changed, 318 insertions, 325 deletions
diff --git a/xps/muxps.h b/xps/muxps.h index e4595dbe..371b5983 100644 --- a/xps/muxps.h +++ b/xps/muxps.h @@ -96,14 +96,17 @@ struct xps_page_s char *name; int width; int height; - struct element *root; + xml_element *root; xps_page *next; }; -int xps_parse_metadata(xps_context *ctx, xps_part *part); -void xps_free_fixed_pages(xps_context *ctx); -void xps_free_fixed_documents(xps_context *ctx); -void xps_debug_fixdocseq(xps_context *ctx); +int xps_read_page_list(xps_context *ctx); +void xps_debug_page_list(xps_context *ctx); +void xps_free_page_list(xps_context *ctx); + +int xps_count_pages(xps_context *ctx); +xps_page *xps_load_page(xps_context *ctx, int number); +void xps_free_page(xps_context *ctx, xps_page *page); /* * Images. @@ -180,7 +183,6 @@ void xps_debug_resource_dictionary(xps_resource *dict); * Fixed page/graphics parsing. */ -int xps_load_fixed_page(xps_context *ctx, xps_page *page); void xps_parse_fixed_page(xps_context *ctx, fz_matrix ctm, xps_page *page); void xps_parse_canvas(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *dict, xml_element *node); void xps_parse_path(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *dict, xml_element *node); @@ -196,8 +198,6 @@ void xps_parse_tiling_brush(xps_context *ctx, fz_matrix ctm, fz_rect area, char void xps_parse_matrix_transform(xps_context *ctx, xml_element *root, fz_matrix *matrix); void xps_parse_render_transform(xps_context *ctx, char *text, fz_matrix *matrix); void xps_parse_rectangle(xps_context *ctx, char *text, fz_rect *rect); -fz_path *xps_parse_abbreviated_geometry(xps_context *ctx, char *geom, int *fill_rule); -fz_path *xps_parse_path_geometry(xps_context *ctx, xps_resource *dict, xml_element *root, int stroking, int *fill_rule); void xps_begin_opacity(xps_context *ctx, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, char *opacity_att, xml_element *opacity_mask_tag); void xps_end_opacity(xps_context *ctx, char *base_uri, xps_resource *dict, char *opacity_att, xml_element *opacity_mask_tag); @@ -207,10 +207,6 @@ void xps_parse_element(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_reso void xps_clip(xps_context *ctx, fz_matrix ctm, xps_resource *dict, char *clip_att, xml_element *clip_tag); -int xps_element_has_transparency(xps_context *ctx, char *base_uri, xml_element *node); -int xps_resource_dictionary_has_transparency(xps_context *ctx, char *base_uri, xml_element *node); -int xps_image_brush_has_transparency(xps_context *ctx, char *base_uri, xml_element *root); - /* * The interpreter context. */ @@ -258,12 +254,8 @@ struct xps_context_s fz_device *dev; }; -int xps_read_and_process_page_part(xps_context *ctx, fz_matrix ctm, char *name); -int xps_open_file(xps_context *ctx, char *filename); -int xps_count_pages(xps_context *ctx); -xps_page *xps_load_page(xps_context *ctx, int number); -void xps_free_page(xps_context *ctx, xps_page *page); xps_context *xps_new_context(void); +int xps_open_file(xps_context *ctx, char *filename); int xps_free_context(xps_context *ctx); #endif diff --git a/xps/xps_doc.c b/xps/xps_doc.c index 94fb32d7..c9a4eec5 100644 --- a/xps/xps_doc.c +++ b/xps/xps_doc.c @@ -1,35 +1,13 @@ #include "fitz.h" #include "muxps.h" -xps_part * -xps_new_part(xps_context *ctx, char *name, int size) -{ - xps_part *part; - - part = fz_malloc(sizeof(xps_part)); - part->name = fz_strdup(name); - part->size = size; - part->data = fz_malloc(size + 1); - part->data[size] = 0; /* null-terminate for xml parser */ - - return part; -} - -void -xps_free_part(xps_context *ctx, xps_part *part) -{ - fz_free(part->name); - fz_free(part->data); - fz_free(part); -} - /* * The FixedDocumentSequence and FixedDocument parts determine * which parts correspond to actual pages, and the page order. */ void -xps_debug_fixdocseq(xps_context *ctx) +xps_debug_page_list(xps_context *ctx) { xps_document *fixdoc = ctx->first_fixdoc; xps_page *page = ctx->first_page; @@ -76,21 +54,6 @@ xps_add_fixed_document(xps_context *ctx, char *name) } } -void -xps_free_fixed_documents(xps_context *ctx) -{ - xps_document *node = ctx->first_fixdoc; - while (node) - { - xps_document *next = node->next; - fz_free(node->name); - fz_free(node); - node = next; - } - ctx->first_fixdoc = NULL; - ctx->last_fixdoc = NULL; -} - static void xps_add_fixed_page(xps_context *ctx, char *name, int width, int height) { @@ -120,7 +83,7 @@ xps_add_fixed_page(xps_context *ctx, char *name, int width, int height) } } -void +static void xps_free_fixed_pages(xps_context *ctx) { xps_page *node = ctx->first_page; @@ -135,6 +98,28 @@ xps_free_fixed_pages(xps_context *ctx) ctx->last_page = NULL; } +static void +xps_free_fixed_documents(xps_context *ctx) +{ + xps_document *node = ctx->first_fixdoc; + while (node) + { + xps_document *next = node->next; + fz_free(node->name); + fz_free(node); + node = next; + } + ctx->first_fixdoc = NULL; + ctx->last_fixdoc = NULL; +} + +void +xps_free_page_list(xps_context *ctx) +{ + xps_free_fixed_documents(ctx); + xps_free_fixed_pages(ctx); +} + /* * Parse the fixed document sequence structure and _rels/.rels to find the start part. */ @@ -189,7 +174,7 @@ xps_parse_metadata_imp(xps_context *ctx, xml_element *item) } } -int +static int xps_parse_metadata(xps_context *ctx, xps_part *part) { xml_element *root; @@ -226,3 +211,129 @@ xps_parse_metadata(xps_context *ctx, xps_part *part) return fz_okay; } + +static int +xps_read_and_process_metadata_part(xps_context *ctx, char *name) +{ + xps_part *part; + int code; + + part = xps_read_part(ctx, name); + if (!part) + return fz_rethrow(-1, "cannot read zip part '%s'", name); + + code = xps_parse_metadata(ctx, part); + if (code) + return fz_rethrow(code, "cannot process metadata part '%s'", name); + + xps_free_part(ctx, part); + + return fz_okay; +} + +int +xps_read_page_list(xps_context *ctx) +{ + xps_document *doc; + int code; + + code = xps_read_and_process_metadata_part(ctx, "/_rels/.rels"); + if (code) + return fz_rethrow(code, "cannot process root relationship part"); + + if (!ctx->start_part) + return fz_throw("cannot find fixed document sequence start part"); + + code = xps_read_and_process_metadata_part(ctx, ctx->start_part); + if (code) + return fz_rethrow(code, "cannot process FixedDocumentSequence part"); + + for (doc = ctx->first_fixdoc; doc; doc = doc->next) + { + code = xps_read_and_process_metadata_part(ctx, doc->name); + if (code) + return fz_rethrow(code, "cannot process FixedDocument part"); + } + + return fz_okay; +} + +int +xps_count_pages(xps_context *ctx) +{ + xps_page *page; + int n = 0; + for (page = ctx->first_page; page; page = page->next) + n ++; + return n; +} + +static int +xps_load_fixed_page(xps_context *ctx, xps_page *page) +{ + xps_part *part; + xml_element *root; + char *width_att; + char *height_att; + + part = xps_read_part(ctx, page->name); + if (!part) + return fz_rethrow(-1, "cannot read zip part '%s'", page->name); + + root = xml_parse_document(part->data, part->size); + if (!root) + return fz_rethrow(-1, "cannot parse xml part '%s'", page->name); + + xps_free_part(ctx, part); + + if (strcmp(xml_tag(root), "FixedPage")) + return fz_throw("expected FixedPage element (found %s)", xml_tag(root)); + + width_att = xml_att(root, "Width"); + if (!width_att) + return fz_throw("FixedPage missing required attribute: Width"); + + height_att = xml_att(root, "Height"); + if (!height_att) + return fz_throw("FixedPage missing required attribute: Height"); + + page->width = atoi(width_att); + page->height = atoi(height_att); + page->root = root; + + return 0; +} + +xps_page * +xps_load_page(xps_context *ctx, int number) +{ + xps_page *page; + int code; + int n = 0; + + for (page = ctx->first_page; page; page = page->next) + { + if (n == number) + { + if (!page->root) + { + code = xps_load_fixed_page(ctx, page); + if (code) { + fz_rethrow(code, "cannot load page %d", number + 1); + return NULL; + } + } + return page; + } + n ++; + } + return nil; +} + +void +xps_free_page(xps_context *ctx, xps_page *page) +{ + if (page->root) + xml_free_element(page->root); + page->root = NULL; +} diff --git a/xps/xps_page.c b/xps/xps_page.c deleted file mode 100644 index 7659a1a7..00000000 --- a/xps/xps_page.c +++ /dev/null @@ -1,154 +0,0 @@ -#include "fitz.h" -#include "muxps.h" - -void -xps_parse_canvas(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *dict, xml_element *root) -{ - xps_resource *new_dict = NULL; - xml_element *node; - char *opacity_mask_uri; - int code; - - char *transform_att; - char *clip_att; - char *opacity_att; - char *opacity_mask_att; - - xml_element *transform_tag = NULL; - xml_element *clip_tag = NULL; - xml_element *opacity_mask_tag = NULL; - - fz_matrix transform; - - transform_att = xml_att(root, "RenderTransform"); - clip_att = xml_att(root, "Clip"); - opacity_att = xml_att(root, "Opacity"); - opacity_mask_att = xml_att(root, "OpacityMask"); - - for (node = xml_down(root); node; node = xml_next(node)) - { - if (!strcmp(xml_tag(node), "Canvas.Resources") && xml_down(node)) - { - code = xps_parse_resource_dictionary(ctx, &new_dict, base_uri, xml_down(node)); - if (code) - fz_catch(code, "cannot load Canvas.Resources"); - else - { - new_dict->parent = dict; - dict = new_dict; - } - } - - if (!strcmp(xml_tag(node), "Canvas.RenderTransform")) - transform_tag = xml_down(node); - if (!strcmp(xml_tag(node), "Canvas.Clip")) - clip_tag = xml_down(node); - if (!strcmp(xml_tag(node), "Canvas.OpacityMask")) - opacity_mask_tag = xml_down(node); - } - - opacity_mask_uri = base_uri; - xps_resolve_resource_reference(ctx, dict, &transform_att, &transform_tag, NULL); - xps_resolve_resource_reference(ctx, dict, &clip_att, &clip_tag, NULL); - xps_resolve_resource_reference(ctx, dict, &opacity_mask_att, &opacity_mask_tag, &opacity_mask_uri); - - transform = fz_identity; - if (transform_att) - xps_parse_render_transform(ctx, transform_att, &transform); - if (transform_tag) - xps_parse_matrix_transform(ctx, transform_tag, &transform); - ctm = fz_concat(transform, ctm); - - if (clip_att || clip_tag) - xps_clip(ctx, ctm, dict, clip_att, clip_tag); - - xps_begin_opacity(ctx, ctm, fz_infiniterect, opacity_mask_uri, dict, opacity_att, opacity_mask_tag); - - for (node = xml_down(root); node; node = xml_next(node)) - { - xps_parse_element(ctx, ctm, base_uri, dict, node); - } - - xps_end_opacity(ctx, opacity_mask_uri, dict, opacity_att, opacity_mask_tag); - - if (clip_att || clip_tag) - ctx->dev->popclip(ctx->dev->user); - - if (new_dict) - xps_free_resource_dictionary(ctx, new_dict); -} - -void -xps_parse_fixed_page(xps_context *ctx, fz_matrix ctm, xps_page *page) -{ - xml_element *node; - xps_resource *dict; - char base_uri[1024]; - char *s; - int code; - - fz_strlcpy(base_uri, page->name, sizeof base_uri); - s = strrchr(base_uri, '/'); - if (s) - s[1] = 0; - - dict = NULL; - - ctx->opacity_top = 0; - ctx->opacity[0] = 1; - - if (!page->root) - return; - - for (node = xml_down(page->root); node; node = xml_next(node)) - { - if (!strcmp(xml_tag(node), "FixedPage.Resources") && xml_down(node)) - { - code = xps_parse_resource_dictionary(ctx, &dict, base_uri, xml_down(node)); - if (code) - fz_catch(code, "cannot load FixedPage.Resources"); - } - xps_parse_element(ctx, ctm, base_uri, dict, node); - } - - if (dict) - { - xps_free_resource_dictionary(ctx, dict); - } -} - -int -xps_load_fixed_page(xps_context *ctx, xps_page *page) -{ - xps_part *part; - xml_element *root; - char *width_att; - char *height_att; - - part = xps_read_part(ctx, page->name); - if (!part) - return fz_rethrow(-1, "cannot read zip part '%s'", page->name); - - root = xml_parse_document(part->data, part->size); - if (!root) - return fz_rethrow(-1, "cannot parse xml part '%s'", page->name); - - xps_free_part(ctx, part); - - if (strcmp(xml_tag(root), "FixedPage")) - return fz_throw("expected FixedPage element (found %s)", xml_tag(root)); - - width_att = xml_att(root, "Width"); - if (!width_att) - return fz_throw("FixedPage missing required attribute: Width"); - - height_att = xml_att(root, "Height"); - if (!height_att) - return fz_throw("FixedPage missing required attribute: Height"); - - page->width = atoi(width_att); - page->height = atoi(height_att); - page->root = root; - - return 0; -} diff --git a/xps/xps_path.c b/xps/xps_path.c index 00e57bee..5674eac2 100644 --- a/xps/xps_path.c +++ b/xps/xps_path.c @@ -35,22 +35,6 @@ fz_currentpoint(fz_path *path) return c; } -void -xps_clip(xps_context *ctx, fz_matrix ctm, xps_resource *dict, char *clip_att, xml_element *clip_tag) -{ - fz_path *path; - int fill_rule = 0; - - if (clip_att) - path = xps_parse_abbreviated_geometry(ctx, clip_att, &fill_rule); - else if (clip_tag) - path = xps_parse_path_geometry(ctx, dict, clip_tag, 0, &fill_rule); - else - path = fz_newpath(); - ctx->dev->clippath(ctx->dev->user, path, fill_rule, ctm); - fz_freepath(path); -} - /* Draw an arc segment transformed by the matrix, we approximate with straight * line segments. We cannot use the fz_arc function because they only draw * circular arcs, we need to transform the line to make them elliptical but @@ -234,7 +218,7 @@ xps_draw_arc(fz_path *path, * build up a path. */ -fz_path * +static fz_path * xps_parse_abbreviated_geometry(xps_context *ctx, char *geom, int *fill_rule) { fz_path *path; @@ -762,6 +746,22 @@ xps_parse_line_cap(char *attr) return 0; } +void +xps_clip(xps_context *ctx, fz_matrix ctm, xps_resource *dict, char *clip_att, xml_element *clip_tag) +{ + fz_path *path; + int fill_rule = 0; + + if (clip_att) + path = xps_parse_abbreviated_geometry(ctx, clip_att, &fill_rule); + else if (clip_tag) + path = xps_parse_path_geometry(ctx, dict, clip_tag, 0, &fill_rule); + else + path = fz_newpath(); + ctx->dev->clippath(ctx->dev->user, path, fill_rule, ctm); + fz_freepath(path); +} + /* * Parse an XPS <Path> element, and call relevant ghostscript * functions for drawing and/or clipping the child elements. diff --git a/xps/xps_tile.c b/xps/xps_tile.c index 82ec543f..353f769a 100644 --- a/xps/xps_tile.c +++ b/xps/xps_tile.c @@ -226,3 +226,119 @@ xps_parse_visual_brush(xps_context *ctx, fz_matrix ctm, fz_rect area, visual_uri, dict, root, xps_paint_visual_brush, visual_tag); } } + +void +xps_parse_canvas(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *dict, xml_element *root) +{ + xps_resource *new_dict = NULL; + xml_element *node; + char *opacity_mask_uri; + int code; + + char *transform_att; + char *clip_att; + char *opacity_att; + char *opacity_mask_att; + + xml_element *transform_tag = NULL; + xml_element *clip_tag = NULL; + xml_element *opacity_mask_tag = NULL; + + fz_matrix transform; + + transform_att = xml_att(root, "RenderTransform"); + clip_att = xml_att(root, "Clip"); + opacity_att = xml_att(root, "Opacity"); + opacity_mask_att = xml_att(root, "OpacityMask"); + + for (node = xml_down(root); node; node = xml_next(node)) + { + if (!strcmp(xml_tag(node), "Canvas.Resources") && xml_down(node)) + { + code = xps_parse_resource_dictionary(ctx, &new_dict, base_uri, xml_down(node)); + if (code) + fz_catch(code, "cannot load Canvas.Resources"); + else + { + new_dict->parent = dict; + dict = new_dict; + } + } + + if (!strcmp(xml_tag(node), "Canvas.RenderTransform")) + transform_tag = xml_down(node); + if (!strcmp(xml_tag(node), "Canvas.Clip")) + clip_tag = xml_down(node); + if (!strcmp(xml_tag(node), "Canvas.OpacityMask")) + opacity_mask_tag = xml_down(node); + } + + opacity_mask_uri = base_uri; + xps_resolve_resource_reference(ctx, dict, &transform_att, &transform_tag, NULL); + xps_resolve_resource_reference(ctx, dict, &clip_att, &clip_tag, NULL); + xps_resolve_resource_reference(ctx, dict, &opacity_mask_att, &opacity_mask_tag, &opacity_mask_uri); + + transform = fz_identity; + if (transform_att) + xps_parse_render_transform(ctx, transform_att, &transform); + if (transform_tag) + xps_parse_matrix_transform(ctx, transform_tag, &transform); + ctm = fz_concat(transform, ctm); + + if (clip_att || clip_tag) + xps_clip(ctx, ctm, dict, clip_att, clip_tag); + + xps_begin_opacity(ctx, ctm, fz_infiniterect, opacity_mask_uri, dict, opacity_att, opacity_mask_tag); + + for (node = xml_down(root); node; node = xml_next(node)) + { + xps_parse_element(ctx, ctm, base_uri, dict, node); + } + + xps_end_opacity(ctx, opacity_mask_uri, dict, opacity_att, opacity_mask_tag); + + if (clip_att || clip_tag) + ctx->dev->popclip(ctx->dev->user); + + if (new_dict) + xps_free_resource_dictionary(ctx, new_dict); +} + +void +xps_parse_fixed_page(xps_context *ctx, fz_matrix ctm, xps_page *page) +{ + xml_element *node; + xps_resource *dict; + char base_uri[1024]; + char *s; + int code; + + fz_strlcpy(base_uri, page->name, sizeof base_uri); + s = strrchr(base_uri, '/'); + if (s) + s[1] = 0; + + dict = NULL; + + ctx->opacity_top = 0; + ctx->opacity[0] = 1; + + if (!page->root) + return; + + for (node = xml_down(page->root); node; node = xml_next(node)) + { + if (!strcmp(xml_tag(node), "FixedPage.Resources") && xml_down(node)) + { + code = xps_parse_resource_dictionary(ctx, &dict, base_uri, xml_down(node)); + if (code) + fz_catch(code, "cannot load FixedPage.Resources"); + } + xps_parse_element(ctx, ctm, base_uri, dict, node); + } + + if (dict) + { + xps_free_resource_dictionary(ctx, dict); + } +} diff --git a/xps/xps_zip.c b/xps/xps_zip.c index ad708bcb..89509cb3 100644 --- a/xps/xps_zip.c +++ b/xps/xps_zip.c @@ -3,6 +3,28 @@ #include <zlib.h> +xps_part * +xps_new_part(xps_context *ctx, char *name, int size) +{ + xps_part *part; + + part = fz_malloc(sizeof(xps_part)); + part->name = fz_strdup(name); + part->size = size; + part->data = fz_malloc(size + 1); + part->data[size] = 0; /* null-terminate for xml parser */ + + return part; +} + +void +xps_free_part(xps_context *ctx, xps_part *part) +{ + fz_free(part->name); + fz_free(part->data); + fz_free(part); +} + static inline int getshort(FILE *file) { int a = getc(file); @@ -58,10 +80,6 @@ xps_find_zip_entry(xps_context *ctx, char *name) return NULL; } -/* - * Inflate the data in a zip entry. - */ - static int xps_read_zip_entry(xps_context *ctx, xps_entry *ent, unsigned char *outbuf) { @@ -234,7 +252,6 @@ xps_find_and_read_zip_dir(xps_context *ctx) /* * Read and interleave split parts from a ZIP file. */ - static xps_part * xps_read_zip_part(xps_context *ctx, char *partname) { @@ -299,7 +316,6 @@ xps_read_zip_part(xps_context *ctx, char *partname) /* * Read and interleave split parts from files in the directory. */ - static xps_part * xps_read_dir_part(xps_context *ctx, char *name) { @@ -374,38 +390,10 @@ xps_read_part(xps_context *ctx, char *partname) return xps_read_zip_part(ctx, partname); } -/* - * Read and process the XPS document. - */ - -static int -xps_read_and_process_metadata_part(xps_context *ctx, char *name) -{ - xps_part *part; - int code; - - part = xps_read_part(ctx, name); - if (!part) - return fz_rethrow(-1, "cannot read zip part '%s'", name); - - code = xps_parse_metadata(ctx, part); - if (code) - return fz_rethrow(code, "cannot process metadata part '%s'", name); - - xps_free_part(ctx, part); - - return fz_okay; -} - -/* - * Called by xpstop.c - */ - int xps_open_file(xps_context *ctx, char *filename) { char buf[2048]; - xps_document *doc; int code; char *p; @@ -429,71 +417,13 @@ xps_open_file(xps_context *ctx, char *filename) return fz_rethrow(code, "cannot read zip central directory"); } - code = xps_read_and_process_metadata_part(ctx, "/_rels/.rels"); - if (code) - return fz_rethrow(code, "cannot process root relationship part"); - - if (!ctx->start_part) - return fz_throw("cannot find fixed document sequence start part"); - - code = xps_read_and_process_metadata_part(ctx, ctx->start_part); + code = xps_read_page_list(ctx); if (code) - return fz_rethrow(code, "cannot process FixedDocumentSequence part"); - - for (doc = ctx->first_fixdoc; doc; doc = doc->next) - { - code = xps_read_and_process_metadata_part(ctx, doc->name); - if (code) - return fz_rethrow(code, "cannot process FixedDocument part"); - } + return fz_rethrow(code, "cannot read page list"); return fz_okay; } -int -xps_count_pages(xps_context *ctx) -{ - xps_page *page; - int n = 0; - for (page = ctx->first_page; page; page = page->next) - n ++; - return n; -} - -xps_page * -xps_load_page(xps_context *ctx, int number) -{ - xps_page *page; - int code; - int n = 0; - - for (page = ctx->first_page; page; page = page->next) - { - if (n == number) - { - if (!page->root) - { - code = xps_load_fixed_page(ctx, page); - if (code) { - fz_rethrow(code, "cannot load page %d", number + 1); - return NULL; - } - } - return page; - } - n ++; - } - return nil; -} - -void -xps_free_page(xps_context *ctx, xps_page *page) -{ - if (page->root) - xml_free_element(page->root); - page->root = NULL; -} - xps_context * xps_new_context(void) { @@ -521,7 +451,6 @@ static void xps_free_font_func(xps_context *ctx, void *ptr) fz_dropfont(ptr); } -/* Wrap up interp instance after a "job" */ int xps_free_context(xps_context *ctx) { @@ -538,8 +467,7 @@ xps_free_context(xps_context *ctx) xps_hash_free(ctx, ctx->font_table, xps_free_key_func, xps_free_font_func); xps_hash_free(ctx, ctx->colorspace_table, xps_free_key_func, NULL); - xps_free_fixed_pages(ctx); - xps_free_fixed_documents(ctx); + xps_free_page_list(ctx); return 0; } |