/[public]/psiconv/trunk/lib/psiconv/data.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/data.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 67 Revision 125
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
26static psiconv_color clone_color(psiconv_color color); 27static psiconv_color clone_color(psiconv_color color);
27static psiconv_font clone_font(psiconv_font font); 28static psiconv_font clone_font(psiconv_font font);
28static psiconv_border clone_border(psiconv_border border); 29static psiconv_border clone_border(psiconv_border border);
29static psiconv_bullet clone_bullet(psiconv_bullet bullet); 30static psiconv_bullet clone_bullet(psiconv_bullet bullet);
31static void psiconv_free_style_aux(void *style); 32static void psiconv_free_style_aux(void *style);
32static void psiconv_free_in_line_layout_aux(void * layout); 33static void psiconv_free_in_line_layout_aux(void * layout);
33static void psiconv_free_paragraph_aux(void * paragraph); 34static void psiconv_free_paragraph_aux(void * paragraph);
34static void psiconv_free_paint_data_section_aux(void * section); 35static void psiconv_free_paint_data_section_aux(void * section);
35static void psiconv_free_clipart_section_aux(void * section); 36static void psiconv_free_clipart_section_aux(void * section);
37static void psiconv_free_formula_aux(void *data);
38static void psiconv_free_sheet_worksheet_aux (void *data);
36 39
40static psiconv_word_styles_section psiconv_empty_word_styles_section(void);
41static psiconv_text_and_layout psiconv_empty_text_and_layout(void);
42static psiconv_texted_section psiconv_empty_texted_section(void);
43static psiconv_page_header psiconv_empty_page_header(void);
44static psiconv_page_layout_section psiconv_empty_page_layout_section(void);
45static psiconv_word_status_section psiconv_empty_word_status_section(void);
46static psiconv_word_f psiconv_empty_word_f(void);
47static psiconv_sheet_status_section psiconv_empty_sheet_status_section(void);
48static psiconv_formula_list psiconv_empty_formula_list(void);
49static psiconv_sheet_workbook_section
50 psiconv_empty_sheet_workbook_section(void);
51static psiconv_sheet_f psiconv_empty_sheet_f(void);
52static psiconv_texted_f psiconv_empty_texted_f(void);
53static psiconv_paint_data_section psiconv_empty_paint_data_section(void);
54static psiconv_pictures psiconv_empty_pictures(void);
55static psiconv_mbm_f psiconv_empty_mbm_f(void);
56static psiconv_sketch_section psiconv_empty_sketch_section(void);
57static psiconv_sketch_f psiconv_empty_sketch_f(void);
58static psiconv_clipart_f psiconv_empty_clipart_f(void);
59static psiconv_cliparts psiconv_empty_cliparts(void);
60
61
62/* Note: these defaults seem to be hard-coded somewhere outside the
63 files themself. */
37psiconv_character_layout psiconv_basic_character_layout(void) 64psiconv_character_layout psiconv_basic_character_layout(void)
38{ 65{
39 /* Make the structures static, to oblige IRIX */ 66 /* Make the structures static, to oblige IRIX */
40 static struct psiconv_color_s black = 67 static struct psiconv_color_s black =
41 { 68 {
68 }; 95 };
69 96
70 return psiconv_clone_character_layout(&cl); 97 return psiconv_clone_character_layout(&cl);
71} 98}
72 99
100/* Note: these defaults seem to be hard-coded somewhere outside the
101 files themself. */
73psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) 102psiconv_paragraph_layout psiconv_basic_paragraph_layout(void)
74{ 103{
75 static struct psiconv_font_s font = 104 static struct psiconv_font_s font =
76 { 105 {
77 "Times New Roman", /* name */ 106 "Times New Roman", /* name */
115 0.0, /* indent_left */ 144 0.0, /* indent_left */
116 0.0, /* indent_right */ 145 0.0, /* indent_right */
117 0.0, /* indent_first */ 146 0.0, /* indent_first */
118 psiconv_justify_left, /* justify_hor */ 147 psiconv_justify_left, /* justify_hor */
119 psiconv_justify_middle,/* justify_ver */ 148 psiconv_justify_middle,/* justify_ver */
120 0.0, /* linespacing */ 149 10.0, /* linespacing */
121 psiconv_bool_false, /* linespacing_exact */ 150 psiconv_bool_false, /* linespacing_exact */
122 0.0, /* space_above */ 151 0.0, /* space_above */
123 0.0, /* space_below */ 152 0.0, /* space_below */
124 psiconv_bool_false, /* keep_together */ 153 psiconv_bool_false, /* keep_together */
125 psiconv_bool_false, /* keep_with_next */ 154 psiconv_bool_false, /* keep_with_next */
126 psiconv_bool_false, /* on_next_page */ 155 psiconv_bool_false, /* on_next_page */
127 psiconv_bool_false, /* no_widow_protection */ 156 psiconv_bool_false, /* no_widow_protection */
157 psiconv_bool_false, /* wrap_to_fit_cell */
128 0.0, /* left_margin */ 158 0.0, /* left_margin */
129 &bullet, /* bullet */ 159 &bullet, /* bullet */
130 &no_border, /* left_border */ 160 &no_border, /* left_border */
131 &no_border, /* right_border */ 161 &no_border, /* right_border */
132 &no_border, /* top_border */ 162 &no_border, /* top_border */
287 return ss->normal; 317 return ss->normal;
288 else 318 else
289 return psiconv_list_get(ss->styles,0xff - nr); 319 return psiconv_list_get(ss->styles,0xff - nr);
290} 320}
291 321
322psiconv_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
292void psiconv_free_color (psiconv_color color) 328void psiconv_free_color (psiconv_color color)
293{ 329{
294 if (color) 330 if (color)
295 free(color); 331 free(color);
296} 332}
508 if (file) { 544 if (file) {
509 psiconv_free_page_layout_section(file->page_sec); 545 psiconv_free_page_layout_section(file->page_sec);
510 psiconv_free_text_and_layout(file->paragraphs); 546 psiconv_free_text_and_layout(file->paragraphs);
511 psiconv_free_word_status_section(file->status_sec); 547 psiconv_free_word_status_section(file->status_sec);
512 psiconv_free_word_styles_section(file->styles_sec); 548 psiconv_free_word_styles_section(file->styles_sec);
549 free(file);
550 }
551}
552
553void psiconv_free_sheet_status_section(psiconv_sheet_status_section section)
554{
555 if (section)
556 free(section);
557}
558
559void psiconv_free_sheet_numberformat(psiconv_sheet_numberformat numberformat)
560{
561 if (numberformat)
562 free(numberformat);
563}
564
565void 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
572void 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
582void 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
590void 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
596void 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
603void 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
611void 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
617void 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
636void psiconv_free_formula(psiconv_formula formula)
637{
638 if (formula) {
639 psiconv_free_formula_aux(formula);
640 free(formula);
641 }
642}
643
644void psiconv_free_formula_list(psiconv_formula_list list)
645{
646 if (list)
647 psiconv_list_free_el(list,psiconv_free_formula_aux);
648}
649
650void 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
659void 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);
513 free(file); 665 free(file);
514 } 666 }
515} 667}
516 668
517void psiconv_free_texted_f(psiconv_texted_f file) 669void psiconv_free_texted_f(psiconv_texted_f file)
616 psiconv_free_mbm_f((psiconv_mbm_f) file->file); 768 psiconv_free_mbm_f((psiconv_mbm_f) file->file);
617 else if (file->type == psiconv_sketch_file) 769 else if (file->type == psiconv_sketch_file)
618 psiconv_free_sketch_f((psiconv_sketch_f) file->file); 770 psiconv_free_sketch_f((psiconv_sketch_f) file->file);
619 else if (file->type == psiconv_clipart_file) 771 else if (file->type == psiconv_clipart_file)
620 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);
621 free(file); 775 free(file);
622 } 776 }
623} 777}
778
779int 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
792int 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
804int 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
817int 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
833int 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
844int 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
864int 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
895int 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
916psiconv_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;
934ERROR5:
935 psiconv_free_character_layout(result->normal->character);
936ERROR4:
937 free(result->normal);
938ERROR3:
939 psiconv_list_free(result->styles);
940ERROR2:
941 free(result);
942ERROR1:
943 return NULL;
944}
945
946psiconv_text_and_layout psiconv_empty_text_and_layout(void)
947{
948 return psiconv_list_new(sizeof(struct psiconv_paragraph_s));
949}
950
951psiconv_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;
959ERROR2:
960 free(result);
961ERROR1:
962 return NULL;
963}
964
965psiconv_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;
978ERROR4:
979 psiconv_free_character_layout(result->base_character_layout);
980ERROR3:
981 psiconv_free_paragraph_layout(result->base_paragraph_layout);
982ERROR2:
983 free(result);
984ERROR1:
985 return NULL;
986}
987
988psiconv_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;
1005ERROR3:
1006 psiconv_free_page_header(result->header);
1007ERROR2:
1008 free(result);
1009ERROR1:
1010 return NULL;
1011}
1012
1013psiconv_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
1029psiconv_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;
1043ERROR5:
1044 psiconv_free_word_status_section(result->status_sec);
1045ERROR4:
1046 psiconv_free_text_and_layout(result->paragraphs);
1047ERROR3:
1048 psiconv_free_page_layout_section(result->page_sec);
1049ERROR2:
1050 free(result);
1051ERROR1:
1052 return NULL;
1053}
1054
1055psiconv_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
1071psiconv_formula_list psiconv_empty_formula_list(void)
1072{
1073 return psiconv_list_new(sizeof(struct psiconv_formula_s));
1074}
1075
1076psiconv_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;
1084ERROR2:
1085 free(result);
1086ERROR1:
1087 return NULL;
1088}
1089
1090
1091psiconv_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;
1103ERROR4:
1104 psiconv_free_sheet_status_section(result->status_sec);
1105ERROR3:
1106 psiconv_free_page_layout_section(result->page_sec);
1107ERROR2:
1108 free(result);
1109ERROR1:
1110 return NULL;
1111}
1112
1113psiconv_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;
1123ERROR3:
1124 psiconv_free_page_layout_section(result->page_sec);
1125ERROR2:
1126 free(result);
1127ERROR1:
1128 return NULL;
1129}
1130
1131psiconv_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;
1146ERROR4:
1147 free(result->green);
1148ERROR3:
1149 free(result->red);
1150ERROR2:
1151 free(result);
1152ERROR1:
1153 return NULL;
1154}
1155
1156
1157psiconv_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;
1169ERROR3:
1170 psiconv_free_paint_data_section(pds);
1171ERROR2:
1172 psiconv_list_free(result);
1173ERROR1:
1174 return NULL;
1175}
1176
1177psiconv_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;
1185ERROR2:
1186 free(result);
1187ERROR1:
1188 return NULL;
1189}
1190
1191psiconv_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;
1206ERROR2:
1207 free(result);
1208ERROR1:
1209 return NULL;
1210}
1211
1212psiconv_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;
1220ERROR2:
1221 free(result);
1222ERROR1:
1223 return NULL;
1224}
1225
1226psiconv_cliparts psiconv_empty_cliparts(void)
1227{
1228 /* Is this correct? */
1229 return psiconv_list_new(sizeof(struct psiconv_clipart_section_s));
1230}
1231
1232psiconv_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;
1240ERROR2:
1241 free(result);
1242ERROR1:
1243 return NULL;
1244}
1245
1246psiconv_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;
1273ERROR:
1274 free(result);
1275 return NULL;
1276}

Legend:
Removed from v.67  
changed lines
  Added in v.125

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26