… | |
… | |
32 | static void psiconv_free_style_aux(void *style); |
32 | static void psiconv_free_style_aux(void *style); |
33 | static void psiconv_free_in_line_layout_aux(void * layout); |
33 | static void psiconv_free_in_line_layout_aux(void * layout); |
34 | static void psiconv_free_paragraph_aux(void * paragraph); |
34 | static void psiconv_free_paragraph_aux(void * paragraph); |
35 | static void psiconv_free_paint_data_section_aux(void * section); |
35 | static void psiconv_free_paint_data_section_aux(void * section); |
36 | static void psiconv_free_clipart_section_aux(void * section); |
36 | static void psiconv_free_clipart_section_aux(void * section); |
|
|
37 | static void psiconv_free_formula_aux(void *data); |
|
|
38 | static void psiconv_free_sheet_worksheet_aux (void *data); |
|
|
39 | static void psiconv_free_sheet_variable_aux(void * variable); |
37 | |
40 | |
38 | static psiconv_word_styles_section psiconv_empty_word_styles_section(void); |
41 | static psiconv_word_styles_section psiconv_empty_word_styles_section(void); |
39 | static psiconv_text_and_layout psiconv_empty_text_and_layout(void); |
42 | static psiconv_text_and_layout psiconv_empty_text_and_layout(void); |
40 | static psiconv_texted_section psiconv_empty_texted_section(void); |
43 | static psiconv_texted_section psiconv_empty_texted_section(void); |
41 | static psiconv_page_header psiconv_empty_page_header(void); |
44 | static psiconv_page_header psiconv_empty_page_header(void); |
42 | static psiconv_page_layout_section psiconv_empty_page_layout_section(void); |
45 | static psiconv_page_layout_section psiconv_empty_page_layout_section(void); |
43 | static psiconv_word_status_section psiconv_empty_word_status_section(void); |
46 | static psiconv_word_status_section psiconv_empty_word_status_section(void); |
44 | static psiconv_word_f psiconv_empty_word_f(void); |
47 | static psiconv_word_f psiconv_empty_word_f(void); |
|
|
48 | static psiconv_sheet_status_section psiconv_empty_sheet_status_section(void); |
|
|
49 | static psiconv_formula_list psiconv_empty_formula_list(void); |
|
|
50 | static psiconv_sheet_workbook_section |
|
|
51 | psiconv_empty_sheet_workbook_section(void); |
|
|
52 | static psiconv_sheet_f psiconv_empty_sheet_f(void); |
45 | static psiconv_texted_f psiconv_empty_texted_f(void); |
53 | static psiconv_texted_f psiconv_empty_texted_f(void); |
46 | static psiconv_paint_data_section psiconv_empty_paint_data_section(void); |
54 | static psiconv_paint_data_section psiconv_empty_paint_data_section(void); |
47 | static psiconv_pictures psiconv_empty_pictures(void); |
55 | static psiconv_pictures psiconv_empty_pictures(void); |
48 | static psiconv_mbm_f psiconv_empty_mbm_f(void); |
56 | static psiconv_mbm_f psiconv_empty_mbm_f(void); |
49 | static psiconv_sketch_section psiconv_empty_sketch_section(void); |
57 | static psiconv_sketch_section psiconv_empty_sketch_section(void); |
… | |
… | |
145 | 0.0, /* space_below */ |
153 | 0.0, /* space_below */ |
146 | psiconv_bool_false, /* keep_together */ |
154 | psiconv_bool_false, /* keep_together */ |
147 | psiconv_bool_false, /* keep_with_next */ |
155 | psiconv_bool_false, /* keep_with_next */ |
148 | psiconv_bool_false, /* on_next_page */ |
156 | psiconv_bool_false, /* on_next_page */ |
149 | psiconv_bool_false, /* no_widow_protection */ |
157 | psiconv_bool_false, /* no_widow_protection */ |
|
|
158 | psiconv_bool_false, /* wrap_to_fit_cell */ |
150 | 0.0, /* left_margin */ |
159 | 0.0, /* left_margin */ |
151 | &bullet, /* bullet */ |
160 | &bullet, /* bullet */ |
152 | &no_border, /* left_border */ |
161 | &no_border, /* left_border */ |
153 | &no_border, /* right_border */ |
162 | &no_border, /* right_border */ |
154 | &no_border, /* top_border */ |
163 | &no_border, /* top_border */ |
… | |
… | |
309 | return ss->normal; |
318 | return ss->normal; |
310 | else |
319 | else |
311 | return psiconv_list_get(ss->styles,0xff - nr); |
320 | return psiconv_list_get(ss->styles,0xff - nr); |
312 | } |
321 | } |
313 | |
322 | |
|
|
323 | psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr) |
|
|
324 | { |
|
|
325 | return psiconv_list_get(ss,psiconv_list_length(ss)-nr-1); |
|
|
326 | } |
|
|
327 | |
|
|
328 | /* TODO: What if a cell is both in a default row and a default column?!? */ |
|
|
329 | psiconv_sheet_cell_layout psiconv_get_default_layout |
|
|
330 | (psiconv_sheet_line_list row_defaults, |
|
|
331 | psiconv_sheet_line_list col_defaults, |
|
|
332 | psiconv_sheet_cell_layout cell_default, |
|
|
333 | int row,int col) |
|
|
334 | { |
|
|
335 | int i; |
|
|
336 | psiconv_sheet_line line; |
|
|
337 | for (i = 0;i < psiconv_list_length(row_defaults);i++) { |
|
|
338 | line = psiconv_list_get(row_defaults,i); |
|
|
339 | if (line->position == row) |
|
|
340 | return line->layout; |
|
|
341 | } |
|
|
342 | for (i = 0;i < psiconv_list_length(col_defaults);i++) { |
|
|
343 | line = psiconv_list_get(col_defaults,i); |
|
|
344 | if (line->position == col) |
|
|
345 | return line->layout; |
|
|
346 | } |
|
|
347 | return cell_default; |
|
|
348 | } |
|
|
349 | |
|
|
350 | |
314 | void psiconv_free_color (psiconv_color color) |
351 | void psiconv_free_color (psiconv_color color) |
315 | { |
352 | { |
316 | if (color) |
353 | if (color) |
317 | free(color); |
354 | free(color); |
318 | } |
355 | } |
… | |
… | |
530 | if (file) { |
567 | if (file) { |
531 | psiconv_free_page_layout_section(file->page_sec); |
568 | psiconv_free_page_layout_section(file->page_sec); |
532 | psiconv_free_text_and_layout(file->paragraphs); |
569 | psiconv_free_text_and_layout(file->paragraphs); |
533 | psiconv_free_word_status_section(file->status_sec); |
570 | psiconv_free_word_status_section(file->status_sec); |
534 | psiconv_free_word_styles_section(file->styles_sec); |
571 | psiconv_free_word_styles_section(file->styles_sec); |
|
|
572 | free(file); |
|
|
573 | } |
|
|
574 | } |
|
|
575 | |
|
|
576 | void psiconv_free_sheet_status_section(psiconv_sheet_status_section section) |
|
|
577 | { |
|
|
578 | if (section) |
|
|
579 | free(section); |
|
|
580 | } |
|
|
581 | |
|
|
582 | void psiconv_free_sheet_numberformat(psiconv_sheet_numberformat numberformat) |
|
|
583 | { |
|
|
584 | if (numberformat) |
|
|
585 | free(numberformat); |
|
|
586 | } |
|
|
587 | |
|
|
588 | void psiconv_free_sheet_cell_layout(psiconv_sheet_cell_layout layout) |
|
|
589 | { |
|
|
590 | psiconv_free_paragraph_layout(layout->paragraph); |
|
|
591 | psiconv_free_character_layout(layout->character); |
|
|
592 | psiconv_free_sheet_numberformat(layout->numberformat); |
|
|
593 | } |
|
|
594 | |
|
|
595 | void psiconv_free_sheet_cell_aux(void *cell) |
|
|
596 | { |
|
|
597 | psiconv_sheet_cell data = cell; |
|
|
598 | |
|
|
599 | psiconv_free_sheet_cell_layout(data->layout); |
|
|
600 | |
|
|
601 | if ((data->type == psiconv_cell_string) && (data->data.dat_string)) |
|
|
602 | free(data->data.dat_string); |
|
|
603 | } |
|
|
604 | |
|
|
605 | void psiconv_free_sheet_cell(psiconv_sheet_cell cell) |
|
|
606 | { |
|
|
607 | if (cell) { |
|
|
608 | psiconv_free_sheet_cell_aux(cell); |
|
|
609 | free(cell); |
|
|
610 | } |
|
|
611 | } |
|
|
612 | |
|
|
613 | void psiconv_free_sheet_cell_list(psiconv_sheet_cell_list list) |
|
|
614 | { |
|
|
615 | if (list) |
|
|
616 | psiconv_list_free_el(list,psiconv_free_sheet_cell_aux); |
|
|
617 | } |
|
|
618 | |
|
|
619 | void psiconv_free_sheet_line_aux(void *line) |
|
|
620 | { |
|
|
621 | psiconv_sheet_line data = line; |
|
|
622 | |
|
|
623 | psiconv_free_sheet_cell_layout(data->layout); |
|
|
624 | } |
|
|
625 | |
|
|
626 | void psiconv_free_sheet_line(psiconv_sheet_line line) |
|
|
627 | { |
|
|
628 | if (line) { |
|
|
629 | psiconv_free_sheet_line_aux(line); |
|
|
630 | free(line); |
|
|
631 | } |
|
|
632 | } |
|
|
633 | |
|
|
634 | |
|
|
635 | void psiconv_free_sheet_line_list(psiconv_sheet_line_list list) |
|
|
636 | { |
|
|
637 | if (list) |
|
|
638 | psiconv_list_free_el(list,psiconv_free_sheet_line_aux); |
|
|
639 | } |
|
|
640 | |
|
|
641 | void psiconv_free_sheet_grid_break_list(psiconv_sheet_grid_break_list list) |
|
|
642 | { |
|
|
643 | if (list) |
|
|
644 | psiconv_list_free(list); |
|
|
645 | } |
|
|
646 | |
|
|
647 | void psiconv_free_sheet_grid_size(psiconv_sheet_grid_size s) |
|
|
648 | { |
|
|
649 | if (s) |
|
|
650 | free(s); |
|
|
651 | } |
|
|
652 | |
|
|
653 | void psiconv_free_sheet_grid_size_list(psiconv_sheet_grid_size_list list) |
|
|
654 | { |
|
|
655 | if (list) |
|
|
656 | psiconv_list_free(list); |
|
|
657 | } |
|
|
658 | |
|
|
659 | void psiconv_free_sheet_grid_section(psiconv_sheet_grid_section sec) |
|
|
660 | { |
|
|
661 | if (sec) { |
|
|
662 | psiconv_free_sheet_grid_size_list(sec->row_heights); |
|
|
663 | psiconv_free_sheet_grid_size_list(sec->column_heights); |
|
|
664 | psiconv_free_sheet_grid_break_list(sec->row_page_breaks); |
|
|
665 | psiconv_free_sheet_grid_break_list(sec->column_page_breaks); |
|
|
666 | free(sec); |
|
|
667 | } |
|
|
668 | } |
|
|
669 | |
|
|
670 | void psiconv_free_sheet_worksheet_aux (void *data) |
|
|
671 | { |
|
|
672 | psiconv_sheet_worksheet section = data; |
|
|
673 | psiconv_free_sheet_cell_layout(section->default_layout); |
|
|
674 | psiconv_free_sheet_cell_list(section->cells); |
|
|
675 | psiconv_free_sheet_line_list(section->row_default_layouts); |
|
|
676 | psiconv_free_sheet_line_list(section->col_default_layouts); |
|
|
677 | psiconv_free_sheet_grid_section(section->grid); |
|
|
678 | } |
|
|
679 | |
|
|
680 | void psiconv_free_sheet_worksheet(psiconv_sheet_worksheet sheet) |
|
|
681 | { |
|
|
682 | if (sheet) { |
|
|
683 | psiconv_free_sheet_worksheet_aux(sheet); |
|
|
684 | free(sheet); |
|
|
685 | } |
|
|
686 | } |
|
|
687 | |
|
|
688 | void psiconv_free_sheet_worksheet_list(psiconv_sheet_worksheet_list list) |
|
|
689 | { |
|
|
690 | if (list) |
|
|
691 | psiconv_list_free_el(list,psiconv_free_sheet_worksheet_aux); |
|
|
692 | } |
|
|
693 | |
|
|
694 | void psiconv_free_formula_aux(void *data) |
|
|
695 | { |
|
|
696 | psiconv_formula formula; |
|
|
697 | formula = data; |
|
|
698 | if (formula->type == psiconv_formula_dat_string) |
|
|
699 | free(formula->data.dat_string); |
|
|
700 | else if ((formula->type != psiconv_formula_dat_int) && |
|
|
701 | (formula->type != psiconv_formula_dat_var) && |
|
|
702 | (formula->type != psiconv_formula_dat_float) && |
|
|
703 | (formula->type != psiconv_formula_dat_cellref) && |
|
|
704 | (formula->type != psiconv_formula_dat_cellblock) && |
|
|
705 | (formula->type != psiconv_formula_dat_vcellblock) && |
|
|
706 | (formula->type != psiconv_formula_mark_opsep) && |
|
|
707 | (formula->type != psiconv_formula_mark_opend) && |
|
|
708 | (formula->type != psiconv_formula_mark_eof) && |
|
|
709 | (formula->type != psiconv_formula_unknown)) |
|
|
710 | psiconv_free_formula_list(formula->data.fun_operands); |
|
|
711 | } |
|
|
712 | |
|
|
713 | void psiconv_free_formula(psiconv_formula formula) |
|
|
714 | { |
|
|
715 | if (formula) { |
|
|
716 | psiconv_free_formula_aux(formula); |
|
|
717 | free(formula); |
|
|
718 | } |
|
|
719 | } |
|
|
720 | |
|
|
721 | void psiconv_free_formula_list(psiconv_formula_list list) |
|
|
722 | { |
|
|
723 | if (list) |
|
|
724 | psiconv_list_free_el(list,psiconv_free_formula_aux); |
|
|
725 | } |
|
|
726 | |
|
|
727 | void psiconv_free_sheet_name_section(psiconv_sheet_name_section section) |
|
|
728 | { |
|
|
729 | if (section) { |
|
|
730 | if(section->name) |
|
|
731 | free(section->name); |
|
|
732 | free(section); |
|
|
733 | } |
|
|
734 | } |
|
|
735 | |
|
|
736 | void psiconv_free_sheet_info_section(psiconv_sheet_info_section section) |
|
|
737 | { |
|
|
738 | if (section) { |
|
|
739 | free(section); |
|
|
740 | } |
|
|
741 | } |
|
|
742 | |
|
|
743 | void psiconv_free_sheet_variable_aux(void * variable) |
|
|
744 | { |
|
|
745 | psiconv_sheet_variable var = variable; |
|
|
746 | if (var->name) |
|
|
747 | free(var->name); |
|
|
748 | if (var->type == psiconv_var_string) |
|
|
749 | free(var->data.dat_string); |
|
|
750 | } |
|
|
751 | |
|
|
752 | void psiconv_free_sheet_variable(psiconv_sheet_variable var) |
|
|
753 | { |
|
|
754 | if (var) { |
|
|
755 | psiconv_free_sheet_variable_aux(var); |
|
|
756 | free(var); |
|
|
757 | } |
|
|
758 | } |
|
|
759 | |
|
|
760 | void psiconv_free_sheet_variable_list(psiconv_sheet_variable_list list) |
|
|
761 | { |
|
|
762 | if (list) |
|
|
763 | psiconv_list_free_el(list,psiconv_free_sheet_variable_aux); |
|
|
764 | } |
|
|
765 | |
|
|
766 | void psiconv_free_sheet_workbook_section(psiconv_sheet_workbook_section section) |
|
|
767 | { |
|
|
768 | if (section) { |
|
|
769 | psiconv_free_formula_list(section->formulas); |
|
|
770 | psiconv_free_sheet_worksheet_list(section->worksheets); |
|
|
771 | psiconv_free_sheet_name_section(section->name); |
|
|
772 | psiconv_free_sheet_info_section(section->info); |
|
|
773 | psiconv_free_sheet_variable_list(section->variables); |
|
|
774 | free(section); |
|
|
775 | } |
|
|
776 | } |
|
|
777 | |
|
|
778 | void psiconv_free_sheet_f(psiconv_sheet_f file) |
|
|
779 | { |
|
|
780 | if (file) { |
|
|
781 | psiconv_free_page_layout_section(file->page_sec); |
|
|
782 | psiconv_free_sheet_status_section(file->status_sec); |
|
|
783 | psiconv_free_sheet_workbook_section(file->workbook_sec); |
535 | free(file); |
784 | free(file); |
536 | } |
785 | } |
537 | } |
786 | } |
538 | |
787 | |
539 | void psiconv_free_texted_f(psiconv_texted_f file) |
788 | void psiconv_free_texted_f(psiconv_texted_f file) |
… | |
… | |
638 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
887 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
639 | else if (file->type == psiconv_sketch_file) |
888 | else if (file->type == psiconv_sketch_file) |
640 | psiconv_free_sketch_f((psiconv_sketch_f) file->file); |
889 | psiconv_free_sketch_f((psiconv_sketch_f) file->file); |
641 | else if (file->type == psiconv_clipart_file) |
890 | else if (file->type == psiconv_clipart_file) |
642 | psiconv_free_clipart_f((psiconv_clipart_f) file->file); |
891 | psiconv_free_clipart_f((psiconv_clipart_f) file->file); |
|
|
892 | else if (file->type == psiconv_sheet_file) |
|
|
893 | psiconv_free_sheet_f((psiconv_sheet_f) file->file); |
643 | free(file); |
894 | free(file); |
644 | } |
895 | } |
645 | } |
896 | } |
646 | |
897 | |
647 | int psiconv_compare_color(const psiconv_color value1, |
898 | int psiconv_compare_color(const psiconv_color value1, |
… | |
… | |
918 | free(result); |
1169 | free(result); |
919 | ERROR1: |
1170 | ERROR1: |
920 | return NULL; |
1171 | return NULL; |
921 | } |
1172 | } |
922 | |
1173 | |
|
|
1174 | psiconv_sheet_status_section psiconv_empty_sheet_status_section(void) |
|
|
1175 | { |
|
|
1176 | psiconv_sheet_status_section result; |
|
|
1177 | if (!(result = malloc(sizeof(*result)))) |
|
|
1178 | return NULL; |
|
|
1179 | result->show_horizontal_scrollbar = result->show_vertical_scrollbar = |
|
|
1180 | psiconv_triple_auto; |
|
|
1181 | result->show_graph = psiconv_bool_false; |
|
|
1182 | result->show_top_sheet_toolbar = result->show_side_sheet_toolbar = |
|
|
1183 | result->show_top_graph_toolbar = result->show_side_graph_toolbar = |
|
|
1184 | psiconv_bool_true; |
|
|
1185 | result->cursor_row = result->cursor_column = 0; |
|
|
1186 | result->sheet_display_size = result->graph_display_size = 1000; |
|
|
1187 | return result; |
|
|
1188 | } |
|
|
1189 | |
|
|
1190 | psiconv_formula_list psiconv_empty_formula_list(void) |
|
|
1191 | { |
|
|
1192 | return psiconv_list_new(sizeof(struct psiconv_formula_s)); |
|
|
1193 | } |
|
|
1194 | |
|
|
1195 | psiconv_sheet_workbook_section psiconv_empty_sheet_workbook_section(void) |
|
|
1196 | { |
|
|
1197 | psiconv_sheet_workbook_section result; |
|
|
1198 | if (!(result = malloc(sizeof(*result)))) |
|
|
1199 | goto ERROR1; |
|
|
1200 | if (!(result->formulas = psiconv_empty_formula_list())) |
|
|
1201 | goto ERROR2; |
|
|
1202 | return result; |
|
|
1203 | ERROR2: |
|
|
1204 | free(result); |
|
|
1205 | ERROR1: |
|
|
1206 | return NULL; |
|
|
1207 | } |
|
|
1208 | |
|
|
1209 | |
|
|
1210 | psiconv_sheet_f psiconv_empty_sheet_f(void) |
|
|
1211 | { |
|
|
1212 | psiconv_sheet_f result; |
|
|
1213 | if (!(result = malloc(sizeof(*result)))) |
|
|
1214 | goto ERROR1; |
|
|
1215 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1216 | goto ERROR2; |
|
|
1217 | if (!(result->status_sec = psiconv_empty_sheet_status_section())) |
|
|
1218 | goto ERROR3; |
|
|
1219 | if (!(result->workbook_sec = psiconv_empty_sheet_workbook_section())) |
|
|
1220 | goto ERROR4; |
|
|
1221 | return result; |
|
|
1222 | ERROR4: |
|
|
1223 | psiconv_free_sheet_status_section(result->status_sec); |
|
|
1224 | ERROR3: |
|
|
1225 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1226 | ERROR2: |
|
|
1227 | free(result); |
|
|
1228 | ERROR1: |
|
|
1229 | return NULL; |
|
|
1230 | } |
|
|
1231 | |
923 | psiconv_texted_f psiconv_empty_texted_f(void) |
1232 | psiconv_texted_f psiconv_empty_texted_f(void) |
924 | { |
1233 | { |
925 | psiconv_texted_f result; |
1234 | psiconv_texted_f result; |
926 | if (!(result = malloc(sizeof(*result)))) |
1235 | if (!(result = malloc(sizeof(*result)))) |
927 | goto ERROR1; |
1236 | goto ERROR1; |
… | |
… | |
1059 | if (!(result = malloc(sizeof(*result)))) |
1368 | if (!(result = malloc(sizeof(*result)))) |
1060 | return NULL; |
1369 | return NULL; |
1061 | result->type = type; |
1370 | result->type = type; |
1062 | if (type == psiconv_word_file) { |
1371 | if (type == psiconv_word_file) { |
1063 | if (!(result->file = psiconv_empty_word_f())) |
1372 | if (!(result->file = psiconv_empty_word_f())) |
|
|
1373 | goto ERROR; |
|
|
1374 | } else if (type == psiconv_sheet_file) { |
|
|
1375 | if (!(result->file = psiconv_empty_sheet_f())) |
1064 | goto ERROR; |
1376 | goto ERROR; |
1065 | } else if (type == psiconv_texted_file) { |
1377 | } else if (type == psiconv_texted_file) { |
1066 | if (!(result->file = psiconv_empty_texted_f())) |
1378 | if (!(result->file = psiconv_empty_texted_f())) |
1067 | goto ERROR; |
1379 | goto ERROR; |
1068 | } else if (type == psiconv_mbm_file) { |
1380 | } else if (type == psiconv_mbm_file) { |