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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
#include "fitz.h"
#include "mupdf-internal.h"
typedef struct
{
fz_doc_event base;
fz_alert_event alert;
} fz_alert_event_internal;
fz_alert_event *fz_access_alert_event(fz_doc_event *event)
{
fz_alert_event *alert = NULL;
if (event->type == FZ_DOCUMENT_EVENT_ALERT)
alert = &((fz_alert_event_internal *)event)->alert;
return alert;
}
void pdf_event_issue_alert(pdf_document *doc, fz_alert_event *alert)
{
if (doc->event_cb)
{
fz_alert_event_internal ievent;
ievent.base.type = FZ_DOCUMENT_EVENT_ALERT;
ievent.alert = *alert;
doc->event_cb((fz_doc_event *)&ievent, doc->event_cb_data);
*alert = ievent.alert;
}
}
void pdf_event_issue_print(pdf_document *doc)
{
fz_doc_event e;
e.type = FZ_DOCUMENT_EVENT_PRINT;
if (doc->event_cb)
doc->event_cb(&e, doc->event_cb_data);
}
typedef struct
{
fz_doc_event base;
char *item;
} fz_exec_menu_item_event_internal;
char *fz_access_exec_menu_item_event(fz_doc_event *event)
{
char *item = NULL;
if (event->type == FZ_DOCUMENT_EVENT_EXEC_MENU_ITEM)
item = ((fz_exec_menu_item_event_internal *)event)->item;
return item;
}
void pdf_event_issue_exec_menu_item(pdf_document *doc, char *item)
{
if (doc->event_cb)
{
fz_exec_menu_item_event_internal ievent;
ievent.base.type = FZ_DOCUMENT_EVENT_EXEC_MENU_ITEM;
ievent.item = item;
doc->event_cb((fz_doc_event *)&ievent, doc->event_cb_data);
}
}
void pdf_event_issue_exec_dialog(pdf_document *doc)
{
fz_doc_event e;
e.type = FZ_DOCUMENT_EVENT_EXEC_DIALOG;
if (doc->event_cb)
doc->event_cb(&e, doc->event_cb_data);
}
typedef struct
{
fz_doc_event base;
fz_launch_url_event launch_url;
} fz_launch_url_event_internal;
fz_launch_url_event *fz_access_launch_url_event(fz_doc_event *event)
{
fz_launch_url_event *launch_url = NULL;
if (event->type == FZ_DOCUMENT_EVENT_LAUNCH_URL)
launch_url = &((fz_launch_url_event_internal *)event)->launch_url;
return launch_url;
}
void pdf_event_issue_launch_url(pdf_document *doc, char *url, int new_frame)
{
if (doc->event_cb)
{
fz_launch_url_event_internal e;
e.base.type = FZ_DOCUMENT_EVENT_LAUNCH_URL;
e.launch_url.url = url;
e.launch_url.new_frame = new_frame;
doc->event_cb((fz_doc_event *)&e, doc->event_cb_data);
}
}
typedef struct
{
fz_doc_event base;
fz_mail_doc_event mail_doc;
} fz_mail_doc_event_internal;
fz_mail_doc_event *fz_access_mail_doc_event(fz_doc_event *event)
{
fz_mail_doc_event *mail_doc = NULL;
if (event->type == FZ_DOCUMENT_EVENT_MAIL_DOC)
mail_doc = &((fz_mail_doc_event_internal *)event)->mail_doc;
return mail_doc;
}
void pdf_event_issue_mail_doc(pdf_document *doc, fz_mail_doc_event *event)
{
if (doc->event_cb)
{
fz_mail_doc_event_internal e;
e.base.type = FZ_DOCUMENT_EVENT_MAIL_DOC;
e.mail_doc = *event;
doc->event_cb((fz_doc_event *)&e, doc->event_cb_data);
}
}
void pdf_set_doc_event_callback(pdf_document *doc, fz_doc_event_cb *fn, void *data)
{
doc->event_cb = fn;
doc->event_cb_data = data;
}
|