]> rtime.felk.cvut.cz Git - hornmich/skoda-qr-demo.git/blob - QRScanner/mobile/jni/include/mupdf/pdf/object.h
Add MuPDF native source codes
[hornmich/skoda-qr-demo.git] / QRScanner / mobile / jni / include / mupdf / pdf / object.h
1 #ifndef MUPDF_PDF_OBJECT_H
2 #define MUPDF_PDF_OBJECT_H
3
4 typedef struct pdf_document_s pdf_document;
5
6 /*
7  * Dynamic objects.
8  * The same type of objects as found in PDF and PostScript.
9  * Used by the filters and the mupdf parser.
10  */
11
12 typedef struct pdf_obj_s pdf_obj;
13
14 pdf_obj *pdf_new_null(pdf_document *doc);
15 pdf_obj *pdf_new_bool(pdf_document *doc, int b);
16 pdf_obj *pdf_new_int(pdf_document *doc, int i);
17 pdf_obj *pdf_new_real(pdf_document *doc, float f);
18 pdf_obj *pdf_new_name(pdf_document *doc, const char *str);
19 pdf_obj *pdf_new_string(pdf_document *doc, const char *str, int len);
20 pdf_obj *pdf_new_indirect(pdf_document *doc, int num, int gen);
21 pdf_obj *pdf_new_array(pdf_document *doc, int initialcap);
22 pdf_obj *pdf_new_dict(pdf_document *doc, int initialcap);
23 pdf_obj *pdf_new_rect(pdf_document *doc, const fz_rect *rect);
24 pdf_obj *pdf_new_matrix(pdf_document *doc, const fz_matrix *mtx);
25 pdf_obj *pdf_copy_array(pdf_obj *array);
26 pdf_obj *pdf_copy_dict(pdf_obj *dict);
27
28 pdf_obj *pdf_new_obj_from_str(pdf_document *doc, const char *src);
29
30 pdf_obj *pdf_keep_obj(pdf_obj *obj);
31 void pdf_drop_obj(pdf_obj *obj);
32
33 /* type queries */
34 int pdf_is_null(pdf_obj *obj);
35 int pdf_is_bool(pdf_obj *obj);
36 int pdf_is_int(pdf_obj *obj);
37 int pdf_is_real(pdf_obj *obj);
38 int pdf_is_number(pdf_obj *obj);
39 int pdf_is_name(pdf_obj *obj);
40 int pdf_is_string(pdf_obj *obj);
41 int pdf_is_array(pdf_obj *obj);
42 int pdf_is_dict(pdf_obj *obj);
43 int pdf_is_indirect(pdf_obj *obj);
44 int pdf_is_stream(pdf_document *doc, int num, int gen);
45
46 int pdf_objcmp(pdf_obj *a, pdf_obj *b);
47
48 /* obj marking and unmarking functions - to avoid infinite recursions. */
49 int pdf_obj_marked(pdf_obj *obj);
50 int pdf_mark_obj(pdf_obj *obj);
51 void pdf_unmark_obj(pdf_obj *obj);
52
53 /* obj memo functions - allows us to secretly remember "a memo" (a bool) in
54  * an object, and to read back whether there was a memo, and if so, what it
55  * was. */
56 void pdf_set_obj_memo(pdf_obj *obj, int memo);
57 int pdf_obj_memo(pdf_obj *obj, int *memo);
58
59 /* obj dirty bit support. */
60 int pdf_obj_is_dirty(pdf_obj *obj);
61 void pdf_dirty_obj(pdf_obj *obj);
62 void pdf_clean_obj(pdf_obj *obj);
63
64 /* safe, silent failure, no error reporting on type mismatches */
65 int pdf_to_bool(pdf_obj *obj);
66 int pdf_to_int(pdf_obj *obj);
67 float pdf_to_real(pdf_obj *obj);
68 char *pdf_to_name(pdf_obj *obj);
69 char *pdf_to_str_buf(pdf_obj *obj);
70 pdf_obj *pdf_to_dict(pdf_obj *obj);
71 int pdf_to_str_len(pdf_obj *obj);
72 int pdf_to_num(pdf_obj *obj);
73 int pdf_to_gen(pdf_obj *obj);
74
75 int pdf_array_len(pdf_obj *array);
76 pdf_obj *pdf_array_get(pdf_obj *array, int i);
77 void pdf_array_put(pdf_obj *array, int i, pdf_obj *obj);
78 void pdf_array_push(pdf_obj *array, pdf_obj *obj);
79 void pdf_array_push_drop(pdf_obj *array, pdf_obj *obj);
80 void pdf_array_insert(pdf_obj *array, pdf_obj *obj, int index);
81 void pdf_array_insert_drop(pdf_obj *array, pdf_obj *obj, int index);
82 void pdf_array_delete(pdf_obj *array, int index);
83 int pdf_array_contains(pdf_obj *array, pdf_obj *obj);
84
85 int pdf_dict_len(pdf_obj *dict);
86 pdf_obj *pdf_dict_get_key(pdf_obj *dict, int idx);
87 pdf_obj *pdf_dict_get_val(pdf_obj *dict, int idx);
88 pdf_obj *pdf_dict_get(pdf_obj *dict, pdf_obj *key);
89 pdf_obj *pdf_dict_gets(pdf_obj *dict, const char *key);
90 pdf_obj *pdf_dict_getp(pdf_obj *dict, const char *key);
91 pdf_obj *pdf_dict_getsa(pdf_obj *dict, const char *key, const char *abbrev);
92 void pdf_dict_put(pdf_obj *dict, pdf_obj *key, pdf_obj *val);
93 void pdf_dict_puts(pdf_obj *dict, const char *key, pdf_obj *val);
94 void pdf_dict_puts_drop(pdf_obj *dict, const char *key, pdf_obj *val);
95 void pdf_dict_putp(pdf_obj *dict, const char *key, pdf_obj *val);
96 void pdf_dict_putp_drop(pdf_obj *dict, const char *key, pdf_obj *val);
97 void pdf_dict_del(pdf_obj *dict, pdf_obj *key);
98 void pdf_dict_dels(pdf_obj *dict, const char *key);
99 void pdf_sort_dict(pdf_obj *dict);
100
101 /*
102         Recurse through the object structure setting the node's parent_num to num.
103         parent_num is used when a subobject is to be changed during a document edit.
104         The whole containing hierarchy is moved to the incremental xref section, so
105         to be later written out as an incremental file update.
106 */
107 void pdf_set_obj_parent(pdf_obj *obj, int num);
108
109 int pdf_obj_refs(pdf_obj *ref);
110
111 int pdf_obj_parent_num(pdf_obj *obj);
112
113 int pdf_sprint_obj(char *s, int n, pdf_obj *obj, int tight);
114 int pdf_fprint_obj(FILE *fp, pdf_obj *obj, int tight);
115 int pdf_output_obj(fz_output *out, pdf_obj *obj, int tight);
116
117 #ifndef NDEBUG
118 void pdf_print_obj(pdf_obj *obj);
119 void pdf_print_ref(pdf_obj *obj);
120 #endif
121
122 char *pdf_to_utf8(pdf_document *doc, pdf_obj *src);
123 unsigned short *pdf_to_ucs2(pdf_document *doc, pdf_obj *src);
124 pdf_obj *pdf_to_utf8_name(pdf_document *doc, pdf_obj *src);
125 char *pdf_from_ucs2(pdf_document *doc, unsigned short *str);
126 void pdf_to_ucs2_buf(unsigned short *buffer, pdf_obj *src);
127
128 fz_rect *pdf_to_rect(fz_context *ctx, pdf_obj *array, fz_rect *rect);
129 fz_matrix *pdf_to_matrix(fz_context *ctx, pdf_obj *array, fz_matrix *mat);
130
131 pdf_document *pdf_get_indirect_document(pdf_obj *obj);
132 void pdf_set_str_len(pdf_obj *obj, int newlen);
133 void pdf_set_int(pdf_obj *obj, int i);
134
135 #endif