/[public]/psiconv/trunk/lib/psiconv/generate_word.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/generate_word.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 76 Revision 85
23#include <stdlib.h> 23#include <stdlib.h>
24 24
25#include "generate_routines.h" 25#include "generate_routines.h"
26#include "error.h" 26#include "error.h"
27 27
28int psiconv_generate_word_status_section(psiconv_buffer buf, 28int psiconv_write_word_status_section(psiconv_buffer buf,
29 psiconv_word_status_section value) 29 psiconv_word_status_section value)
30{ 30{
31 int res; 31 int res;
32 32
33 if (!value) { 33 if (!value) {
34 psiconv_warn(0,psiconv_list_length(buf),"Null word status section"); 34 psiconv_warn(0,psiconv_buffer_length(buf),"Null word status section");
35 return -PSICONV_E_GENERATE; 35 return -PSICONV_E_GENERATE;
36 } 36 }
37 37
38 if ((res = psiconv_write_u8(buf,0x02))) 38 if ((res = psiconv_write_u8(buf,0x02)))
39 return res; 39 return res;
63{ 63{
64 int res,i; 64 int res,i;
65 psiconv_word_style style; 65 psiconv_word_style style;
66 psiconv_paragraph_layout basepara; 66 psiconv_paragraph_layout basepara;
67 psiconv_character_layout basechar; 67 psiconv_character_layout basechar;
68 psiconv_font font;
68 69
69 70
70 if (!value || !value->normal || !value->styles) { 71 if (!value || !value->normal || !value->styles) {
71 psiconv_warn(0,psiconv_list_length(buf),"Null word styles section"); 72 psiconv_warn(0,psiconv_buffer_length(buf),"Null word styles section");
72 res = -PSICONV_E_GENERATE; 73 res = -PSICONV_E_GENERATE;
73 goto ERROR1; 74 goto ERROR1;
74 } 75 }
75 76
76 if (!(basepara=psiconv_basic_paragraph_layout())) { 77 if (!(basepara=psiconv_basic_paragraph_layout())) {
85 86
86 87
87 if ((res = psiconv_write_paragraph_layout_list(buf,value->normal->paragraph, 88 if ((res = psiconv_write_paragraph_layout_list(buf,value->normal->paragraph,
88 basepara))) 89 basepara)))
89 goto ERROR3; 90 goto ERROR3;
91 /* Always generate the font for Normal */
92 font = basechar->font;
93 basechar->font = NULL;
90 if ((res = psiconv_write_character_layout_list(buf,value->normal->character, 94 res = psiconv_write_character_layout_list(buf,value->normal->character,
91 basechar))) 95 basechar);
96 basechar->font = font;
97 if (res)
92 goto ERROR3; 98 goto ERROR3;
93 if ((res = psiconv_write_u32(buf,value->normal->hotkey))) 99 if ((res = psiconv_write_u32(buf,value->normal->hotkey)))
94 goto ERROR3; 100 goto ERROR3;
95 if ((res = psiconv_write_u8(buf,psiconv_list_length(value->styles)))) 101 if ((res = psiconv_write_u8(buf,psiconv_list_length(value->styles))))
96 goto ERROR3; 102 goto ERROR3;
97 103
98 104
99 105
100 for (i = 0; i < psiconv_list_length(value->styles); i++) { 106 for (i = 0; i < psiconv_list_length(value->styles); i++) {
101 if (!(style = psiconv_list_get(value->styles,i))) { 107 if (!(style = psiconv_list_get(value->styles,i))) {
102 psiconv_warn(0,psiconv_list_length(buf),"Massive memory corruption"); 108 psiconv_warn(0,psiconv_buffer_length(buf),"Massive memory corruption");
103 res = -PSICONV_E_OTHER; 109 res = -PSICONV_E_OTHER;
104 goto ERROR3; 110 goto ERROR3;
105 } 111 }
106 if ((res = psiconv_write_u32(buf,style->hotkey))) 112 if ((res = psiconv_write_u32(buf,style->hotkey)))
107 goto ERROR3; 113 goto ERROR3;
108 } 114 }
109 if ((res = psiconv_write_u8(buf,psiconv_list_length(value->styles)))) 115 if ((res = psiconv_write_u8(buf,psiconv_list_length(value->styles))))
110 goto ERROR3; 116 goto ERROR3;
111 for (i = 0; i < psiconv_list_length(value->styles); i++) { 117 for (i = 0; i < psiconv_list_length(value->styles); i++) {
112 if (!(style = psiconv_list_get(value->styles,i))) { 118 if (!(style = psiconv_list_get(value->styles,i))) {
113 psiconv_warn(0,psiconv_list_length(buf),"Massive memory corruption"); 119 psiconv_warn(0,psiconv_buffer_length(buf),"Massive memory corruption");
114 res = -PSICONV_E_OTHER; 120 res = -PSICONV_E_OTHER;
115 goto ERROR3; 121 goto ERROR3;
116 } 122 }
117 if (!style->name) { 123 if (!style->name) {
118 psiconv_warn(0,psiconv_list_length(buf),"Null style name"); 124 psiconv_warn(0,psiconv_buffer_length(buf),"Null style name");
119 res = -PSICONV_E_GENERATE; 125 res = -PSICONV_E_GENERATE;
120 goto ERROR3; 126 goto ERROR3;
121 } 127 }
122 if ((res = psiconv_write_string(buf,style->name))) 128 if ((res = psiconv_write_string(buf,style->name)))
123 goto ERROR3; 129 goto ERROR3;
131 goto ERROR3; 137 goto ERROR3;
132 if ((res = psiconv_write_paragraph_layout_list(buf,style->paragraph, 138 if ((res = psiconv_write_paragraph_layout_list(buf,style->paragraph,
133 value->normal->paragraph))) 139 value->normal->paragraph)))
134 goto ERROR3; 140 goto ERROR3;
135 } 141 }
142
143 for (i = 0; i < psiconv_list_length(value->styles); i++)
144 if ((res = psiconv_write_u8(buf,0xff)))
145 goto ERROR3;
136 res = -PSICONV_E_OK; 146 res = -PSICONV_E_OK;
137 147
138ERROR3: 148ERROR3:
139 psiconv_free_character_layout(basechar); 149 psiconv_free_character_layout(basechar);
140ERROR2: 150ERROR2:

Legend:
Removed from v.76  
changed lines
  Added in v.85

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