1 | #ifndef SOURCE_XPS_IMP_H |
2 | #define SOURCE_XPS_IMP_H |
3 | |
4 | typedef struct xps_document_s xps_document; |
5 | typedef struct xps_page_s xps_page; |
6 | |
7 | fz_document *xps_open_document(fz_context *ctx, const char *filename); |
8 | fz_document *xps_open_document_with_stream(fz_context *ctx, fz_stream *file); |
9 | int xps_count_pages(fz_context *ctx, fz_document *doc); |
10 | fz_page *xps_load_page(fz_context *ctx, fz_document *doc, int number); |
11 | fz_outline *xps_load_outline(fz_context *ctx, fz_document *doc); |
12 | void xps_run_page(fz_context *ctx, fz_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie); |
13 | fz_link *xps_load_links(fz_context *ctx, fz_page *page); |
14 | int xps_lookup_link_target(fz_context *ctx, fz_document *doc, const char *target_uri, float *xp, float *yp); |
15 | |
16 | int xps_strcasecmp(char *a, char *b); |
17 | void xps_resolve_url(fz_context *ctx, xps_document *doc, char *output, char *base_uri, char *path, int output_size); |
18 | char *xps_parse_point(fz_context *ctx, xps_document *doc, char *s_in, float *x, float *y); |
19 | |
20 | typedef struct xps_part_s xps_part; |
21 | |
22 | struct xps_part_s |
23 | { |
24 | char *name; |
25 | fz_buffer *data; |
26 | }; |
27 | |
28 | int xps_has_part(fz_context *ctx, xps_document *doc, char *partname); |
29 | xps_part *xps_read_part(fz_context *ctx, xps_document *doc, char *partname); |
30 | void xps_drop_part(fz_context *ctx, xps_document *doc, xps_part *part); |
31 | |
32 | typedef struct xps_fixdoc_s xps_fixdoc; |
33 | typedef struct xps_fixpage_s xps_fixpage; |
34 | typedef struct xps_target_s xps_target; |
35 | |
36 | struct xps_fixdoc_s |
37 | { |
38 | char *name; |
39 | char *outline; |
40 | xps_fixdoc *next; |
41 | }; |
42 | |
43 | struct xps_fixpage_s |
44 | { |
45 | char *name; |
46 | int number; |
47 | int width; |
48 | int height; |
49 | xps_fixpage *next; |
50 | }; |
51 | |
52 | struct xps_page_s |
53 | { |
54 | fz_page super; |
55 | xps_document *doc; |
56 | xps_fixpage *fix; |
57 | fz_xml_doc *xml; |
58 | }; |
59 | |
60 | struct xps_target_s |
61 | { |
62 | char *name; |
63 | int page; |
64 | xps_target *next; |
65 | }; |
66 | |
67 | void xps_read_page_list(fz_context *ctx, xps_document *doc); |
68 | void xps_print_page_list(fz_context *ctx, xps_document *doc); |
69 | void xps_drop_page_list(fz_context *ctx, xps_document *doc); |
70 | |
71 | typedef struct xps_font_cache_s xps_font_cache; |
72 | |
73 | struct xps_font_cache_s |
74 | { |
75 | char *name; |
76 | fz_font *font; |
77 | xps_font_cache *next; |
78 | }; |
79 | |
80 | typedef struct xps_glyph_metrics_s xps_glyph_metrics; |
81 | |
82 | struct xps_glyph_metrics_s |
83 | { |
84 | float hadv, vadv, vorg; |
85 | }; |
86 | |
87 | int xps_count_font_encodings(fz_context *ctx, fz_font *font); |
88 | void xps_identify_font_encoding(fz_context *ctx, fz_font *font, int idx, int *pid, int *eid); |
89 | void xps_select_font_encoding(fz_context *ctx, fz_font *font, int idx); |
90 | int xps_encode_font_char(fz_context *ctx, fz_font *font, int key); |
91 | |
92 | void xps_measure_font_glyph(fz_context *ctx, xps_document *doc, fz_font *font, int gid, xps_glyph_metrics *mtx); |
93 | |
94 | void xps_print_path(fz_context *ctx, xps_document *doc); |
95 | |
96 | void xps_parse_color(fz_context *ctx, xps_document *doc, char *base_uri, char *hexstring, fz_colorspace **csp, float *samples); |
97 | void xps_set_color(fz_context *ctx, xps_document *doc, fz_colorspace *colorspace, float *samples); |
98 | |
99 | typedef struct xps_resource_s xps_resource; |
100 | |
101 | struct xps_resource_s |
102 | { |
103 | char *name; |
104 | char *base_uri; /* only used in the head nodes */ |
105 | fz_xml_doc *base_xml; /* only used in the head nodes, to free the xml document */ |
106 | fz_xml *data; |
107 | xps_resource *next; |
108 | xps_resource *parent; /* up to the previous dict in the stack */ |
109 | }; |
110 | |
111 | xps_resource * xps_parse_resource_dictionary(fz_context *ctx, xps_document *doc, char *base_uri, fz_xml *root); |
112 | void xps_drop_resource_dictionary(fz_context *ctx, xps_document *doc, xps_resource *dict); |
113 | void xps_resolve_resource_reference(fz_context *ctx, xps_document *doc, xps_resource *dict, char **attp, fz_xml **tagp, char **urip); |
114 | |
115 | void xps_print_resource_dictionary(fz_context *ctx, xps_document *doc, xps_resource *dict); |
116 | |
117 | void xps_parse_fixed_page(fz_context *ctx, xps_document *doc, fz_matrix ctm, xps_page *page); |
118 | void xps_parse_canvas(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node); |
119 | void xps_parse_path(fz_context *ctx, xps_document *doc, fz_matrix ctm, char *base_uri, xps_resource *dict, fz_xml *node); |
120 | void xps_parse_glyphs(fz_context *ctx, xps_document *doc, fz_matrix ctm, char *base_uri, xps_resource *dict, fz_xml *node); |
121 | void xps_parse_solid_color_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, char *base_uri, xps_resource *dict, fz_xml *node); |
122 | void xps_parse_image_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node); |
123 | void xps_parse_visual_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node); |
124 | void xps_parse_linear_gradient_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node); |
125 | void xps_parse_radial_gradient_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node); |
126 | |
127 | void xps_parse_tiling_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *root, void(*func)(fz_context *ctx, xps_document*, fz_matrix, fz_rect, char*, xps_resource*, fz_xml*, void*), void *user); |
128 | |
129 | fz_font *xps_lookup_font(fz_context *ctx, xps_document *doc, char *base_uri, char *font_uri, char *style_att); |
130 | fz_text *xps_parse_glyphs_imp(fz_context *ctx, xps_document *doc, fz_matrix ctm, |
131 | fz_font *font, float size, float originx, float originy, |
132 | int is_sideways, int bidi_level, |
133 | char *indices, char *unicode); |
134 | fz_path *xps_parse_abbreviated_geometry(fz_context *ctx, xps_document *doc, char *geom, int *fill_rule); |
135 | fz_path *xps_parse_path_geometry(fz_context *ctx, xps_document *doc, xps_resource *dict, fz_xml *root, int stroking, int *fill_rule); |
136 | fz_matrix xps_parse_transform(fz_context *ctx, xps_document *doc, char *att, fz_xml *tag, fz_matrix ctm); |
137 | fz_rect xps_parse_rectangle(fz_context *ctx, xps_document *doc, char *text); |
138 | |
139 | void xps_begin_opacity(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, char *opacity_att, fz_xml *opacity_mask_tag); |
140 | void xps_end_opacity(fz_context *ctx, xps_document *doc, char *base_uri, xps_resource *dict, char *opacity_att, fz_xml *opacity_mask_tag); |
141 | |
142 | void xps_parse_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node); |
143 | void xps_parse_element(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node); |
144 | |
145 | void xps_clip(fz_context *ctx, xps_document *doc, fz_matrix ctm, xps_resource *dict, char *clip_att, fz_xml *clip_tag); |
146 | |
147 | fz_xml *xps_lookup_alternate_content(fz_context *ctx, xps_document *doc, fz_xml *node); |
148 | |
149 | typedef struct xps_entry_s xps_entry; |
150 | |
151 | struct xps_entry_s |
152 | { |
153 | char *name; |
154 | int64_t offset; |
155 | int csize; |
156 | int usize; |
157 | }; |
158 | |
159 | struct xps_document_s |
160 | { |
161 | fz_document super; |
162 | fz_archive *zip; |
163 | |
164 | char *start_part; /* fixed document sequence */ |
165 | xps_fixdoc *first_fixdoc; /* first fixed document */ |
166 | xps_fixdoc *last_fixdoc; /* last fixed document */ |
167 | xps_fixpage *first_page; /* first page of document */ |
168 | xps_fixpage *last_page; /* last page of document */ |
169 | int page_count; |
170 | |
171 | xps_target *target; /* link targets */ |
172 | |
173 | char *base_uri; /* base uri for parsing XML and resolving relative paths */ |
174 | char *part_uri; /* part uri for parsing metadata relations */ |
175 | |
176 | /* We cache font resources */ |
177 | xps_font_cache *font_table; |
178 | |
179 | /* Opacity attribute stack */ |
180 | float opacity[64]; |
181 | int opacity_top; |
182 | |
183 | /* Current color */ |
184 | fz_colorspace *colorspace; |
185 | float color[8]; |
186 | float alpha; |
187 | |
188 | /* Current device */ |
189 | fz_device *dev; |
190 | fz_cookie *cookie; |
191 | }; |
192 | |
193 | #endif |
194 | |