summaryrefslogtreecommitdiff
path: root/pdf/pdf_event.c
blob: 653d2a1fbff706d20ffc480fd2cd326855fe06fd (plain)
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
#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);
}

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;
}