File: pdfannot.w

package info (click to toggle)
texlive-bin 2018.20181218.49446-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 186,920 kB
  • sloc: ansic: 873,264; cpp: 311,278; perl: 82,918; sh: 23,243; makefile: 8,590; lex: 4,939; python: 4,462; pascal: 3,813; java: 3,569; yacc: 2,901; tcl: 2,379; exp: 2,031; xml: 844; ruby: 678; lisp: 398; sed: 331; asm: 140; csh: 46; awk: 30
file content (94 lines) | stat: -rw-r--r-- 2,965 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
% pdfannot.w
%
% Copyright 2009-2011 Taco Hoekwater <taco@@luatex.org>
%
% This file is part of LuaTeX.
%
% LuaTeX is free software; you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation; either version 2 of the License, or (at your
% option) any later version.
%
% LuaTeX is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
% License for more details.
%
% You should have received a copy of the GNU General Public License along
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.

@ @c

#include "ptexlib.h"

@ @c
void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
{
    scaled_whd alt_rule;
    int k;
    if (global_shipping_mode == SHIPPING_FORM)
        normal_error("pdf backend", "annotations cannot be inside an xform");
    if (doing_leaders)
        return;
    if (is_obj_scheduled(pdf, pdf_annot_objnum(p))) {
        k = pdf_create_obj(pdf, obj_type_annot, 0);
        obj_annot_ptr(pdf, pdf_annot_objnum(p)) = p;
        pdf_annot_objnum(p) = k;
    }
    alt_rule.wd = width(p);
    alt_rule.ht = height(p);
    alt_rule.dp = depth(p);
    set_rect_dimens(pdf, p, parent_box, cur, alt_rule, 0);
    obj_annot_ptr(pdf, pdf_annot_objnum(p)) = p;
    addto_page_resources(pdf, obj_type_annot, pdf_annot_objnum(p));
}

@ create a new whatsit node for annotation

@c void new_annot_whatsit(small_number w)
{
    scaled_whd alt_rule;
    new_whatsit(w);
    alt_rule = scan_alt_rule(); /* scans |<rule spec>| to |alt_rule| */
    set_width(tail_par, alt_rule.wd);
    set_height(tail_par, alt_rule.ht);
    set_depth(tail_par, alt_rule.dp);
    if ((w == pdf_thread_node) || (w == pdf_start_thread_node)) {
        if (scan_keyword("attr")) {
            scan_toks(false, true);
            set_pdf_thread_attr(tail_par, def_ref);
        } else {
            set_pdf_thread_attr(tail_par, null);
        }
    }
}

@ scanning at the \TeX\ end

@c void scan_annot(PDF pdf)
{
    int k;
    if (scan_keyword("reserveobjnum")) {
        k = pdf_create_obj(pdf, obj_type_annot, 0);
        /* Scan an optional space */
        get_x_token();
        if (cur_cmd != spacer_cmd)
            back_input();
    } else {
        if (scan_keyword("useobjnum")) {
            scan_int();
            k = cur_val;
            check_obj_type(pdf, obj_type_annot, k);
            if (obj_annot_ptr(pdf, k) != 0)
                normal_error("pdf backend", "annot object in use");
        } else {
            k = pdf_create_obj(pdf, obj_type_annot, 0);
        }
        new_annot_whatsit(pdf_annot_node);
        obj_annot_ptr(pdf, k) = tail_par;
        set_pdf_annot_objnum(tail_par, k);
        scan_toks(false, true);
        set_pdf_annot_data(tail_par, def_ref);
    }
    pdf_last_annot = k;
}