… | |
… | |
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); |
37 | |
39 | |
38 | static psiconv_word_styles_section psiconv_empty_word_styles_section(void); |
40 | static psiconv_word_styles_section psiconv_empty_word_styles_section(void); |
39 | static psiconv_text_and_layout psiconv_empty_text_and_layout(void); |
41 | static psiconv_text_and_layout psiconv_empty_text_and_layout(void); |
40 | static psiconv_texted_section psiconv_empty_texted_section(void); |
42 | static psiconv_texted_section psiconv_empty_texted_section(void); |
41 | static psiconv_page_header psiconv_empty_page_header(void); |
43 | static psiconv_page_header psiconv_empty_page_header(void); |
42 | static psiconv_page_layout_section psiconv_empty_page_layout_section(void); |
44 | static psiconv_page_layout_section psiconv_empty_page_layout_section(void); |
43 | static psiconv_word_status_section psiconv_empty_word_status_section(void); |
45 | static psiconv_word_status_section psiconv_empty_word_status_section(void); |
44 | static psiconv_word_f psiconv_empty_word_f(void); |
46 | static psiconv_word_f psiconv_empty_word_f(void); |
|
|
47 | static psiconv_sheet_status_section psiconv_empty_sheet_status_section(void); |
|
|
48 | static psiconv_formula_list psiconv_empty_formula_list(void); |
|
|
49 | static psiconv_sheet_workbook_section |
|
|
50 | psiconv_empty_sheet_workbook_section(void); |
|
|
51 | static psiconv_sheet_f psiconv_empty_sheet_f(void); |
45 | static psiconv_texted_f psiconv_empty_texted_f(void); |
52 | static psiconv_texted_f psiconv_empty_texted_f(void); |
46 | static psiconv_paint_data_section psiconv_empty_paint_data_section(void); |
53 | static psiconv_paint_data_section psiconv_empty_paint_data_section(void); |
47 | static psiconv_pictures psiconv_empty_pictures(void); |
54 | static psiconv_pictures psiconv_empty_pictures(void); |
48 | static psiconv_mbm_f psiconv_empty_mbm_f(void); |
55 | static psiconv_mbm_f psiconv_empty_mbm_f(void); |
49 | static psiconv_sketch_section psiconv_empty_sketch_section(void); |
56 | static psiconv_sketch_section psiconv_empty_sketch_section(void); |
… | |
… | |
145 | 0.0, /* space_below */ |
152 | 0.0, /* space_below */ |
146 | psiconv_bool_false, /* keep_together */ |
153 | psiconv_bool_false, /* keep_together */ |
147 | psiconv_bool_false, /* keep_with_next */ |
154 | psiconv_bool_false, /* keep_with_next */ |
148 | psiconv_bool_false, /* on_next_page */ |
155 | psiconv_bool_false, /* on_next_page */ |
149 | psiconv_bool_false, /* no_widow_protection */ |
156 | psiconv_bool_false, /* no_widow_protection */ |
|
|
157 | psiconv_bool_false, /* wrap_to_fit_cell */ |
150 | 0.0, /* left_margin */ |
158 | 0.0, /* left_margin */ |
151 | &bullet, /* bullet */ |
159 | &bullet, /* bullet */ |
152 | &no_border, /* left_border */ |
160 | &no_border, /* left_border */ |
153 | &no_border, /* right_border */ |
161 | &no_border, /* right_border */ |
154 | &no_border, /* top_border */ |
162 | &no_border, /* top_border */ |
… | |
… | |
309 | return ss->normal; |
317 | return ss->normal; |
310 | else |
318 | else |
311 | return psiconv_list_get(ss->styles,0xff - nr); |
319 | return psiconv_list_get(ss->styles,0xff - nr); |
312 | } |
320 | } |
313 | |
321 | |
|
|
322 | psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr) |
|
|
323 | { |
|
|
324 | return psiconv_list_get(ss,psiconv_list_length(ss)-nr-1); |
|
|
325 | } |
|
|
326 | |
|
|
327 | /* TODO: What if a cell is both in a default row and a default column?!? */ |
|
|
328 | psiconv_sheet_cell_layout psiconv_get_default_layout |
|
|
329 | (psiconv_sheet_line_list row_defaults, |
|
|
330 | psiconv_sheet_line_list col_defaults, |
|
|
331 | psiconv_sheet_cell_layout cell_default, |
|
|
332 | int row,int col) |
|
|
333 | { |
|
|
334 | int i; |
|
|
335 | psiconv_sheet_line line; |
|
|
336 | for (i = 0;i < psiconv_list_length(row_defaults);i++) { |
|
|
337 | line = psiconv_list_get(row_defaults,i); |
|
|
338 | if (line->position == row) |
|
|
339 | return line->layout; |
|
|
340 | } |
|
|
341 | for (i = 0;i < psiconv_list_length(col_defaults);i++) { |
|
|
342 | line = psiconv_list_get(col_defaults,i); |
|
|
343 | if (line->position == col) |
|
|
344 | return line->layout; |
|
|
345 | } |
|
|
346 | return cell_default; |
|
|
347 | } |
|
|
348 | |
|
|
349 | |
314 | void psiconv_free_color (psiconv_color color) |
350 | void psiconv_free_color (psiconv_color color) |
315 | { |
351 | { |
316 | if (color) |
352 | if (color) |
317 | free(color); |
353 | free(color); |
318 | } |
354 | } |
… | |
… | |
530 | if (file) { |
566 | if (file) { |
531 | psiconv_free_page_layout_section(file->page_sec); |
567 | psiconv_free_page_layout_section(file->page_sec); |
532 | psiconv_free_text_and_layout(file->paragraphs); |
568 | psiconv_free_text_and_layout(file->paragraphs); |
533 | psiconv_free_word_status_section(file->status_sec); |
569 | psiconv_free_word_status_section(file->status_sec); |
534 | psiconv_free_word_styles_section(file->styles_sec); |
570 | psiconv_free_word_styles_section(file->styles_sec); |
|
|
571 | free(file); |
|
|
572 | } |
|
|
573 | } |
|
|
574 | |
|
|
575 | void psiconv_free_sheet_status_section(psiconv_sheet_status_section section) |
|
|
576 | { |
|
|
577 | if (section) |
|
|
578 | free(section); |
|
|
579 | } |
|
|
580 | |
|
|
581 | void psiconv_free_sheet_numberformat(psiconv_sheet_numberformat numberformat) |
|
|
582 | { |
|
|
583 | if (numberformat) |
|
|
584 | free(numberformat); |
|
|
585 | } |
|
|
586 | |
|
|
587 | void psiconv_free_sheet_cell_layout(psiconv_sheet_cell_layout layout) |
|
|
588 | { |
|
|
589 | psiconv_free_paragraph_layout(layout->paragraph); |
|
|
590 | psiconv_free_character_layout(layout->character); |
|
|
591 | psiconv_free_sheet_numberformat(layout->numberformat); |
|
|
592 | } |
|
|
593 | |
|
|
594 | void psiconv_free_sheet_cell_aux(void *cell) |
|
|
595 | { |
|
|
596 | psiconv_sheet_cell data = cell; |
|
|
597 | |
|
|
598 | psiconv_free_sheet_cell_layout(data->layout); |
|
|
599 | |
|
|
600 | if ((data->type == psiconv_cell_string) && (data->data.dat_string)) |
|
|
601 | free(data->data.dat_string); |
|
|
602 | } |
|
|
603 | |
|
|
604 | void psiconv_free_sheet_cell(psiconv_sheet_cell cell) |
|
|
605 | { |
|
|
606 | if (cell) { |
|
|
607 | psiconv_free_sheet_cell_aux(cell); |
|
|
608 | free(cell); |
|
|
609 | } |
|
|
610 | } |
|
|
611 | |
|
|
612 | void psiconv_free_sheet_cell_list(psiconv_sheet_cell_list list) |
|
|
613 | { |
|
|
614 | if (list) |
|
|
615 | psiconv_list_free_el(list,psiconv_free_sheet_cell_aux); |
|
|
616 | } |
|
|
617 | |
|
|
618 | void psiconv_free_sheet_line_aux(void *line) |
|
|
619 | { |
|
|
620 | psiconv_sheet_line data = line; |
|
|
621 | |
|
|
622 | psiconv_free_sheet_cell_layout(data->layout); |
|
|
623 | } |
|
|
624 | |
|
|
625 | void psiconv_free_sheet_line(psiconv_sheet_line line) |
|
|
626 | { |
|
|
627 | if (line) { |
|
|
628 | psiconv_free_sheet_line_aux(line); |
|
|
629 | free(line); |
|
|
630 | } |
|
|
631 | } |
|
|
632 | |
|
|
633 | void psiconv_free_sheet_line_list(psiconv_sheet_line_list list) |
|
|
634 | { |
|
|
635 | if (list) |
|
|
636 | psiconv_list_free_el(list,psiconv_free_sheet_line_aux); |
|
|
637 | } |
|
|
638 | |
|
|
639 | void psiconv_free_sheet_worksheet_aux (void *data) |
|
|
640 | { |
|
|
641 | psiconv_sheet_worksheet section = data; |
|
|
642 | psiconv_free_sheet_cell_layout(section->default_layout); |
|
|
643 | psiconv_free_sheet_cell_list(section->cells); |
|
|
644 | psiconv_free_sheet_line_list(section->row_default_layouts); |
|
|
645 | psiconv_free_sheet_line_list(section->col_default_layouts); |
|
|
646 | } |
|
|
647 | |
|
|
648 | void psiconv_free_sheet_worksheet(psiconv_sheet_worksheet sheet) |
|
|
649 | { |
|
|
650 | if (sheet) { |
|
|
651 | psiconv_free_sheet_worksheet_aux(sheet); |
|
|
652 | free(sheet); |
|
|
653 | } |
|
|
654 | } |
|
|
655 | |
|
|
656 | void psiconv_free_sheet_worksheet_list(psiconv_sheet_worksheet_list list) |
|
|
657 | { |
|
|
658 | if (list) |
|
|
659 | psiconv_list_free_el(list,psiconv_free_sheet_worksheet_aux); |
|
|
660 | } |
|
|
661 | |
|
|
662 | void psiconv_free_formula_aux(void *data) |
|
|
663 | { |
|
|
664 | psiconv_formula formula; |
|
|
665 | formula = data; |
|
|
666 | if (formula->type == psiconv_formula_dat_string) |
|
|
667 | free(formula->data.dat_string); |
|
|
668 | else if ((formula->type != psiconv_formula_dat_int) && |
|
|
669 | (formula->type != psiconv_formula_dat_var) && |
|
|
670 | (formula->type != psiconv_formula_dat_float) && |
|
|
671 | (formula->type != psiconv_formula_dat_cellref) && |
|
|
672 | (formula->type != psiconv_formula_dat_cellblock) && |
|
|
673 | (formula->type != psiconv_formula_dat_vcellblock) && |
|
|
674 | (formula->type != psiconv_formula_mark_opsep) && |
|
|
675 | (formula->type != psiconv_formula_mark_opend) && |
|
|
676 | (formula->type != psiconv_formula_mark_eof) && |
|
|
677 | (formula->type != psiconv_formula_unknown)) |
|
|
678 | psiconv_free_formula_list(formula->data.fun_operands); |
|
|
679 | } |
|
|
680 | |
|
|
681 | void psiconv_free_formula(psiconv_formula formula) |
|
|
682 | { |
|
|
683 | if (formula) { |
|
|
684 | psiconv_free_formula_aux(formula); |
|
|
685 | free(formula); |
|
|
686 | } |
|
|
687 | } |
|
|
688 | |
|
|
689 | void psiconv_free_formula_list(psiconv_formula_list list) |
|
|
690 | { |
|
|
691 | if (list) |
|
|
692 | psiconv_list_free_el(list,psiconv_free_formula_aux); |
|
|
693 | } |
|
|
694 | |
|
|
695 | void psiconv_free_sheet_workbook_section(psiconv_sheet_workbook_section section) |
|
|
696 | { |
|
|
697 | if (section) { |
|
|
698 | psiconv_free_formula_list(section->formulas); |
|
|
699 | psiconv_free_sheet_worksheet_list(section->worksheets); |
|
|
700 | free(section); |
|
|
701 | } |
|
|
702 | } |
|
|
703 | |
|
|
704 | void psiconv_free_sheet_f(psiconv_sheet_f file) |
|
|
705 | { |
|
|
706 | if (file) { |
|
|
707 | psiconv_free_page_layout_section(file->page_sec); |
|
|
708 | psiconv_free_sheet_status_section(file->status_sec); |
|
|
709 | psiconv_free_sheet_workbook_section(file->workbook_sec); |
535 | free(file); |
710 | free(file); |
536 | } |
711 | } |
537 | } |
712 | } |
538 | |
713 | |
539 | void psiconv_free_texted_f(psiconv_texted_f file) |
714 | void psiconv_free_texted_f(psiconv_texted_f file) |
… | |
… | |
638 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
813 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
639 | else if (file->type == psiconv_sketch_file) |
814 | else if (file->type == psiconv_sketch_file) |
640 | psiconv_free_sketch_f((psiconv_sketch_f) file->file); |
815 | psiconv_free_sketch_f((psiconv_sketch_f) file->file); |
641 | else if (file->type == psiconv_clipart_file) |
816 | else if (file->type == psiconv_clipart_file) |
642 | psiconv_free_clipart_f((psiconv_clipart_f) file->file); |
817 | psiconv_free_clipart_f((psiconv_clipart_f) file->file); |
|
|
818 | else if (file->type == psiconv_sheet_file) |
|
|
819 | psiconv_free_sheet_f((psiconv_sheet_f) file->file); |
643 | free(file); |
820 | free(file); |
644 | } |
821 | } |
645 | } |
822 | } |
646 | |
823 | |
647 | int psiconv_compare_color(const psiconv_color value1, |
824 | int psiconv_compare_color(const psiconv_color value1, |
… | |
… | |
918 | free(result); |
1095 | free(result); |
919 | ERROR1: |
1096 | ERROR1: |
920 | return NULL; |
1097 | return NULL; |
921 | } |
1098 | } |
922 | |
1099 | |
|
|
1100 | psiconv_sheet_status_section psiconv_empty_sheet_status_section(void) |
|
|
1101 | { |
|
|
1102 | psiconv_sheet_status_section result; |
|
|
1103 | if (!(result = malloc(sizeof(*result)))) |
|
|
1104 | return NULL; |
|
|
1105 | result->show_horizontal_scrollbar = result->show_vertical_scrollbar = |
|
|
1106 | psiconv_triple_auto; |
|
|
1107 | result->show_graph = psiconv_bool_false; |
|
|
1108 | result->show_top_sheet_toolbar = result->show_side_sheet_toolbar = |
|
|
1109 | result->show_top_graph_toolbar = result->show_side_graph_toolbar = |
|
|
1110 | psiconv_bool_true; |
|
|
1111 | result->cursor_row = result->cursor_column = 0; |
|
|
1112 | result->sheet_display_size = result->graph_display_size = 1000; |
|
|
1113 | return result; |
|
|
1114 | } |
|
|
1115 | |
|
|
1116 | psiconv_formula_list psiconv_empty_formula_list(void) |
|
|
1117 | { |
|
|
1118 | return psiconv_list_new(sizeof(struct psiconv_formula_s)); |
|
|
1119 | } |
|
|
1120 | |
|
|
1121 | psiconv_sheet_workbook_section psiconv_empty_sheet_workbook_section(void) |
|
|
1122 | { |
|
|
1123 | psiconv_sheet_workbook_section result; |
|
|
1124 | if (!(result = malloc(sizeof(*result)))) |
|
|
1125 | goto ERROR1; |
|
|
1126 | if (!(result->formulas = psiconv_empty_formula_list())) |
|
|
1127 | goto ERROR2; |
|
|
1128 | return result; |
|
|
1129 | ERROR2: |
|
|
1130 | free(result); |
|
|
1131 | ERROR1: |
|
|
1132 | return NULL; |
|
|
1133 | } |
|
|
1134 | |
|
|
1135 | |
|
|
1136 | psiconv_sheet_f psiconv_empty_sheet_f(void) |
|
|
1137 | { |
|
|
1138 | psiconv_sheet_f result; |
|
|
1139 | if (!(result = malloc(sizeof(*result)))) |
|
|
1140 | goto ERROR1; |
|
|
1141 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1142 | goto ERROR2; |
|
|
1143 | if (!(result->status_sec = psiconv_empty_sheet_status_section())) |
|
|
1144 | goto ERROR3; |
|
|
1145 | if (!(result->workbook_sec = psiconv_empty_sheet_workbook_section())) |
|
|
1146 | goto ERROR4; |
|
|
1147 | return result; |
|
|
1148 | ERROR4: |
|
|
1149 | psiconv_free_sheet_status_section(result->status_sec); |
|
|
1150 | ERROR3: |
|
|
1151 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1152 | ERROR2: |
|
|
1153 | free(result); |
|
|
1154 | ERROR1: |
|
|
1155 | return NULL; |
|
|
1156 | } |
|
|
1157 | |
923 | psiconv_texted_f psiconv_empty_texted_f(void) |
1158 | psiconv_texted_f psiconv_empty_texted_f(void) |
924 | { |
1159 | { |
925 | psiconv_texted_f result; |
1160 | psiconv_texted_f result; |
926 | if (!(result = malloc(sizeof(*result)))) |
1161 | if (!(result = malloc(sizeof(*result)))) |
927 | goto ERROR1; |
1162 | goto ERROR1; |
… | |
… | |
1059 | if (!(result = malloc(sizeof(*result)))) |
1294 | if (!(result = malloc(sizeof(*result)))) |
1060 | return NULL; |
1295 | return NULL; |
1061 | result->type = type; |
1296 | result->type = type; |
1062 | if (type == psiconv_word_file) { |
1297 | if (type == psiconv_word_file) { |
1063 | if (!(result->file = psiconv_empty_word_f())) |
1298 | if (!(result->file = psiconv_empty_word_f())) |
|
|
1299 | goto ERROR; |
|
|
1300 | } else if (type == psiconv_sheet_file) { |
|
|
1301 | if (!(result->file = psiconv_empty_sheet_f())) |
1064 | goto ERROR; |
1302 | goto ERROR; |
1065 | } else if (type == psiconv_texted_file) { |
1303 | } else if (type == psiconv_texted_file) { |
1066 | if (!(result->file = psiconv_empty_texted_f())) |
1304 | if (!(result->file = psiconv_empty_texted_f())) |
1067 | goto ERROR; |
1305 | goto ERROR; |
1068 | } else if (type == psiconv_mbm_file) { |
1306 | } else if (type == psiconv_mbm_file) { |