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

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

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