Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7858 views
1
#ifndef MUPDF_FITZ_LINK_H
2
#define MUPDF_FITZ_LINK_H
3
4
#include "mupdf/fitz/system.h"
5
#include "mupdf/fitz/context.h"
6
#include "mupdf/fitz/math.h"
7
8
/*
9
Links
10
11
NOTE: The link destination struct is scheduled for imminent change!
12
Use at your own peril.
13
*/
14
15
typedef struct fz_link_s fz_link;
16
17
typedef struct fz_link_dest_s fz_link_dest;
18
19
typedef enum fz_link_kind_e
20
{
21
FZ_LINK_NONE = 0,
22
FZ_LINK_GOTO,
23
FZ_LINK_URI,
24
FZ_LINK_LAUNCH,
25
FZ_LINK_NAMED,
26
FZ_LINK_GOTOR
27
} fz_link_kind;
28
29
enum {
30
fz_link_flag_l_valid = 1, /* lt.x is valid */
31
fz_link_flag_t_valid = 2, /* lt.y is valid */
32
fz_link_flag_r_valid = 4, /* rb.x is valid */
33
fz_link_flag_b_valid = 8, /* rb.y is valid */
34
fz_link_flag_fit_h = 16, /* Fit horizontally */
35
fz_link_flag_fit_v = 32, /* Fit vertically */
36
fz_link_flag_r_is_zoom = 64 /* rb.x is actually a zoom figure */
37
};
38
39
/*
40
fz_link_dest: This structure represents the destination of
41
an fz_link; this may be a page to display, a new file to open,
42
a javascript action to perform, etc.
43
44
kind: This identifies the kind of link destination. Different
45
kinds use different sections of the union.
46
47
For FZ_LINK_GOTO or FZ_LINK_GOTOR:
48
49
gotor.page: The target page number to move to (0 being the
50
first page in the document). In the FZ_LINK_GOTOR case, the
51
page number either refers to to the file specified by
52
gotor.file_spec, or the page number is -1 suggesting that
53
the destination is given by gotor.dest.
54
55
gotor.dest: If set, the target destination name to be
56
resolved in the file specified by gotor.file_spec. Always
57
NULL in the FZ_LINK_GOTO case.
58
59
gotor.flags: A bitfield consisting of fz_link_flag_*
60
describing the validity and meaning of the different parts
61
of gotor.lt and gotor.rb. Link destinations are constructed
62
(as far as possible) so that lt and rb can be treated as a
63
bounding box, though the validity flags indicate which of the
64
values was actually specified in the file.
65
66
gotor.lt: The top left corner of the destination bounding box.
67
68
gotor.rb: The bottom right corner of the destination bounding
69
box. If fz_link_flag_r_is_zoom is set, then the r figure
70
should actually be interpretted as a zoom ratio.
71
72
gotor.file_spec: If set, this destination should cause a new
73
file to be opened; this field holds a pointer to a remote
74
file specification (UTF-8). Always NULL in the FZ_LINK_GOTO
75
case.
76
77
gotor.new_window: If true, the destination should open in a
78
new window. Always false in the FZ_LINK_GOTO case.
79
80
For FZ_LINK_URI:
81
82
uri.uri: A UTF-8 encoded URI to launch.
83
84
uri.is_map: If true, the x and y coords (as ints, in user
85
space) should be appended to the URI before launch.
86
87
For FZ_LINK_LAUNCH:
88
89
launch.file_spec: A UTF-8 file specification to launch.
90
91
launch.new_window: If true, the destination should be launched
92
in a new window.
93
94
launch.is_uri: If true, launch.file_spec is a URI to launch.
95
96
For FZ_LINK_NAMED:
97
98
named.named: The named action to perform. Likely to be
99
client specific.
100
*/
101
struct fz_link_dest_s
102
{
103
fz_link_kind kind;
104
union
105
{
106
struct
107
{
108
int page;
109
char *dest;
110
int flags;
111
fz_point lt;
112
fz_point rb;
113
char *file_spec;
114
int new_window;
115
}
116
gotor;
117
struct
118
{
119
char *uri;
120
int is_map;
121
}
122
uri;
123
struct
124
{
125
char *file_spec;
126
int new_window;
127
int is_uri;
128
}
129
launch;
130
struct
131
{
132
char *named;
133
}
134
named;
135
}
136
ld;
137
};
138
139
/*
140
fz_link is a list of interactive links on a page.
141
142
There is no relation between the order of the links in the
143
list and the order they appear on the page. The list of links
144
for a given page can be obtained from fz_load_links.
145
146
A link is reference counted. Dropping a reference to a link is
147
done by calling fz_drop_link.
148
149
rect: The hot zone. The area that can be clicked in
150
untransformed coordinates.
151
152
dest: Link destinations come in two forms: Page and area that
153
an application should display when this link is activated. Or
154
as an URI that can be given to a browser.
155
156
next: A pointer to the next link on the same page.
157
*/
158
struct fz_link_s
159
{
160
int refs;
161
fz_rect rect;
162
fz_link_dest dest;
163
fz_link *next;
164
};
165
166
fz_link *fz_new_link(fz_context *ctx, const fz_rect *bbox, fz_link_dest dest);
167
fz_link *fz_keep_link(fz_context *ctx, fz_link *link);
168
169
/*
170
fz_drop_link: Drop and free a list of links.
171
172
Does not throw exceptions.
173
*/
174
void fz_drop_link(fz_context *ctx, fz_link *link);
175
176
void fz_drop_link_dest(fz_context *ctx, fz_link_dest *dest);
177
178
#endif
179
180