/[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 87 Revision 99
32static void psiconv_free_style_aux(void *style); 32static void psiconv_free_style_aux(void *style);
33static void psiconv_free_in_line_layout_aux(void * layout); 33static void psiconv_free_in_line_layout_aux(void * layout);
34static void psiconv_free_paragraph_aux(void * paragraph); 34static void psiconv_free_paragraph_aux(void * paragraph);
35static void psiconv_free_paint_data_section_aux(void * section); 35static void psiconv_free_paint_data_section_aux(void * section);
36static 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);
37 38
38static psiconv_word_styles_section psiconv_empty_word_styles_section(void); 39static psiconv_word_styles_section psiconv_empty_word_styles_section(void);
39static psiconv_text_and_layout psiconv_empty_text_and_layout(void); 40static psiconv_text_and_layout psiconv_empty_text_and_layout(void);
40static psiconv_texted_section psiconv_empty_texted_section(void); 41static psiconv_texted_section psiconv_empty_texted_section(void);
41static psiconv_page_header psiconv_empty_page_header(void); 42static psiconv_page_header psiconv_empty_page_header(void);
42static psiconv_page_layout_section psiconv_empty_page_layout_section(void); 43static psiconv_page_layout_section psiconv_empty_page_layout_section(void);
43static psiconv_word_status_section psiconv_empty_word_status_section(void); 44static psiconv_word_status_section psiconv_empty_word_status_section(void);
44static psiconv_word_f psiconv_empty_word_f(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);
45static psiconv_texted_f psiconv_empty_texted_f(void); 51static psiconv_texted_f psiconv_empty_texted_f(void);
46static psiconv_paint_data_section psiconv_empty_paint_data_section(void); 52static psiconv_paint_data_section psiconv_empty_paint_data_section(void);
47static psiconv_pictures psiconv_empty_pictures(void); 53static psiconv_pictures psiconv_empty_pictures(void);
48static psiconv_mbm_f psiconv_empty_mbm_f(void); 54static psiconv_mbm_f psiconv_empty_mbm_f(void);
49static psiconv_sketch_section psiconv_empty_sketch_section(void); 55static psiconv_sketch_section psiconv_empty_sketch_section(void);
534 psiconv_free_word_styles_section(file->styles_sec); 540 psiconv_free_word_styles_section(file->styles_sec);
535 free(file); 541 free(file);
536 } 542 }
537} 543}
538 544
545void psiconv_free_sheet_status_section(psiconv_sheet_status_section section)
546{
547 if (section)
548 free(section);
549}
550
551void 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
570void psiconv_free_formula(psiconv_formula formula)
571{
572 if (formula) {
573 psiconv_free_formula_aux(formula);
574 free(formula);
575 }
576}
577
578void psiconv_free_formula_list(psiconv_formula_list list)
579{
580 if (list)
581 psiconv_list_free_el(list,psiconv_free_formula_aux);
582}
583
584void 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
592void 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
539void psiconv_free_texted_f(psiconv_texted_f file) 602void psiconv_free_texted_f(psiconv_texted_f file)
540{ 603{
541 if (file) { 604 if (file) {
542 psiconv_free_page_layout_section(file->page_sec); 605 psiconv_free_page_layout_section(file->page_sec);
543 psiconv_free_texted_section(file->texted_sec); 606 psiconv_free_texted_section(file->texted_sec);
638 psiconv_free_mbm_f((psiconv_mbm_f) file->file); 701 psiconv_free_mbm_f((psiconv_mbm_f) file->file);
639 else if (file->type == psiconv_sketch_file) 702 else if (file->type == psiconv_sketch_file)
640 psiconv_free_sketch_f((psiconv_sketch_f) file->file); 703 psiconv_free_sketch_f((psiconv_sketch_f) file->file);
641 else if (file->type == psiconv_clipart_file) 704 else if (file->type == psiconv_clipart_file)
642 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);
643 free(file); 708 free(file);
644 } 709 }
645} 710}
646 711
647int psiconv_compare_color(const psiconv_color value1, 712int psiconv_compare_color(const psiconv_color value1,
856psiconv_page_layout_section psiconv_empty_page_layout_section(void) 921psiconv_page_layout_section psiconv_empty_page_layout_section(void)
857{ 922{
858 psiconv_page_layout_section result; 923 psiconv_page_layout_section result;
859 if (!(result = malloc(sizeof(*result)))) 924 if (!(result = malloc(sizeof(*result))))
860 goto ERROR1; 925 goto ERROR1;
861 result->first_page_nr = 0; 926 result->first_page_nr = 1;
862 result->header_dist = result->footer_dist = 1.27; 927 result->header_dist = result->footer_dist = 1.27;
863 result->left_margin = result->right_margin = 3.175; 928 result->left_margin = result->right_margin = 3.175;
864 result->top_margin = result->bottom_margin = 2.54; 929 result->top_margin = result->bottom_margin = 2.54;
865 result->page_width = 21.0; 930 result->page_width = 21.0;
866 result->page_height = 29.7; 931 result->page_height = 29.7;
918 free(result); 983 free(result);
919ERROR1: 984ERROR1:
920 return NULL; 985 return NULL;
921} 986}
922 987
988psiconv_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
1004psiconv_formula_list psiconv_empty_formula_list(void)
1005{
1006 return psiconv_list_new(sizeof(struct psiconv_formula_s));
1007}
1008
1009psiconv_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;
1017ERROR2:
1018 free(result);
1019ERROR1:
1020 return NULL;
1021}
1022
1023
1024psiconv_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;
1036ERROR4:
1037 psiconv_free_sheet_status_section(result->status_sec);
1038ERROR3:
1039 psiconv_free_page_layout_section(result->page_sec);
1040ERROR2:
1041 free(result);
1042ERROR1:
1043 return NULL;
1044}
1045
923psiconv_texted_f psiconv_empty_texted_f(void) 1046psiconv_texted_f psiconv_empty_texted_f(void)
924{ 1047{
925 psiconv_texted_f result; 1048 psiconv_texted_f result;
926 if (!(result = malloc(sizeof(*result)))) 1049 if (!(result = malloc(sizeof(*result))))
927 goto ERROR1; 1050 goto ERROR1;
1059 if (!(result = malloc(sizeof(*result)))) 1182 if (!(result = malloc(sizeof(*result))))
1060 return NULL; 1183 return NULL;
1061 result->type = type; 1184 result->type = type;
1062 if (type == psiconv_word_file) { 1185 if (type == psiconv_word_file) {
1063 if (!(result->file = psiconv_empty_word_f())) 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()))
1064 goto ERROR; 1190 goto ERROR;
1065 } else if (type == psiconv_texted_file) { 1191 } else if (type == psiconv_texted_file) {
1066 if (!(result->file = psiconv_empty_texted_f())) 1192 if (!(result->file = psiconv_empty_texted_f()))
1067 goto ERROR; 1193 goto ERROR;
1068 } else if (type == psiconv_mbm_file) { 1194 } else if (type == psiconv_mbm_file) {

Legend:
Removed from v.87  
changed lines
  Added in v.99

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