diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-12-23 12:59:24 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2011-12-23 13:18:42 +0000 |
commit | 73e548cdd564c6c2099ceafaa4019a7dbb188a30 (patch) | |
tree | e2d0b498abf0f0057d7d565d6b465226e6491d60 /apps | |
parent | cc4dd0f8358d3de1594cc530b8f2691bccf194f0 (diff) | |
download | mupdf-73e548cdd564c6c2099ceafaa4019a7dbb188a30.tar.xz |
Generalise pdf_links to be fz_links.
Move to a non-pdf specific type for links. PDF specific parsing is
done in pdf_annots.c as before, but the essential type (and handling
functions for that type) are in a new file fitz/base_link.c.
The new type is more expressive than before; specifically all the
possible PDF modes are expressable in it. Hopefully this should
allow XPS links to be represented too.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/pdfapp.c | 32 | ||||
-rw-r--r-- | apps/pdfapp.h | 2 |
2 files changed, 11 insertions, 23 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 849b0d18..cf136261 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -238,7 +238,7 @@ void pdfapp_close(pdfapp_t *app) app->page_text = NULL; if (app->page_links) - pdf_free_link(app->ctx, app->page_links); + fz_free_link(app->ctx, app->page_links); app->page_links = NULL; if (app->doctitle) @@ -394,7 +394,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai if (app->page_text) fz_free_text_span(app->ctx, app->page_text); if (app->page_links) - pdf_free_link(app->ctx, app->page_links); + fz_free_link(app->ctx, app->page_links); if (app->xref) pdfapp_loadpage_pdf(app); @@ -467,25 +467,13 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai fz_flush_warnings(app->ctx); } -static void pdfapp_gotouri(pdfapp_t *app, fz_obj *uri) +static void pdfapp_gotouri(pdfapp_t *app, char *uri) { - char *buf; - int n = fz_to_str_len(uri); - buf = fz_malloc(app->ctx, n + 1); - memcpy(buf, fz_to_str_buf(uri), n); - buf[n] = 0; - winopenuri(app, buf); - fz_free(app->ctx, buf); + winopenuri(app, uri); } -static void pdfapp_gotopage(pdfapp_t *app, fz_obj *obj) +static void pdfapp_gotopage(pdfapp_t *app, int number) { - int number; - - number = pdf_find_page_number(app->xref, obj); - if (number < 0) - return; - if (app->histlen + 1 == 256) { memmove(app->hist, app->hist + 1, sizeof(int) * 255); @@ -1025,7 +1013,7 @@ void pdfapp_onkey(pdfapp_t *app, int c) void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int state) { - pdf_link *link; + fz_link *link; fz_matrix ctm; fz_point p; @@ -1049,10 +1037,10 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta wincursor(app, HAND); if (btn == 1 && state == 1) { - if (link->kind == PDF_LINK_URI) - pdfapp_gotouri(app, link->dest); - else if (link->kind == PDF_LINK_GOTO) - pdfapp_gotopage(app, fz_array_get(link->dest, 0)); /* [ pageobj ... ] */ + if (link->kind == FZ_LINK_URI) + pdfapp_gotouri(app, link->dest.uri.uri); + else if (link->kind == FZ_LINK_GOTO) + pdfapp_gotopage(app, link->dest.gotor.page); return; } } diff --git a/apps/pdfapp.h b/apps/pdfapp.h index c9fe1d4f..22b6ad0d 100644 --- a/apps/pdfapp.h +++ b/apps/pdfapp.h @@ -49,7 +49,7 @@ struct pdfapp_s float page_rotate; fz_display_list *page_list; fz_text_span *page_text; - pdf_link *page_links; + fz_link *page_links; /* snapback history */ int hist[256]; |