diff options
Diffstat (limited to 'source/html')
-rw-r--r-- | source/html/epub-doc.c | 10 | ||||
-rw-r--r-- | source/html/html-doc.c | 9 |
2 files changed, 13 insertions, 6 deletions
diff --git a/source/html/epub-doc.c b/source/html/epub-doc.c index a30fbcd3..f5f3ca67 100644 --- a/source/html/epub-doc.c +++ b/source/html/epub-doc.c @@ -35,7 +35,7 @@ struct epub_page_s }; static int -epub_resolve_link(fz_context *ctx, fz_document *doc_, const char *dest) +epub_resolve_link(fz_context *ctx, fz_document *doc_, const char *dest, float *xp, float *yp) { epub_document *doc = (epub_document*)doc_; epub_chapter *ch; @@ -54,7 +54,11 @@ epub_resolve_link(fz_context *ctx, fz_document *doc_, const char *dest) /* Search for a matching fragment */ float y = fz_find_html_target(ctx, ch->html, s+1); if (y >= 0) - return ch->start + y / ch->page_h; + { + int page = y / ch->page_h; + if (yp) *yp = y - page * ch->page_h; + return ch->start + page; + } } return ch->start; } @@ -68,7 +72,7 @@ epub_update_outline(fz_context *ctx, fz_document *doc, fz_outline *node) { while (node) { - node->page = epub_resolve_link(ctx, doc, node->uri); + node->page = epub_resolve_link(ctx, doc, node->uri, NULL, NULL); epub_update_outline(ctx, doc, node->down); node = node->next; } diff --git a/source/html/html-doc.c b/source/html/html-doc.c index 810b92c1..8d602030 100644 --- a/source/html/html-doc.c +++ b/source/html/html-doc.c @@ -32,16 +32,19 @@ htdoc_drop_document(fz_context *ctx, fz_document *doc_) } static int -htdoc_resolve_link(fz_context *ctx, fz_document *doc_, const char *dest) +htdoc_resolve_link(fz_context *ctx, fz_document *doc_, const char *dest, float *xp, float *yp) { html_document *doc = (html_document*)doc_; - const char *s = strchr(dest, '#'); if (s && s[1] != 0) { float y = fz_find_html_target(ctx, doc->html, s+1); if (y >= 0) - return y / doc->page_h; + { + int page = y / doc->page_h; + if (yp) *yp = y - page * doc->page_h; + return page; + } } return -1; |