diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-10-17 17:13:32 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-10-28 16:18:38 +0200 |
commit | 8a07b7fb14f11204a0d840792ab9f4bd54b066e5 (patch) | |
tree | e617a898c17aeb353f35d7b362ca2de290cf2b82 /source/xps | |
parent | 4029b45e494634361a4205f8896ec429d11e990a (diff) | |
download | mupdf-8a07b7fb14f11204a0d840792ab9f4bd54b066e5.tar.xz |
Clean up link destination handling.
All link destinations should be URIs, and a document specific function
can be called to resolve them to actual page numbers.
Outlines have cached page numbers as well as string URIs.
Diffstat (limited to 'source/xps')
-rw-r--r-- | source/xps/xps-link.c | 18 | ||||
-rw-r--r-- | source/xps/xps-outline.c | 5 | ||||
-rw-r--r-- | source/xps/xps-zip.c | 1 |
3 files changed, 4 insertions, 20 deletions
diff --git a/source/xps/xps-link.c b/source/xps/xps-link.c index 9986d25f..1b2423ad 100644 --- a/source/xps/xps-link.c +++ b/source/xps/xps-link.c @@ -10,23 +10,7 @@ xps_load_links_in_element(fz_context *ctx, xps_document *doc, const fz_matrix *c static void xps_add_link(fz_context *ctx, xps_document *doc, const fz_rect *area, char *base_uri, char *target_uri, fz_link **head) { - fz_link_dest dest; - fz_link *link; - - memset(&dest, 0, sizeof dest); - - if (xps_url_is_remote(ctx, doc, target_uri)) - { - dest.kind = FZ_LINK_URI; - dest.ld.uri.uri = fz_strdup(ctx, target_uri); - } - else - { - dest.kind = FZ_LINK_GOTO; - dest.ld.gotor.page = xps_lookup_link_target(ctx, doc, target_uri); - } - - link = fz_new_link(ctx, area, dest); + fz_link *link = fz_new_link(ctx, area, doc, target_uri); link->next = *head; *head = link; } diff --git a/source/xps/xps-outline.c b/source/xps/xps-outline.c index 50eaf960..1fe294fb 100644 --- a/source/xps/xps-outline.c +++ b/source/xps/xps-outline.c @@ -33,9 +33,8 @@ 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->dest.kind = FZ_LINK_GOTO; - entry->dest.ld.gotor.flags = 0; - entry->dest.ld.gotor.page = xps_lookup_link_target(ctx, doc, target); + entry->uri = fz_strdup(ctx, target); + entry->page = xps_lookup_link_target(ctx, doc, target); entry->down = NULL; entry->next = NULL; diff --git a/source/xps/xps-zip.c b/source/xps/xps-zip.c index b2cc9e77..ba9947c7 100644 --- a/source/xps/xps-zip.c +++ b/source/xps/xps-zip.c @@ -231,6 +231,7 @@ 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; |