… | |
… | |
20 | #include "config.h" |
20 | #include "config.h" |
21 | #include "compat.h" |
21 | #include "compat.h" |
22 | #include <stdlib.h> |
22 | #include <stdlib.h> |
23 | #include <string.h> |
23 | #include <string.h> |
24 | #include "data.h" |
24 | #include "data.h" |
|
|
25 | #include "list.h" |
25 | |
26 | |
26 | static psiconv_color clone_color(psiconv_color color); |
27 | static psiconv_color clone_color(psiconv_color color); |
27 | static psiconv_font clone_font(psiconv_font font); |
28 | static psiconv_font clone_font(psiconv_font font); |
28 | static psiconv_border clone_border(psiconv_border border); |
29 | static psiconv_border clone_border(psiconv_border border); |
29 | static psiconv_bullet clone_bullet(psiconv_bullet bullet); |
30 | static psiconv_bullet clone_bullet(psiconv_bullet bullet); |
… | |
… | |
31 | static void psiconv_free_style_aux(void *style); |
32 | static void psiconv_free_style_aux(void *style); |
32 | static void psiconv_free_in_line_layout_aux(void * layout); |
33 | static void psiconv_free_in_line_layout_aux(void * layout); |
33 | static void psiconv_free_paragraph_aux(void * paragraph); |
34 | static void psiconv_free_paragraph_aux(void * paragraph); |
34 | static void psiconv_free_paint_data_section_aux(void * section); |
35 | static void psiconv_free_paint_data_section_aux(void * section); |
35 | 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 | |
|
|
40 | static psiconv_word_styles_section psiconv_empty_word_styles_section(void); |
|
|
41 | static psiconv_text_and_layout psiconv_empty_text_and_layout(void); |
|
|
42 | static psiconv_texted_section psiconv_empty_texted_section(void); |
|
|
43 | static psiconv_page_header psiconv_empty_page_header(void); |
|
|
44 | static psiconv_page_layout_section psiconv_empty_page_layout_section(void); |
|
|
45 | static psiconv_word_status_section psiconv_empty_word_status_section(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); |
|
|
52 | static psiconv_texted_f psiconv_empty_texted_f(void); |
|
|
53 | static psiconv_paint_data_section psiconv_empty_paint_data_section(void); |
|
|
54 | static psiconv_pictures psiconv_empty_pictures(void); |
|
|
55 | static psiconv_mbm_f psiconv_empty_mbm_f(void); |
|
|
56 | static psiconv_sketch_section psiconv_empty_sketch_section(void); |
|
|
57 | static psiconv_sketch_f psiconv_empty_sketch_f(void); |
|
|
58 | static psiconv_clipart_f psiconv_empty_clipart_f(void); |
|
|
59 | static psiconv_cliparts psiconv_empty_cliparts(void); |
|
|
60 | |
36 | |
61 | |
37 | /* Note: these defaults seem to be hard-coded somewhere outside the |
62 | /* Note: these defaults seem to be hard-coded somewhere outside the |
38 | files themself. */ |
63 | files themself. */ |
39 | psiconv_character_layout psiconv_basic_character_layout(void) |
64 | psiconv_character_layout psiconv_basic_character_layout(void) |
40 | { |
65 | { |
… | |
… | |
127 | 0.0, /* space_below */ |
152 | 0.0, /* space_below */ |
128 | psiconv_bool_false, /* keep_together */ |
153 | psiconv_bool_false, /* keep_together */ |
129 | psiconv_bool_false, /* keep_with_next */ |
154 | psiconv_bool_false, /* keep_with_next */ |
130 | psiconv_bool_false, /* on_next_page */ |
155 | psiconv_bool_false, /* on_next_page */ |
131 | psiconv_bool_false, /* no_widow_protection */ |
156 | psiconv_bool_false, /* no_widow_protection */ |
|
|
157 | psiconv_bool_false, /* wrap_to_fit_cell */ |
132 | 0.0, /* left_margin */ |
158 | 0.0, /* left_margin */ |
133 | &bullet, /* bullet */ |
159 | &bullet, /* bullet */ |
134 | &no_border, /* left_border */ |
160 | &no_border, /* left_border */ |
135 | &no_border, /* right_border */ |
161 | &no_border, /* right_border */ |
136 | &no_border, /* top_border */ |
162 | &no_border, /* top_border */ |
… | |
… | |
291 | return ss->normal; |
317 | return ss->normal; |
292 | else |
318 | else |
293 | return psiconv_list_get(ss->styles,0xff - nr); |
319 | return psiconv_list_get(ss->styles,0xff - nr); |
294 | } |
320 | } |
295 | |
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 | |
296 | void psiconv_free_color (psiconv_color color) |
328 | void psiconv_free_color (psiconv_color color) |
297 | { |
329 | { |
298 | if (color) |
330 | if (color) |
299 | free(color); |
331 | free(color); |
300 | } |
332 | } |
… | |
… | |
512 | if (file) { |
544 | if (file) { |
513 | psiconv_free_page_layout_section(file->page_sec); |
545 | psiconv_free_page_layout_section(file->page_sec); |
514 | psiconv_free_text_and_layout(file->paragraphs); |
546 | psiconv_free_text_and_layout(file->paragraphs); |
515 | psiconv_free_word_status_section(file->status_sec); |
547 | psiconv_free_word_status_section(file->status_sec); |
516 | psiconv_free_word_styles_section(file->styles_sec); |
548 | psiconv_free_word_styles_section(file->styles_sec); |
|
|
549 | free(file); |
|
|
550 | } |
|
|
551 | } |
|
|
552 | |
|
|
553 | void psiconv_free_sheet_status_section(psiconv_sheet_status_section section) |
|
|
554 | { |
|
|
555 | if (section) |
|
|
556 | free(section); |
|
|
557 | } |
|
|
558 | |
|
|
559 | void psiconv_free_sheet_numberformat(psiconv_sheet_numberformat numberformat) |
|
|
560 | { |
|
|
561 | if (numberformat) |
|
|
562 | free(numberformat); |
|
|
563 | } |
|
|
564 | |
|
|
565 | void psiconv_free_sheet_cell_layout(psiconv_sheet_cell_layout layout) |
|
|
566 | { |
|
|
567 | psiconv_free_paragraph_layout(layout->paragraph); |
|
|
568 | psiconv_free_character_layout(layout->character); |
|
|
569 | psiconv_free_sheet_numberformat(layout->numberformat); |
|
|
570 | } |
|
|
571 | |
|
|
572 | void psiconv_free_sheet_cell_aux(void *cell) |
|
|
573 | { |
|
|
574 | psiconv_sheet_cell data = cell; |
|
|
575 | |
|
|
576 | psiconv_free_sheet_cell_layout(data->layout); |
|
|
577 | |
|
|
578 | if ((data->type == psiconv_cell_string) && (data->data.dat_string)) |
|
|
579 | free(data->data.dat_string); |
|
|
580 | } |
|
|
581 | |
|
|
582 | void psiconv_free_sheet_cell(psiconv_sheet_cell cell) |
|
|
583 | { |
|
|
584 | if (cell) { |
|
|
585 | psiconv_free_sheet_cell_aux(cell); |
|
|
586 | free(cell); |
|
|
587 | } |
|
|
588 | } |
|
|
589 | |
|
|
590 | void psiconv_free_sheet_cell_list(psiconv_sheet_cell_list list) |
|
|
591 | { |
|
|
592 | if (list) |
|
|
593 | psiconv_list_free_el(list,psiconv_free_sheet_cell_aux); |
|
|
594 | } |
|
|
595 | |
|
|
596 | void psiconv_free_sheet_worksheet_aux (void *data) |
|
|
597 | { |
|
|
598 | psiconv_sheet_worksheet section = data; |
|
|
599 | psiconv_free_sheet_cell_layout(section->default_layout); |
|
|
600 | psiconv_free_sheet_cell_list(section->cells); |
|
|
601 | } |
|
|
602 | |
|
|
603 | void psiconv_free_sheet_worksheet(psiconv_sheet_worksheet sheet) |
|
|
604 | { |
|
|
605 | if (sheet) { |
|
|
606 | psiconv_free_sheet_worksheet_aux(sheet); |
|
|
607 | free(sheet); |
|
|
608 | } |
|
|
609 | } |
|
|
610 | |
|
|
611 | void psiconv_free_sheet_worksheet_list(psiconv_sheet_worksheet_list list) |
|
|
612 | { |
|
|
613 | if (list) |
|
|
614 | psiconv_list_free_el(list,psiconv_free_sheet_worksheet_aux); |
|
|
615 | } |
|
|
616 | |
|
|
617 | void psiconv_free_formula_aux(void *data) |
|
|
618 | { |
|
|
619 | psiconv_formula formula; |
|
|
620 | formula = data; |
|
|
621 | if (formula->type == psiconv_formula_dat_string) |
|
|
622 | free(formula->data.dat_string); |
|
|
623 | else if ((formula->type != psiconv_formula_dat_int) && |
|
|
624 | (formula->type != psiconv_formula_dat_var) && |
|
|
625 | (formula->type != psiconv_formula_dat_float) && |
|
|
626 | (formula->type != psiconv_formula_dat_cellref) && |
|
|
627 | (formula->type != psiconv_formula_dat_cellblock) && |
|
|
628 | (formula->type != psiconv_formula_dat_vcellblock) && |
|
|
629 | (formula->type != psiconv_formula_mark_opsep) && |
|
|
630 | (formula->type != psiconv_formula_mark_opend) && |
|
|
631 | (formula->type != psiconv_formula_mark_eof) && |
|
|
632 | (formula->type != psiconv_formula_unknown)) |
|
|
633 | psiconv_free_formula_list(formula->data.fun_operands); |
|
|
634 | } |
|
|
635 | |
|
|
636 | void psiconv_free_formula(psiconv_formula formula) |
|
|
637 | { |
|
|
638 | if (formula) { |
|
|
639 | psiconv_free_formula_aux(formula); |
|
|
640 | free(formula); |
|
|
641 | } |
|
|
642 | } |
|
|
643 | |
|
|
644 | void psiconv_free_formula_list(psiconv_formula_list list) |
|
|
645 | { |
|
|
646 | if (list) |
|
|
647 | psiconv_list_free_el(list,psiconv_free_formula_aux); |
|
|
648 | } |
|
|
649 | |
|
|
650 | void psiconv_free_sheet_workbook_section(psiconv_sheet_workbook_section section) |
|
|
651 | { |
|
|
652 | if (section) { |
|
|
653 | psiconv_free_formula_list(section->formulas); |
|
|
654 | psiconv_free_sheet_worksheet_list(section->worksheets); |
|
|
655 | free(section); |
|
|
656 | } |
|
|
657 | } |
|
|
658 | |
|
|
659 | void psiconv_free_sheet_f(psiconv_sheet_f file) |
|
|
660 | { |
|
|
661 | if (file) { |
|
|
662 | psiconv_free_page_layout_section(file->page_sec); |
|
|
663 | psiconv_free_sheet_status_section(file->status_sec); |
|
|
664 | psiconv_free_sheet_workbook_section(file->workbook_sec); |
517 | free(file); |
665 | free(file); |
518 | } |
666 | } |
519 | } |
667 | } |
520 | |
668 | |
521 | void psiconv_free_texted_f(psiconv_texted_f file) |
669 | void psiconv_free_texted_f(psiconv_texted_f file) |
… | |
… | |
620 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
768 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
621 | else if (file->type == psiconv_sketch_file) |
769 | else if (file->type == psiconv_sketch_file) |
622 | psiconv_free_sketch_f((psiconv_sketch_f) file->file); |
770 | psiconv_free_sketch_f((psiconv_sketch_f) file->file); |
623 | else if (file->type == psiconv_clipart_file) |
771 | else if (file->type == psiconv_clipart_file) |
624 | psiconv_free_clipart_f((psiconv_clipart_f) file->file); |
772 | psiconv_free_clipart_f((psiconv_clipart_f) file->file); |
|
|
773 | else if (file->type == psiconv_sheet_file) |
|
|
774 | psiconv_free_sheet_f((psiconv_sheet_f) file->file); |
625 | free(file); |
775 | free(file); |
626 | } |
776 | } |
627 | } |
777 | } |
|
|
778 | |
|
|
779 | int psiconv_compare_color(const psiconv_color value1, |
|
|
780 | const psiconv_color value2) |
|
|
781 | { |
|
|
782 | if (!value1 || !value2) |
|
|
783 | return 1; |
|
|
784 | if ((value1->red == value2->red) && |
|
|
785 | (value1->green == value2->green) && |
|
|
786 | (value1->blue == value2->blue)) |
|
|
787 | return 0; |
|
|
788 | else |
|
|
789 | return 1; |
|
|
790 | } |
|
|
791 | |
|
|
792 | int psiconv_compare_font(const psiconv_font value1, |
|
|
793 | const psiconv_font value2) |
|
|
794 | { |
|
|
795 | if (!value1 || !value2 || !value1->name || !value2->name) |
|
|
796 | return 1; |
|
|
797 | if ((value1->screenfont == value2->screenfont) && |
|
|
798 | !strcmp(value1->name,value2->name)) |
|
|
799 | return 0; |
|
|
800 | else |
|
|
801 | return 1; |
|
|
802 | } |
|
|
803 | |
|
|
804 | int psiconv_compare_border(const psiconv_border value1, |
|
|
805 | const psiconv_border value2) |
|
|
806 | { |
|
|
807 | if (!value1 || !value2) |
|
|
808 | return 1; |
|
|
809 | if ((value1->kind == value2->kind) && |
|
|
810 | (value1->thickness == value2->thickness) && |
|
|
811 | !psiconv_compare_color(value1->color,value2->color)) |
|
|
812 | return 0; |
|
|
813 | else |
|
|
814 | return 1; |
|
|
815 | } |
|
|
816 | |
|
|
817 | int psiconv_compare_bullet(const psiconv_bullet value1, |
|
|
818 | const psiconv_bullet value2) |
|
|
819 | { |
|
|
820 | if (!value1 || !value2) |
|
|
821 | return 1; |
|
|
822 | if ((value1->on == value2->on) && |
|
|
823 | (value1->font_size == value2->font_size) && |
|
|
824 | (value1->character == value2->character) && |
|
|
825 | (value1->indent == value2->indent) && |
|
|
826 | !psiconv_compare_color(value1->color,value2->color) && |
|
|
827 | !psiconv_compare_font(value1->font,value2->font)) |
|
|
828 | return 0; |
|
|
829 | else |
|
|
830 | return 1; |
|
|
831 | } |
|
|
832 | |
|
|
833 | int psiconv_compare_tab(const psiconv_tab value1, const psiconv_tab value2) |
|
|
834 | { |
|
|
835 | if (!value1 || !value2) |
|
|
836 | return 1; |
|
|
837 | if ((value1->location == value2->location) && |
|
|
838 | (value1->kind == value2->kind)) |
|
|
839 | return 0; |
|
|
840 | else |
|
|
841 | return 1; |
|
|
842 | } |
|
|
843 | |
|
|
844 | int psiconv_compare_all_tabs(const psiconv_all_tabs value1, |
|
|
845 | const psiconv_all_tabs value2) |
|
|
846 | { |
|
|
847 | int i; |
|
|
848 | |
|
|
849 | if (!value1 || !value2 || !value1->extras || !value2->extras) |
|
|
850 | return 1; |
|
|
851 | |
|
|
852 | if ((value1->normal != value2->normal) || |
|
|
853 | psiconv_list_length(value1->extras) != |
|
|
854 | psiconv_list_length(value2->extras)) |
|
|
855 | return 1; |
|
|
856 | for (i = 0; i < psiconv_list_length(value1->extras); i++) |
|
|
857 | if (psiconv_compare_tab(psiconv_list_get(value1->extras,i), |
|
|
858 | psiconv_list_get(value2->extras,i))) |
|
|
859 | |
|
|
860 | return 1; |
|
|
861 | return 0; |
|
|
862 | } |
|
|
863 | |
|
|
864 | int psiconv_compare_paragraph_layout(const psiconv_paragraph_layout value1, |
|
|
865 | const psiconv_paragraph_layout value2) |
|
|
866 | { |
|
|
867 | if (!value1 || !value2) |
|
|
868 | return 1; |
|
|
869 | if ((value1->indent_left == value2->indent_left) && |
|
|
870 | (value1->indent_right == value2->indent_right) && |
|
|
871 | (value1->indent_first == value2->indent_first) && |
|
|
872 | (value1->justify_hor == value2->justify_hor) && |
|
|
873 | (value1->justify_ver == value2->justify_ver) && |
|
|
874 | (value1->linespacing == value2->linespacing) && |
|
|
875 | (value1->space_above == value2->space_above) && |
|
|
876 | (value1->space_below == value2->space_below) && |
|
|
877 | (value1->keep_together == value2->keep_together) && |
|
|
878 | (value1->keep_with_next == value2->keep_with_next) && |
|
|
879 | (value1->on_next_page == value2->on_next_page) && |
|
|
880 | (value1->no_widow_protection == value2->no_widow_protection) && |
|
|
881 | (value1->border_distance == value2->border_distance) && |
|
|
882 | !psiconv_compare_color(value1->back_color,value2->back_color) && |
|
|
883 | !psiconv_compare_bullet(value1->bullet,value2->bullet) && |
|
|
884 | !psiconv_compare_border(value1->left_border,value2->left_border) && |
|
|
885 | !psiconv_compare_border(value1->right_border,value2->right_border) && |
|
|
886 | !psiconv_compare_border(value1->top_border,value2->top_border) && |
|
|
887 | !psiconv_compare_border(value1->bottom_border,value2->bottom_border) && |
|
|
888 | !psiconv_compare_all_tabs(value1->tabs,value2->tabs)) |
|
|
889 | return 0; |
|
|
890 | else |
|
|
891 | return 1; |
|
|
892 | } |
|
|
893 | |
|
|
894 | |
|
|
895 | int psiconv_compare_character_layout(const psiconv_character_layout value1, |
|
|
896 | const psiconv_character_layout value2) |
|
|
897 | { |
|
|
898 | if (!value1 || !value2) |
|
|
899 | return 1; |
|
|
900 | if ((value1->font_size == value2->font_size) && |
|
|
901 | (value1->italic == value2->italic) && |
|
|
902 | (value1->bold == value2->bold) && |
|
|
903 | (value1->super_sub == value2->super_sub) && |
|
|
904 | (value1->underline == value2->underline) && |
|
|
905 | (value1->strikethrough == value2->strikethrough) && |
|
|
906 | !psiconv_compare_color(value1->color,value2->color) && |
|
|
907 | !psiconv_compare_color(value1->back_color,value2->back_color) && |
|
|
908 | !psiconv_compare_font(value1->font,value2->font)) |
|
|
909 | return 0; |
|
|
910 | else |
|
|
911 | return 1; |
|
|
912 | } |
|
|
913 | |
|
|
914 | |
|
|
915 | |
|
|
916 | psiconv_word_styles_section psiconv_empty_word_styles_section(void) |
|
|
917 | { |
|
|
918 | psiconv_word_styles_section result; |
|
|
919 | if (!(result = malloc(sizeof(*result)))) |
|
|
920 | goto ERROR1; |
|
|
921 | if (!(result->styles = psiconv_list_new(sizeof(struct psiconv_word_style_s)))) |
|
|
922 | goto ERROR2; |
|
|
923 | if (!(result->normal = malloc(sizeof(struct psiconv_word_style_s)))) |
|
|
924 | goto ERROR3; |
|
|
925 | if (!(result->normal->character = psiconv_basic_character_layout())) |
|
|
926 | goto ERROR4; |
|
|
927 | if (!(result->normal->paragraph = psiconv_basic_paragraph_layout())) |
|
|
928 | goto ERROR5; |
|
|
929 | result->normal->hotkey = 'N'; |
|
|
930 | result->normal->name = NULL; |
|
|
931 | result->normal->built_in = psiconv_bool_true; |
|
|
932 | result->normal->outline_level = 0; |
|
|
933 | return result; |
|
|
934 | ERROR5: |
|
|
935 | psiconv_free_character_layout(result->normal->character); |
|
|
936 | ERROR4: |
|
|
937 | free(result->normal); |
|
|
938 | ERROR3: |
|
|
939 | psiconv_list_free(result->styles); |
|
|
940 | ERROR2: |
|
|
941 | free(result); |
|
|
942 | ERROR1: |
|
|
943 | return NULL; |
|
|
944 | } |
|
|
945 | |
|
|
946 | psiconv_text_and_layout psiconv_empty_text_and_layout(void) |
|
|
947 | { |
|
|
948 | return psiconv_list_new(sizeof(struct psiconv_paragraph_s)); |
|
|
949 | } |
|
|
950 | |
|
|
951 | psiconv_texted_section psiconv_empty_texted_section(void) |
|
|
952 | { |
|
|
953 | psiconv_texted_section result; |
|
|
954 | if (!(result = malloc(sizeof(*result)))) |
|
|
955 | goto ERROR1; |
|
|
956 | if (!(result->paragraphs = psiconv_empty_text_and_layout())) |
|
|
957 | goto ERROR2; |
|
|
958 | return result; |
|
|
959 | ERROR2: |
|
|
960 | free(result); |
|
|
961 | ERROR1: |
|
|
962 | return NULL; |
|
|
963 | } |
|
|
964 | |
|
|
965 | psiconv_page_header psiconv_empty_page_header(void) |
|
|
966 | { |
|
|
967 | psiconv_page_header result; |
|
|
968 | if (!(result = malloc(sizeof(*result)))) |
|
|
969 | goto ERROR1; |
|
|
970 | result->on_first_page = psiconv_bool_true; |
|
|
971 | if (!(result->base_paragraph_layout = psiconv_basic_paragraph_layout())) |
|
|
972 | goto ERROR2; |
|
|
973 | if (!(result->base_character_layout = psiconv_basic_character_layout())) |
|
|
974 | goto ERROR3; |
|
|
975 | if (!(result->text = psiconv_empty_texted_section())) |
|
|
976 | goto ERROR4; |
|
|
977 | return result; |
|
|
978 | ERROR4: |
|
|
979 | psiconv_free_character_layout(result->base_character_layout); |
|
|
980 | ERROR3: |
|
|
981 | psiconv_free_paragraph_layout(result->base_paragraph_layout); |
|
|
982 | ERROR2: |
|
|
983 | free(result); |
|
|
984 | ERROR1: |
|
|
985 | return NULL; |
|
|
986 | } |
|
|
987 | |
|
|
988 | psiconv_page_layout_section psiconv_empty_page_layout_section(void) |
|
|
989 | { |
|
|
990 | psiconv_page_layout_section result; |
|
|
991 | if (!(result = malloc(sizeof(*result)))) |
|
|
992 | goto ERROR1; |
|
|
993 | result->first_page_nr = 1; |
|
|
994 | result->header_dist = result->footer_dist = 1.27; |
|
|
995 | result->left_margin = result->right_margin = 3.175; |
|
|
996 | result->top_margin = result->bottom_margin = 2.54; |
|
|
997 | result->page_width = 21.0; |
|
|
998 | result->page_height = 29.7; |
|
|
999 | result->landscape = psiconv_bool_false; |
|
|
1000 | if (!(result->header = psiconv_empty_page_header())) |
|
|
1001 | goto ERROR2; |
|
|
1002 | if (!(result->footer = psiconv_empty_page_header())) |
|
|
1003 | goto ERROR3; |
|
|
1004 | return result; |
|
|
1005 | ERROR3: |
|
|
1006 | psiconv_free_page_header(result->header); |
|
|
1007 | ERROR2: |
|
|
1008 | free(result); |
|
|
1009 | ERROR1: |
|
|
1010 | return NULL; |
|
|
1011 | } |
|
|
1012 | |
|
|
1013 | psiconv_word_status_section psiconv_empty_word_status_section(void) |
|
|
1014 | { |
|
|
1015 | psiconv_word_status_section result; |
|
|
1016 | if (!(result = malloc(sizeof(*result)))) |
|
|
1017 | return NULL; |
|
|
1018 | result->show_tabs = result->show_spaces = result->show_paragraph_ends = |
|
|
1019 | result->show_hard_minus = result->show_hard_space = |
|
|
1020 | result->fit_lines_to_screen = psiconv_bool_false; |
|
|
1021 | result->show_full_pictures = result->show_full_graphs = |
|
|
1022 | result->show_top_toolbar = result->show_side_toolbar = |
|
|
1023 | psiconv_bool_true; |
|
|
1024 | result->cursor_position = 0; |
|
|
1025 | result->display_size = 1000; |
|
|
1026 | return result; |
|
|
1027 | } |
|
|
1028 | |
|
|
1029 | psiconv_word_f psiconv_empty_word_f(void) |
|
|
1030 | { |
|
|
1031 | psiconv_word_f result; |
|
|
1032 | if (!(result = malloc(sizeof(*result)))) |
|
|
1033 | goto ERROR1; |
|
|
1034 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1035 | goto ERROR2; |
|
|
1036 | if (!(result->paragraphs = psiconv_empty_text_and_layout())) |
|
|
1037 | goto ERROR3; |
|
|
1038 | if (!(result->status_sec = psiconv_empty_word_status_section())) |
|
|
1039 | goto ERROR4; |
|
|
1040 | if (!(result->styles_sec = psiconv_empty_word_styles_section())) |
|
|
1041 | goto ERROR5; |
|
|
1042 | return result; |
|
|
1043 | ERROR5: |
|
|
1044 | psiconv_free_word_status_section(result->status_sec); |
|
|
1045 | ERROR4: |
|
|
1046 | psiconv_free_text_and_layout(result->paragraphs); |
|
|
1047 | ERROR3: |
|
|
1048 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1049 | ERROR2: |
|
|
1050 | free(result); |
|
|
1051 | ERROR1: |
|
|
1052 | return NULL; |
|
|
1053 | } |
|
|
1054 | |
|
|
1055 | psiconv_sheet_status_section psiconv_empty_sheet_status_section(void) |
|
|
1056 | { |
|
|
1057 | psiconv_sheet_status_section result; |
|
|
1058 | if (!(result = malloc(sizeof(*result)))) |
|
|
1059 | return NULL; |
|
|
1060 | result->show_horizontal_scrollbar = result->show_vertical_scrollbar = |
|
|
1061 | psiconv_triple_auto; |
|
|
1062 | result->show_graph = psiconv_bool_false; |
|
|
1063 | result->show_top_sheet_toolbar = result->show_side_sheet_toolbar = |
|
|
1064 | result->show_top_graph_toolbar = result->show_side_graph_toolbar = |
|
|
1065 | psiconv_bool_true; |
|
|
1066 | result->cursor_row = result->cursor_column = 0; |
|
|
1067 | result->sheet_display_size = result->graph_display_size = 1000; |
|
|
1068 | return result; |
|
|
1069 | } |
|
|
1070 | |
|
|
1071 | psiconv_formula_list psiconv_empty_formula_list(void) |
|
|
1072 | { |
|
|
1073 | return psiconv_list_new(sizeof(struct psiconv_formula_s)); |
|
|
1074 | } |
|
|
1075 | |
|
|
1076 | psiconv_sheet_workbook_section psiconv_empty_sheet_workbook_section(void) |
|
|
1077 | { |
|
|
1078 | psiconv_sheet_workbook_section result; |
|
|
1079 | if (!(result = malloc(sizeof(*result)))) |
|
|
1080 | goto ERROR1; |
|
|
1081 | if (!(result->formulas = psiconv_empty_formula_list())) |
|
|
1082 | goto ERROR2; |
|
|
1083 | return result; |
|
|
1084 | ERROR2: |
|
|
1085 | free(result); |
|
|
1086 | ERROR1: |
|
|
1087 | return NULL; |
|
|
1088 | } |
|
|
1089 | |
|
|
1090 | |
|
|
1091 | psiconv_sheet_f psiconv_empty_sheet_f(void) |
|
|
1092 | { |
|
|
1093 | psiconv_sheet_f result; |
|
|
1094 | if (!(result = malloc(sizeof(*result)))) |
|
|
1095 | goto ERROR1; |
|
|
1096 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1097 | goto ERROR2; |
|
|
1098 | if (!(result->status_sec = psiconv_empty_sheet_status_section())) |
|
|
1099 | goto ERROR3; |
|
|
1100 | if (!(result->workbook_sec = psiconv_empty_sheet_workbook_section())) |
|
|
1101 | goto ERROR4; |
|
|
1102 | return result; |
|
|
1103 | ERROR4: |
|
|
1104 | psiconv_free_sheet_status_section(result->status_sec); |
|
|
1105 | ERROR3: |
|
|
1106 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1107 | ERROR2: |
|
|
1108 | free(result); |
|
|
1109 | ERROR1: |
|
|
1110 | return NULL; |
|
|
1111 | } |
|
|
1112 | |
|
|
1113 | psiconv_texted_f psiconv_empty_texted_f(void) |
|
|
1114 | { |
|
|
1115 | psiconv_texted_f result; |
|
|
1116 | if (!(result = malloc(sizeof(*result)))) |
|
|
1117 | goto ERROR1; |
|
|
1118 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1119 | goto ERROR2; |
|
|
1120 | if (!(result->texted_sec = psiconv_empty_texted_section())) |
|
|
1121 | goto ERROR3; |
|
|
1122 | return result; |
|
|
1123 | ERROR3: |
|
|
1124 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1125 | ERROR2: |
|
|
1126 | free(result); |
|
|
1127 | ERROR1: |
|
|
1128 | return NULL; |
|
|
1129 | } |
|
|
1130 | |
|
|
1131 | psiconv_paint_data_section psiconv_empty_paint_data_section(void) |
|
|
1132 | { |
|
|
1133 | psiconv_paint_data_section result; |
|
|
1134 | if (!(result = malloc(sizeof(*result)))) |
|
|
1135 | goto ERROR1; |
|
|
1136 | /* Is this correct? */ |
|
|
1137 | result->xsize = result->ysize = result->pic_xsize = result->pic_ysize = 0; |
|
|
1138 | /* Probably forbidden... */ |
|
|
1139 | if (!(result->red = malloc(0))) |
|
|
1140 | goto ERROR2; |
|
|
1141 | if (!(result->green = malloc(0))) |
|
|
1142 | goto ERROR3; |
|
|
1143 | if (!(result->blue = malloc(0))) |
|
|
1144 | goto ERROR4; |
|
|
1145 | return result; |
|
|
1146 | ERROR4: |
|
|
1147 | free(result->green); |
|
|
1148 | ERROR3: |
|
|
1149 | free(result->red); |
|
|
1150 | ERROR2: |
|
|
1151 | free(result); |
|
|
1152 | ERROR1: |
|
|
1153 | return NULL; |
|
|
1154 | } |
|
|
1155 | |
|
|
1156 | |
|
|
1157 | psiconv_pictures psiconv_empty_pictures(void) |
|
|
1158 | { |
|
|
1159 | psiconv_pictures result; |
|
|
1160 | psiconv_paint_data_section pds; |
|
|
1161 | if (!(result = psiconv_list_new(sizeof(struct psiconv_paint_data_section_s)))) |
|
|
1162 | goto ERROR1; |
|
|
1163 | if (!(pds = psiconv_empty_paint_data_section())) |
|
|
1164 | goto ERROR2; |
|
|
1165 | if (psiconv_list_add(result,pds)) |
|
|
1166 | goto ERROR3; |
|
|
1167 | free(pds); |
|
|
1168 | return result; |
|
|
1169 | ERROR3: |
|
|
1170 | psiconv_free_paint_data_section(pds); |
|
|
1171 | ERROR2: |
|
|
1172 | psiconv_list_free(result); |
|
|
1173 | ERROR1: |
|
|
1174 | return NULL; |
|
|
1175 | } |
|
|
1176 | |
|
|
1177 | psiconv_mbm_f psiconv_empty_mbm_f(void) |
|
|
1178 | { |
|
|
1179 | psiconv_mbm_f result; |
|
|
1180 | if (!(result = malloc(sizeof(*result)))) |
|
|
1181 | goto ERROR1; |
|
|
1182 | if (!(result->sections = psiconv_empty_pictures())) |
|
|
1183 | goto ERROR2; |
|
|
1184 | return result; |
|
|
1185 | ERROR2: |
|
|
1186 | free(result); |
|
|
1187 | ERROR1: |
|
|
1188 | return NULL; |
|
|
1189 | } |
|
|
1190 | |
|
|
1191 | psiconv_sketch_section psiconv_empty_sketch_section(void) |
|
|
1192 | { |
|
|
1193 | psiconv_sketch_section result; |
|
|
1194 | if (!(result = malloc(sizeof(*result)))) |
|
|
1195 | goto ERROR1; |
|
|
1196 | result->form_xsize = 320; |
|
|
1197 | result->form_ysize = 200; |
|
|
1198 | result->picture_x_offset = result->picture_y_offset = result->picture_xsize = |
|
|
1199 | result->picture_ysize = 0; |
|
|
1200 | result->magnification_x = result->magnification_y = 1.0; |
|
|
1201 | result->cut_left = result->cut_right = result->cut_top = |
|
|
1202 | result->cut_bottom = 0.0; |
|
|
1203 | if (!(result->picture = psiconv_empty_paint_data_section())) |
|
|
1204 | goto ERROR2; |
|
|
1205 | return result; |
|
|
1206 | ERROR2: |
|
|
1207 | free(result); |
|
|
1208 | ERROR1: |
|
|
1209 | return NULL; |
|
|
1210 | } |
|
|
1211 | |
|
|
1212 | psiconv_sketch_f psiconv_empty_sketch_f(void) |
|
|
1213 | { |
|
|
1214 | psiconv_sketch_f result; |
|
|
1215 | if (!(result = malloc(sizeof(*result)))) |
|
|
1216 | goto ERROR1; |
|
|
1217 | if (!(result->sketch_sec = psiconv_empty_sketch_section())) |
|
|
1218 | goto ERROR2; |
|
|
1219 | return result; |
|
|
1220 | ERROR2: |
|
|
1221 | free(result); |
|
|
1222 | ERROR1: |
|
|
1223 | return NULL; |
|
|
1224 | } |
|
|
1225 | |
|
|
1226 | psiconv_cliparts psiconv_empty_cliparts(void) |
|
|
1227 | { |
|
|
1228 | /* Is this correct? */ |
|
|
1229 | return psiconv_list_new(sizeof(struct psiconv_clipart_section_s)); |
|
|
1230 | } |
|
|
1231 | |
|
|
1232 | psiconv_clipart_f psiconv_empty_clipart_f(void) |
|
|
1233 | { |
|
|
1234 | psiconv_clipart_f result; |
|
|
1235 | if (!(result = malloc(sizeof(*result)))) |
|
|
1236 | goto ERROR1; |
|
|
1237 | if (!(result->sections = psiconv_empty_cliparts())) |
|
|
1238 | goto ERROR2; |
|
|
1239 | return result; |
|
|
1240 | ERROR2: |
|
|
1241 | free(result); |
|
|
1242 | ERROR1: |
|
|
1243 | return NULL; |
|
|
1244 | } |
|
|
1245 | |
|
|
1246 | psiconv_file psiconv_empty_file(psiconv_file_type_t type) |
|
|
1247 | { |
|
|
1248 | psiconv_file result; |
|
|
1249 | if (!(result = malloc(sizeof(*result)))) |
|
|
1250 | return NULL; |
|
|
1251 | result->type = type; |
|
|
1252 | if (type == psiconv_word_file) { |
|
|
1253 | if (!(result->file = psiconv_empty_word_f())) |
|
|
1254 | goto ERROR; |
|
|
1255 | } else if (type == psiconv_sheet_file) { |
|
|
1256 | if (!(result->file = psiconv_empty_sheet_f())) |
|
|
1257 | goto ERROR; |
|
|
1258 | } else if (type == psiconv_texted_file) { |
|
|
1259 | if (!(result->file = psiconv_empty_texted_f())) |
|
|
1260 | goto ERROR; |
|
|
1261 | } else if (type == psiconv_mbm_file) { |
|
|
1262 | if (!(result->file = psiconv_empty_mbm_f())) |
|
|
1263 | goto ERROR; |
|
|
1264 | } else if (type == psiconv_sketch_file) { |
|
|
1265 | if (!(result->file = psiconv_empty_sketch_f())) |
|
|
1266 | goto ERROR; |
|
|
1267 | } else if (type == psiconv_clipart_file) { |
|
|
1268 | if (!(result->file = psiconv_empty_clipart_f())) |
|
|
1269 | goto ERROR; |
|
|
1270 | } else |
|
|
1271 | goto ERROR; |
|
|
1272 | return result; |
|
|
1273 | ERROR: |
|
|
1274 | free(result); |
|
|
1275 | return NULL; |
|
|
1276 | } |