1#ifndef SOURCE_XPS_IMP_H
2#define SOURCE_XPS_IMP_H
3
4typedef struct xps_document_s xps_document;
5typedef struct xps_page_s xps_page;
6
7fz_document *xps_open_document(fz_context *ctx, const char *filename);
8fz_document *xps_open_document_with_stream(fz_context *ctx, fz_stream *file);
9int xps_count_pages(fz_context *ctx, fz_document *doc);
10fz_page *xps_load_page(fz_context *ctx, fz_document *doc, int number);
11fz_outline *xps_load_outline(fz_context *ctx, fz_document *doc);
12void xps_run_page(fz_context *ctx, fz_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie);
13fz_link *xps_load_links(fz_context *ctx, fz_page *page);
14int xps_lookup_link_target(fz_context *ctx, fz_document *doc, const char *target_uri, float *xp, float *yp);
15
16int xps_strcasecmp(char *a, char *b);
17void xps_resolve_url(fz_context *ctx, xps_document *doc, char *output, char *base_uri, char *path, int output_size);
18char *xps_parse_point(fz_context *ctx, xps_document *doc, char *s_in, float *x, float *y);
19
20typedef struct xps_part_s xps_part;
21
22struct xps_part_s
23{
24 char *name;
25 fz_buffer *data;
26};
27
28int xps_has_part(fz_context *ctx, xps_document *doc, char *partname);
29xps_part *xps_read_part(fz_context *ctx, xps_document *doc, char *partname);
30void xps_drop_part(fz_context *ctx, xps_document *doc, xps_part *part);
31
32typedef struct xps_fixdoc_s xps_fixdoc;
33typedef struct xps_fixpage_s xps_fixpage;
34typedef struct xps_target_s xps_target;
35
36struct xps_fixdoc_s
37{
38 char *name;
39 char *outline;
40 xps_fixdoc *next;
41};
42
43struct xps_fixpage_s
44{
45 char *name;
46 int number;
47 int width;
48 int height;
49 xps_fixpage *next;
50};
51
52struct xps_page_s
53{
54 fz_page super;
55 xps_document *doc;
56 xps_fixpage *fix;
57 fz_xml_doc *xml;
58};
59
60struct xps_target_s
61{
62 char *name;
63 int page;
64 xps_target *next;
65};
66
67void xps_read_page_list(fz_context *ctx, xps_document *doc);
68void xps_print_page_list(fz_context *ctx, xps_document *doc);
69void xps_drop_page_list(fz_context *ctx, xps_document *doc);
70
71typedef struct xps_font_cache_s xps_font_cache;
72
73struct xps_font_cache_s
74{
75 char *name;
76 fz_font *font;
77 xps_font_cache *next;
78};
79
80typedef struct xps_glyph_metrics_s xps_glyph_metrics;
81
82struct xps_glyph_metrics_s
83{
84 float hadv, vadv, vorg;
85};
86
87int xps_count_font_encodings(fz_context *ctx, fz_font *font);
88void xps_identify_font_encoding(fz_context *ctx, fz_font *font, int idx, int *pid, int *eid);
89void xps_select_font_encoding(fz_context *ctx, fz_font *font, int idx);
90int xps_encode_font_char(fz_context *ctx, fz_font *font, int key);
91
92void xps_measure_font_glyph(fz_context *ctx, xps_document *doc, fz_font *font, int gid, xps_glyph_metrics *mtx);
93
94void xps_print_path(fz_context *ctx, xps_document *doc);
95
96void xps_parse_color(fz_context *ctx, xps_document *doc, char *base_uri, char *hexstring, fz_colorspace **csp, float *samples);
97void xps_set_color(fz_context *ctx, xps_document *doc, fz_colorspace *colorspace, float *samples);
98
99typedef struct xps_resource_s xps_resource;
100
101struct 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
111xps_resource * xps_parse_resource_dictionary(fz_context *ctx, xps_document *doc, char *base_uri, fz_xml *root);
112void xps_drop_resource_dictionary(fz_context *ctx, xps_document *doc, xps_resource *dict);
113void xps_resolve_resource_reference(fz_context *ctx, xps_document *doc, xps_resource *dict, char **attp, fz_xml **tagp, char **urip);
114
115void xps_print_resource_dictionary(fz_context *ctx, xps_document *doc, xps_resource *dict);
116
117void xps_parse_fixed_page(fz_context *ctx, xps_document *doc, fz_matrix ctm, xps_page *page);
118void xps_parse_canvas(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node);
119void xps_parse_path(fz_context *ctx, xps_document *doc, fz_matrix ctm, char *base_uri, xps_resource *dict, fz_xml *node);
120void xps_parse_glyphs(fz_context *ctx, xps_document *doc, fz_matrix ctm, char *base_uri, xps_resource *dict, fz_xml *node);
121void xps_parse_solid_color_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, char *base_uri, xps_resource *dict, fz_xml *node);
122void 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);
123void 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);
124void 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);
125void 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
127void 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
129fz_font *xps_lookup_font(fz_context *ctx, xps_document *doc, char *base_uri, char *font_uri, char *style_att);
130fz_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);
134fz_path *xps_parse_abbreviated_geometry(fz_context *ctx, xps_document *doc, char *geom, int *fill_rule);
135fz_path *xps_parse_path_geometry(fz_context *ctx, xps_document *doc, xps_resource *dict, fz_xml *root, int stroking, int *fill_rule);
136fz_matrix xps_parse_transform(fz_context *ctx, xps_document *doc, char *att, fz_xml *tag, fz_matrix ctm);
137fz_rect xps_parse_rectangle(fz_context *ctx, xps_document *doc, char *text);
138
139void 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);
140void xps_end_opacity(fz_context *ctx, xps_document *doc, char *base_uri, xps_resource *dict, char *opacity_att, fz_xml *opacity_mask_tag);
141
142void xps_parse_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node);
143void 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
145void xps_clip(fz_context *ctx, xps_document *doc, fz_matrix ctm, xps_resource *dict, char *clip_att, fz_xml *clip_tag);
146
147fz_xml *xps_lookup_alternate_content(fz_context *ctx, xps_document *doc, fz_xml *node);
148
149typedef struct xps_entry_s xps_entry;
150
151struct xps_entry_s
152{
153 char *name;
154 int64_t offset;
155 int csize;
156 int usize;
157};
158
159struct 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