/[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 18 - (hide annotations)
Wed Oct 27 13:09:40 1999 UTC (20 years, 7 months ago) by frodo
File MIME type: text/plain
File size: 12788 byte(s)
(Frodo) Several changes in header parsing

The definition of header section is changed to exclude the long with the
offset of the Section Table Section. This allows easier integration of
Data-like file formats.

psiconv_parse_{texted,word,mbm}_file now do not parse the header section.
This will allow easier integration for objects-within-objects. They start
at the long with the offset of the Section Table Section.

psiconv_file_type now returns the read header section, and its length.

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     float *red;
326     float *green;
327     float *blue;
328     } *psiconv_paint_data_section;
329    
330 frodo 12 typedef psiconv_list psiconv_pictures;
331     /* of struct psiconv_paint_data_section */
332    
333     typedef struct psiconv_mbm_f {
334     psiconv_pictures sections;
335     } *psiconv_mbm_f;
336    
337 frodo 2 typedef struct psiconv_file {
338     psiconv_file_type_t type;
339     void *file;
340     } *psiconv_file;
341    
342    
343     /* UID1 */
344     #define PSICONV_ID_PSION5 0x10000037
345     /* UID2 */
346     #define PSICONV_ID_DATA_FILE 0x1000006D
347 frodo 12 #define PSICONV_ID_MBM_FILE 0x10000042
348 frodo 2 /* UID3 */
349     #define PSICONV_ID_WORD 0x1000007F
350     #define PSICONV_ID_TEXTED 0x10000085
351    
352     /* Section table ids */
353     #define PSICONV_ID_WORD_STATUS_SECTION 0x10000243
354     #define PSICONV_ID_APPL_ID_SECTION 0x10000089
355     #define PSICONV_ID_TEXT_SECTION 0x10000106
356     #define PSICONV_ID_LAYOUT_SECTION 0x10000143
357     #define PSICONV_ID_WORD_STYLES_SECTION 0x10000104
358     #define PSICONV_ID_PAGE_LAYOUT_SECTION 0x10000105
359     #define PSICONV_ID_PASSWORD_SECTION 0x100000CD
360    
361     /* Other ids */
362     #define PSICONV_ID_PAGE_DIMENSIONS 0x100000fd
363     #define PSICONV_ID_TEXTED_BODY 0x1000005c
364     #define PSICONV_ID_TEXTED_REPLACEMENT 0x10000063
365     #define PSICONV_ID_TEXTED_UNKNOWN 0x10000065
366     #define PSICONV_ID_TEXTED_LAYOUT 0x10000066
367     #define PSICONV_ID_TEXTED_TEXT 0x10000064
368     #define PSICONV_ID_STYLE_REMOVABLE 0x1000004F
369     #define PSICONV_ID_STYLE_BUILT_IN 0x1000004C
370    
371    
372     /* Return a clean layout_status. You can modify it at will */
373     extern psiconv_character_layout psiconv_basic_character_layout(void);
374    
375     /* Return a clean layout_status. You can modify it at will */
376     extern psiconv_paragraph_layout psiconv_basic_paragraph_layout(void);
377    
378     /* Clone a layout_status: the new copy is completely independent of the
379     original one */
380     extern psiconv_paragraph_layout psiconv_clone_paragraph_layout
381     (psiconv_paragraph_layout ls);
382    
383     extern psiconv_character_layout psiconv_clone_character_layout
384     (psiconv_character_layout ls);
385    
386     /* Get a numbered style */
387     extern psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr);
388    
389     extern void psiconv_free_color(psiconv_color color);
390     extern void psiconv_free_border(psiconv_border border);
391     extern void psiconv_free_bullet(psiconv_bullet bullet);
392     extern void psiconv_free_font(psiconv_font font);
393     extern void psiconv_free_tab(psiconv_tab tab);
394     extern void psiconv_free_tabs(psiconv_all_tabs tabs);
395     extern void psiconv_free_paragraph_layout(psiconv_paragraph_layout layout);
396     extern void psiconv_free_character_layout(psiconv_character_layout layout);
397     extern void psiconv_free_word_style(psiconv_word_style style);
398     extern void psiconv_free_word_styles_section
399     (psiconv_word_styles_section styles);
400     extern void psiconv_free_header_section(psiconv_header_section header);
401     extern void psiconv_free_section_table_entry(psiconv_section_table_entry entry);
402     extern void psiconv_free_section_table_section
403     (psiconv_section_table_section section);
404     extern void psiconv_free_application_id_section
405     (psiconv_application_id_section section);
406     extern void psiconv_free_in_line_layout(psiconv_in_line_layout layout);
407     extern void psiconv_free_in_line_layouts(psiconv_in_line_layouts layouts);
408     extern void psiconv_free_replacement(psiconv_replacement replacement);
409     extern void psiconv_free_replacements(psiconv_replacements replacements);
410     extern void psiconv_free_paragraph(psiconv_paragraph paragraph);
411     extern void psiconv_free_text_and_layout(psiconv_text_and_layout text);
412     extern void psiconv_free_texted_section(psiconv_texted_section section);
413     extern void psiconv_free_page_header(psiconv_page_header header);
414     extern void psiconv_free_page_layout_section
415     (psiconv_page_layout_section section);
416     extern void psiconv_free_word_status_section
417     (psiconv_word_status_section section);
418     extern void psiconv_free_word_f(psiconv_word_f file);
419 frodo 12 extern void psiconv_free_texted_f(psiconv_texted_f file);
420     extern void psiconv_free_paint_data_section(psiconv_paint_data_section section);
421     extern void psiconv_free_pictures(psiconv_pictures section);
422     extern void psiconv_free_mbm_jumptable_section
423     (psiconv_mbm_jumptable_section section);
424     extern void psiconv_free_mbm_f(psiconv_mbm_f file);
425 frodo 2 extern void psiconv_free_file(psiconv_file file);
426    
427    
428     #endif /* def PSICONV_DATA_H */

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