--- psiconv/trunk/lib/psiconv/generate_driver.c 2000/12/27 02:13:52 81 +++ psiconv/trunk/lib/psiconv/generate_driver.c 2000/12/27 23:20:45 82 @@ -37,13 +37,10 @@ if (!(*buf = psiconv_buffer_new())) return -PSICONV_E_NOMEM; -#if 0 if (value->type == psiconv_word_file) { if ((res =psiconv_write_word_file(*buf,(psiconv_word_f) (value->file)))) goto ERROR; - } else -#endif - if (value->type == psiconv_texted_file) { + } else if (value->type == psiconv_texted_file) { if ((res =psiconv_write_texted_file(*buf, (psiconv_texted_f) (value->file)))) goto ERROR; @@ -165,6 +162,106 @@ ERROR3: free(entry); ERROR2: + psiconv_list_free(section_table); +ERROR1: + return res; +} + +int psiconv_write_word_file(psiconv_buffer buf,psiconv_word_f value) +{ + int res; + psiconv_section_table_section section_table; + psiconv_section_table_entry entry; + psiconv_u32 section_table_id; + + if (!value) { + psiconv_warn(0,0,"Null Word file"); + return -PSICONV_E_GENERATE; + } + + if (!(section_table = psiconv_list_new(sizeof(*entry)))) { + res = -PSICONV_E_NOMEM; + goto ERROR1; + } + + if (!(entry = malloc(sizeof(*entry)))) { + res = -PSICONV_E_NOMEM; + goto ERROR2; + } + + if ((res = psiconv_write_header_section(buf,PSICONV_ID_PSION5, + PSICONV_ID_DATA_FILE, + PSICONV_ID_WORD))) + goto ERROR3; + + section_table_id = psiconv_buffer_unique_id(); + if ((res = psiconv_write_offset(buf,section_table_id))) + goto ERROR3; + + entry->id = PSICONV_ID_APPL_ID_SECTION; + entry->offset = psiconv_buffer_unique_id(); + if ((res = psiconv_list_add(section_table,entry))) + goto ERROR3; + if ((res = psiconv_buffer_add_target(buf,entry->offset))) + goto ERROR3; + if ((res=psiconv_write_application_id_section(buf, + PSICONV_ID_WORD,"Word.app"))) + goto ERROR3; + + entry->id = PSICONV_ID_WORD_STATUS_SECTION; + entry->offset = psiconv_buffer_unique_id(); + if ((res = psiconv_list_add(section_table,entry))) + goto ERROR3; + if ((res = psiconv_buffer_add_target(buf,entry->offset))) + goto ERROR3; + if ((res = psiconv_write_word_status_section(buf,value->status_sec))) + goto ERROR3; + + entry->id = PSICONV_ID_PAGE_LAYOUT_SECTION; + entry->offset = psiconv_buffer_unique_id(); + if ((res = psiconv_list_add(section_table,entry))) + goto ERROR3; + if ((res = psiconv_buffer_add_target(buf,entry->offset))) + goto ERROR3; + if ((res = psiconv_write_page_layout_section(buf,value->page_sec))) + goto ERROR3; + + entry->id = PSICONV_ID_WORD_STYLES_SECTION; + entry->offset = psiconv_buffer_unique_id(); + if ((res = psiconv_list_add(section_table,entry))) + goto ERROR3; + if ((res = psiconv_buffer_add_target(buf,entry->offset))) + goto ERROR3; + if ((res = psiconv_write_word_styles_section(buf,value->styles_sec))) + goto ERROR3; + + entry->id = PSICONV_ID_TEXT_SECTION; + entry->offset = psiconv_buffer_unique_id(); + if ((res = psiconv_list_add(section_table,entry))) + goto ERROR3; + if ((res = psiconv_buffer_add_target(buf,entry->offset))) + goto ERROR3; + if ((res = psiconv_write_text_section(buf,value->paragraphs))) + goto ERROR3; + + entry->id = PSICONV_ID_LAYOUT_SECTION; + entry->offset = psiconv_buffer_unique_id(); + if ((res = psiconv_list_add(section_table,entry))) + goto ERROR3; + if ((res = psiconv_buffer_add_target(buf,entry->offset))) + goto ERROR3; + if ((res = psiconv_write_styled_layout_section(buf,value->paragraphs, + value->styles_sec))) + goto ERROR3; + + if ((res = psiconv_buffer_add_target(buf,section_table_id))) + goto ERROR3; + + res = psiconv_write_section_table_section(buf,section_table); + +ERROR3: + free(entry); +ERROR2: psiconv_list_free(section_table); ERROR1: return res;