summaryrefslogtreecommitdiff
path: root/pdf/pdf_outline.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-12-28 14:09:26 +0000
committerRobin Watts <robin.watts@artifex.com>2011-12-28 14:25:45 +0000
commitd442ada2f85d91077ef8cc20d43a48d832037635 (patch)
treea086095579001390c82a70ebd44498776069a6f2 /pdf/pdf_outline.c
parent0d70079719b89aae1e5342d098389ef04bf313bc (diff)
downloadmupdf-d442ada2f85d91077ef8cc20d43a48d832037635.tar.xz
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.
Diffstat (limited to 'pdf/pdf_outline.c')
-rw-r--r--pdf/pdf_outline.c50
1 files changed, 26 insertions, 24 deletions
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 *