--- psiconv/trunk/lib/psiconv/data.c 2001/03/06 23:59:46 111 +++ psiconv/trunk/lib/psiconv/data.c 2001/07/18 12:24:08 128 @@ -319,6 +319,34 @@ return psiconv_list_get(ss->styles,0xff - nr); } +psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr) +{ + return psiconv_list_get(ss,psiconv_list_length(ss)-nr-1); +} + +/* TODO: What if a cell is both in a default row and a default column?!? */ +psiconv_sheet_cell_layout psiconv_get_default_layout + (psiconv_sheet_line_list row_defaults, + psiconv_sheet_line_list col_defaults, + psiconv_sheet_cell_layout cell_default, + int row,int col) +{ + int i; + psiconv_sheet_line line; + for (i = 0;i < psiconv_list_length(row_defaults);i++) { + line = psiconv_list_get(row_defaults,i); + if (line->position == row) + return line->layout; + } + for (i = 0;i < psiconv_list_length(col_defaults);i++) { + line = psiconv_list_get(col_defaults,i); + if (line->position == col) + return line->layout; + } + return cell_default; +} + + void psiconv_free_color (psiconv_color color) { if (color) @@ -563,28 +591,49 @@ psiconv_free_sheet_numberformat(layout->numberformat); } +void psiconv_free_sheet_cell_aux(void *cell) +{ + psiconv_sheet_cell data = cell; + + psiconv_free_sheet_cell_layout(data->layout); + + if ((data->type == psiconv_cell_string) && (data->data.dat_string)) + free(data->data.dat_string); +} + 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); + psiconv_free_sheet_cell_aux(cell); free(cell); } } -void psiconv_free_sheet_cell_aux(void *data) +void psiconv_free_sheet_cell_list(psiconv_sheet_cell_list list) { - psiconv_sheet_cell cell; - cell = data; - psiconv_free_sheet_cell(cell); + if (list) + psiconv_list_free_el(list,psiconv_free_sheet_cell_aux); } -void psiconv_free_sheet_cell_list(psiconv_sheet_cell_list list) +void psiconv_free_sheet_line_aux(void *line) +{ + psiconv_sheet_line data = line; + + psiconv_free_sheet_cell_layout(data->layout); +} + +void psiconv_free_sheet_line(psiconv_sheet_line line) +{ + if (line) { + psiconv_free_sheet_line_aux(line); + free(line); + } +} + +void psiconv_free_sheet_line_list(psiconv_sheet_line_list list) { if (list) - psiconv_list_free_el(list,psiconv_free_sheet_cell_aux); + psiconv_list_free_el(list,psiconv_free_sheet_line_aux); } void psiconv_free_sheet_worksheet_aux (void *data) @@ -592,6 +641,8 @@ psiconv_sheet_worksheet section = data; psiconv_free_sheet_cell_layout(section->default_layout); psiconv_free_sheet_cell_list(section->cells); + psiconv_free_sheet_line_list(section->row_default_layouts); + psiconv_free_sheet_line_list(section->col_default_layouts); } void psiconv_free_sheet_worksheet(psiconv_sheet_worksheet sheet) @@ -645,7 +696,7 @@ { if (section) { psiconv_free_formula_list(section->formulas); - psiconv_free_sheet_worksheet_list(section->worksheets); + psiconv_free_sheet_worksheet_list(section->worksheets); free(section); } }