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

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

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