--- psiconv/trunk/lib/psiconv/data.h 1999/10/11 16:15:14 12 +++ psiconv/trunk/lib/psiconv/data.h 2001/01/31 00:35:06 102 @@ -1,6 +1,6 @@ /* data.h - Part of psiconv, a PSION 5 file formats converter - Copyright (c) 1999 Frodo Looijaard + Copyright (c) 1999, 2000 Frodo Looijaard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,18 +24,26 @@ #ifndef PSICONV_DATA_H #define PSICONV_DATA_H -#include "general.h" -#include "list.h" +#include +#include /* All types which end on _t are plain types; all other types are pointers to structs */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef double psiconv_float_t; + typedef enum psiconv_file_type { psiconv_unknown_file, psiconv_word_file, psiconv_texted_file, psiconv_mbm_file, - psiconv_sketch_file + psiconv_sketch_file, + psiconv_clipart_file, + psiconv_sheet_file } psiconv_file_type_t; /* Length indicators */ @@ -57,6 +65,13 @@ psiconv_bool_true } psiconv_bool_t; +typedef enum psiconv_triple +{ + psiconv_triple_on, + psiconv_triple_off, + psiconv_triple_auto +} psiconv_triple_t; + typedef enum psiconv_super_sub { psiconv_normalscript, psiconv_superscript, @@ -81,35 +96,43 @@ psiconv_border_solid, psiconv_border_double, psiconv_border_dotted, - psiconv_border_striped, - psiconv_border_dotstripe, - psiconv_border_dotdotstripe + psiconv_border_dashed, + psiconv_border_dotdashed, + psiconv_border_dotdotdashed } psiconv_border_kind_t; +typedef enum psiconv_screenfont +{ + psiconv_font_misc, + psiconv_font_sansserif, + psiconv_font_nonprop, + psiconv_font_serif +} psiconv_screenfont_t; + /* Colors. black: 0x00 0x00 0x00 white: 0xff 0xff 0xff */ -typedef struct psiconv_color +typedef struct psiconv_color_s { psiconv_u8 red; psiconv_u8 green; psiconv_u8 blue; } * psiconv_color; -typedef struct psiconv_font +typedef struct psiconv_font_s { char *name; - psiconv_u8 screenfont; + psiconv_screenfont_t screenfont; } *psiconv_font; -typedef struct psiconv_border +typedef struct psiconv_border_s { psiconv_border_kind_t kind; psiconv_size_t thickness; /* Set to 1/20 for non-solid lines */ psiconv_color color; } *psiconv_border; -typedef struct psiconv_bullet +typedef struct psiconv_bullet_s { psiconv_bool_t on; psiconv_size_t font_size; @@ -126,7 +149,7 @@ psiconv_tab_right } psiconv_tab_kind_t; -typedef struct psiconv_tab +typedef struct psiconv_tab_s { psiconv_length_t location; psiconv_tab_kind_t kind; @@ -135,13 +158,13 @@ typedef psiconv_list psiconv_tab_list; /* of struct psiconv_tab */ -typedef struct psiconv_all_tabs +typedef struct psiconv_all_tabs_s { psiconv_length_t normal; psiconv_tab_list extras; } *psiconv_all_tabs; -typedef struct psiconv_character_layout +typedef struct psiconv_character_layout_s { psiconv_color color; psiconv_color back_color; @@ -150,11 +173,11 @@ psiconv_bool_t bold; psiconv_super_sub_t super_sub; psiconv_bool_t underline; - psiconv_bool_t strike_out; + psiconv_bool_t strikethrough; psiconv_font font; } *psiconv_character_layout; -typedef struct psiconv_paragraph_layout +typedef struct psiconv_paragraph_layout_s { psiconv_color back_color; psiconv_length_t indent_left; @@ -162,12 +185,12 @@ psiconv_length_t indent_first; psiconv_justify_hor_t justify_hor; psiconv_justify_ver_t justify_ver; - psiconv_size_t interline; - psiconv_bool_t interline_exact; - psiconv_size_t top_space; - psiconv_size_t bottom_space; - psiconv_bool_t on_one_page; - psiconv_bool_t together_with; /* What the heck is this? */ + psiconv_size_t linespacing; + psiconv_bool_t linespacing_exact; + psiconv_size_t space_above; + psiconv_size_t space_below; + psiconv_bool_t keep_together; + psiconv_bool_t keep_with_next; psiconv_bool_t on_next_page; psiconv_bool_t no_widow_protection; psiconv_length_t border_distance; @@ -179,17 +202,16 @@ psiconv_all_tabs tabs; } *psiconv_paragraph_layout; -typedef struct psiconv_header_section +typedef struct psiconv_header_section_s { psiconv_u32 uid1; psiconv_u32 uid2; psiconv_u32 uid3; psiconv_u32 checksum; - psiconv_u32 section_table_offset; psiconv_file_type_t file; } *psiconv_header_section; -typedef struct psiconv_section_table_entry +typedef struct psiconv_section_table_entry_s { psiconv_u32 id; psiconv_u32 offset; @@ -198,13 +220,13 @@ typedef psiconv_list psiconv_section_table_section; /* Of struct sectiontable_entry */ -typedef struct psiconv_application_id_section +typedef struct psiconv_application_id_section_s { psiconv_u32 id; psiconv_string_t name; } *psiconv_application_id_section; -typedef struct psiconv_in_line_layout +typedef struct psiconv_in_line_layout_s { psiconv_character_layout layout; int length; @@ -221,7 +243,7 @@ psiconv_replace_filename } psiconv_replacement_type_t; -typedef struct psiconv_replacement +typedef struct psiconv_replacement_s { int offset; int cur_len; @@ -230,7 +252,7 @@ typedef psiconv_list psiconv_replacements; /* of struct replacement */ -typedef struct psiconv_paragraph +typedef struct psiconv_paragraph_s { char *text; psiconv_character_layout base_character; @@ -242,12 +264,12 @@ typedef psiconv_list psiconv_text_and_layout; /* Of struct paragraphs */ -typedef struct psiconv_texted_section +typedef struct psiconv_texted_section_s { psiconv_text_and_layout paragraphs; } *psiconv_texted_section; -typedef struct psiconv_page_header +typedef struct psiconv_page_header_s { psiconv_bool_t on_first_page; psiconv_paragraph_layout base_paragraph_layout; @@ -255,7 +277,7 @@ psiconv_texted_section text; } *psiconv_page_header; -typedef struct psiconv_page_layout_section +typedef struct psiconv_page_layout_section_s { psiconv_u32 first_page_nr; psiconv_length_t header_dist; @@ -268,9 +290,10 @@ psiconv_length_t page_height; psiconv_page_header header; psiconv_page_header footer; + psiconv_bool_t landscape; } * psiconv_page_layout_section; -typedef struct psiconv_word_status_section +typedef struct psiconv_word_status_section_s { psiconv_bool_t show_tabs; psiconv_bool_t show_spaces; @@ -287,42 +310,48 @@ psiconv_u32 display_size; } *psiconv_word_status_section; -typedef struct psiconv_word_style +typedef struct psiconv_word_style_s { psiconv_character_layout character; psiconv_paragraph_layout paragraph; psiconv_u8 hotkey; psiconv_string_t name; psiconv_bool_t built_in; + psiconv_u32 outline_level; } *psiconv_word_style; typedef psiconv_list psiconv_word_style_list; /* Of style */ -typedef struct psiconv_word_styles_section +typedef struct psiconv_word_styles_section_s { psiconv_word_style normal; psiconv_word_style_list styles; } *psiconv_word_styles_section; -typedef struct psiconv_word_f { +typedef struct psiconv_word_f_s +{ psiconv_page_layout_section page_sec; psiconv_text_and_layout paragraphs; psiconv_word_status_section status_sec; psiconv_word_styles_section styles_sec; } *psiconv_word_f; -typedef struct psiconv_texted_f { +typedef struct psiconv_texted_f_s +{ psiconv_page_layout_section page_sec; psiconv_texted_section texted_sec; } *psiconv_texted_f; -typedef psiconv_list psiconv_mbm_jumptable_section; /* of psiconv_u32 */ +typedef psiconv_list psiconv_jumptable_section; /* of psiconv_u32 */ /* Normalized values [0..1] for each component Origin is (x,y)=(0,0), to get pixel at (X,Y) use index [Y*xsize+X] */ -typedef struct psiconv_paint_data_section { +typedef struct psiconv_paint_data_section_s +{ psiconv_u32 xsize; psiconv_u32 ysize; + psiconv_length_t pic_xsize; /* 0 if not specified */ + psiconv_length_t pic_ysize; /* 0 if not specified */ float *red; float *green; float *blue; @@ -331,11 +360,249 @@ typedef psiconv_list psiconv_pictures; /* of struct psiconv_paint_data_section */ -typedef struct psiconv_mbm_f { +typedef struct psiconv_mbm_f_s +{ psiconv_pictures sections; } *psiconv_mbm_f; -typedef struct psiconv_file { +/* This is a little intricated. A picture may be embedded in a larger form. + A form is empty, except for the picture. The form has size form_{x,y}size, + and the picture is at offset picture_{x,y}_offset within the form. The + picture itself has size picture_{x,y}size. + Cuts are always <= 1.0; a cut of 0.0 cuts nothing away, a cut of 1.0 + cuts everything away. */ +typedef struct psiconv_sketch_section_s +{ + psiconv_u16 form_xsize; + psiconv_u16 form_ysize; + psiconv_u16 picture_x_offset; + psiconv_u16 picture_y_offset; + psiconv_u16 picture_xsize; + psiconv_u16 picture_ysize; + float magnification_x; /* computed relative to first six values */ + float magnification_y; /* computed relative to first six values */ + float cut_left; /* computed relative to first six values */ + float cut_right; /* computed relative to first six values */ + float cut_top; /* computed relative to first six values */ + float cut_bottom; /* computed relative to first six values */ + psiconv_paint_data_section picture; +} *psiconv_sketch_section; + +typedef struct psiconv_sketch_f_s +{ + psiconv_sketch_section sketch_sec; +} *psiconv_sketch_f; + +typedef struct psiconv_clipart_section_s +{ + /* Perhaps later on some currently unknown stuff. */ + psiconv_paint_data_section picture; +} * psiconv_clipart_section; + +typedef psiconv_list psiconv_cliparts; /* of struct psiconv_clipart_section */ + +typedef struct psiconv_clipart_f_s +{ + psiconv_cliparts sections; +} *psiconv_clipart_f; + +typedef struct psiconv_sheet_ref_s +{ + psiconv_s16 offset; + psiconv_bool_t absolute; +} psiconv_sheet_ref_t; + +typedef struct psiconv_sheet_cell_reference_s +{ + psiconv_sheet_ref_t row; + psiconv_sheet_ref_t column; +} psiconv_sheet_cell_reference_t; + +typedef struct psiconv_sheet_cell_block_s +{ + psiconv_sheet_cell_reference_t first; + psiconv_sheet_cell_reference_t last; +} psiconv_sheet_cell_block_t; + +typedef struct psiconv_sheet_status_section_s +{ + psiconv_bool_t show_graph; + psiconv_u32 cursor_row; + psiconv_u32 cursor_column; + psiconv_bool_t show_top_sheet_toolbar; + psiconv_bool_t show_side_sheet_toolbar; + psiconv_bool_t show_top_graph_toolbar; + psiconv_bool_t show_side_graph_toolbar; + psiconv_u32 sheet_display_size; + psiconv_u32 graph_display_size; + psiconv_triple_t show_horizontal_scrollbar; + psiconv_triple_t show_vertical_scrollbar; +} *psiconv_sheet_status_section; + +typedef enum psiconv_formula_type +{ + psiconv_formula_unknown, + psiconv_formula_op_lt, + psiconv_formula_op_le, + psiconv_formula_op_gt, + psiconv_formula_op_ge, + psiconv_formula_op_ne, + psiconv_formula_op_eq, + psiconv_formula_op_add, + psiconv_formula_op_sub, + psiconv_formula_op_mul, + psiconv_formula_op_div, + psiconv_formula_op_pow, + psiconv_formula_op_pos, + psiconv_formula_op_neg, + psiconv_formula_op_con, + psiconv_formula_op_bra, + psiconv_formula_mark_eof, + psiconv_formula_dat_float, + psiconv_formula_dat_int, + psiconv_formula_dat_var, + psiconv_formula_dat_string, + psiconv_formula_dat_cellref, + psiconv_formula_dat_cellblock, + psiconv_formula_dat_vcellblock, + psiconv_formula_mark_opsep, + psiconv_formula_mark_opend, + psiconv_formula_fun_false, + psiconv_formula_fun_if, + psiconv_formula_fun_true, + psiconv_formula_fun_cell, + psiconv_formula_fun_errortype, + psiconv_formula_fun_isblank, + psiconv_formula_fun_iserr, + psiconv_formula_fun_iserror, + psiconv_formula_fun_islogical, + psiconv_formula_fun_isna, + psiconv_formula_fun_isnontext, + psiconv_formula_fun_isnumber, + psiconv_formula_fun_istext, + psiconv_formula_fun_n, + psiconv_formula_fun_type, + psiconv_formula_fun_address, + psiconv_formula_fun_column, + psiconv_formula_fun_columns, + psiconv_formula_fun_hlookup, + psiconv_formula_fun_index, + psiconv_formula_fun_indirect, + psiconv_formula_fun_lookup, + psiconv_formula_fun_offset, + psiconv_formula_fun_row, + psiconv_formula_fun_rows, + psiconv_formula_fun_vlookup, + psiconv_formula_fun_char, + psiconv_formula_fun_code, + psiconv_formula_fun_exact, + psiconv_formula_fun_find, + psiconv_formula_fun_left, + psiconv_formula_fun_len, + psiconv_formula_fun_lower, + psiconv_formula_fun_mid, + psiconv_formula_fun_proper, + psiconv_formula_fun_replace, + psiconv_formula_fun_rept, + psiconv_formula_fun_right, + psiconv_formula_fun_string, + psiconv_formula_fun_t, + psiconv_formula_fun_trim, + psiconv_formula_fun_upper, + psiconv_formula_fun_value, + psiconv_formula_fun_date, + psiconv_formula_fun_datevalue, + psiconv_formula_fun_day, + psiconv_formula_fun_hour, + psiconv_formula_fun_minute, + psiconv_formula_fun_month, + psiconv_formula_fun_now, + psiconv_formula_fun_second, + psiconv_formula_fun_today, + psiconv_formula_fun_time, + psiconv_formula_fun_timevalue, + psiconv_formula_fun_year, + psiconv_formula_fun_abs, + psiconv_formula_fun_acos, + psiconv_formula_fun_asin, + psiconv_formula_fun_atan, + psiconv_formula_fun_atan2, + psiconv_formula_fun_cos, + psiconv_formula_fun_degrees, + psiconv_formula_fun_exp, + psiconv_formula_fun_fact, + psiconv_formula_fun_int, + psiconv_formula_fun_ln, + psiconv_formula_fun_log10, + psiconv_formula_fun_mod, + psiconv_formula_fun_pi, + psiconv_formula_fun_radians, + psiconv_formula_fun_rand, + psiconv_formula_fun_round, + psiconv_formula_fun_sign, + psiconv_formula_fun_sin, + psiconv_formula_fun_sqrt, + psiconv_formula_fun_sumproduct, + psiconv_formula_fun_tan, + psiconv_formula_fun_trunc, + psiconv_formula_fun_cterm, + psiconv_formula_fun_ddb, + psiconv_formula_fun_fv, + psiconv_formula_fun_irr, + psiconv_formula_fun_npv, + psiconv_formula_fun_pmt, + psiconv_formula_fun_pv, + psiconv_formula_fun_rate, + psiconv_formula_fun_sln, + psiconv_formula_fun_syd, + psiconv_formula_fun_term, + psiconv_formula_fun_combin, + psiconv_formula_fun_permut, + psiconv_formula_vfn_average, + psiconv_formula_vfn_choose, + psiconv_formula_vfn_count, + psiconv_formula_vfn_counta, + psiconv_formula_vfn_countblank, + psiconv_formula_vfn_max, + psiconv_formula_vfn_min, + psiconv_formula_vfn_product, + psiconv_formula_vfn_stdevp, + psiconv_formula_vfn_stdev, + psiconv_formula_vfn_sum, + psiconv_formula_vfn_sumsq, + psiconv_formula_vfn_varp, + psiconv_formula_vfn_var +} psiconv_formula_type_t; + +typedef psiconv_list psiconv_formula_list; /* Of struct psiconv_formula_s */ + +typedef struct psiconv_formula_s +{ + psiconv_formula_type_t type; + union { + psiconv_u32 dat_int; + double dat_float; + char *dat_string; + psiconv_sheet_cell_reference_t dat_cellref; + psiconv_sheet_cell_block_t dat_cellblock; + psiconv_formula_list fun_operands; + } data; +} *psiconv_formula; + +typedef struct psiconv_sheet_workbook_section_s +{ + psiconv_formula_list formulas; +} *psiconv_sheet_workbook_section; + +typedef struct psiconv_sheet_f_s +{ + psiconv_page_layout_section page_sec; + psiconv_sheet_status_section status_sec; + psiconv_sheet_workbook_section workbook_sec; +} *psiconv_sheet_f; + +typedef struct psiconv_file_s +{ psiconv_file_type_t type; void *file; } *psiconv_file; @@ -343,12 +610,15 @@ /* UID1 */ #define PSICONV_ID_PSION5 0x10000037 +#define PSICONV_ID_CLIPART 0x10000041 /* UID2 */ #define PSICONV_ID_DATA_FILE 0x1000006D #define PSICONV_ID_MBM_FILE 0x10000042 /* UID3 */ #define PSICONV_ID_WORD 0x1000007F #define PSICONV_ID_TEXTED 0x10000085 +#define PSICONV_ID_SKETCH 0x1000007D +#define PSICONV_ID_SHEET 0x10000088 /* Section table ids */ #define PSICONV_ID_WORD_STATUS_SECTION 0x10000243 @@ -358,9 +628,13 @@ #define PSICONV_ID_WORD_STYLES_SECTION 0x10000104 #define PSICONV_ID_PAGE_LAYOUT_SECTION 0x10000105 #define PSICONV_ID_PASSWORD_SECTION 0x100000CD +#define PSICONV_ID_SKETCH_SECTION 0x1000007D +#define PSICONV_ID_SHEET_STATUS_SECTION 0x1000011F +#define PSICONV_ID_SHEET_WORKBOOK_SECTION 0x1000011D /* Other ids */ -#define PSICONV_ID_PAGE_DIMENSIONS 0x100000fd +#define PSICONV_ID_PAGE_DIMENSIONS1 0x100000fd +#define PSICONV_ID_PAGE_DIMENSIONS2 0x1000010e #define PSICONV_ID_TEXTED_BODY 0x1000005c #define PSICONV_ID_TEXTED_REPLACEMENT 0x10000063 #define PSICONV_ID_TEXTED_UNKNOWN 0x10000065 @@ -368,23 +642,26 @@ #define PSICONV_ID_TEXTED_TEXT 0x10000064 #define PSICONV_ID_STYLE_REMOVABLE 0x1000004F #define PSICONV_ID_STYLE_BUILT_IN 0x1000004C +#define PSICONV_ID_CLIPART_ITEM 0x10000040 -/* Return a clean layout_status. You can modify it at will */ +/* Return a clean layout_status. You can modify it at will. Returns NULL + if there is not enough memory. */ extern psiconv_character_layout psiconv_basic_character_layout(void); -/* Return a clean layout_status. You can modify it at will */ +/* Return a clean layout_status. You can modify it at will. Returns NULL + if there is not enough memory. */ extern psiconv_paragraph_layout psiconv_basic_paragraph_layout(void); /* Clone a layout_status: the new copy is completely independent of the - original one */ + original one. Returns NULL if there is not enough memory. */ extern psiconv_paragraph_layout psiconv_clone_paragraph_layout (psiconv_paragraph_layout ls); extern psiconv_character_layout psiconv_clone_character_layout (psiconv_character_layout ls); -/* Get a numbered style */ +/* Get a numbered style. Returns NULL if the style is unknown. */ extern psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr); extern void psiconv_free_color(psiconv_color color); @@ -398,6 +675,11 @@ extern void psiconv_free_word_style(psiconv_word_style style); extern void psiconv_free_word_styles_section (psiconv_word_styles_section styles); +extern void psiconv_free_formula(psiconv_formula formula); +extern void psiconv_free_formula_list(psiconv_formula_list list); +extern void psiconv_free_sheet_status_section + (psiconv_sheet_status_section section); +extern void psiconv_free_sheet_f(psiconv_sheet_f file); extern void psiconv_free_header_section(psiconv_header_section header); extern void psiconv_free_section_table_entry(psiconv_section_table_entry entry); extern void psiconv_free_section_table_section @@ -420,10 +702,43 @@ extern void psiconv_free_texted_f(psiconv_texted_f file); extern void psiconv_free_paint_data_section(psiconv_paint_data_section section); extern void psiconv_free_pictures(psiconv_pictures section); -extern void psiconv_free_mbm_jumptable_section - (psiconv_mbm_jumptable_section section); +extern void psiconv_free_jumptable_section + (psiconv_jumptable_section section); extern void psiconv_free_mbm_f(psiconv_mbm_f file); +extern void psiconv_free_sketch_section(psiconv_sketch_section sec); +extern void psiconv_free_sketch_f(psiconv_sketch_f file); +extern void psiconv_free_clipart_section(psiconv_clipart_section section); +extern void psiconv_free_cliparts(psiconv_cliparts section); +extern void psiconv_free_clipart_f(psiconv_clipart_f file); + extern void psiconv_free_file(psiconv_file file); +extern int psiconv_compare_color(const psiconv_color value1, + const psiconv_color value2); +extern int psiconv_compare_font(const psiconv_font value1, + const psiconv_font value2); +extern int psiconv_compare_border(const psiconv_border value1, + const psiconv_border value2); +extern int psiconv_compare_bullet(const psiconv_bullet value1, + const psiconv_bullet value2); +extern int psiconv_compare_tab(const psiconv_tab value1, + const psiconv_tab value2); +extern int psiconv_compare_all_tabs(const psiconv_all_tabs value1, + const psiconv_all_tabs value2); +extern int psiconv_compare_paragraph_layout + (const psiconv_paragraph_layout value1, + const psiconv_paragraph_layout value2); + +extern int psiconv_compare_character_layout + (const psiconv_character_layout value1, + const psiconv_character_layout value2); + +/* Get a newly allocated file with sensible defaults, ready to generate. */ +extern psiconv_file psiconv_empty_file(psiconv_file_type_t type); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* def PSICONV_DATA_H */