diff -Naur pre-lint/plugins/mswrite/xp/ie_impexp_MSWrite.cpp post-lint/plugins/mswrite/xp/ie_impexp_MSWrite.cpp
--- pre-lint/plugins/mswrite/xp/ie_impexp_MSWrite.cpp	2011-07-16 00:33:37.949165032 +0200
+++ post-lint/plugins/mswrite/xp/ie_impexp_MSWrite.cpp	2011-07-16 00:33:14.522413935 +0200
@@ -1,6 +1,5 @@
 /* AbiWord
  * Copyright (C) 2001 Sean Young <sean@mess.org>
- * Copyright (C) 2010-2011 Ingo Brueckl
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -130,3 +129,4 @@
     exit (1);
     return 0;
 }
+
diff -Naur pre-lint/plugins/mswrite/xp/ie_impexp_MSWrite.h post-lint/plugins/mswrite/xp/ie_impexp_MSWrite.h
--- pre-lint/plugins/mswrite/xp/ie_impexp_MSWrite.h	2011-07-16 00:33:37.949165032 +0200
+++ post-lint/plugins/mswrite/xp/ie_impexp_MSWrite.h	2011-07-16 00:33:14.521413945 +0200
@@ -2,7 +2,7 @@
  * Copyright (C) 2001 Sean Young <sean@mess.org>
  * Copyright (C) 2001 Hubert Figuiere
  * Copyright (C) 2001 Dom Lachowicz
- * Copyright (C) 2010-2011 Ingo Brueckl
+ *               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
@@ -69,3 +69,11 @@
 				  p[3] = ((s) & 0xff000000) >> 24; }
 
 #endif /* IE_IMPEXP_MSWRITE_H */
+
+
+
+
+
+
+
+
diff -Naur pre-lint/plugins/mswrite/xp/ie_imp_MSWrite.cpp post-lint/plugins/mswrite/xp/ie_imp_MSWrite.cpp
--- pre-lint/plugins/mswrite/xp/ie_imp_MSWrite.cpp	2011-07-16 00:33:37.951165001 +0200
+++ post-lint/plugins/mswrite/xp/ie_imp_MSWrite.cpp	2011-07-16 00:33:14.523413924 +0200
@@ -1,4 +1,4 @@
-/* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
+/* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
 
 /* AbiWord
  * Copyright (C) 2001 Sean Young <sean@mess.org>
@@ -30,8 +30,9 @@
 #endif
 
 #include <stdio.h>
-#include <stdlib.h>
+//#include <stdlib.h>
 #include <string.h>
+#include <set>
 #include "ut_locale.h"
 
 #include "ut_types.h"
@@ -44,6 +45,8 @@
 #include "ut_growbuf.h"
 #include "ut_string_class.h"
 #include "xap_Module.h"
+#include "xap_App.h"
+#include "xap_EncodingManager.h"
 #include "fg_Graphic.h"
 #include "ie_impGraphic.h"
 
@@ -193,8 +196,7 @@
 void IE_Imp_MSWrite::free_ffntb () 
 {
     for (UT_uint32 i=0; i < wri_fonts_count; i++) {
-      free((void*)wri_fonts[i].name);
-      wri_fonts[i].name = NULL;
+      wri_fonts[i].name.~basic_string();
     }
     free(wri_fonts);
     wri_fonts = NULL;
@@ -205,7 +207,6 @@
     int	page, pnMac, font_count, cbFfn;
     unsigned char byt[2], ffid;
     char *ffn;
-    int flen;
     struct wri_font *wri_fonts_tmp;
 	
     /* if the page is the same as pnMac, there are no fonts */
@@ -225,12 +226,13 @@
 		perror ("wri_file");
 		return 1;
     }
-    wri_fonts_count = byt[0] + 256 * byt[1];
+	wri_fonts_count = byt[0] + 256 * byt[1];
 	
-    font_count = 0;
-    wri_fonts = NULL;
+	font_count = 0;
+	wri_fonts = NULL;
+	std::set<std::string> raw_fonts;
 	
-    while (true) {
+	while (true) {
 		if (!gsf_input_read (mFile, 2, byt)) {
 			perror ("wri_file");
 			return 1;
@@ -240,7 +242,7 @@
 			break;
 		}
 		if (cbFfn == 0xffff) {
-    	    if (gsf_input_seek (mFile, page++ * 0x80, G_SEEK_SET)) {
+			if (gsf_input_seek (mFile, page++ * 0x80, G_SEEK_SET)) {
 				perror ("wri_file");
 				return 1;
 			}
@@ -270,30 +272,45 @@
 			perror ("wri_file");
 			return 1;
 		}
-		wri_fonts[font_count].codepage = get_codepage(ffn, &flen);
-		ffn[flen] = 0;
+		char *trname;
+		wri_fonts[font_count].codepage=get_codepage(ffn,&trname);
+		if (wri_fonts[font_count].codepage) {
+			strcpy(ffn,trname);
+			raw_fonts.insert(trname);
+		}
+		memset(&(wri_fonts[font_count].name),0,sizeof(std::string));
 		wri_fonts[font_count].name = ffn;
 		font_count++;
-    }
-    if (static_cast<unsigned>(font_count) != wri_fonts_count) {
+
+		free(ffn);
+	}
+	for (int i=0; i<font_count; i++) {
+		std::set<std::string>::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";
+		}
+	}
+	for (int i=0; i<font_count; i++) {
+		const char *defcp = default_cp.c_str();
+		if (!wri_fonts[i].codepage)
+			wri_fonts[i].codepage = defcp;
+	}
+	if (static_cast<unsigned>(font_count) != wri_fonts_count) {
 		wri_fonts_count = font_count;
 		UT_DEBUGMSG(("write file lied about number of fonts\n"));
-    }
-    return 0;
+	}
+	return 0;
 }
 
 static struct cst_data {
 	const char *suffix;
 	const char *cpid;
 } const cp_suf_tbl[]={
-	{"\x03 CE", "CP1250"},
-	{"\x04 Cyr", "CP1251"},
-	{"\x06 Greek", "CP1253"},
-	{"\x04 Tur", "CP1254"},
-	{"\x09 (Hebrew)", "CP1255"},
-	{"\x09 (Arabic)", "CP1256"},
-	{"\x07 Baltic", "CP1257"},
-	{NULL, "CP1252"}             // default codepage
+	{"\x04 cyr","CP1251"},
+	{"\x03 ce","CP1250"},
+	{NULL,NULL}
 };
 
 inline void IE_Imp_MSWrite::translate_char (char ch, UT_UCS4String &buf)
@@ -324,21 +341,25 @@
 	}
 }
 
-const char *IE_Imp_MSWrite::get_codepage (const char *facename, int *facelen)
+const char *IE_Imp_MSWrite::get_codepage (char *facename, char **newname) const
 {
+	static char facebuf[40];
 	const cst_data *p=cp_suf_tbl;	
 	int l=strlen(facename);	
 	while (p->suffix) {
 		if (*p->suffix < l) {
 			if (!g_ascii_strcasecmp(&p->suffix[1],&facename[l-*p->suffix])) {
-				*facelen = l-*p->suffix;
+				if (newname) {
+					strncpy(facebuf,facename,l-*p->suffix);
+					facebuf[l-*p->suffix]=0;
+					*newname=facebuf;
+				}
 				return p->cpid;
 			}
 		}
 		p++;
 	}
-	*facelen = l;
-	return p->cpid;
+	return NULL;
 }
 
 inline void IE_Imp_MSWrite::set_codepage (const char *charset)
@@ -598,7 +619,7 @@
 			if (fcLim >= fcMac) 
 				return 0;
 		}
-    }
+	}
 }
 
 /* the character information stuff */
@@ -610,13 +631,13 @@
 	UT_String propBuffer;
 	UT_String tempBuffer;
 	
-	static const char *oldcp;
+	static const char *oldcp = "";
 
     fcMac = wri_struct_value (write_file_header, "fcMac");
     page = (fcMac + 127) / 128;
     fcFirst = 0x80;
 	
-    while (true) {
+	while (true) {
 		gsf_input_seek (mFile, page++ * 0x80, G_SEEK_SET);
 		gsf_input_read (mFile, 0x80, char_page);
 		cfod = char_page[0x7f];
@@ -678,15 +699,16 @@
 					propBuffer += tempBuffer;
 				}
 				if (wri_fonts_count) {
-					UT_String_sprintf (tempBuffer, "; font-family:%s", wri_fonts[ftc].name);
+					UT_String_sprintf (tempBuffer, "; font-family:%s", 
+						wri_fonts[ftc].name.c_str());
 					propBuffer += tempBuffer;
 				}
-				
-				if (wri_fonts[ftc].codepage != oldcp /*sic!*/) {
-					set_codepage(wri_fonts[ftc].codepage);
-					oldcp = wri_fonts[ftc].codepage;
+				const char *needcp = wri_fonts[ftc].codepage;
+				if (needcp != oldcp /*sic!*/) {
+					set_codepage((char*)needcp);
+					oldcp = needcp;
 				}
-				
+
 				while (fcFirst2 >= fcFirst) {
 					if ((fcFirst2 >= fcLim) || (fcFirst2 > fcLim2) ||
 						(fcFirst2 - 0x80 >= static_cast<UT_sint32>(mTextBuf.getLength()))) {
@@ -711,7 +733,8 @@
 					p = charBuf;
 					while (*p && *p != (UT_UCS4Char)0x01) p++;
 					if (*p) {
-						if (p - charBuf) appendSpan(reinterpret_cast<const UT_UCSChar *>(charBuf), p - charBuf);
+						if (p - charBuf) 
+							appendSpan(reinterpret_cast<const UT_UCSChar *>(charBuf), p - charBuf);
 						
 						propsArray[2] = PT_TYPE_ATTRIBUTE_NAME;
 						propsArray[3] = "page_number";
@@ -884,6 +907,9 @@
     lf(false), xaLeft(0), xaRight(0),
     hasHeader(false), hasFooter(false), page1Header(false), page1Footer(false)
 {
+	default_cp = XAP_App::getApp()->getEncodingManager()->getNative8BitEncodingName();
+	set_codepage((char*)default_cp.c_str());
+
 	write_file_header = static_cast<struct wri_struct*>(malloc (sizeof (WRITE_FILE_HEADER)));
 	memcpy (write_file_header, WRITE_FILE_HEADER, sizeof (WRITE_FILE_HEADER));
 
diff -Naur pre-lint/plugins/mswrite/xp/ie_imp_MSWrite.h post-lint/plugins/mswrite/xp/ie_imp_MSWrite.h
--- pre-lint/plugins/mswrite/xp/ie_imp_MSWrite.h	2011-07-16 00:33:37.952164988 +0200
+++ post-lint/plugins/mswrite/xp/ie_imp_MSWrite.h	2011-07-16 00:33:14.521413945 +0200
@@ -25,6 +25,8 @@
 #define IE_IMP_MSWRITE_H
 
 #include <stdio.h>
+#include <string>
+#include <map>
 
 #include "ut_bytebuf.h"
 #include "ut_string_class.h"
@@ -38,7 +40,7 @@
 /* the fonts */
 typedef struct wri_font {
 	short	ffid;
-	const char *name;
+	std::string name;
 	const char *codepage;
 } wri_font;
 
@@ -96,8 +98,9 @@
 	struct wri_struct *write_file_header;
 	struct wri_struct *write_picture;
 	struct wri_struct *write_ole_picture;
+	std::string default_cp;
+	const char *get_codepage(char *facename, char **newname=NULL) const; // gets cp by font name;
 	
-	const char *get_codepage(const char *facename, int *facelen);   // gets codepage from font name
 	void set_codepage(const char *charset);                         // sets the input character set for conversion
 	
 	void _append_hdrftr(hdrftr_t which);