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