From a0768d17e6e539bef946fcabf45786bd9f7b8cb3 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 14 Apr 2004 13:23:06 +0000 Subject: [PATCH] The contents section now contains PDF cross-references. git-svn-id: svn://svn.tartarus.org/sgt/halibut@4070 cda61777-01e9-0310-a592-d414129be87e --- bk_paper.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/bk_paper.c b/bk_paper.c index 5d500ff..9ebbbdf 100644 --- a/bk_paper.c +++ b/bk_paper.c @@ -387,9 +387,46 @@ void *paper_pre_backend(paragraph *sourceform, keywordlist *keywords, */ for (pdata = firstpara; pdata; pdata = pdata->next) { int last_x; + xref *cxref; + page_data *cxref_page; xref_dest dest; + para_data *target; + dest.type = NONE; + cxref = NULL; + cxref_page = NULL; + for (ldata = pdata->first; ldata; ldata = ldata->next) { + /* + * If this is a contents entry, we expect to have a single + * enormous cross-reference rectangle covering the whole + * thing. (Unless, of course, it spans multiple pages.) + */ + if (pdata->contents_entry && ldata->page != cxref_page) { + cxref_page = ldata->page; + cxref = mknew(xref); + cxref->next = NULL; + cxref->dest.type = PAGE; + assert(pdata->contents_entry->private_data); + target = (para_data *)pdata->contents_entry->private_data; + cxref->dest.page = target->first->page; + cxref->dest.url = NULL; + if (ldata->page->last_xref) + ldata->page->last_xref->next = cxref; + else + ldata->page->first_xref = cxref; + ldata->page->last_xref = cxref; + cxref->lx = conf->left_margin; + cxref->rx = conf->paper_width - conf->right_margin; + cxref->ty = conf->paper_height - conf->top_margin + - ldata->ypos + ldata->line_height; + } + if (pdata->contents_entry) { + assert(cxref != NULL); + cxref->by = conf->paper_height - conf->top_margin + - ldata->ypos; + } + last_x = render_line(ldata, conf->left_margin, conf->paper_height - conf->top_margin, &dest, keywords); @@ -403,7 +440,6 @@ void *paper_pre_backend(paragraph *sourceform, keywordlist *keywords, */ if (pdata->contents_entry) { word *w; - para_data *target; wchar_t *num; int wid; int x; -- 2.11.0