summaryrefslogtreecommitdiff
path: root/bk_paper.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-04-14 13:23:06 +0000
committerSimon Tatham <anakin@pobox.com>2004-04-14 13:23:06 +0000
commit6cebedbf59b755fffceb5ceed87ec5d9d3437e42 (patch)
tree64c6296c0fbb8b5dd6dd793f8518dfd498ab8a8b /bk_paper.c
parentc9c48312ff1dea25729159c0336b639570dbda47 (diff)
downloadhalibut-6cebedbf59b755fffceb5ceed87ec5d9d3437e42.zip
halibut-6cebedbf59b755fffceb5ceed87ec5d9d3437e42.tar.gz
halibut-6cebedbf59b755fffceb5ceed87ec5d9d3437e42.tar.bz2
halibut-6cebedbf59b755fffceb5ceed87ec5d9d3437e42.tar.xz
The contents section now contains PDF cross-references.
[originally from svn r4070]
Diffstat (limited to 'bk_paper.c')
-rw-r--r--bk_paper.c38
1 files changed, 37 insertions, 1 deletions
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;