diff --git a/ie_imp_MSWrite.cpp b/ie_imp_MSWrite.cpp index 4f68d00..96a0ebb 100644 --- a/ie_imp_MSWrite.cpp +++ b/ie_imp_MSWrite.cpp @@ -46,6 +46,7 @@ #include "xap_Module.h" #include "fg_Graphic.h" #include "ie_impGraphic.h" +#include "ap_Args.h" #ifdef _MSC_VER typedef unsigned __int32 uint32_t; @@ -293,7 +294,7 @@ static struct cst_data { {"\x09 (Hebrew)", "CP1255"}, {"\x09 (Arabic)", "CP1256"}, {"\x07 Baltic", "CP1257"}, - {NULL, "CP1252"} // default codepage + {NULL, NULL} }; inline void IE_Imp_MSWrite::translate_char (char ch, UT_UCS4String &buf) @@ -338,7 +339,7 @@ const char *IE_Imp_MSWrite::get_codepage (const char *facename, int *facelen) p++; } *facelen = l; - return p->cpid; + return default_codepage; } inline void IE_Imp_MSWrite::set_codepage (const char *charset) @@ -881,9 +882,14 @@ IE_Imp_MSWrite::~IE_Imp_MSWrite() 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), xaLeft(0), xaRight(0), + default_codepage("CP1252"), lf(false), xaLeft(0), xaRight(0), hasHeader(false), hasFooter(false), page1Header(false), page1Footer(false) { + setProps(AP_Args::m_impProps); + const std::string propCP = getProperty("mswrite-codepage"); + + if (!propCP.empty()) default_codepage = propCP.c_str(); + write_file_header = static_cast(malloc (sizeof (WRITE_FILE_HEADER))); memcpy (write_file_header, WRITE_FILE_HEADER, sizeof (WRITE_FILE_HEADER)); diff --git a/ie_imp_MSWrite.h b/ie_imp_MSWrite.h index 6256404..87ad62c 100644 --- a/ie_imp_MSWrite.h +++ b/ie_imp_MSWrite.h @@ -105,6 +105,7 @@ private: UT_UCS4String mCharBuf; // buffer for char runs. UT_ByteBuf mTextBuf; // complete text buffer as extracted out of the file. UT_UCS4_mbtowc charconv; // Windows codepage to unicode conversion + const char *default_codepage; bool lf; int xaLeft, xaRight; bool hasHeader, hasFooter, page1Header, page1Footer;