3 % Copyright
2009-2011 Taco Hoekwater
<taco@@luatex.org
>
5 % This file is part of LuaTeX.
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.
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.
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
/>.
25 #define tail cur_list.tail_field
27 void do_annot
(PDF pdf
, halfword p
, halfword parent_box
, scaledpos cur
)
31 if
(global_shipping_mode
== SHIPPING_FORM
)
32 normal_error
("pdf backend", "annotations cannot be inside an xform");
35 if
(is_obj_scheduled
(pdf
, pdf_annot_objnum
(p
))) {
36 k
= pdf_create_obj
(pdf
, obj_type_annot
, 0);
37 obj_annot_ptr
(pdf
, pdf_annot_objnum
(p
)) = p
;
38 pdf_annot_objnum
(p
) = k
;
40 alt_rule.wd
= width
(p
);
41 alt_rule.ht
= height
(p
);
42 alt_rule.dp
= depth
(p
);
43 set_rect_dimens
(pdf
, p
, parent_box
, cur
, alt_rule
, 0);
44 obj_annot_ptr
(pdf
, pdf_annot_objnum
(p
)) = p
;
45 addto_page_resources
(pdf
, obj_type_annot
, pdf_annot_objnum
(p
));
48 @ create a new whatsit node for annotation
50 @c void new_annot_whatsit
(small_number w
)
54 alt_rule
= scan_alt_rule
(); /* scans |
<rule spec
>| to |alt_rule|
*/
55 set_width
(tail
, alt_rule.wd
);
56 set_height
(tail
, alt_rule.ht
);
57 set_depth
(tail
, alt_rule.dp
);
58 if
((w
== pdf_thread_node
) ||
(w
== pdf_start_thread_node
)) {
59 if
(scan_keyword
("attr")) {
60 scan_toks
(false
, true
);
61 set_pdf_thread_attr
(tail
, def_ref
);
63 set_pdf_thread_attr
(tail
, null
);
68 @ scanning at the \TeX\ end
70 @c void scan_annot
(PDF pdf
)
73 if
(scan_keyword
("reserveobjnum")) {
74 k
= pdf_create_obj
(pdf
, obj_type_annot
, 0);
75 /* Scan an optional space
*/
77 if
(cur_cmd
!= spacer_cmd
)
80 if
(scan_keyword
("useobjnum")) {
83 check_obj_type
(pdf
, obj_type_annot
, k
);
84 if
(obj_annot_ptr
(pdf
, k
) != 0)
85 normal_error
("pdf backend", "annot object in use");
87 k
= pdf_create_obj
(pdf
, obj_type_annot
, 0);
89 new_annot_whatsit
(pdf_annot_node
);
90 obj_annot_ptr
(pdf
, k
) = tail
;
91 set_pdf_annot_objnum
(tail
, k
);
92 scan_toks
(false
, true
);
93 set_pdf_annot_data
(tail
, def_ref
);