--- psiconv/trunk/lib/psiconv/data.c 2001/01/22 20:36:50 97 +++ psiconv/trunk/lib/psiconv/data.c 2001/03/06 23:59:46 111 @@ -34,6 +34,8 @@ static void psiconv_free_paragraph_aux(void * paragraph); static void psiconv_free_paint_data_section_aux(void * section); static void psiconv_free_clipart_section_aux(void * section); +static void psiconv_free_formula_aux(void *data); +static void psiconv_free_sheet_worksheet_aux (void *data); static psiconv_word_styles_section psiconv_empty_word_styles_section(void); static psiconv_text_and_layout psiconv_empty_text_and_layout(void); @@ -43,7 +45,7 @@ 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_formula_list psiconv_empty_formula_list(void); static psiconv_sheet_workbook_section psiconv_empty_sheet_workbook_section(void); static psiconv_sheet_f psiconv_empty_sheet_f(void); @@ -152,6 +154,7 @@ psiconv_bool_false, /* keep_with_next */ psiconv_bool_false, /* on_next_page */ psiconv_bool_false, /* no_widow_protection */ + psiconv_bool_false, /* wrap_to_fit_cell */ 0.0, /* left_margin */ &bullet, /* bullet */ &no_border, /* left_border */ @@ -547,22 +550,102 @@ free(section); } -void psiconv_free_sheet_formula(psiconv_sheet_formula formula) +void psiconv_free_sheet_numberformat(psiconv_sheet_numberformat numberformat) { - if (formula) + if (numberformat) + free(numberformat); +} + +void psiconv_free_sheet_cell_layout(psiconv_sheet_cell_layout layout) +{ + psiconv_free_paragraph_layout(layout->paragraph); + psiconv_free_character_layout(layout->character); + psiconv_free_sheet_numberformat(layout->numberformat); +} + +void psiconv_free_sheet_cell(psiconv_sheet_cell cell) +{ + if (cell) { + psiconv_free_sheet_cell_layout(cell->layout); + + if ((cell->type == psiconv_cell_string) && (cell->data.dat_string)) + free(cell->data.dat_string); + free(cell); + } +} + +void psiconv_free_sheet_cell_aux(void *data) +{ + psiconv_sheet_cell cell; + cell = data; + psiconv_free_sheet_cell(cell); +} + +void psiconv_free_sheet_cell_list(psiconv_sheet_cell_list list) +{ + if (list) + psiconv_list_free_el(list,psiconv_free_sheet_cell_aux); +} + +void psiconv_free_sheet_worksheet_aux (void *data) +{ + psiconv_sheet_worksheet section = data; + psiconv_free_sheet_cell_layout(section->default_layout); + psiconv_free_sheet_cell_list(section->cells); +} + +void psiconv_free_sheet_worksheet(psiconv_sheet_worksheet sheet) +{ + if (sheet) { + psiconv_free_sheet_worksheet_aux(sheet); + free(sheet); + } +} + +void psiconv_free_sheet_worksheet_list(psiconv_sheet_worksheet_list list) +{ + if (list) + psiconv_list_free_el(list,psiconv_free_sheet_worksheet_aux); +} + +void psiconv_free_formula_aux(void *data) +{ + psiconv_formula formula; + formula = data; + if (formula->type == psiconv_formula_dat_string) + free(formula->data.dat_string); + else if ((formula->type != psiconv_formula_dat_int) && + (formula->type != psiconv_formula_dat_var) && + (formula->type != psiconv_formula_dat_float) && + (formula->type != psiconv_formula_dat_cellref) && + (formula->type != psiconv_formula_dat_cellblock) && + (formula->type != psiconv_formula_dat_vcellblock) && + (formula->type != psiconv_formula_mark_opsep) && + (formula->type != psiconv_formula_mark_opend) && + (formula->type != psiconv_formula_mark_eof) && + (formula->type != psiconv_formula_unknown)) + psiconv_free_formula_list(formula->data.fun_operands); +} + +void psiconv_free_formula(psiconv_formula formula) +{ + if (formula) { + psiconv_free_formula_aux(formula); free(formula); + } } -void psiconv_free_sheet_formula_list(psiconv_sheet_formula_list list) +void psiconv_free_formula_list(psiconv_formula_list list) { - if (list) - psiconv_list_free(list); + if (list) + psiconv_list_free_el(list,psiconv_free_formula_aux); } void psiconv_free_sheet_workbook_section(psiconv_sheet_workbook_section section) { if (section) { - psiconv_free_sheet_formula_list(section->formulas); + psiconv_free_formula_list(section->formulas); + psiconv_free_sheet_worksheet_list(section->worksheets); free(section); } } @@ -979,9 +1062,9 @@ return result; } -psiconv_sheet_formula_list psiconv_empty_sheet_formula_list(void) +psiconv_formula_list psiconv_empty_formula_list(void) { - return psiconv_list_new(sizeof(struct psiconv_sheet_formula_s)); + return psiconv_list_new(sizeof(struct psiconv_formula_s)); } psiconv_sheet_workbook_section psiconv_empty_sheet_workbook_section(void) @@ -989,7 +1072,7 @@ psiconv_sheet_workbook_section result; if (!(result = malloc(sizeof(*result)))) goto ERROR1; - if (!(result->formulas = psiconv_empty_sheet_formula_list())) + if (!(result->formulas = psiconv_empty_formula_list())) goto ERROR2; return result; ERROR2: