/[public]/psiconv/trunk/lib/psiconv/data.h
ViewVC logotype

Contents of /psiconv/trunk/lib/psiconv/data.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 27 - (show annotations)
Mon Nov 1 12:35:16 1999 UTC (24 years, 5 months ago) by frodo
File MIME type: text/plain
File size: 14288 byte(s)
(Kevin Wheatley) 5MX patches, mostly outline stuff

1 /*
2 data.h - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 /* This file contains the declarations of all types that are used to
21 represent the Word file. Variables of these types are written by the
22 parse routines, and read by the generation routines. */
23
24 #ifndef PSICONV_DATA_H
25 #define PSICONV_DATA_H
26
27 #include "general.h"
28 #include "list.h"
29
30 /* All types which end on _t are plain types; all other types are pointers
31 to structs */
32
33 typedef enum psiconv_file_type {
34 psiconv_unknown_file,
35 psiconv_word_file,
36 psiconv_texted_file,
37 psiconv_mbm_file,
38 psiconv_sketch_file
39 } psiconv_file_type_t;
40
41 /* Length indicators */
42 typedef psiconv_u32 psiconv_S_t;
43 typedef psiconv_u32 psiconv_X_t;
44
45 /* A string */
46 typedef char *psiconv_string_t;
47
48 /* In the Psion file, these are identical; but we translate them to more
49 human-readable quantities */
50 typedef float psiconv_length_t; /* For offsets in centimeters */
51 typedef float psiconv_size_t; /* For sizes in points */
52
53 /* Some enums */
54 typedef enum psiconv_bool
55 {
56 psiconv_bool_false,
57 psiconv_bool_true
58 } psiconv_bool_t;
59
60 typedef enum psiconv_super_sub
61 { psiconv_normalscript,
62 psiconv_superscript,
63 psiconv_subscript
64 } psiconv_super_sub_t;
65
66 typedef enum psiconv_justify_hor
67 { psiconv_justify_left,
68 psiconv_justify_centre,
69 psiconv_justify_right,
70 psiconv_justify_full
71 } psiconv_justify_hor_t;
72
73 typedef enum psiconv_justify_ver
74 { psiconv_justify_top,
75 psiconv_justify_middle,
76 psiconv_justify_bottom
77 } psiconv_justify_ver_t;
78
79 typedef enum psiconv_border_kind
80 { psiconv_border_none,
81 psiconv_border_solid,
82 psiconv_border_double,
83 psiconv_border_dotted,
84 psiconv_border_striped,
85 psiconv_border_dotstripe,
86 psiconv_border_dotdotstripe
87 } psiconv_border_kind_t;
88
89 /* Colors.
90 black: 0x00 0x00 0x00
91 white: 0xff 0xff 0xff */
92 typedef struct psiconv_color
93 {
94 psiconv_u8 red;
95 psiconv_u8 green;
96 psiconv_u8 blue;
97 } * psiconv_color;
98
99 typedef struct psiconv_font
100 {
101 char *name;
102 psiconv_u8 screenfont;
103 } *psiconv_font;
104
105 typedef struct psiconv_border
106 {
107 psiconv_border_kind_t kind;
108 psiconv_size_t thickness; /* Set to 1/20 for non-solid lines */
109 psiconv_color color;
110 } *psiconv_border;
111
112 typedef struct psiconv_bullet
113 {
114 psiconv_bool_t on;
115 psiconv_size_t font_size;
116 psiconv_u8 character;
117 psiconv_bool_t indent;
118 psiconv_color color;
119 psiconv_font font;
120 } *psiconv_bullet;
121
122 typedef enum psiconv_tab_kind
123 {
124 psiconv_tab_left,
125 psiconv_tab_centre,
126 psiconv_tab_right
127 } psiconv_tab_kind_t;
128
129 typedef struct psiconv_tab
130 {
131 psiconv_length_t location;
132 psiconv_tab_kind_t kind;
133 } *psiconv_tab;
134
135
136 typedef psiconv_list psiconv_tab_list; /* of struct psiconv_tab */
137
138 typedef struct psiconv_all_tabs
139 {
140 psiconv_length_t normal;
141 psiconv_tab_list extras;
142 } *psiconv_all_tabs;
143
144 typedef struct psiconv_character_layout
145 {
146 psiconv_color color;
147 psiconv_color back_color;
148 psiconv_size_t font_size;
149 psiconv_bool_t italic;
150 psiconv_bool_t bold;
151 psiconv_super_sub_t super_sub;
152 psiconv_bool_t underline;
153 psiconv_bool_t strike_out;
154 psiconv_font font;
155 } *psiconv_character_layout;
156
157 typedef struct psiconv_paragraph_layout
158 {
159 psiconv_color back_color;
160 psiconv_length_t indent_left;
161 psiconv_length_t indent_right;
162 psiconv_length_t indent_first;
163 psiconv_justify_hor_t justify_hor;
164 psiconv_justify_ver_t justify_ver;
165 psiconv_size_t interline;
166 psiconv_bool_t interline_exact;
167 psiconv_size_t top_space;
168 psiconv_size_t bottom_space;
169 psiconv_bool_t on_one_page;
170 psiconv_bool_t together_with; /* What the heck is this? */
171 psiconv_bool_t on_next_page;
172 psiconv_bool_t no_widow_protection;
173 psiconv_length_t border_distance;
174 psiconv_bullet bullet;
175 psiconv_border left_border;
176 psiconv_border right_border;
177 psiconv_border top_border;
178 psiconv_border bottom_border;
179 psiconv_all_tabs tabs;
180 } *psiconv_paragraph_layout;
181
182 typedef struct psiconv_header_section
183 {
184 psiconv_u32 uid1;
185 psiconv_u32 uid2;
186 psiconv_u32 uid3;
187 psiconv_u32 checksum;
188 psiconv_file_type_t file;
189 } *psiconv_header_section;
190
191 typedef struct psiconv_section_table_entry
192 {
193 psiconv_u32 id;
194 psiconv_u32 offset;
195 } *psiconv_section_table_entry;
196
197 typedef psiconv_list psiconv_section_table_section;
198 /* Of struct sectiontable_entry */
199
200 typedef struct psiconv_application_id_section
201 {
202 psiconv_u32 id;
203 psiconv_string_t name;
204 } *psiconv_application_id_section;
205
206 typedef struct psiconv_in_line_layout
207 {
208 psiconv_character_layout layout;
209 int length;
210 } *psiconv_in_line_layout;
211
212 typedef psiconv_list psiconv_in_line_layouts; /* of struct in_line_layout */
213
214 typedef enum psiconv_replacement_type
215 {
216 psiconv_replace_time,
217 psiconv_replace_date,
218 psiconv_replace_pagenr,
219 psiconv_replace_nr_of_pages,
220 psiconv_replace_filename
221 } psiconv_replacement_type_t;
222
223 typedef struct psiconv_replacement
224 {
225 int offset;
226 int cur_len;
227 psiconv_replacement_type_t type;
228 } *psiconv_replacement;
229
230 typedef psiconv_list psiconv_replacements; /* of struct replacement */
231
232 typedef struct psiconv_paragraph
233 {
234 char *text;
235 psiconv_character_layout base_character;
236 psiconv_paragraph_layout base_paragraph;
237 psiconv_s16 base_style;
238 psiconv_in_line_layouts in_lines;
239 psiconv_replacements replacements;
240 } *psiconv_paragraph;
241
242 typedef psiconv_list psiconv_text_and_layout; /* Of struct paragraphs */
243
244 typedef struct psiconv_texted_section
245 {
246 psiconv_text_and_layout paragraphs;
247 } *psiconv_texted_section;
248
249 typedef struct psiconv_page_header
250 {
251 psiconv_bool_t on_first_page;
252 psiconv_paragraph_layout base_paragraph_layout;
253 psiconv_character_layout base_character_layout;
254 psiconv_texted_section text;
255 } *psiconv_page_header;
256
257 typedef struct psiconv_page_layout_section
258 {
259 psiconv_u32 first_page_nr;
260 psiconv_length_t header_dist;
261 psiconv_length_t footer_dist;
262 psiconv_length_t left_margin;
263 psiconv_length_t right_margin;
264 psiconv_length_t top_margin;
265 psiconv_length_t bottom_margin;
266 psiconv_length_t page_width;
267 psiconv_length_t page_height;
268 psiconv_page_header header;
269 psiconv_page_header footer;
270 } * psiconv_page_layout_section;
271
272 typedef struct psiconv_word_status_section
273 {
274 psiconv_bool_t show_tabs;
275 psiconv_bool_t show_spaces;
276 psiconv_bool_t show_paragraph_ends;
277 psiconv_bool_t show_line_breaks;
278 psiconv_bool_t show_hard_minus;
279 psiconv_bool_t show_hard_space;
280 psiconv_bool_t show_full_pictures;
281 psiconv_bool_t show_full_graphs;
282 psiconv_bool_t show_top_toolbar;
283 psiconv_bool_t show_side_toolbar;
284 psiconv_bool_t fit_lines_to_screen;
285 psiconv_u32 cursor_position;
286 psiconv_u32 display_size;
287 } *psiconv_word_status_section;
288
289 typedef struct psiconv_word_style
290 {
291 psiconv_character_layout character;
292 psiconv_paragraph_layout paragraph;
293 psiconv_u8 hotkey;
294 psiconv_string_t name;
295 psiconv_bool_t built_in;
296 outline_level;
297 } *psiconv_word_style;
298
299 typedef psiconv_list psiconv_word_style_list; /* Of style */
300
301 typedef struct psiconv_word_styles_section
302 {
303 psiconv_word_style normal;
304 psiconv_word_style_list styles;
305 } *psiconv_word_styles_section;
306
307 typedef struct psiconv_word_f {
308 psiconv_page_layout_section page_sec;
309 psiconv_text_and_layout paragraphs;
310 psiconv_word_status_section status_sec;
311 psiconv_word_styles_section styles_sec;
312 } *psiconv_word_f;
313
314 typedef struct psiconv_texted_f {
315 psiconv_page_layout_section page_sec;
316 psiconv_texted_section texted_sec;
317 } *psiconv_texted_f;
318
319 typedef psiconv_list psiconv_mbm_jumptable_section; /* of psiconv_u32 */
320
321 /* Normalized values [0..1] for each component
322 Origin is (x,y)=(0,0), to get pixel at (X,Y) use index [Y*xsize+X] */
323 typedef struct psiconv_paint_data_section {
324 psiconv_u32 xsize;
325 psiconv_u32 ysize;
326 psiconv_length_t pic_xsize; /* 0 if not specified */
327 psiconv_length_t pic_ysize; /* 0 if not specified */
328 float *red;
329 float *green;
330 float *blue;
331 } *psiconv_paint_data_section;
332
333 typedef psiconv_list psiconv_pictures;
334 /* of struct psiconv_paint_data_section */
335
336 typedef struct psiconv_mbm_f {
337 psiconv_pictures sections;
338 } *psiconv_mbm_f;
339
340 /* This is a little intricated. A picture may be embedded in a larger form.
341 A form is empty, except for the picture. The form has size form_{x,y}size,
342 and the picture is at offset picture_{x,y}_offset within the form. The
343 picture itself has size picture_{x,y}size.
344 Cuts are always <= 1.0; a cut of 0.0 cuts nothing away, a cut of 1.0
345 cuts everything away. */
346 typedef struct psiconv_sketch_section {
347 psiconv_u16 form_xsize;
348 psiconv_u16 form_ysize;
349 psiconv_u16 picture_x_offset;
350 psiconv_u16 picture_y_offset;
351 psiconv_u16 picture_xsize;
352 psiconv_u16 picture_ysize;
353 float magnification_x; /* computed relative to first six values */
354 float magnification_y; /* computed relative to first six values */
355 float cut_left; /* computed relative to first six values */
356 float cut_right; /* computed relative to first six values */
357 float cut_top; /* computed relative to first six values */
358 float cut_bottom; /* computed relative to first six values */
359 psiconv_paint_data_section picture;
360 } *psiconv_sketch_section;
361
362 typedef struct psiconv_sketch_f {
363 psiconv_sketch_section sketch_sec;
364 } *psiconv_sketch_f;
365
366 typedef struct psiconv_file {
367 psiconv_file_type_t type;
368 void *file;
369 } *psiconv_file;
370
371
372 /* UID1 */
373 #define PSICONV_ID_PSION5 0x10000037
374 /* UID2 */
375 #define PSICONV_ID_DATA_FILE 0x1000006D
376 #define PSICONV_ID_MBM_FILE 0x10000042
377 /* UID3 */
378 #define PSICONV_ID_WORD 0x1000007F
379 #define PSICONV_ID_TEXTED 0x10000085
380 #define PSICONV_ID_SKETCH 0x1000007D
381
382 /* Section table ids */
383 #define PSICONV_ID_WORD_STATUS_SECTION 0x10000243
384 #define PSICONV_ID_APPL_ID_SECTION 0x10000089
385 #define PSICONV_ID_TEXT_SECTION 0x10000106
386 #define PSICONV_ID_LAYOUT_SECTION 0x10000143
387 #define PSICONV_ID_WORD_STYLES_SECTION 0x10000104
388 #define PSICONV_ID_PAGE_LAYOUT_SECTION 0x10000105
389 #define PSICONV_ID_PASSWORD_SECTION 0x100000CD
390 #define PSICONV_ID_SKETCH_SECTION 0x1000007D
391
392 /* Other ids */
393 #define PSICONV_ID_PAGE_DIMENSIONS 0x100000fd
394 #define PSICONV_ID_TEXTED_BODY 0x1000005c
395 #define PSICONV_ID_TEXTED_REPLACEMENT 0x10000063
396 #define PSICONV_ID_TEXTED_UNKNOWN 0x10000065
397 #define PSICONV_ID_TEXTED_LAYOUT 0x10000066
398 #define PSICONV_ID_TEXTED_TEXT 0x10000064
399 #define PSICONV_ID_STYLE_REMOVABLE 0x1000004F
400 #define PSICONV_ID_STYLE_BUILT_IN 0x1000004C
401
402
403 /* Return a clean layout_status. You can modify it at will */
404 extern psiconv_character_layout psiconv_basic_character_layout(void);
405
406 /* Return a clean layout_status. You can modify it at will */
407 extern psiconv_paragraph_layout psiconv_basic_paragraph_layout(void);
408
409 /* Clone a layout_status: the new copy is completely independent of the
410 original one */
411 extern psiconv_paragraph_layout psiconv_clone_paragraph_layout
412 (psiconv_paragraph_layout ls);
413
414 extern psiconv_character_layout psiconv_clone_character_layout
415 (psiconv_character_layout ls);
416
417 /* Get a numbered style */
418 extern psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr);
419
420 extern void psiconv_free_color(psiconv_color color);
421 extern void psiconv_free_border(psiconv_border border);
422 extern void psiconv_free_bullet(psiconv_bullet bullet);
423 extern void psiconv_free_font(psiconv_font font);
424 extern void psiconv_free_tab(psiconv_tab tab);
425 extern void psiconv_free_tabs(psiconv_all_tabs tabs);
426 extern void psiconv_free_paragraph_layout(psiconv_paragraph_layout layout);
427 extern void psiconv_free_character_layout(psiconv_character_layout layout);
428 extern void psiconv_free_word_style(psiconv_word_style style);
429 extern void psiconv_free_word_styles_section
430 (psiconv_word_styles_section styles);
431 extern void psiconv_free_header_section(psiconv_header_section header);
432 extern void psiconv_free_section_table_entry(psiconv_section_table_entry entry);
433 extern void psiconv_free_section_table_section
434 (psiconv_section_table_section section);
435 extern void psiconv_free_application_id_section
436 (psiconv_application_id_section section);
437 extern void psiconv_free_in_line_layout(psiconv_in_line_layout layout);
438 extern void psiconv_free_in_line_layouts(psiconv_in_line_layouts layouts);
439 extern void psiconv_free_replacement(psiconv_replacement replacement);
440 extern void psiconv_free_replacements(psiconv_replacements replacements);
441 extern void psiconv_free_paragraph(psiconv_paragraph paragraph);
442 extern void psiconv_free_text_and_layout(psiconv_text_and_layout text);
443 extern void psiconv_free_texted_section(psiconv_texted_section section);
444 extern void psiconv_free_page_header(psiconv_page_header header);
445 extern void psiconv_free_page_layout_section
446 (psiconv_page_layout_section section);
447 extern void psiconv_free_word_status_section
448 (psiconv_word_status_section section);
449 extern void psiconv_free_word_f(psiconv_word_f file);
450 extern void psiconv_free_texted_f(psiconv_texted_f file);
451 extern void psiconv_free_paint_data_section(psiconv_paint_data_section section);
452 extern void psiconv_free_pictures(psiconv_pictures section);
453 extern void psiconv_free_mbm_jumptable_section
454 (psiconv_mbm_jumptable_section section);
455 extern void psiconv_free_mbm_f(psiconv_mbm_f file);
456 extern void psiconv_free_sketch_section(psiconv_sketch_section sec);
457 extern void psiconv_free_sketch_f(psiconv_sketch_f file);
458
459 extern void psiconv_free_file(psiconv_file file);
460
461
462 #endif /* def PSICONV_DATA_H */

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26