… | |
… | |
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 | #include "list.h" |
|
|
26 | #include "unicode.h" |
|
|
27 | |
|
|
28 | #ifdef DMALLOC |
|
|
29 | #include <dmalloc.h> |
|
|
30 | #endif |
26 | |
31 | |
27 | static psiconv_color clone_color(psiconv_color color); |
32 | static psiconv_color clone_color(psiconv_color color); |
28 | static psiconv_font clone_font(psiconv_font font); |
33 | static psiconv_font clone_font(psiconv_font font); |
29 | static psiconv_border clone_border(psiconv_border border); |
34 | static psiconv_border clone_border(psiconv_border border); |
30 | static psiconv_bullet clone_bullet(psiconv_bullet bullet); |
35 | static psiconv_bullet clone_bullet(psiconv_bullet bullet); |
… | |
… | |
35 | static void psiconv_free_paint_data_section_aux(void * section); |
40 | static void psiconv_free_paint_data_section_aux(void * section); |
36 | static void psiconv_free_clipart_section_aux(void * section); |
41 | static void psiconv_free_clipart_section_aux(void * section); |
37 | static void psiconv_free_formula_aux(void *data); |
42 | static void psiconv_free_formula_aux(void *data); |
38 | static void psiconv_free_sheet_worksheet_aux (void *data); |
43 | static void psiconv_free_sheet_worksheet_aux (void *data); |
39 | static void psiconv_free_sheet_variable_aux(void * variable); |
44 | static void psiconv_free_sheet_variable_aux(void * variable); |
|
|
45 | static void psiconv_free_sheet_cell_aux(void *cell); |
|
|
46 | static void psiconv_free_sheet_line_aux(void *line); |
|
|
47 | static void psiconv_free_sheet_worksheet_aux (void *data); |
40 | |
48 | |
41 | static psiconv_word_styles_section psiconv_empty_word_styles_section(void); |
49 | static psiconv_word_styles_section psiconv_empty_word_styles_section(void); |
42 | static psiconv_text_and_layout psiconv_empty_text_and_layout(void); |
50 | static psiconv_text_and_layout psiconv_empty_text_and_layout(void); |
43 | static psiconv_texted_section psiconv_empty_texted_section(void); |
51 | static psiconv_texted_section psiconv_empty_texted_section(void); |
44 | static psiconv_page_header psiconv_empty_page_header(void); |
52 | static psiconv_page_header psiconv_empty_page_header(void); |
… | |
… | |
75 | { |
83 | { |
76 | 0xff, /* red */ |
84 | 0xff, /* red */ |
77 | 0xff, /* green */ |
85 | 0xff, /* green */ |
78 | 0xff, /* blue */ |
86 | 0xff, /* blue */ |
79 | }; |
87 | }; |
|
|
88 | static psiconv_ucs2 font_times[16] = { 'T','i','m','e','s',' ', |
|
|
89 | 'N','e','w',' ', |
|
|
90 | 'R','o','m','a','n',0 }; |
80 | static struct psiconv_font_s font = |
91 | static struct psiconv_font_s font = |
81 | { |
92 | { |
82 | "Times New Roman", /* name */ |
93 | font_times, /* name */ |
83 | 3 /* screenfont */ |
94 | 3 /* screenfont */ |
84 | }; |
95 | }; |
85 | struct psiconv_character_layout_s cl = |
96 | struct psiconv_character_layout_s cl = |
86 | { |
97 | { |
87 | &black, /* color */ |
98 | &black, /* color */ |
… | |
… | |
100 | |
111 | |
101 | /* Note: these defaults seem to be hard-coded somewhere outside the |
112 | /* Note: these defaults seem to be hard-coded somewhere outside the |
102 | files themself. */ |
113 | files themself. */ |
103 | psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) |
114 | psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) |
104 | { |
115 | { |
|
|
116 | static psiconv_ucs2 font_times[16] = { 'T','i','m','e','s',' ', |
|
|
117 | 'N','e','w',' ', |
|
|
118 | 'R','o','m','a','n',0 }; |
|
|
119 | |
105 | static struct psiconv_font_s font = |
120 | static struct psiconv_font_s font = |
106 | { |
121 | { |
107 | "Times New Roman", /* name */ |
122 | font_times, /* name */ |
108 | 2 /* screenfont */ |
123 | 2 /* screenfont */ |
109 | }; |
124 | }; |
110 | static struct psiconv_color_s black = |
125 | static struct psiconv_color_s black = |
111 | { |
126 | { |
112 | 0x00, /* red */ |
127 | 0x00, /* red */ |
… | |
… | |
127 | }; |
142 | }; |
128 | static struct psiconv_bullet_s bullet = |
143 | static struct psiconv_bullet_s bullet = |
129 | { |
144 | { |
130 | psiconv_bool_false, /* on */ |
145 | psiconv_bool_false, /* on */ |
131 | 10.0, /* font_size */ |
146 | 10.0, /* font_size */ |
132 | 0x95, /* character */ |
147 | 0x201d, /* character */ |
133 | psiconv_bool_true, /* indent */ |
148 | psiconv_bool_true, /* indent */ |
134 | &black, /* color */ |
149 | &black, /* color */ |
135 | &font, /* font */ |
150 | &font, /* font */ |
136 | }; |
151 | }; |
137 | static struct psiconv_all_tabs_s tabs = |
152 | static struct psiconv_all_tabs_s tabs = |
… | |
… | |
186 | { |
201 | { |
187 | psiconv_font result; |
202 | psiconv_font result; |
188 | if(!(result = malloc(sizeof(*result)))) |
203 | if(!(result = malloc(sizeof(*result)))) |
189 | goto ERROR1; |
204 | goto ERROR1; |
190 | *result = *font; |
205 | *result = *font; |
191 | if (!(result->name = strdup(result->name))) |
206 | if (!(result->name = psiconv_unicode_strdup(result->name))) |
192 | goto ERROR2; |
207 | goto ERROR2; |
193 | return result; |
208 | return result; |
194 | ERROR2: |
209 | ERROR2: |
195 | free(result); |
210 | free(result); |
196 | ERROR1: |
211 | ERROR1: |
… | |
… | |
438 | { |
453 | { |
439 | if (styles) { |
454 | if (styles) { |
440 | psiconv_free_word_style(styles->normal); |
455 | psiconv_free_word_style(styles->normal); |
441 | if (styles->styles) |
456 | if (styles->styles) |
442 | psiconv_list_free_el(styles->styles,psiconv_free_style_aux); |
457 | psiconv_list_free_el(styles->styles,psiconv_free_style_aux); |
|
|
458 | free(styles); |
443 | } |
459 | } |
444 | } |
460 | } |
445 | |
461 | |
446 | void psiconv_free_header_section(psiconv_header_section header) |
462 | void psiconv_free_header_section(psiconv_header_section header) |
447 | { |
463 | { |
… | |
… | |
468 | free(section->name); |
484 | free(section->name); |
469 | free(section); |
485 | free(section); |
470 | } |
486 | } |
471 | } |
487 | } |
472 | |
488 | |
|
|
489 | void psiconv_free_object_icon_section(psiconv_object_icon_section section) |
|
|
490 | { |
|
|
491 | if (section) { |
|
|
492 | if (section->icon_name) |
|
|
493 | free(section->icon_name); |
|
|
494 | free(section); |
|
|
495 | } |
|
|
496 | } |
|
|
497 | |
|
|
498 | void psiconv_free_object_display_section(psiconv_object_display_section section) |
|
|
499 | { |
|
|
500 | if (section) |
|
|
501 | free(section); |
|
|
502 | } |
|
|
503 | |
|
|
504 | void psiconv_free_embedded_object_section |
|
|
505 | (psiconv_embedded_object_section object) |
|
|
506 | { |
|
|
507 | if (object) { |
|
|
508 | psiconv_free_object_icon_section(object->icon); |
|
|
509 | psiconv_free_object_display_section(object->display); |
|
|
510 | psiconv_free_file(object->object); |
|
|
511 | free(object); |
|
|
512 | } |
|
|
513 | } |
|
|
514 | |
473 | void psiconv_free_in_line_layout_aux(void * layout) |
515 | void psiconv_free_in_line_layout_aux(void * layout) |
474 | { |
516 | { |
475 | psiconv_free_character_layout(((psiconv_in_line_layout) layout)->layout); |
517 | psiconv_free_character_layout(((psiconv_in_line_layout) layout)->layout); |
|
|
518 | psiconv_free_embedded_object_section |
|
|
519 | (((psiconv_in_line_layout) layout)->object); |
476 | } |
520 | } |
477 | |
521 | |
478 | void psiconv_free_in_line_layout(psiconv_in_line_layout layout) |
522 | void psiconv_free_in_line_layout(psiconv_in_line_layout layout) |
479 | { |
523 | { |
480 | if (layout) { |
524 | if (layout) { |
… | |
… | |
629 | psiconv_free_sheet_line_aux(line); |
673 | psiconv_free_sheet_line_aux(line); |
630 | free(line); |
674 | free(line); |
631 | } |
675 | } |
632 | } |
676 | } |
633 | |
677 | |
|
|
678 | |
634 | void psiconv_free_sheet_line_list(psiconv_sheet_line_list list) |
679 | void psiconv_free_sheet_line_list(psiconv_sheet_line_list list) |
635 | { |
680 | { |
636 | if (list) |
681 | if (list) |
637 | psiconv_list_free_el(list,psiconv_free_sheet_line_aux); |
682 | psiconv_list_free_el(list,psiconv_free_sheet_line_aux); |
|
|
683 | } |
|
|
684 | |
|
|
685 | void psiconv_free_sheet_grid_break_list(psiconv_sheet_grid_break_list list) |
|
|
686 | { |
|
|
687 | if (list) |
|
|
688 | psiconv_list_free(list); |
|
|
689 | } |
|
|
690 | |
|
|
691 | void psiconv_free_sheet_grid_size(psiconv_sheet_grid_size s) |
|
|
692 | { |
|
|
693 | if (s) |
|
|
694 | free(s); |
|
|
695 | } |
|
|
696 | |
|
|
697 | void psiconv_free_sheet_grid_size_list(psiconv_sheet_grid_size_list list) |
|
|
698 | { |
|
|
699 | if (list) |
|
|
700 | psiconv_list_free(list); |
|
|
701 | } |
|
|
702 | |
|
|
703 | void psiconv_free_sheet_grid_section(psiconv_sheet_grid_section sec) |
|
|
704 | { |
|
|
705 | if (sec) { |
|
|
706 | psiconv_free_sheet_grid_size_list(sec->row_heights); |
|
|
707 | psiconv_free_sheet_grid_size_list(sec->column_heights); |
|
|
708 | psiconv_free_sheet_grid_break_list(sec->row_page_breaks); |
|
|
709 | psiconv_free_sheet_grid_break_list(sec->column_page_breaks); |
|
|
710 | free(sec); |
|
|
711 | } |
638 | } |
712 | } |
639 | |
713 | |
640 | void psiconv_free_sheet_worksheet_aux (void *data) |
714 | void psiconv_free_sheet_worksheet_aux (void *data) |
641 | { |
715 | { |
642 | psiconv_sheet_worksheet section = data; |
716 | psiconv_sheet_worksheet section = data; |
643 | psiconv_free_sheet_cell_layout(section->default_layout); |
717 | psiconv_free_sheet_cell_layout(section->default_layout); |
644 | psiconv_free_sheet_cell_list(section->cells); |
718 | psiconv_free_sheet_cell_list(section->cells); |
645 | psiconv_free_sheet_line_list(section->row_default_layouts); |
719 | psiconv_free_sheet_line_list(section->row_default_layouts); |
646 | psiconv_free_sheet_line_list(section->col_default_layouts); |
720 | psiconv_free_sheet_line_list(section->col_default_layouts); |
|
|
721 | psiconv_free_sheet_grid_section(section->grid); |
647 | } |
722 | } |
648 | |
723 | |
649 | void psiconv_free_sheet_worksheet(psiconv_sheet_worksheet sheet) |
724 | void psiconv_free_sheet_worksheet(psiconv_sheet_worksheet sheet) |
650 | { |
725 | { |
651 | if (sheet) { |
726 | if (sheet) { |
… | |
… | |
881 | const psiconv_font value2) |
956 | const psiconv_font value2) |
882 | { |
957 | { |
883 | if (!value1 || !value2 || !value1->name || !value2->name) |
958 | if (!value1 || !value2 || !value1->name || !value2->name) |
884 | return 1; |
959 | return 1; |
885 | if ((value1->screenfont == value2->screenfont) && |
960 | if ((value1->screenfont == value2->screenfont) && |
886 | !strcmp(value1->name,value2->name)) |
961 | !psiconv_unicode_strcmp(value1->name,value2->name)) |
887 | return 0; |
962 | return 0; |
888 | else |
963 | else |
889 | return 1; |
964 | return 1; |
890 | } |
965 | } |
891 | |
966 | |
… | |
… | |
1279 | psiconv_sketch_section psiconv_empty_sketch_section(void) |
1354 | psiconv_sketch_section psiconv_empty_sketch_section(void) |
1280 | { |
1355 | { |
1281 | psiconv_sketch_section result; |
1356 | psiconv_sketch_section result; |
1282 | if (!(result = malloc(sizeof(*result)))) |
1357 | if (!(result = malloc(sizeof(*result)))) |
1283 | goto ERROR1; |
1358 | goto ERROR1; |
1284 | result->form_xsize = 320; |
1359 | result->displayed_xsize = 320; |
1285 | result->form_ysize = 200; |
1360 | result->displayed_ysize = 200; |
1286 | result->picture_x_offset = result->picture_y_offset = result->picture_xsize = |
1361 | result->picture_data_x_offset = result->picture_data_y_offset = |
1287 | result->picture_ysize = 0; |
1362 | result->form_xsize = result->form_ysize = |
|
|
1363 | result->displayed_size_x_offset = result->displayed_size_y_offset = 0; |
1288 | result->magnification_x = result->magnification_y = 1.0; |
1364 | result->magnification_x = result->magnification_y = 1.0; |
1289 | result->cut_left = result->cut_right = result->cut_top = |
1365 | result->cut_left = result->cut_right = result->cut_top = |
1290 | result->cut_bottom = 0.0; |
1366 | result->cut_bottom = 0.0; |
1291 | if (!(result->picture = psiconv_empty_paint_data_section())) |
1367 | if (!(result->picture = psiconv_empty_paint_data_section())) |
1292 | goto ERROR2; |
1368 | goto ERROR2; |