diff -urwB abiword.r29620/plugins/mswrite/xp/ie_impexp_MSWrite.cpp abiword.pre.r29620.patched/plugins/mswrite/xp/ie_impexp_MSWrite.cpp --- abiword.r29620/plugins/mswrite/xp/ie_impexp_MSWrite.cpp 2011-03-06 19:10:30.000000000 +0100 +++ abiword.pre.r29620.patched/plugins/mswrite/xp/ie_impexp_MSWrite.cpp 2011-03-06 19:21:43.000000000 +0100 @@ -1,5 +1,6 @@ /* AbiWord * Copyright (C) 2001 Sean Young + * 2010 Ingo Brueckl * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff -urwB abiword.r29620/plugins/mswrite/xp/ie_imp_MSWrite.cpp abiword.pre.r29620.patched/plugins/mswrite/xp/ie_imp_MSWrite.cpp --- abiword.r29620/plugins/mswrite/xp/ie_imp_MSWrite.cpp 2011-03-06 19:13:17.000000000 +0100 +++ abiword.pre.r29620.patched/plugins/mswrite/xp/ie_imp_MSWrite.cpp 2011-03-06 19:21:43.000000000 +0100 @@ -24,16 +24,14 @@ * Documentation at http://www.msxnet.org/word2rtf/formats/write * * TODO: - * - pictures: clean up / polish off code, add wmf - * - OLE: no support yet * - headers/footers (can only be page numbers) + * - clean up / polish off code * - speed it up! */ #include #include #include -#include #include "ut_locale.h" #include "ut_types.h" @@ -219,8 +217,6 @@ font_count = 0; wri_fonts = NULL; - std::set raw_fonts; - while (true) { if (!gsf_input_read (mFile, 2, byt)) { perror ("wri_file"); @@ -261,23 +257,9 @@ perror ("wri_file"); return 1; } - char *trname; - wri_fonts[font_count].codepage=get_codepage(ffn,&trname); - if (wri_fonts[font_count].codepage) { - strcpy(ffn,trname); - raw_fonts.insert(strdup(trname)); - } wri_fonts[font_count].name = ffn; font_count++; } - for (int i=0; i::iterator pos; - if (!wri_fonts[i].codepage) { - pos = raw_fonts.find(wri_fonts[i].name); - if (pos != raw_fonts.end()) - wri_fonts[i].codepage="CP1252"; - } - } if (static_cast(font_count) != wri_fonts_count) { wri_fonts_count = font_count; UT_DEBUGMSG(("write file lied about number of fonts\n")); @@ -285,18 +267,9 @@ return 0; } -static struct cst_data { - char *suffix; - char *cpid; -} cp_suf_tbl[]={ - {"\x04 cyr","CP1251"}, - {"\x03 ce","CP1250"}, - {NULL,NULL} -}; - void IE_Imp_MSWrite::translate_char (char ch, UT_UCS4String &buf) { - UT_UCS4Char uch=ch; + UT_UCS4Char wch; lf = false; @@ -315,38 +288,15 @@ case 13: /* carriage return */ case 31: /* soft hyphen */ break; - default: - if (ch & 0x80) { - charconv.mbtowc(uch, ch); - } - buf += uch; - } -} -char *IE_Imp_MSWrite::get_codepage(char *facename, char **newname) + default: + if (ch & 0x80) { - static char facebuf[40]; - cst_data *p=cp_suf_tbl; - int l=strlen(facename); - while (p->suffix) { - if (*p->suffix < l) { - if (!strcmpi(&p->suffix[1],&facename[l-*p->suffix])) { - if (newname) { - strncpy(facebuf,facename,l-*p->suffix); - facebuf[l-*p->suffix]=0; - *newname=facebuf; - } - return p->cpid; + charconv.mbtowc(wch, ch); + buf += wch; } + else buf += ch; } - p++; - } - return 0; -} - -void IE_Imp_MSWrite::set_codepage(char *charset) -{ - charconv.setInCharset(charset); } /* the section property */ @@ -634,7 +584,7 @@ UT_String_sprintf (tempBuffer, "; font-family:%s", wri_fonts[ftc].name); propBuffer += tempBuffer; } - set_codepage(wri_fonts[ftc].codepage); + while (fcFirst2 >= fcFirst) { if ((fcFirst2 >= fcLim) || (fcFirst2 > fcLim2) || (fcFirst2 - 0x80 >= static_cast(mTextBuf.getLength()))) { @@ -808,16 +757,12 @@ IE_Imp_MSWrite::IE_Imp_MSWrite(PD_Document * pDocument) : IE_Imp(pDocument), mFile(0), wri_fonts_count(0), wri_fonts(0), pic_nr(0), - lf(false) + charconv("WINDOWS-1252"), lf(false) { - charconv.setInCharset("CP1252"); - write_file_header = static_cast(malloc (sizeof (WRITE_FILE_HEADER))); memcpy (write_file_header, WRITE_FILE_HEADER, sizeof (WRITE_FILE_HEADER)); - write_ole_picture = static_cast(malloc (sizeof (WRITE_OLE_PICTURE))); memcpy (write_ole_picture, WRITE_OLE_PICTURE, sizeof (WRITE_OLE_PICTURE)); - write_picture = static_cast(malloc (sizeof (WRITE_PICTURE))); memcpy (write_picture, WRITE_PICTURE, sizeof (WRITE_PICTURE)); } @@ -867,11 +812,6 @@ return UT_OK; } -#ifdef _MSC_VER -typedef unsigned __int32 uint32_t; -typedef unsigned __int16 uint16_t; -#endif - /*****************************************************************/ /*****************************************************************/ @@ -1271,6 +1211,7 @@ break; case 0xe4: /* ole object */ + write_pic = write_ole_picture; read_wri_struct_mem(write_pic, page); @@ -1307,6 +1250,7 @@ objLen -= OLE_MF_Object - OLE_Object; objectType = 2; // we can go embedded now } + if (size <= cbHeader + OLE_Object + ole_offset || cbHeader + OLE_Object + ole_offset > 0x80 || size < cbHeader + OLE_Object + ole_offset + objLen) diff -urwB abiword.r29620/plugins/mswrite/xp/ie_imp_MSWrite.h abiword.pre.r29620.patched/plugins/mswrite/xp/ie_imp_MSWrite.h --- abiword.r29620/plugins/mswrite/xp/ie_imp_MSWrite.h 2011-03-06 19:13:16.000000000 +0100 +++ abiword.pre.r29620.patched/plugins/mswrite/xp/ie_imp_MSWrite.h 2011-03-06 19:21:43.000000000 +0100 @@ -3,6 +3,7 @@ /* AbiWord * Copyright (C) 1998 AbiSource, Inc. * Copyright (C) 2000 Hubert Figuière + * 2010 Ingo Brueckl * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +25,6 @@ #define IE_IMP_MSWRITE_H #include -#include -#include #include "ut_bytebuf.h" #include "ut_string_class.h" @@ -40,7 +39,6 @@ typedef struct wri_font { short ffid; char *name; - char *codepage; } wri_font; // The importer/reader for MS Write Files. @@ -95,13 +93,9 @@ struct wri_struct *write_picture; struct wri_struct *write_ole_picture; - UT_UCS4Char *transtbl; // table for decoding codepage-specific symbols - char *get_codepage(char *facename, char **newname=NULL); // gets cp id by font name; - void set_codepage(char *cp); // sets the translation table to corresponding codeset - UT_UCS4String mCharBuf; // buffer for char runs. UT_ByteBuf mTextBuf; // complete text buffer as extracted out of the file. - UT_UCS4_mbtowc charconv; // unicode conversion. + UT_UCS4_mbtowc charconv; // CP1252 to unicode conversion. bool lf; };