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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (hide annotations)
Wed Dec 13 16:17:54 2000 UTC (19 years, 5 months ago) by frodo
File MIME type: text/plain
File size: 15285 byte(s)
(Frodo) Several important changes:
  * Created new misc.c, error.c and error.h files
  * Split parse_aux.c among them
  * Made list.c, data.c, error.c, checkuid.c and misc.c failsafe.

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

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