… | |
… | |
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 | |
|
|
39 | static psiconv_word_styles_section psiconv_empty_word_styles_section(void); |
|
|
40 | static psiconv_text_and_layout psiconv_empty_text_and_layout(void); |
|
|
41 | static psiconv_texted_section psiconv_empty_texted_section(void); |
|
|
42 | static psiconv_page_header psiconv_empty_page_header(void); |
|
|
43 | static psiconv_page_layout_section psiconv_empty_page_layout_section(void); |
|
|
44 | static psiconv_word_status_section psiconv_empty_word_status_section(void); |
|
|
45 | static psiconv_word_f psiconv_empty_word_f(void); |
|
|
46 | static psiconv_sheet_status_section psiconv_empty_sheet_status_section(void); |
|
|
47 | static psiconv_formula_list psiconv_empty_formula_list(void); |
|
|
48 | static psiconv_sheet_workbook_section |
|
|
49 | psiconv_empty_sheet_workbook_section(void); |
|
|
50 | static psiconv_sheet_f psiconv_empty_sheet_f(void); |
|
|
51 | static psiconv_texted_f psiconv_empty_texted_f(void); |
|
|
52 | static psiconv_paint_data_section psiconv_empty_paint_data_section(void); |
|
|
53 | static psiconv_pictures psiconv_empty_pictures(void); |
|
|
54 | static psiconv_mbm_f psiconv_empty_mbm_f(void); |
|
|
55 | static psiconv_sketch_section psiconv_empty_sketch_section(void); |
|
|
56 | static psiconv_sketch_f psiconv_empty_sketch_f(void); |
|
|
57 | static psiconv_clipart_f psiconv_empty_clipart_f(void); |
|
|
58 | static psiconv_cliparts psiconv_empty_cliparts(void); |
|
|
59 | |
36 | |
60 | |
37 | /* Note: these defaults seem to be hard-coded somewhere outside the |
61 | /* Note: these defaults seem to be hard-coded somewhere outside the |
38 | files themself. */ |
62 | files themself. */ |
39 | psiconv_character_layout psiconv_basic_character_layout(void) |
63 | psiconv_character_layout psiconv_basic_character_layout(void) |
40 | { |
64 | { |
… | |
… | |
127 | 0.0, /* space_below */ |
151 | 0.0, /* space_below */ |
128 | psiconv_bool_false, /* keep_together */ |
152 | psiconv_bool_false, /* keep_together */ |
129 | psiconv_bool_false, /* keep_with_next */ |
153 | psiconv_bool_false, /* keep_with_next */ |
130 | psiconv_bool_false, /* on_next_page */ |
154 | psiconv_bool_false, /* on_next_page */ |
131 | psiconv_bool_false, /* no_widow_protection */ |
155 | psiconv_bool_false, /* no_widow_protection */ |
|
|
156 | psiconv_bool_false, /* wrap_to_fit_cell */ |
132 | 0.0, /* left_margin */ |
157 | 0.0, /* left_margin */ |
133 | &bullet, /* bullet */ |
158 | &bullet, /* bullet */ |
134 | &no_border, /* left_border */ |
159 | &no_border, /* left_border */ |
135 | &no_border, /* right_border */ |
160 | &no_border, /* right_border */ |
136 | &no_border, /* top_border */ |
161 | &no_border, /* top_border */ |
… | |
… | |
516 | psiconv_free_word_styles_section(file->styles_sec); |
541 | psiconv_free_word_styles_section(file->styles_sec); |
517 | free(file); |
542 | free(file); |
518 | } |
543 | } |
519 | } |
544 | } |
520 | |
545 | |
|
|
546 | void psiconv_free_sheet_status_section(psiconv_sheet_status_section section) |
|
|
547 | { |
|
|
548 | if (section) |
|
|
549 | free(section); |
|
|
550 | } |
|
|
551 | |
|
|
552 | void psiconv_free_formula_aux(void *data) |
|
|
553 | { |
|
|
554 | psiconv_formula formula; |
|
|
555 | formula = data; |
|
|
556 | if (formula->type == psiconv_formula_dat_string) |
|
|
557 | free(formula->data.dat_string); |
|
|
558 | else if ((formula->type != psiconv_formula_dat_int) && |
|
|
559 | (formula->type != psiconv_formula_dat_var) && |
|
|
560 | (formula->type != psiconv_formula_dat_float) && |
|
|
561 | (formula->type != psiconv_formula_dat_cellref) && |
|
|
562 | (formula->type != psiconv_formula_dat_cellblock) && |
|
|
563 | (formula->type != psiconv_formula_dat_vcellblock) && |
|
|
564 | (formula->type != psiconv_formula_mark_opsep) && |
|
|
565 | (formula->type != psiconv_formula_mark_opend) && |
|
|
566 | (formula->type != psiconv_formula_mark_eof) && |
|
|
567 | (formula->type != psiconv_formula_unknown)) |
|
|
568 | psiconv_free_formula_list(formula->data.fun_operands); |
|
|
569 | } |
|
|
570 | |
|
|
571 | void psiconv_free_formula(psiconv_formula formula) |
|
|
572 | { |
|
|
573 | if (formula) { |
|
|
574 | psiconv_free_formula_aux(formula); |
|
|
575 | free(formula); |
|
|
576 | } |
|
|
577 | } |
|
|
578 | |
|
|
579 | void psiconv_free_formula_list(psiconv_formula_list list) |
|
|
580 | { |
|
|
581 | if (list) |
|
|
582 | psiconv_list_free_el(list,psiconv_free_formula_aux); |
|
|
583 | } |
|
|
584 | |
|
|
585 | void psiconv_free_sheet_workbook_section(psiconv_sheet_workbook_section section) |
|
|
586 | { |
|
|
587 | if (section) { |
|
|
588 | psiconv_free_formula_list(section->formulas); |
|
|
589 | free(section); |
|
|
590 | } |
|
|
591 | } |
|
|
592 | |
|
|
593 | void psiconv_free_sheet_f(psiconv_sheet_f file) |
|
|
594 | { |
|
|
595 | if (file) { |
|
|
596 | psiconv_free_page_layout_section(file->page_sec); |
|
|
597 | psiconv_free_sheet_status_section(file->status_sec); |
|
|
598 | psiconv_free_sheet_workbook_section(file->workbook_sec); |
|
|
599 | free(file); |
|
|
600 | } |
|
|
601 | } |
|
|
602 | |
521 | void psiconv_free_texted_f(psiconv_texted_f file) |
603 | void psiconv_free_texted_f(psiconv_texted_f file) |
522 | { |
604 | { |
523 | if (file) { |
605 | if (file) { |
524 | psiconv_free_page_layout_section(file->page_sec); |
606 | psiconv_free_page_layout_section(file->page_sec); |
525 | psiconv_free_texted_section(file->texted_sec); |
607 | psiconv_free_texted_section(file->texted_sec); |
… | |
… | |
620 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
702 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
621 | else if (file->type == psiconv_sketch_file) |
703 | else if (file->type == psiconv_sketch_file) |
622 | psiconv_free_sketch_f((psiconv_sketch_f) file->file); |
704 | psiconv_free_sketch_f((psiconv_sketch_f) file->file); |
623 | else if (file->type == psiconv_clipart_file) |
705 | else if (file->type == psiconv_clipart_file) |
624 | psiconv_free_clipart_f((psiconv_clipart_f) file->file); |
706 | psiconv_free_clipart_f((psiconv_clipart_f) file->file); |
|
|
707 | else if (file->type == psiconv_sheet_file) |
|
|
708 | psiconv_free_sheet_f((psiconv_sheet_f) file->file); |
625 | free(file); |
709 | free(file); |
626 | } |
710 | } |
627 | } |
711 | } |
|
|
712 | |
|
|
713 | int psiconv_compare_color(const psiconv_color value1, |
|
|
714 | const psiconv_color value2) |
|
|
715 | { |
|
|
716 | if (!value1 || !value2) |
|
|
717 | return 1; |
|
|
718 | if ((value1->red == value2->red) && |
|
|
719 | (value1->green == value2->green) && |
|
|
720 | (value1->blue == value2->blue)) |
|
|
721 | return 0; |
|
|
722 | else |
|
|
723 | return 1; |
|
|
724 | } |
|
|
725 | |
|
|
726 | int psiconv_compare_font(const psiconv_font value1, |
|
|
727 | const psiconv_font value2) |
|
|
728 | { |
|
|
729 | if (!value1 || !value2 || !value1->name || !value2->name) |
|
|
730 | return 1; |
|
|
731 | if ((value1->screenfont == value2->screenfont) && |
|
|
732 | !strcmp(value1->name,value2->name)) |
|
|
733 | return 0; |
|
|
734 | else |
|
|
735 | return 1; |
|
|
736 | } |
|
|
737 | |
|
|
738 | int psiconv_compare_border(const psiconv_border value1, |
|
|
739 | const psiconv_border value2) |
|
|
740 | { |
|
|
741 | if (!value1 || !value2) |
|
|
742 | return 1; |
|
|
743 | if ((value1->kind == value2->kind) && |
|
|
744 | (value1->thickness == value2->thickness) && |
|
|
745 | !psiconv_compare_color(value1->color,value2->color)) |
|
|
746 | return 0; |
|
|
747 | else |
|
|
748 | return 1; |
|
|
749 | } |
|
|
750 | |
|
|
751 | int psiconv_compare_bullet(const psiconv_bullet value1, |
|
|
752 | const psiconv_bullet value2) |
|
|
753 | { |
|
|
754 | if (!value1 || !value2) |
|
|
755 | return 1; |
|
|
756 | if ((value1->on == value2->on) && |
|
|
757 | (value1->font_size == value2->font_size) && |
|
|
758 | (value1->character == value2->character) && |
|
|
759 | (value1->indent == value2->indent) && |
|
|
760 | !psiconv_compare_color(value1->color,value2->color) && |
|
|
761 | !psiconv_compare_font(value1->font,value2->font)) |
|
|
762 | return 0; |
|
|
763 | else |
|
|
764 | return 1; |
|
|
765 | } |
|
|
766 | |
|
|
767 | int psiconv_compare_tab(const psiconv_tab value1, const psiconv_tab value2) |
|
|
768 | { |
|
|
769 | if (!value1 || !value2) |
|
|
770 | return 1; |
|
|
771 | if ((value1->location == value2->location) && |
|
|
772 | (value1->kind == value2->kind)) |
|
|
773 | return 0; |
|
|
774 | else |
|
|
775 | return 1; |
|
|
776 | } |
|
|
777 | |
|
|
778 | int psiconv_compare_all_tabs(const psiconv_all_tabs value1, |
|
|
779 | const psiconv_all_tabs value2) |
|
|
780 | { |
|
|
781 | int i; |
|
|
782 | |
|
|
783 | if (!value1 || !value2 || !value1->extras || !value2->extras) |
|
|
784 | return 1; |
|
|
785 | |
|
|
786 | if ((value1->normal != value2->normal) || |
|
|
787 | psiconv_list_length(value1->extras) != |
|
|
788 | psiconv_list_length(value2->extras)) |
|
|
789 | return 1; |
|
|
790 | for (i = 0; i < psiconv_list_length(value1->extras); i++) |
|
|
791 | if (psiconv_compare_tab(psiconv_list_get(value1->extras,i), |
|
|
792 | psiconv_list_get(value2->extras,i))) |
|
|
793 | |
|
|
794 | return 1; |
|
|
795 | return 0; |
|
|
796 | } |
|
|
797 | |
|
|
798 | int psiconv_compare_paragraph_layout(const psiconv_paragraph_layout value1, |
|
|
799 | const psiconv_paragraph_layout value2) |
|
|
800 | { |
|
|
801 | if (!value1 || !value2) |
|
|
802 | return 1; |
|
|
803 | if ((value1->indent_left == value2->indent_left) && |
|
|
804 | (value1->indent_right == value2->indent_right) && |
|
|
805 | (value1->indent_first == value2->indent_first) && |
|
|
806 | (value1->justify_hor == value2->justify_hor) && |
|
|
807 | (value1->justify_ver == value2->justify_ver) && |
|
|
808 | (value1->linespacing == value2->linespacing) && |
|
|
809 | (value1->space_above == value2->space_above) && |
|
|
810 | (value1->space_below == value2->space_below) && |
|
|
811 | (value1->keep_together == value2->keep_together) && |
|
|
812 | (value1->keep_with_next == value2->keep_with_next) && |
|
|
813 | (value1->on_next_page == value2->on_next_page) && |
|
|
814 | (value1->no_widow_protection == value2->no_widow_protection) && |
|
|
815 | (value1->border_distance == value2->border_distance) && |
|
|
816 | !psiconv_compare_color(value1->back_color,value2->back_color) && |
|
|
817 | !psiconv_compare_bullet(value1->bullet,value2->bullet) && |
|
|
818 | !psiconv_compare_border(value1->left_border,value2->left_border) && |
|
|
819 | !psiconv_compare_border(value1->right_border,value2->right_border) && |
|
|
820 | !psiconv_compare_border(value1->top_border,value2->top_border) && |
|
|
821 | !psiconv_compare_border(value1->bottom_border,value2->bottom_border) && |
|
|
822 | !psiconv_compare_all_tabs(value1->tabs,value2->tabs)) |
|
|
823 | return 0; |
|
|
824 | else |
|
|
825 | return 1; |
|
|
826 | } |
|
|
827 | |
|
|
828 | |
|
|
829 | int psiconv_compare_character_layout(const psiconv_character_layout value1, |
|
|
830 | const psiconv_character_layout value2) |
|
|
831 | { |
|
|
832 | if (!value1 || !value2) |
|
|
833 | return 1; |
|
|
834 | if ((value1->font_size == value2->font_size) && |
|
|
835 | (value1->italic == value2->italic) && |
|
|
836 | (value1->bold == value2->bold) && |
|
|
837 | (value1->super_sub == value2->super_sub) && |
|
|
838 | (value1->underline == value2->underline) && |
|
|
839 | (value1->strikethrough == value2->strikethrough) && |
|
|
840 | !psiconv_compare_color(value1->color,value2->color) && |
|
|
841 | !psiconv_compare_color(value1->back_color,value2->back_color) && |
|
|
842 | !psiconv_compare_font(value1->font,value2->font)) |
|
|
843 | return 0; |
|
|
844 | else |
|
|
845 | return 1; |
|
|
846 | } |
|
|
847 | |
|
|
848 | |
|
|
849 | |
|
|
850 | psiconv_word_styles_section psiconv_empty_word_styles_section(void) |
|
|
851 | { |
|
|
852 | psiconv_word_styles_section result; |
|
|
853 | if (!(result = malloc(sizeof(*result)))) |
|
|
854 | goto ERROR1; |
|
|
855 | if (!(result->styles = psiconv_list_new(sizeof(struct psiconv_word_style_s)))) |
|
|
856 | goto ERROR2; |
|
|
857 | if (!(result->normal = malloc(sizeof(struct psiconv_word_style_s)))) |
|
|
858 | goto ERROR3; |
|
|
859 | if (!(result->normal->character = psiconv_basic_character_layout())) |
|
|
860 | goto ERROR4; |
|
|
861 | if (!(result->normal->paragraph = psiconv_basic_paragraph_layout())) |
|
|
862 | goto ERROR5; |
|
|
863 | result->normal->hotkey = 'N'; |
|
|
864 | result->normal->name = NULL; |
|
|
865 | result->normal->built_in = psiconv_bool_true; |
|
|
866 | result->normal->outline_level = 0; |
|
|
867 | return result; |
|
|
868 | ERROR5: |
|
|
869 | psiconv_free_character_layout(result->normal->character); |
|
|
870 | ERROR4: |
|
|
871 | free(result->normal); |
|
|
872 | ERROR3: |
|
|
873 | psiconv_list_free(result->styles); |
|
|
874 | ERROR2: |
|
|
875 | free(result); |
|
|
876 | ERROR1: |
|
|
877 | return NULL; |
|
|
878 | } |
|
|
879 | |
|
|
880 | psiconv_text_and_layout psiconv_empty_text_and_layout(void) |
|
|
881 | { |
|
|
882 | return psiconv_list_new(sizeof(struct psiconv_paragraph_s)); |
|
|
883 | } |
|
|
884 | |
|
|
885 | psiconv_texted_section psiconv_empty_texted_section(void) |
|
|
886 | { |
|
|
887 | psiconv_texted_section result; |
|
|
888 | if (!(result = malloc(sizeof(*result)))) |
|
|
889 | goto ERROR1; |
|
|
890 | if (!(result->paragraphs = psiconv_empty_text_and_layout())) |
|
|
891 | goto ERROR2; |
|
|
892 | return result; |
|
|
893 | ERROR2: |
|
|
894 | free(result); |
|
|
895 | ERROR1: |
|
|
896 | return NULL; |
|
|
897 | } |
|
|
898 | |
|
|
899 | psiconv_page_header psiconv_empty_page_header(void) |
|
|
900 | { |
|
|
901 | psiconv_page_header result; |
|
|
902 | if (!(result = malloc(sizeof(*result)))) |
|
|
903 | goto ERROR1; |
|
|
904 | result->on_first_page = psiconv_bool_true; |
|
|
905 | if (!(result->base_paragraph_layout = psiconv_basic_paragraph_layout())) |
|
|
906 | goto ERROR2; |
|
|
907 | if (!(result->base_character_layout = psiconv_basic_character_layout())) |
|
|
908 | goto ERROR3; |
|
|
909 | if (!(result->text = psiconv_empty_texted_section())) |
|
|
910 | goto ERROR4; |
|
|
911 | return result; |
|
|
912 | ERROR4: |
|
|
913 | psiconv_free_character_layout(result->base_character_layout); |
|
|
914 | ERROR3: |
|
|
915 | psiconv_free_paragraph_layout(result->base_paragraph_layout); |
|
|
916 | ERROR2: |
|
|
917 | free(result); |
|
|
918 | ERROR1: |
|
|
919 | return NULL; |
|
|
920 | } |
|
|
921 | |
|
|
922 | psiconv_page_layout_section psiconv_empty_page_layout_section(void) |
|
|
923 | { |
|
|
924 | psiconv_page_layout_section result; |
|
|
925 | if (!(result = malloc(sizeof(*result)))) |
|
|
926 | goto ERROR1; |
|
|
927 | result->first_page_nr = 1; |
|
|
928 | result->header_dist = result->footer_dist = 1.27; |
|
|
929 | result->left_margin = result->right_margin = 3.175; |
|
|
930 | result->top_margin = result->bottom_margin = 2.54; |
|
|
931 | result->page_width = 21.0; |
|
|
932 | result->page_height = 29.7; |
|
|
933 | result->landscape = psiconv_bool_false; |
|
|
934 | if (!(result->header = psiconv_empty_page_header())) |
|
|
935 | goto ERROR2; |
|
|
936 | if (!(result->footer = psiconv_empty_page_header())) |
|
|
937 | goto ERROR3; |
|
|
938 | return result; |
|
|
939 | ERROR3: |
|
|
940 | psiconv_free_page_header(result->header); |
|
|
941 | ERROR2: |
|
|
942 | free(result); |
|
|
943 | ERROR1: |
|
|
944 | return NULL; |
|
|
945 | } |
|
|
946 | |
|
|
947 | psiconv_word_status_section psiconv_empty_word_status_section(void) |
|
|
948 | { |
|
|
949 | psiconv_word_status_section result; |
|
|
950 | if (!(result = malloc(sizeof(*result)))) |
|
|
951 | return NULL; |
|
|
952 | result->show_tabs = result->show_spaces = result->show_paragraph_ends = |
|
|
953 | result->show_hard_minus = result->show_hard_space = |
|
|
954 | result->fit_lines_to_screen = psiconv_bool_false; |
|
|
955 | result->show_full_pictures = result->show_full_graphs = |
|
|
956 | result->show_top_toolbar = result->show_side_toolbar = |
|
|
957 | psiconv_bool_true; |
|
|
958 | result->cursor_position = 0; |
|
|
959 | result->display_size = 1000; |
|
|
960 | return result; |
|
|
961 | } |
|
|
962 | |
|
|
963 | psiconv_word_f psiconv_empty_word_f(void) |
|
|
964 | { |
|
|
965 | psiconv_word_f result; |
|
|
966 | if (!(result = malloc(sizeof(*result)))) |
|
|
967 | goto ERROR1; |
|
|
968 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
969 | goto ERROR2; |
|
|
970 | if (!(result->paragraphs = psiconv_empty_text_and_layout())) |
|
|
971 | goto ERROR3; |
|
|
972 | if (!(result->status_sec = psiconv_empty_word_status_section())) |
|
|
973 | goto ERROR4; |
|
|
974 | if (!(result->styles_sec = psiconv_empty_word_styles_section())) |
|
|
975 | goto ERROR5; |
|
|
976 | return result; |
|
|
977 | ERROR5: |
|
|
978 | psiconv_free_word_status_section(result->status_sec); |
|
|
979 | ERROR4: |
|
|
980 | psiconv_free_text_and_layout(result->paragraphs); |
|
|
981 | ERROR3: |
|
|
982 | psiconv_free_page_layout_section(result->page_sec); |
|
|
983 | ERROR2: |
|
|
984 | free(result); |
|
|
985 | ERROR1: |
|
|
986 | return NULL; |
|
|
987 | } |
|
|
988 | |
|
|
989 | psiconv_sheet_status_section psiconv_empty_sheet_status_section(void) |
|
|
990 | { |
|
|
991 | psiconv_sheet_status_section result; |
|
|
992 | if (!(result = malloc(sizeof(*result)))) |
|
|
993 | return NULL; |
|
|
994 | result->show_horizontal_scrollbar = result->show_vertical_scrollbar = |
|
|
995 | psiconv_triple_auto; |
|
|
996 | result->show_graph = psiconv_bool_false; |
|
|
997 | result->show_top_sheet_toolbar = result->show_side_sheet_toolbar = |
|
|
998 | result->show_top_graph_toolbar = result->show_side_graph_toolbar = |
|
|
999 | psiconv_bool_true; |
|
|
1000 | result->cursor_row = result->cursor_column = 0; |
|
|
1001 | result->sheet_display_size = result->graph_display_size = 1000; |
|
|
1002 | return result; |
|
|
1003 | } |
|
|
1004 | |
|
|
1005 | psiconv_formula_list psiconv_empty_formula_list(void) |
|
|
1006 | { |
|
|
1007 | return psiconv_list_new(sizeof(struct psiconv_formula_s)); |
|
|
1008 | } |
|
|
1009 | |
|
|
1010 | psiconv_sheet_workbook_section psiconv_empty_sheet_workbook_section(void) |
|
|
1011 | { |
|
|
1012 | psiconv_sheet_workbook_section result; |
|
|
1013 | if (!(result = malloc(sizeof(*result)))) |
|
|
1014 | goto ERROR1; |
|
|
1015 | if (!(result->formulas = psiconv_empty_formula_list())) |
|
|
1016 | goto ERROR2; |
|
|
1017 | return result; |
|
|
1018 | ERROR2: |
|
|
1019 | free(result); |
|
|
1020 | ERROR1: |
|
|
1021 | return NULL; |
|
|
1022 | } |
|
|
1023 | |
|
|
1024 | |
|
|
1025 | psiconv_sheet_f psiconv_empty_sheet_f(void) |
|
|
1026 | { |
|
|
1027 | psiconv_sheet_f result; |
|
|
1028 | if (!(result = malloc(sizeof(*result)))) |
|
|
1029 | goto ERROR1; |
|
|
1030 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1031 | goto ERROR2; |
|
|
1032 | if (!(result->status_sec = psiconv_empty_sheet_status_section())) |
|
|
1033 | goto ERROR3; |
|
|
1034 | if (!(result->workbook_sec = psiconv_empty_sheet_workbook_section())) |
|
|
1035 | goto ERROR4; |
|
|
1036 | return result; |
|
|
1037 | ERROR4: |
|
|
1038 | psiconv_free_sheet_status_section(result->status_sec); |
|
|
1039 | ERROR3: |
|
|
1040 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1041 | ERROR2: |
|
|
1042 | free(result); |
|
|
1043 | ERROR1: |
|
|
1044 | return NULL; |
|
|
1045 | } |
|
|
1046 | |
|
|
1047 | psiconv_texted_f psiconv_empty_texted_f(void) |
|
|
1048 | { |
|
|
1049 | psiconv_texted_f result; |
|
|
1050 | if (!(result = malloc(sizeof(*result)))) |
|
|
1051 | goto ERROR1; |
|
|
1052 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1053 | goto ERROR2; |
|
|
1054 | if (!(result->texted_sec = psiconv_empty_texted_section())) |
|
|
1055 | goto ERROR3; |
|
|
1056 | return result; |
|
|
1057 | ERROR3: |
|
|
1058 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1059 | ERROR2: |
|
|
1060 | free(result); |
|
|
1061 | ERROR1: |
|
|
1062 | return NULL; |
|
|
1063 | } |
|
|
1064 | |
|
|
1065 | psiconv_paint_data_section psiconv_empty_paint_data_section(void) |
|
|
1066 | { |
|
|
1067 | psiconv_paint_data_section result; |
|
|
1068 | if (!(result = malloc(sizeof(*result)))) |
|
|
1069 | goto ERROR1; |
|
|
1070 | /* Is this correct? */ |
|
|
1071 | result->xsize = result->ysize = result->pic_xsize = result->pic_ysize = 0; |
|
|
1072 | /* Probably forbidden... */ |
|
|
1073 | if (!(result->red = malloc(0))) |
|
|
1074 | goto ERROR2; |
|
|
1075 | if (!(result->green = malloc(0))) |
|
|
1076 | goto ERROR3; |
|
|
1077 | if (!(result->blue = malloc(0))) |
|
|
1078 | goto ERROR4; |
|
|
1079 | return result; |
|
|
1080 | ERROR4: |
|
|
1081 | free(result->green); |
|
|
1082 | ERROR3: |
|
|
1083 | free(result->red); |
|
|
1084 | ERROR2: |
|
|
1085 | free(result); |
|
|
1086 | ERROR1: |
|
|
1087 | return NULL; |
|
|
1088 | } |
|
|
1089 | |
|
|
1090 | |
|
|
1091 | psiconv_pictures psiconv_empty_pictures(void) |
|
|
1092 | { |
|
|
1093 | psiconv_pictures result; |
|
|
1094 | psiconv_paint_data_section pds; |
|
|
1095 | if (!(result = psiconv_list_new(sizeof(struct psiconv_paint_data_section_s)))) |
|
|
1096 | goto ERROR1; |
|
|
1097 | if (!(pds = psiconv_empty_paint_data_section())) |
|
|
1098 | goto ERROR2; |
|
|
1099 | if (psiconv_list_add(result,pds)) |
|
|
1100 | goto ERROR3; |
|
|
1101 | free(pds); |
|
|
1102 | return result; |
|
|
1103 | ERROR3: |
|
|
1104 | psiconv_free_paint_data_section(pds); |
|
|
1105 | ERROR2: |
|
|
1106 | psiconv_list_free(result); |
|
|
1107 | ERROR1: |
|
|
1108 | return NULL; |
|
|
1109 | } |
|
|
1110 | |
|
|
1111 | psiconv_mbm_f psiconv_empty_mbm_f(void) |
|
|
1112 | { |
|
|
1113 | psiconv_mbm_f result; |
|
|
1114 | if (!(result = malloc(sizeof(*result)))) |
|
|
1115 | goto ERROR1; |
|
|
1116 | if (!(result->sections = psiconv_empty_pictures())) |
|
|
1117 | goto ERROR2; |
|
|
1118 | return result; |
|
|
1119 | ERROR2: |
|
|
1120 | free(result); |
|
|
1121 | ERROR1: |
|
|
1122 | return NULL; |
|
|
1123 | } |
|
|
1124 | |
|
|
1125 | psiconv_sketch_section psiconv_empty_sketch_section(void) |
|
|
1126 | { |
|
|
1127 | psiconv_sketch_section result; |
|
|
1128 | if (!(result = malloc(sizeof(*result)))) |
|
|
1129 | goto ERROR1; |
|
|
1130 | result->form_xsize = 320; |
|
|
1131 | result->form_ysize = 200; |
|
|
1132 | result->picture_x_offset = result->picture_y_offset = result->picture_xsize = |
|
|
1133 | result->picture_ysize = 0; |
|
|
1134 | result->magnification_x = result->magnification_y = 1.0; |
|
|
1135 | result->cut_left = result->cut_right = result->cut_top = |
|
|
1136 | result->cut_bottom = 0.0; |
|
|
1137 | if (!(result->picture = psiconv_empty_paint_data_section())) |
|
|
1138 | goto ERROR2; |
|
|
1139 | return result; |
|
|
1140 | ERROR2: |
|
|
1141 | free(result); |
|
|
1142 | ERROR1: |
|
|
1143 | return NULL; |
|
|
1144 | } |
|
|
1145 | |
|
|
1146 | psiconv_sketch_f psiconv_empty_sketch_f(void) |
|
|
1147 | { |
|
|
1148 | psiconv_sketch_f result; |
|
|
1149 | if (!(result = malloc(sizeof(*result)))) |
|
|
1150 | goto ERROR1; |
|
|
1151 | if (!(result->sketch_sec = psiconv_empty_sketch_section())) |
|
|
1152 | goto ERROR2; |
|
|
1153 | return result; |
|
|
1154 | ERROR2: |
|
|
1155 | free(result); |
|
|
1156 | ERROR1: |
|
|
1157 | return NULL; |
|
|
1158 | } |
|
|
1159 | |
|
|
1160 | psiconv_cliparts psiconv_empty_cliparts(void) |
|
|
1161 | { |
|
|
1162 | /* Is this correct? */ |
|
|
1163 | return psiconv_list_new(sizeof(struct psiconv_clipart_section_s)); |
|
|
1164 | } |
|
|
1165 | |
|
|
1166 | psiconv_clipart_f psiconv_empty_clipart_f(void) |
|
|
1167 | { |
|
|
1168 | psiconv_clipart_f result; |
|
|
1169 | if (!(result = malloc(sizeof(*result)))) |
|
|
1170 | goto ERROR1; |
|
|
1171 | if (!(result->sections = psiconv_empty_cliparts())) |
|
|
1172 | goto ERROR2; |
|
|
1173 | return result; |
|
|
1174 | ERROR2: |
|
|
1175 | free(result); |
|
|
1176 | ERROR1: |
|
|
1177 | return NULL; |
|
|
1178 | } |
|
|
1179 | |
|
|
1180 | psiconv_file psiconv_empty_file(psiconv_file_type_t type) |
|
|
1181 | { |
|
|
1182 | psiconv_file result; |
|
|
1183 | if (!(result = malloc(sizeof(*result)))) |
|
|
1184 | return NULL; |
|
|
1185 | result->type = type; |
|
|
1186 | if (type == psiconv_word_file) { |
|
|
1187 | if (!(result->file = psiconv_empty_word_f())) |
|
|
1188 | goto ERROR; |
|
|
1189 | } else if (type == psiconv_sheet_file) { |
|
|
1190 | if (!(result->file = psiconv_empty_sheet_f())) |
|
|
1191 | goto ERROR; |
|
|
1192 | } else if (type == psiconv_texted_file) { |
|
|
1193 | if (!(result->file = psiconv_empty_texted_f())) |
|
|
1194 | goto ERROR; |
|
|
1195 | } else if (type == psiconv_mbm_file) { |
|
|
1196 | if (!(result->file = psiconv_empty_mbm_f())) |
|
|
1197 | goto ERROR; |
|
|
1198 | } else if (type == psiconv_sketch_file) { |
|
|
1199 | if (!(result->file = psiconv_empty_sketch_f())) |
|
|
1200 | goto ERROR; |
|
|
1201 | } else if (type == psiconv_clipart_file) { |
|
|
1202 | if (!(result->file = psiconv_empty_clipart_f())) |
|
|
1203 | goto ERROR; |
|
|
1204 | } else |
|
|
1205 | goto ERROR; |
|
|
1206 | return result; |
|
|
1207 | ERROR: |
|
|
1208 | free(result); |
|
|
1209 | return NULL; |
|
|
1210 | } |