1 | /* |
1 | /* |
2 | parse_word.c - Part of psiconv, a PSION 5 file formats converter |
2 | parse_word.c - Part of psiconv, a PSION 5 file formats converter |
3 | Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> |
3 | Copyright (c) 1999-2004 Frodo Looijaard <frodol@dds.nl> |
4 | |
4 | |
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
… | |
… | |
201 | goto ERROR2_2; |
201 | goto ERROR2_2; |
202 | if ((res = psiconv_parse_character_layout_list(config,buf,lev+3,off+len,&leng, |
202 | if ((res = psiconv_parse_character_layout_list(config,buf,lev+3,off+len,&leng, |
203 | style->character))) |
203 | style->character))) |
204 | goto ERROR2_3; |
204 | goto ERROR2_3; |
205 | len += leng; |
205 | len += leng; |
|
|
206 | /* Ugly: I really don't know whether this is right for UTF8 */ |
206 | psiconv_progress(config,lev+3,off+len,"Going to read the hotkey"); |
207 | psiconv_progress(config,lev+3,off+len,"Going to read the hotkey"); |
207 | temp = psiconv_read_u32(config,buf,lev+3,off+len,&res); |
208 | style->hotkey = psiconv_unicode_read_char(config,buf,lev+3,off+len,NULL,&res); |
|
|
209 | psiconv_debug(config,lev+3,off+len,"Normal Hotkey value %08x",style->hotkey); |
208 | if (res) |
210 | if (res) |
209 | goto ERROR2_3; |
211 | goto ERROR2_3; |
210 | if (temp & 0xffffff00) { |
212 | len += 0x04; |
211 | psiconv_warn(config,lev+3,off+len, |
|
|
212 | "Normal style hotkey has unknown value (ignored)"); |
|
|
213 | psiconv_debug(config,lev+3,off+len,"Hotkey value %08x",temp); |
|
|
214 | temp = 0; |
|
|
215 | } |
|
|
216 | style->hotkey = psiconv_unicode_from_char(config,temp); |
|
|
217 | (*result)->normal = style; |
213 | (*result)->normal = style; |
218 | len += 0x04; |
|
|
219 | |
214 | |
220 | psiconv_progress(config,lev+2,off+len,"Going to read hotkeys list"); |
215 | psiconv_progress(config,lev+2,off+len,"Going to read hotkeys list"); |
221 | if (!((*result)->styles = psiconv_list_new(sizeof(*style)))) |
216 | if (!((*result)->styles = psiconv_list_new(sizeof(*style)))) |
222 | goto ERROR3; |
217 | goto ERROR3; |
223 | if (!(style = malloc(sizeof(*style)))) { |
218 | if (!(style = malloc(sizeof(*style)))) { |
… | |
… | |
229 | if (res) |
224 | if (res) |
230 | goto ERROR3_2; |
225 | goto ERROR3_2; |
231 | len ++; |
226 | len ++; |
232 | psiconv_debug(config,lev+3,off+len,"Nummer of hotkeys: %02x",nr); |
227 | psiconv_debug(config,lev+3,off+len,"Nummer of hotkeys: %02x",nr); |
233 | for (i = 0; i < nr; i ++) { |
228 | for (i = 0; i < nr; i ++) { |
234 | temp = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
229 | /* Ugly: I really don't know whether this is right for UTF8 */ |
235 | if (res) |
230 | style->hotkey = psiconv_unicode_read_char(config,buf,lev+3,off+len, |
236 | goto ERROR3_2; |
231 | NULL,&res); |
237 | if (temp & 0xffffff00) { |
|
|
238 | psiconv_warn(config,lev+3,off+len,"Style hotkey has unknown value (ignored)"); |
|
|
239 | psiconv_debug(config,lev+3,off+len,"Hotkey %d value %08x",i,temp); |
|
|
240 | temp = 0; |
|
|
241 | } |
|
|
242 | style->hotkey = temp & 0x000000ff; |
|
|
243 | if ((style->hotkey >= 32) && (style->hotkey < 127)) |
|
|
244 | psiconv_debug(config,lev+3,off+len,"Hotkey %d: %c",i,style->hotkey); |
|
|
245 | else if (style->hotkey == 0x00) |
|
|
246 | psiconv_debug(config,lev+3,off+len,"Hotkey %d: <none>",i); |
|
|
247 | else |
|
|
248 | psiconv_debug(config,lev+3,off+len,"Hotkey %d: %02x",i,style->hotkey); |
232 | psiconv_debug(config,lev+3,off+len,"Hotkey %d value %08x",i,style->hotkey); |
|
|
233 | len += 0x04; |
249 | if ((res = psiconv_list_add((*result)->styles,style))) |
234 | if ((res = psiconv_list_add((*result)->styles,style))) |
250 | goto ERROR3_2; |
235 | goto ERROR3_2; |
251 | len += 0x04; |
|
|
252 | } |
236 | } |
253 | free(style); |
237 | free(style); |
254 | |
238 | |
255 | psiconv_progress(config,lev+2,off+len,"Going to read all other styles"); |
239 | psiconv_progress(config,lev+2,off+len,"Going to read all other styles"); |
256 | psiconv_progress(config,lev+2,off+len,"Going to read the number of styles"); |
240 | psiconv_progress(config,lev+2,off+len,"Going to read the number of styles"); |