/[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 63 Revision 104
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);
36 38
39static psiconv_word_styles_section psiconv_empty_word_styles_section(void);
40static psiconv_text_and_layout psiconv_empty_text_and_layout(void);
41static psiconv_texted_section psiconv_empty_texted_section(void);
42static psiconv_page_header psiconv_empty_page_header(void);
43static psiconv_page_layout_section psiconv_empty_page_layout_section(void);
44static psiconv_word_status_section psiconv_empty_word_status_section(void);
45static psiconv_word_f psiconv_empty_word_f(void);
46static psiconv_sheet_status_section psiconv_empty_sheet_status_section(void);
47static psiconv_formula_list psiconv_empty_formula_list(void);
48static psiconv_sheet_workbook_section
49 psiconv_empty_sheet_workbook_section(void);
50static psiconv_sheet_f psiconv_empty_sheet_f(void);
51static psiconv_texted_f psiconv_empty_texted_f(void);
52static psiconv_paint_data_section psiconv_empty_paint_data_section(void);
53static psiconv_pictures psiconv_empty_pictures(void);
54static psiconv_mbm_f psiconv_empty_mbm_f(void);
55static psiconv_sketch_section psiconv_empty_sketch_section(void);
56static psiconv_sketch_f psiconv_empty_sketch_f(void);
57static psiconv_clipart_f psiconv_empty_clipart_f(void);
58static psiconv_cliparts psiconv_empty_cliparts(void);
59
60
61/* Note: these defaults seem to be hard-coded somewhere outside the
62 files themself. */
37psiconv_character_layout psiconv_basic_character_layout(void) 63psiconv_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 {
61 10.0, /* font_size */ 87 10.0, /* font_size */
62 psiconv_bool_false, /* italic */ 88 psiconv_bool_false, /* italic */
63 psiconv_bool_false, /* bold */ 89 psiconv_bool_false, /* bold */
64 psiconv_normalscript, /* super_sub */ 90 psiconv_normalscript, /* super_sub */
65 psiconv_bool_false, /* underline */ 91 psiconv_bool_false, /* underline */
66 psiconv_bool_false, /* strike_out */ 92 psiconv_bool_false, /* strikethrough */
67 &font, /* font */ 93 &font, /* font */
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. */
73psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) 101psiconv_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, /* interline */ 148 10.0, /* linespacing */
121 psiconv_bool_false, /* interline_exact */ 149 psiconv_bool_false, /* linespacing_exact */
122 0.0, /* top_space */ 150 0.0, /* space_above */
123 0.0, /* bottom_space */ 151 0.0, /* space_below */
124 psiconv_bool_false, /* on_one_page */
125 psiconv_bool_false, /* together_with */ 152 psiconv_bool_false, /* keep_together */
153 psiconv_bool_false, /* keep_with_next */
126 psiconv_bool_false, /* on_next_page */ 154 psiconv_bool_false, /* on_next_page */
127 psiconv_bool_false, /* no_widow_protection */ 155 psiconv_bool_false, /* no_widow_protection */
156 psiconv_bool_false, /* wrap_to_fit_cell */
128 0.0, /* left_margin */ 157 0.0, /* left_margin */
129 &bullet, /* bullet */ 158 &bullet, /* bullet */
130 &no_border, /* left_border */ 159 &no_border, /* left_border */
131 &no_border, /* right_border */ 160 &no_border, /* right_border */
132 &no_border, /* top_border */ 161 &no_border, /* top_border */
512 psiconv_free_word_styles_section(file->styles_sec); 541 psiconv_free_word_styles_section(file->styles_sec);
513 free(file); 542 free(file);
514 } 543 }
515} 544}
516 545
546void psiconv_free_sheet_status_section(psiconv_sheet_status_section section)
547{
548 if (section)
549 free(section);
550}
551
552void 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
571void psiconv_free_formula(psiconv_formula formula)
572{
573 if (formula) {
574 psiconv_free_formula_aux(formula);
575 free(formula);
576 }
577}
578
579void psiconv_free_formula_list(psiconv_formula_list list)
580{
581 if (list)
582 psiconv_list_free_el(list,psiconv_free_formula_aux);
583}
584
585void 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
593void 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
517void psiconv_free_texted_f(psiconv_texted_f file) 603void psiconv_free_texted_f(psiconv_texted_f file)
518{ 604{
519 if (file) { 605 if (file) {
520 psiconv_free_page_layout_section(file->page_sec); 606 psiconv_free_page_layout_section(file->page_sec);
521 psiconv_free_texted_section(file->texted_sec); 607 psiconv_free_texted_section(file->texted_sec);
616 psiconv_free_mbm_f((psiconv_mbm_f) file->file); 702 psiconv_free_mbm_f((psiconv_mbm_f) file->file);
617 else if (file->type == psiconv_sketch_file) 703 else if (file->type == psiconv_sketch_file)
618 psiconv_free_sketch_f((psiconv_sketch_f) file->file); 704 psiconv_free_sketch_f((psiconv_sketch_f) file->file);
619 else if (file->type == psiconv_clipart_file) 705 else if (file->type == psiconv_clipart_file)
620 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);
621 free(file); 709 free(file);
622 } 710 }
623} 711}
712
713int 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
726int 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
738int 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
751int 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
767int 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
778int 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
798int 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
829int 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
850psiconv_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;
868ERROR5:
869 psiconv_free_character_layout(result->normal->character);
870ERROR4:
871 free(result->normal);
872ERROR3:
873 psiconv_list_free(result->styles);
874ERROR2:
875 free(result);
876ERROR1:
877 return NULL;
878}
879
880psiconv_text_and_layout psiconv_empty_text_and_layout(void)
881{
882 return psiconv_list_new(sizeof(struct psiconv_paragraph_s));
883}
884
885psiconv_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;
893ERROR2:
894 free(result);
895ERROR1:
896 return NULL;
897}
898
899psiconv_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;
912ERROR4:
913 psiconv_free_character_layout(result->base_character_layout);
914ERROR3:
915 psiconv_free_paragraph_layout(result->base_paragraph_layout);
916ERROR2:
917 free(result);
918ERROR1:
919 return NULL;
920}
921
922psiconv_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;
939ERROR3:
940 psiconv_free_page_header(result->header);
941ERROR2:
942 free(result);
943ERROR1:
944 return NULL;
945}
946
947psiconv_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
963psiconv_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;
977ERROR5:
978 psiconv_free_word_status_section(result->status_sec);
979ERROR4:
980 psiconv_free_text_and_layout(result->paragraphs);
981ERROR3:
982 psiconv_free_page_layout_section(result->page_sec);
983ERROR2:
984 free(result);
985ERROR1:
986 return NULL;
987}
988
989psiconv_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
1005psiconv_formula_list psiconv_empty_formula_list(void)
1006{
1007 return psiconv_list_new(sizeof(struct psiconv_formula_s));
1008}
1009
1010psiconv_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;
1018ERROR2:
1019 free(result);
1020ERROR1:
1021 return NULL;
1022}
1023
1024
1025psiconv_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;
1037ERROR4:
1038 psiconv_free_sheet_status_section(result->status_sec);
1039ERROR3:
1040 psiconv_free_page_layout_section(result->page_sec);
1041ERROR2:
1042 free(result);
1043ERROR1:
1044 return NULL;
1045}
1046
1047psiconv_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;
1057ERROR3:
1058 psiconv_free_page_layout_section(result->page_sec);
1059ERROR2:
1060 free(result);
1061ERROR1:
1062 return NULL;
1063}
1064
1065psiconv_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;
1080ERROR4:
1081 free(result->green);
1082ERROR3:
1083 free(result->red);
1084ERROR2:
1085 free(result);
1086ERROR1:
1087 return NULL;
1088}
1089
1090
1091psiconv_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;
1103ERROR3:
1104 psiconv_free_paint_data_section(pds);
1105ERROR2:
1106 psiconv_list_free(result);
1107ERROR1:
1108 return NULL;
1109}
1110
1111psiconv_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;
1119ERROR2:
1120 free(result);
1121ERROR1:
1122 return NULL;
1123}
1124
1125psiconv_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;
1140ERROR2:
1141 free(result);
1142ERROR1:
1143 return NULL;
1144}
1145
1146psiconv_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;
1154ERROR2:
1155 free(result);
1156ERROR1:
1157 return NULL;
1158}
1159
1160psiconv_cliparts psiconv_empty_cliparts(void)
1161{
1162 /* Is this correct? */
1163 return psiconv_list_new(sizeof(struct psiconv_clipart_section_s));
1164}
1165
1166psiconv_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;
1174ERROR2:
1175 free(result);
1176ERROR1:
1177 return NULL;
1178}
1179
1180psiconv_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;
1207ERROR:
1208 free(result);
1209 return NULL;
1210}

Legend:
Removed from v.63  
changed lines
  Added in v.104

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