comparison mupdf-source/include/mupdf/fitz/link.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 // Copyright (C) 2004-2022 Artifex Software, Inc.
2 //
3 // This file is part of MuPDF.
4 //
5 // MuPDF is free software: you can redistribute it and/or modify it under the
6 // terms of the GNU Affero General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or (at your option)
8 // any later version.
9 //
10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Affero General Public License
16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17 //
18 // Alternative licensing terms are available from the licensor.
19 // For commercial licensing, see <https://www.artifex.com/> or contact
20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21 // CA 94129, USA, for further information.
22
23 #ifndef MUPDF_FITZ_LINK_H
24 #define MUPDF_FITZ_LINK_H
25
26 #include "mupdf/fitz/system.h"
27 #include "mupdf/fitz/context.h"
28 #include "mupdf/fitz/geometry.h"
29 #include "mupdf/fitz/types.h"
30
31 typedef struct fz_link fz_link;
32 typedef void (fz_link_set_rect_fn)(fz_context *ctx, fz_link *link, fz_rect rect);
33 typedef void (fz_link_set_uri_fn)(fz_context *ctx, fz_link *link, const char *uri);
34 typedef void (fz_link_drop_link_fn)(fz_context *ctx, fz_link *link);
35
36 /**
37 fz_link is a list of interactive links on a page.
38
39 There is no relation between the order of the links in the
40 list and the order they appear on the page. The list of links
41 for a given page can be obtained from fz_load_links.
42
43 A link is reference counted. Dropping a reference to a link is
44 done by calling fz_drop_link.
45
46 rect: The hot zone. The area that can be clicked in
47 untransformed coordinates.
48
49 uri: Link destinations come in two forms: internal and external.
50 Internal links refer to other pages in the same document.
51 External links are URLs to other documents.
52
53 next: A pointer to the next link on the same page.
54 */
55 typedef struct fz_link
56 {
57 int refs;
58 struct fz_link *next;
59 fz_rect rect;
60 char *uri;
61 fz_link_set_rect_fn *set_rect_fn;
62 fz_link_set_uri_fn *set_uri_fn;
63 fz_link_drop_link_fn *drop;
64 } fz_link;
65
66 typedef enum
67 {
68 FZ_LINK_DEST_FIT,
69 FZ_LINK_DEST_FIT_B,
70 FZ_LINK_DEST_FIT_H,
71 FZ_LINK_DEST_FIT_BH,
72 FZ_LINK_DEST_FIT_V,
73 FZ_LINK_DEST_FIT_BV,
74 FZ_LINK_DEST_FIT_R,
75 FZ_LINK_DEST_XYZ
76 } fz_link_dest_type;
77
78 typedef struct
79 {
80 fz_location loc;
81 fz_link_dest_type type;
82 float x, y, w, h, zoom;
83 } fz_link_dest;
84
85 fz_link_dest fz_make_link_dest_none(void);
86 fz_link_dest fz_make_link_dest_xyz(int chapter, int page, float x, float y, float z);
87
88 /**
89 Create a new link record.
90
91 next is set to NULL with the expectation that the caller will
92 handle the linked list setup. Internal function.
93
94 Different document types will be implemented by deriving from
95 fz_link. This macro allocates such derived structures, and
96 initialises the base sections.
97 */
98 fz_link *fz_new_link_of_size(fz_context *ctx, int size, fz_rect rect, const char *uri);
99 #define fz_new_derived_link(CTX,TYPE,RECT,URI) \
100 ((TYPE *)Memento_label(fz_new_link_of_size(CTX,sizeof(TYPE),RECT,URI),#TYPE))
101
102 /**
103 Increment the reference count for a link. The same pointer is
104 returned.
105
106 Never throws exceptions.
107 */
108 fz_link *fz_keep_link(fz_context *ctx, fz_link *link);
109
110 /**
111 Decrement the reference count for a link. When the reference
112 count reaches zero, the link is destroyed.
113
114 When a link is freed, the reference for any linked link (next)
115 is dropped too, thus an entire linked list of fz_link's can be
116 freed by just dropping the head.
117 */
118 void fz_drop_link(fz_context *ctx, fz_link *link);
119
120 /**
121 Query whether a link is external to a document (determined by
122 uri containing a ':', intended to match with '://' which
123 separates the scheme from the scheme specific parts in URIs).
124 */
125 int fz_is_external_link(fz_context *ctx, const char *uri);
126
127 void fz_set_link_rect(fz_context *ctx, fz_link *link, fz_rect rect);
128 void fz_set_link_uri(fz_context *ctx, fz_link *link, const char *uri);
129
130 #endif