/[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 129
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);
38static void psiconv_free_sheet_worksheet_aux (void *data);
39static void psiconv_free_sheet_variable_aux(void * variable);
37 40
38static psiconv_word_styles_section psiconv_empty_word_styles_section(void); 41static psiconv_word_styles_section psiconv_empty_word_styles_section(void);
39static psiconv_text_and_layout psiconv_empty_text_and_layout(void); 42static psiconv_text_and_layout psiconv_empty_text_and_layout(void);
40static psiconv_texted_section psiconv_empty_texted_section(void); 43static psiconv_texted_section psiconv_empty_texted_section(void);
41static psiconv_page_header psiconv_empty_page_header(void); 44static psiconv_page_header psiconv_empty_page_header(void);
42static psiconv_page_layout_section psiconv_empty_page_layout_section(void); 45static psiconv_page_layout_section psiconv_empty_page_layout_section(void);
43static psiconv_word_status_section psiconv_empty_word_status_section(void); 46static psiconv_word_status_section psiconv_empty_word_status_section(void);
44static psiconv_word_f psiconv_empty_word_f(void); 47static psiconv_word_f psiconv_empty_word_f(void);
48static psiconv_sheet_status_section psiconv_empty_sheet_status_section(void);
49static psiconv_formula_list psiconv_empty_formula_list(void);
50static psiconv_sheet_workbook_section
51 psiconv_empty_sheet_workbook_section(void);
52static psiconv_sheet_f psiconv_empty_sheet_f(void);
45static psiconv_texted_f psiconv_empty_texted_f(void); 53static psiconv_texted_f psiconv_empty_texted_f(void);
46static psiconv_paint_data_section psiconv_empty_paint_data_section(void); 54static psiconv_paint_data_section psiconv_empty_paint_data_section(void);
47static psiconv_pictures psiconv_empty_pictures(void); 55static psiconv_pictures psiconv_empty_pictures(void);
48static psiconv_mbm_f psiconv_empty_mbm_f(void); 56static psiconv_mbm_f psiconv_empty_mbm_f(void);
49static psiconv_sketch_section psiconv_empty_sketch_section(void); 57static psiconv_sketch_section psiconv_empty_sketch_section(void);
145 0.0, /* space_below */ 153 0.0, /* space_below */
146 psiconv_bool_false, /* keep_together */ 154 psiconv_bool_false, /* keep_together */
147 psiconv_bool_false, /* keep_with_next */ 155 psiconv_bool_false, /* keep_with_next */
148 psiconv_bool_false, /* on_next_page */ 156 psiconv_bool_false, /* on_next_page */
149 psiconv_bool_false, /* no_widow_protection */ 157 psiconv_bool_false, /* no_widow_protection */
158 psiconv_bool_false, /* wrap_to_fit_cell */
150 0.0, /* left_margin */ 159 0.0, /* left_margin */
151 &bullet, /* bullet */ 160 &bullet, /* bullet */
152 &no_border, /* left_border */ 161 &no_border, /* left_border */
153 &no_border, /* right_border */ 162 &no_border, /* right_border */
154 &no_border, /* top_border */ 163 &no_border, /* top_border */
309 return ss->normal; 318 return ss->normal;
310 else 319 else
311 return psiconv_list_get(ss->styles,0xff - nr); 320 return psiconv_list_get(ss->styles,0xff - nr);
312} 321}
313 322
323psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr)
324{
325 return psiconv_list_get(ss,psiconv_list_length(ss)-nr-1);
326}
327
328/* TODO: What if a cell is both in a default row and a default column?!? */
329psiconv_sheet_cell_layout psiconv_get_default_layout
330 (psiconv_sheet_line_list row_defaults,
331 psiconv_sheet_line_list col_defaults,
332 psiconv_sheet_cell_layout cell_default,
333 int row,int col)
334{
335 int i;
336 psiconv_sheet_line line;
337 for (i = 0;i < psiconv_list_length(row_defaults);i++) {
338 line = psiconv_list_get(row_defaults,i);
339 if (line->position == row)
340 return line->layout;
341 }
342 for (i = 0;i < psiconv_list_length(col_defaults);i++) {
343 line = psiconv_list_get(col_defaults,i);
344 if (line->position == col)
345 return line->layout;
346 }
347 return cell_default;
348}
349
350
314void psiconv_free_color (psiconv_color color) 351void psiconv_free_color (psiconv_color color)
315{ 352{
316 if (color) 353 if (color)
317 free(color); 354 free(color);
318} 355}
530 if (file) { 567 if (file) {
531 psiconv_free_page_layout_section(file->page_sec); 568 psiconv_free_page_layout_section(file->page_sec);
532 psiconv_free_text_and_layout(file->paragraphs); 569 psiconv_free_text_and_layout(file->paragraphs);
533 psiconv_free_word_status_section(file->status_sec); 570 psiconv_free_word_status_section(file->status_sec);
534 psiconv_free_word_styles_section(file->styles_sec); 571 psiconv_free_word_styles_section(file->styles_sec);
572 free(file);
573 }
574}
575
576void psiconv_free_sheet_status_section(psiconv_sheet_status_section section)
577{
578 if (section)
579 free(section);
580}
581
582void psiconv_free_sheet_numberformat(psiconv_sheet_numberformat numberformat)
583{
584 if (numberformat)
585 free(numberformat);
586}
587
588void psiconv_free_sheet_cell_layout(psiconv_sheet_cell_layout layout)
589{
590 psiconv_free_paragraph_layout(layout->paragraph);
591 psiconv_free_character_layout(layout->character);
592 psiconv_free_sheet_numberformat(layout->numberformat);
593}
594
595void psiconv_free_sheet_cell_aux(void *cell)
596{
597 psiconv_sheet_cell data = cell;
598
599 psiconv_free_sheet_cell_layout(data->layout);
600
601 if ((data->type == psiconv_cell_string) && (data->data.dat_string))
602 free(data->data.dat_string);
603}
604
605void psiconv_free_sheet_cell(psiconv_sheet_cell cell)
606{
607 if (cell) {
608 psiconv_free_sheet_cell_aux(cell);
609 free(cell);
610 }
611}
612
613void psiconv_free_sheet_cell_list(psiconv_sheet_cell_list list)
614{
615 if (list)
616 psiconv_list_free_el(list,psiconv_free_sheet_cell_aux);
617}
618
619void psiconv_free_sheet_line_aux(void *line)
620{
621 psiconv_sheet_line data = line;
622
623 psiconv_free_sheet_cell_layout(data->layout);
624}
625
626void psiconv_free_sheet_line(psiconv_sheet_line line)
627{
628 if (line) {
629 psiconv_free_sheet_line_aux(line);
630 free(line);
631 }
632}
633
634void psiconv_free_sheet_line_list(psiconv_sheet_line_list list)
635{
636 if (list)
637 psiconv_list_free_el(list,psiconv_free_sheet_line_aux);
638}
639
640void psiconv_free_sheet_worksheet_aux (void *data)
641{
642 psiconv_sheet_worksheet section = data;
643 psiconv_free_sheet_cell_layout(section->default_layout);
644 psiconv_free_sheet_cell_list(section->cells);
645 psiconv_free_sheet_line_list(section->row_default_layouts);
646 psiconv_free_sheet_line_list(section->col_default_layouts);
647}
648
649void psiconv_free_sheet_worksheet(psiconv_sheet_worksheet sheet)
650{
651 if (sheet) {
652 psiconv_free_sheet_worksheet_aux(sheet);
653 free(sheet);
654 }
655}
656
657void psiconv_free_sheet_worksheet_list(psiconv_sheet_worksheet_list list)
658{
659 if (list)
660 psiconv_list_free_el(list,psiconv_free_sheet_worksheet_aux);
661}
662
663void psiconv_free_formula_aux(void *data)
664{
665 psiconv_formula formula;
666 formula = data;
667 if (formula->type == psiconv_formula_dat_string)
668 free(formula->data.dat_string);
669 else if ((formula->type != psiconv_formula_dat_int) &&
670 (formula->type != psiconv_formula_dat_var) &&
671 (formula->type != psiconv_formula_dat_float) &&
672 (formula->type != psiconv_formula_dat_cellref) &&
673 (formula->type != psiconv_formula_dat_cellblock) &&
674 (formula->type != psiconv_formula_dat_vcellblock) &&
675 (formula->type != psiconv_formula_mark_opsep) &&
676 (formula->type != psiconv_formula_mark_opend) &&
677 (formula->type != psiconv_formula_mark_eof) &&
678 (formula->type != psiconv_formula_unknown))
679 psiconv_free_formula_list(formula->data.fun_operands);
680}
681
682void psiconv_free_formula(psiconv_formula formula)
683{
684 if (formula) {
685 psiconv_free_formula_aux(formula);
686 free(formula);
687 }
688}
689
690void psiconv_free_formula_list(psiconv_formula_list list)
691{
692 if (list)
693 psiconv_list_free_el(list,psiconv_free_formula_aux);
694}
695
696void psiconv_free_sheet_name_section(psiconv_sheet_name_section section)
697{
698 if (section) {
699 if(section->name)
700 free(section->name);
701 free(section);
702 }
703}
704
705void psiconv_free_sheet_info_section(psiconv_sheet_info_section section)
706{
707 if (section) {
708 free(section);
709 }
710}
711
712void psiconv_free_sheet_variable_aux(void * variable)
713{
714 psiconv_sheet_variable var = variable;
715 if (var->name)
716 free(var->name);
717 if (var->type == psiconv_var_string)
718 free(var->data.dat_string);
719}
720
721void psiconv_free_sheet_variable(psiconv_sheet_variable var)
722{
723 if (var) {
724 psiconv_free_sheet_variable_aux(var);
725 free(var);
726 }
727}
728
729void psiconv_free_sheet_variable_list(psiconv_sheet_variable_list list)
730{
731 if (list)
732 psiconv_list_free_el(list,psiconv_free_sheet_variable_aux);
733}
734
735void psiconv_free_sheet_workbook_section(psiconv_sheet_workbook_section section)
736{
737 if (section) {
738 psiconv_free_formula_list(section->formulas);
739 psiconv_free_sheet_worksheet_list(section->worksheets);
740 psiconv_free_sheet_name_section(section->name);
741 psiconv_free_sheet_info_section(section->info);
742 psiconv_free_sheet_variable_list(section->variables);
743 free(section);
744 }
745}
746
747void psiconv_free_sheet_f(psiconv_sheet_f file)
748{
749 if (file) {
750 psiconv_free_page_layout_section(file->page_sec);
751 psiconv_free_sheet_status_section(file->status_sec);
752 psiconv_free_sheet_workbook_section(file->workbook_sec);
535 free(file); 753 free(file);
536 } 754 }
537} 755}
538 756
539void psiconv_free_texted_f(psiconv_texted_f file) 757void psiconv_free_texted_f(psiconv_texted_f file)
638 psiconv_free_mbm_f((psiconv_mbm_f) file->file); 856 psiconv_free_mbm_f((psiconv_mbm_f) file->file);
639 else if (file->type == psiconv_sketch_file) 857 else if (file->type == psiconv_sketch_file)
640 psiconv_free_sketch_f((psiconv_sketch_f) file->file); 858 psiconv_free_sketch_f((psiconv_sketch_f) file->file);
641 else if (file->type == psiconv_clipart_file) 859 else if (file->type == psiconv_clipart_file)
642 psiconv_free_clipart_f((psiconv_clipart_f) file->file); 860 psiconv_free_clipart_f((psiconv_clipart_f) file->file);
861 else if (file->type == psiconv_sheet_file)
862 psiconv_free_sheet_f((psiconv_sheet_f) file->file);
643 free(file); 863 free(file);
644 } 864 }
645} 865}
646 866
647int psiconv_compare_color(const psiconv_color value1, 867int psiconv_compare_color(const psiconv_color value1,
856psiconv_page_layout_section psiconv_empty_page_layout_section(void) 1076psiconv_page_layout_section psiconv_empty_page_layout_section(void)
857{ 1077{
858 psiconv_page_layout_section result; 1078 psiconv_page_layout_section result;
859 if (!(result = malloc(sizeof(*result)))) 1079 if (!(result = malloc(sizeof(*result))))
860 goto ERROR1; 1080 goto ERROR1;
861 result->first_page_nr = 0; 1081 result->first_page_nr = 1;
862 result->header_dist = result->footer_dist = 1.27; 1082 result->header_dist = result->footer_dist = 1.27;
863 result->left_margin = result->right_margin = 3.175; 1083 result->left_margin = result->right_margin = 3.175;
864 result->top_margin = result->bottom_margin = 2.54; 1084 result->top_margin = result->bottom_margin = 2.54;
865 result->page_width = 21.0; 1085 result->page_width = 21.0;
866 result->page_height = 29.7; 1086 result->page_height = 29.7;
918 free(result); 1138 free(result);
919ERROR1: 1139ERROR1:
920 return NULL; 1140 return NULL;
921} 1141}
922 1142
1143psiconv_sheet_status_section psiconv_empty_sheet_status_section(void)
1144{
1145 psiconv_sheet_status_section result;
1146 if (!(result = malloc(sizeof(*result))))
1147 return NULL;
1148 result->show_horizontal_scrollbar = result->show_vertical_scrollbar =
1149 psiconv_triple_auto;
1150 result->show_graph = psiconv_bool_false;
1151 result->show_top_sheet_toolbar = result->show_side_sheet_toolbar =
1152 result->show_top_graph_toolbar = result->show_side_graph_toolbar =
1153 psiconv_bool_true;
1154 result->cursor_row = result->cursor_column = 0;
1155 result->sheet_display_size = result->graph_display_size = 1000;
1156 return result;
1157}
1158
1159psiconv_formula_list psiconv_empty_formula_list(void)
1160{
1161 return psiconv_list_new(sizeof(struct psiconv_formula_s));
1162}
1163
1164psiconv_sheet_workbook_section psiconv_empty_sheet_workbook_section(void)
1165{
1166 psiconv_sheet_workbook_section result;
1167 if (!(result = malloc(sizeof(*result))))
1168 goto ERROR1;
1169 if (!(result->formulas = psiconv_empty_formula_list()))
1170 goto ERROR2;
1171 return result;
1172ERROR2:
1173 free(result);
1174ERROR1:
1175 return NULL;
1176}
1177
1178
1179psiconv_sheet_f psiconv_empty_sheet_f(void)
1180{
1181 psiconv_sheet_f result;
1182 if (!(result = malloc(sizeof(*result))))
1183 goto ERROR1;
1184 if (!(result->page_sec = psiconv_empty_page_layout_section()))
1185 goto ERROR2;
1186 if (!(result->status_sec = psiconv_empty_sheet_status_section()))
1187 goto ERROR3;
1188 if (!(result->workbook_sec = psiconv_empty_sheet_workbook_section()))
1189 goto ERROR4;
1190 return result;
1191ERROR4:
1192 psiconv_free_sheet_status_section(result->status_sec);
1193ERROR3:
1194 psiconv_free_page_layout_section(result->page_sec);
1195ERROR2:
1196 free(result);
1197ERROR1:
1198 return NULL;
1199}
1200
923psiconv_texted_f psiconv_empty_texted_f(void) 1201psiconv_texted_f psiconv_empty_texted_f(void)
924{ 1202{
925 psiconv_texted_f result; 1203 psiconv_texted_f result;
926 if (!(result = malloc(sizeof(*result)))) 1204 if (!(result = malloc(sizeof(*result))))
927 goto ERROR1; 1205 goto ERROR1;
1059 if (!(result = malloc(sizeof(*result)))) 1337 if (!(result = malloc(sizeof(*result))))
1060 return NULL; 1338 return NULL;
1061 result->type = type; 1339 result->type = type;
1062 if (type == psiconv_word_file) { 1340 if (type == psiconv_word_file) {
1063 if (!(result->file = psiconv_empty_word_f())) 1341 if (!(result->file = psiconv_empty_word_f()))
1342 goto ERROR;
1343 } else if (type == psiconv_sheet_file) {
1344 if (!(result->file = psiconv_empty_sheet_f()))
1064 goto ERROR; 1345 goto ERROR;
1065 } else if (type == psiconv_texted_file) { 1346 } else if (type == psiconv_texted_file) {
1066 if (!(result->file = psiconv_empty_texted_f())) 1347 if (!(result->file = psiconv_empty_texted_f()))
1067 goto ERROR; 1348 goto ERROR;
1068 } else if (type == psiconv_mbm_file) { 1349 } else if (type == psiconv_mbm_file) {

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

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