/[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 25 - (hide annotations)
Sat Oct 30 22:28:54 1999 UTC (20 years, 7 months ago) by frodo
File MIME type: text/plain
File size: 14271 byte(s)
(Frodo) Parsing of both MBM and Sketch files finished and correct!

To do:
  * Need to ask ImageMagick what output formats are available;
  * Need to display those formats in --help, and understand them on the
    command-line;
  * Need to generate the correct type of file;
  * Need to take a look at some special Sketch options (size, cuts, etc)
  * Sometimes, the file seems to be negative. Probably an ImageMagick
    problem.
  * Need to handle several images in one file elegantly

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     #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 frodo 12 psiconv_mbm_file,
38 frodo 2 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     } *psiconv_word_style;
297    
298     typedef psiconv_list psiconv_word_style_list; /* Of style */
299    
300     typedef struct psiconv_word_styles_section
301     {
302     psiconv_word_style normal;
303     psiconv_word_style_list styles;
304     } *psiconv_word_styles_section;
305    
306     typedef struct psiconv_word_f {
307     psiconv_page_layout_section page_sec;
308     psiconv_text_and_layout paragraphs;
309     psiconv_word_status_section status_sec;
310     psiconv_word_styles_section styles_sec;
311     } *psiconv_word_f;
312    
313     typedef struct psiconv_texted_f {
314     psiconv_page_layout_section page_sec;
315     psiconv_texted_section texted_sec;
316     } *psiconv_texted_f;
317    
318 frodo 12 typedef psiconv_list psiconv_mbm_jumptable_section; /* of psiconv_u32 */
319    
320 frodo 11 /* Normalized values [0..1] for each component
321     Origin is (x,y)=(0,0), to get pixel at (X,Y) use index [Y*xsize+X] */
322     typedef struct psiconv_paint_data_section {
323     psiconv_u32 xsize;
324     psiconv_u32 ysize;
325 frodo 25 psiconv_length_t pic_xsize; /* 0 if not specified */
326     psiconv_length_t pic_ysize; /* 0 if not specified */
327 frodo 11 float *red;
328     float *green;
329     float *blue;
330     } *psiconv_paint_data_section;
331    
332 frodo 12 typedef psiconv_list psiconv_pictures;
333     /* of struct psiconv_paint_data_section */
334    
335     typedef struct psiconv_mbm_f {
336     psiconv_pictures sections;
337     } *psiconv_mbm_f;
338    
339 frodo 24 /* This is a little intricated. A picture may be embedded in a larger form.
340     A form is empty, except for the picture. The form has size form_{x,y}size,
341     and the picture is at offset picture_{x,y}_offset within the form. The
342     picture itself has size picture_{x,y}size.
343     Cuts are always <= 1.0; a cut of 0.0 cuts nothing away, a cut of 1.0
344     cuts everything away. */
345     typedef struct psiconv_sketch_section {
346     psiconv_u16 form_xsize;
347     psiconv_u16 form_ysize;
348     psiconv_u16 picture_x_offset;
349     psiconv_u16 picture_y_offset;
350     psiconv_u16 picture_xsize;
351     psiconv_u16 picture_ysize;
352     float magnification_x; /* computed relative to first six values */
353     float magnification_y; /* computed relative to first six values */
354     float cut_left; /* computed relative to first six values */
355     float cut_right; /* computed relative to first six values */
356     float cut_top; /* computed relative to first six values */
357     float cut_bottom; /* computed relative to first six values */
358     psiconv_paint_data_section picture;
359     } *psiconv_sketch_section;
360    
361     typedef struct psiconv_sketch_f {
362     psiconv_sketch_section sketch_sec;
363     } *psiconv_sketch_f;
364    
365 frodo 2 typedef struct psiconv_file {
366     psiconv_file_type_t type;
367     void *file;
368     } *psiconv_file;
369    
370    
371     /* UID1 */
372     #define PSICONV_ID_PSION5 0x10000037
373     /* UID2 */
374     #define PSICONV_ID_DATA_FILE 0x1000006D
375 frodo 12 #define PSICONV_ID_MBM_FILE 0x10000042
376 frodo 2 /* UID3 */
377     #define PSICONV_ID_WORD 0x1000007F
378     #define PSICONV_ID_TEXTED 0x10000085
379 frodo 24 #define PSICONV_ID_SKETCH 0x1000007D
380 frodo 2
381     /* Section table ids */
382     #define PSICONV_ID_WORD_STATUS_SECTION 0x10000243
383     #define PSICONV_ID_APPL_ID_SECTION 0x10000089
384     #define PSICONV_ID_TEXT_SECTION 0x10000106
385     #define PSICONV_ID_LAYOUT_SECTION 0x10000143
386     #define PSICONV_ID_WORD_STYLES_SECTION 0x10000104
387     #define PSICONV_ID_PAGE_LAYOUT_SECTION 0x10000105
388     #define PSICONV_ID_PASSWORD_SECTION 0x100000CD
389 frodo 24 #define PSICONV_ID_SKETCH_SECTION 0x1000007D
390 frodo 2
391     /* Other ids */
392     #define PSICONV_ID_PAGE_DIMENSIONS 0x100000fd
393     #define PSICONV_ID_TEXTED_BODY 0x1000005c
394     #define PSICONV_ID_TEXTED_REPLACEMENT 0x10000063
395     #define PSICONV_ID_TEXTED_UNKNOWN 0x10000065
396     #define PSICONV_ID_TEXTED_LAYOUT 0x10000066
397     #define PSICONV_ID_TEXTED_TEXT 0x10000064
398     #define PSICONV_ID_STYLE_REMOVABLE 0x1000004F
399     #define PSICONV_ID_STYLE_BUILT_IN 0x1000004C
400    
401    
402     /* Return a clean layout_status. You can modify it at will */
403     extern psiconv_character_layout psiconv_basic_character_layout(void);
404    
405     /* Return a clean layout_status. You can modify it at will */
406     extern psiconv_paragraph_layout psiconv_basic_paragraph_layout(void);
407    
408     /* Clone a layout_status: the new copy is completely independent of the
409     original one */
410     extern psiconv_paragraph_layout psiconv_clone_paragraph_layout
411     (psiconv_paragraph_layout ls);
412    
413     extern psiconv_character_layout psiconv_clone_character_layout
414     (psiconv_character_layout ls);
415    
416     /* Get a numbered style */
417     extern psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr);
418    
419     extern void psiconv_free_color(psiconv_color color);
420     extern void psiconv_free_border(psiconv_border border);
421     extern void psiconv_free_bullet(psiconv_bullet bullet);
422     extern void psiconv_free_font(psiconv_font font);
423     extern void psiconv_free_tab(psiconv_tab tab);
424     extern void psiconv_free_tabs(psiconv_all_tabs tabs);
425     extern void psiconv_free_paragraph_layout(psiconv_paragraph_layout layout);
426     extern void psiconv_free_character_layout(psiconv_character_layout layout);
427     extern void psiconv_free_word_style(psiconv_word_style style);
428     extern void psiconv_free_word_styles_section
429     (psiconv_word_styles_section styles);
430     extern void psiconv_free_header_section(psiconv_header_section header);
431     extern void psiconv_free_section_table_entry(psiconv_section_table_entry entry);
432     extern void psiconv_free_section_table_section
433     (psiconv_section_table_section section);
434     extern void psiconv_free_application_id_section
435     (psiconv_application_id_section section);
436     extern void psiconv_free_in_line_layout(psiconv_in_line_layout layout);
437     extern void psiconv_free_in_line_layouts(psiconv_in_line_layouts layouts);
438     extern void psiconv_free_replacement(psiconv_replacement replacement);
439     extern void psiconv_free_replacements(psiconv_replacements replacements);
440     extern void psiconv_free_paragraph(psiconv_paragraph paragraph);
441     extern void psiconv_free_text_and_layout(psiconv_text_and_layout text);
442     extern void psiconv_free_texted_section(psiconv_texted_section section);
443     extern void psiconv_free_page_header(psiconv_page_header header);
444     extern void psiconv_free_page_layout_section
445     (psiconv_page_layout_section section);
446     extern void psiconv_free_word_status_section
447     (psiconv_word_status_section section);
448     extern void psiconv_free_word_f(psiconv_word_f file);
449 frodo 12 extern void psiconv_free_texted_f(psiconv_texted_f file);
450     extern void psiconv_free_paint_data_section(psiconv_paint_data_section section);
451     extern void psiconv_free_pictures(psiconv_pictures section);
452     extern void psiconv_free_mbm_jumptable_section
453     (psiconv_mbm_jumptable_section section);
454     extern void psiconv_free_mbm_f(psiconv_mbm_f file);
455 frodo 24 extern void psiconv_free_sketch_section(psiconv_sketch_section sec);
456     extern void psiconv_free_sketch_f(psiconv_sketch_f file);
457    
458 frodo 2 extern void psiconv_free_file(psiconv_file file);
459    
460    
461     #endif /* def PSICONV_DATA_H */

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