From d442ada2f85d91077ef8cc20d43a48d832037635 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 28 Dec 2011 14:09:26 +0000 Subject: Outline/link destination tweaks. Move 'kind' into the fz_link_dest structure (as this makes more sense). Put an fz_link_dest rather than just a page number into the outlines structure. Correct parsing of actions and dests from pdf outlines. --- pdf/pdf_outline.c | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'pdf/pdf_outline.c') diff --git a/pdf/pdf_outline.c b/pdf/pdf_outline.c index 3f6b745b..be43d709 100644 --- a/pdf/pdf_outline.c +++ b/pdf/pdf_outline.c @@ -5,38 +5,40 @@ static fz_outline * pdf_load_outline_imp(pdf_xref *xref, fz_obj *dict) { fz_context *ctx = xref->ctx; - fz_outline *node; + fz_outline *node, *first = NULL; fz_obj *obj; if (fz_is_null(dict)) return NULL; - node = fz_malloc_struct(ctx, fz_outline); - node->ctx = ctx; - node->title = NULL; - node->page = 0; - node->down = NULL; - node->next = NULL; - - obj = fz_dict_gets(dict, "Title"); - if (obj) - node->title = pdf_to_utf8(ctx, obj); - - if (fz_dict_gets(dict, "Dest") || fz_dict_gets(dict, "A")) + while (dict) { - fz_link_dest ld = pdf_parse_link_dest(xref, dict); - node->page = ld.gotor.page; + node = fz_malloc_struct(ctx, fz_outline); + node->ctx = ctx; + node->title = NULL; + node->dest.kind = FZ_LINK_NONE; + node->down = NULL; + node->next = NULL; + if (first == NULL) + first = node; + + obj = fz_dict_gets(dict, "Title"); + if (obj) + node->title = pdf_to_utf8(ctx, obj); + + if ((obj = fz_dict_gets(dict, "Dest"))) + node->dest = pdf_parse_link_dest(xref, obj); + else if ((obj = fz_dict_gets(dict, "A"))) + node->dest = pdf_parse_action(xref, obj); + + obj = fz_dict_gets(dict, "First"); + if (obj) + node->down = pdf_load_outline_imp(xref, obj); + + dict = fz_dict_gets(dict, "Next"); } - obj = fz_dict_gets(dict, "First"); - if (obj) - node->down = pdf_load_outline_imp(xref, obj); - - obj = fz_dict_gets(dict, "Next"); - if (obj) - node->next = pdf_load_outline_imp(xref, obj); - - return node; + return first; } fz_outline * -- cgit v1.2.3