--- psiconv/trunk/lib/psiconv/data.c 2000/12/30 22:17:59 87 +++ psiconv/trunk/lib/psiconv/data.c 2001/01/22 20:36:50 97 @@ -42,6 +42,11 @@ static psiconv_page_layout_section psiconv_empty_page_layout_section(void); static psiconv_word_status_section psiconv_empty_word_status_section(void); static psiconv_word_f psiconv_empty_word_f(void); +static psiconv_sheet_status_section psiconv_empty_sheet_status_section(void); +static psiconv_sheet_formula_list psiconv_empty_sheet_formula_list(void); +static psiconv_sheet_workbook_section + psiconv_empty_sheet_workbook_section(void); +static psiconv_sheet_f psiconv_empty_sheet_f(void); static psiconv_texted_f psiconv_empty_texted_f(void); static psiconv_paint_data_section psiconv_empty_paint_data_section(void); static psiconv_pictures psiconv_empty_pictures(void); @@ -536,6 +541,42 @@ } } +void psiconv_free_sheet_status_section(psiconv_sheet_status_section section) +{ + if (section) + free(section); +} + +void psiconv_free_sheet_formula(psiconv_sheet_formula formula) +{ + if (formula) + free(formula); +} + +void psiconv_free_sheet_formula_list(psiconv_sheet_formula_list list) +{ + if (list) + psiconv_list_free(list); +} + +void psiconv_free_sheet_workbook_section(psiconv_sheet_workbook_section section) +{ + if (section) { + psiconv_free_sheet_formula_list(section->formulas); + free(section); + } +} + +void psiconv_free_sheet_f(psiconv_sheet_f file) +{ + if (file) { + psiconv_free_page_layout_section(file->page_sec); + psiconv_free_sheet_status_section(file->status_sec); + psiconv_free_sheet_workbook_section(file->workbook_sec); + free(file); + } +} + void psiconv_free_texted_f(psiconv_texted_f file) { if (file) { @@ -640,6 +681,8 @@ psiconv_free_sketch_f((psiconv_sketch_f) file->file); else if (file->type == psiconv_clipart_file) psiconv_free_clipart_f((psiconv_clipart_f) file->file); + else if (file->type == psiconv_sheet_file) + psiconv_free_sheet_f((psiconv_sheet_f) file->file); free(file); } } @@ -858,7 +901,7 @@ psiconv_page_layout_section result; if (!(result = malloc(sizeof(*result)))) goto ERROR1; - result->first_page_nr = 0; + result->first_page_nr = 1; result->header_dist = result->footer_dist = 1.27; result->left_margin = result->right_margin = 3.175; result->top_margin = result->bottom_margin = 2.54; @@ -920,6 +963,64 @@ return NULL; } +psiconv_sheet_status_section psiconv_empty_sheet_status_section(void) +{ + psiconv_sheet_status_section result; + if (!(result = malloc(sizeof(*result)))) + return NULL; + result->show_horizontal_scrollbar = result->show_vertical_scrollbar = + psiconv_triple_auto; + result->show_graph = psiconv_bool_false; + result->show_top_sheet_toolbar = result->show_side_sheet_toolbar = + result->show_top_graph_toolbar = result->show_side_graph_toolbar = + psiconv_bool_true; + result->cursor_row = result->cursor_column = 0; + result->sheet_display_size = result->graph_display_size = 1000; + return result; +} + +psiconv_sheet_formula_list psiconv_empty_sheet_formula_list(void) +{ + return psiconv_list_new(sizeof(struct psiconv_sheet_formula_s)); +} + +psiconv_sheet_workbook_section psiconv_empty_sheet_workbook_section(void) +{ + psiconv_sheet_workbook_section result; + if (!(result = malloc(sizeof(*result)))) + goto ERROR1; + if (!(result->formulas = psiconv_empty_sheet_formula_list())) + goto ERROR2; + return result; +ERROR2: + free(result); +ERROR1: + return NULL; +} + + +psiconv_sheet_f psiconv_empty_sheet_f(void) +{ + psiconv_sheet_f result; + if (!(result = malloc(sizeof(*result)))) + goto ERROR1; + if (!(result->page_sec = psiconv_empty_page_layout_section())) + goto ERROR2; + if (!(result->status_sec = psiconv_empty_sheet_status_section())) + goto ERROR3; + if (!(result->workbook_sec = psiconv_empty_sheet_workbook_section())) + goto ERROR4; + return result; +ERROR4: + psiconv_free_sheet_status_section(result->status_sec); +ERROR3: + psiconv_free_page_layout_section(result->page_sec); +ERROR2: + free(result); +ERROR1: + return NULL; +} + psiconv_texted_f psiconv_empty_texted_f(void) { psiconv_texted_f result; @@ -1062,6 +1163,9 @@ if (type == psiconv_word_file) { if (!(result->file = psiconv_empty_word_f())) goto ERROR; + } else if (type == psiconv_sheet_file) { + if (!(result->file = psiconv_empty_sheet_f())) + goto ERROR; } else if (type == psiconv_texted_file) { if (!(result->file = psiconv_empty_texted_f())) goto ERROR;