#ifndef MUPDF_FITZ_LINK_H1#define MUPDF_FITZ_LINK_H23#include "mupdf/fitz/system.h"4#include "mupdf/fitz/context.h"5#include "mupdf/fitz/math.h"67/*8Links910NOTE: The link destination struct is scheduled for imminent change!11Use at your own peril.12*/1314typedef struct fz_link_s fz_link;1516typedef struct fz_link_dest_s fz_link_dest;1718typedef enum fz_link_kind_e19{20FZ_LINK_NONE = 0,21FZ_LINK_GOTO,22FZ_LINK_URI,23FZ_LINK_LAUNCH,24FZ_LINK_NAMED,25FZ_LINK_GOTOR26} fz_link_kind;2728enum {29fz_link_flag_l_valid = 1, /* lt.x is valid */30fz_link_flag_t_valid = 2, /* lt.y is valid */31fz_link_flag_r_valid = 4, /* rb.x is valid */32fz_link_flag_b_valid = 8, /* rb.y is valid */33fz_link_flag_fit_h = 16, /* Fit horizontally */34fz_link_flag_fit_v = 32, /* Fit vertically */35fz_link_flag_r_is_zoom = 64 /* rb.x is actually a zoom figure */36};3738/*39fz_link_dest: This structure represents the destination of40an fz_link; this may be a page to display, a new file to open,41a javascript action to perform, etc.4243kind: This identifies the kind of link destination. Different44kinds use different sections of the union.4546For FZ_LINK_GOTO or FZ_LINK_GOTOR:4748gotor.page: The target page number to move to (0 being the49first page in the document). In the FZ_LINK_GOTOR case, the50page number either refers to to the file specified by51gotor.file_spec, or the page number is -1 suggesting that52the destination is given by gotor.dest.5354gotor.dest: If set, the target destination name to be55resolved in the file specified by gotor.file_spec. Always56NULL in the FZ_LINK_GOTO case.5758gotor.flags: A bitfield consisting of fz_link_flag_*59describing the validity and meaning of the different parts60of gotor.lt and gotor.rb. Link destinations are constructed61(as far as possible) so that lt and rb can be treated as a62bounding box, though the validity flags indicate which of the63values was actually specified in the file.6465gotor.lt: The top left corner of the destination bounding box.6667gotor.rb: The bottom right corner of the destination bounding68box. If fz_link_flag_r_is_zoom is set, then the r figure69should actually be interpretted as a zoom ratio.7071gotor.file_spec: If set, this destination should cause a new72file to be opened; this field holds a pointer to a remote73file specification (UTF-8). Always NULL in the FZ_LINK_GOTO74case.7576gotor.new_window: If true, the destination should open in a77new window. Always false in the FZ_LINK_GOTO case.7879For FZ_LINK_URI:8081uri.uri: A UTF-8 encoded URI to launch.8283uri.is_map: If true, the x and y coords (as ints, in user84space) should be appended to the URI before launch.8586For FZ_LINK_LAUNCH:8788launch.file_spec: A UTF-8 file specification to launch.8990launch.new_window: If true, the destination should be launched91in a new window.9293launch.is_uri: If true, launch.file_spec is a URI to launch.9495For FZ_LINK_NAMED:9697named.named: The named action to perform. Likely to be98client specific.99*/100struct fz_link_dest_s101{102fz_link_kind kind;103union104{105struct106{107int page;108char *dest;109int flags;110fz_point lt;111fz_point rb;112char *file_spec;113int new_window;114}115gotor;116struct117{118char *uri;119int is_map;120}121uri;122struct123{124char *file_spec;125int new_window;126int is_uri;127}128launch;129struct130{131char *named;132}133named;134}135ld;136};137138/*139fz_link is a list of interactive links on a page.140141There is no relation between the order of the links in the142list and the order they appear on the page. The list of links143for a given page can be obtained from fz_load_links.144145A link is reference counted. Dropping a reference to a link is146done by calling fz_drop_link.147148rect: The hot zone. The area that can be clicked in149untransformed coordinates.150151dest: Link destinations come in two forms: Page and area that152an application should display when this link is activated. Or153as an URI that can be given to a browser.154155next: A pointer to the next link on the same page.156*/157struct fz_link_s158{159int refs;160fz_rect rect;161fz_link_dest dest;162fz_link *next;163};164165fz_link *fz_new_link(fz_context *ctx, const fz_rect *bbox, fz_link_dest dest);166fz_link *fz_keep_link(fz_context *ctx, fz_link *link);167168/*169fz_drop_link: Drop and free a list of links.170171Does not throw exceptions.172*/173void fz_drop_link(fz_context *ctx, fz_link *link);174175void fz_drop_link_dest(fz_context *ctx, fz_link_dest *dest);176177#endif178179180