| 1 |
/* |
| 2 |
|
| 3 |
Copyright 2009-2011 Taco Hoekwater <[email protected]> |
| 4 |
|
| 5 |
This file is part of LuaTeX. |
| 6 |
|
| 7 |
LuaTeX is free software; you can redistribute it and/or modify it under |
| 8 |
the terms of the GNU General Public License as published by the Free |
| 9 |
Software Foundation; either version 2 of the License, or (at your |
| 10 |
option) any later version. |
| 11 |
|
| 12 |
LuaTeX is distributed in the hope that it will be useful, but WITHOUT |
| 13 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 15 |
License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License along |
| 18 |
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
*/ |
| 21 |
|
| 22 |
#include "ptexlib.h" |
| 23 |
|
| 24 |
void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur) |
| 25 |
{ |
| 26 |
scaled_whd alt_rule; |
| 27 |
int k; |
| 28 |
if (global_shipping_mode == SHIPPING_FORM) |
| 29 |
normal_error("pdf backend", "annotations cannot be inside an xform"); |
| 30 |
if (doing_leaders) |
| 31 |
return; |
| 32 |
if (is_obj_scheduled(pdf, pdf_annot_objnum(p))) { |
| 33 |
k = pdf_create_obj(pdf, obj_type_annot, 0); |
| 34 |
obj_annot_ptr(pdf, pdf_annot_objnum(p)) = p; |
| 35 |
pdf_annot_objnum(p) = k; |
| 36 |
} |
| 37 |
alt_rule.wd = width(p); |
| 38 |
alt_rule.ht = height(p); |
| 39 |
alt_rule.dp = depth(p); |
| 40 |
set_rect_dimens(pdf, p, parent_box, cur, alt_rule); |
| 41 |
obj_annot_ptr(pdf, pdf_annot_objnum(p)) = p; |
| 42 |
addto_page_resources(pdf, obj_type_annot, pdf_annot_objnum(p)); |
| 43 |
} |
| 44 |
|
| 45 |
/*tex Create a new whatsit node for annotation. */ |
| 46 |
|
| 47 |
void new_annot_whatsit(small_number w) |
| 48 |
{ |
| 49 |
scaled_whd alt_rule; |
| 50 |
new_whatsit(w); |
| 51 |
alt_rule = scan_alt_rule(); |
| 52 |
set_width(tail_par, alt_rule.wd); |
| 53 |
set_height(tail_par, alt_rule.ht); |
| 54 |
set_depth(tail_par, alt_rule.dp); |
| 55 |
if ((w == pdf_thread_node) || (w == pdf_start_thread_node)) { |
| 56 |
if (scan_keyword("attr")) { |
| 57 |
scan_toks(false, true); |
| 58 |
set_pdf_thread_attr(tail_par, def_ref); |
| 59 |
} else { |
| 60 |
set_pdf_thread_attr(tail_par, null); |
| 61 |
} |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
/*tex Scanning at the \TEX\ end: */ |
| 66 |
|
| 67 |
void scan_annot(PDF pdf) |
| 68 |
{ |
| 69 |
int k; |
| 70 |
if (scan_keyword("reserveobjnum")) { |
| 71 |
k = pdf_create_obj(pdf, obj_type_annot, 0); |
| 72 |
/*tex Scan an optional space. */ |
| 73 |
get_x_token(); |
| 74 |
if (cur_cmd != spacer_cmd) |
| 75 |
back_input(); |
| 76 |
} else { |
| 77 |
if (scan_keyword("useobjnum")) { |
| 78 |
scan_int(); |
| 79 |
k = cur_val; |
| 80 |
check_obj_type(pdf, obj_type_annot, k); |
| 81 |
if (obj_annot_ptr(pdf, k) != 0) |
| 82 |
normal_error("pdf backend", "annot object in use"); |
| 83 |
} else { |
| 84 |
k = pdf_create_obj(pdf, obj_type_annot, 0); |
| 85 |
} |
| 86 |
new_annot_whatsit(pdf_annot_node); |
| 87 |
obj_annot_ptr(pdf, k) = tail_par; |
| 88 |
set_pdf_annot_objnum(tail_par, k); |
| 89 |
scan_toks(false, true); |
| 90 |
set_pdf_annot_data(tail_par, def_ref); |
| 91 |
} |
| 92 |
pdf_last_annot = k; |
| 93 |
} |