Commit b4f28733 authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormat - codepage from font charset

parent eb0d03f7
......@@ -37,9 +37,9 @@
#else
#include <iconv.h>
#endif
#else
#include "../../../../UnicodeConverter/UnicodeConverter.h"
#endif
#include "../../../../UnicodeConverter/UnicodeConverter.h"
#include <Logic/Biff_structures/CellRangeRef.h>
......@@ -555,7 +555,22 @@ const std::string toStdString(std::wstring wide_string, const unsigned int code_
}
const std::wstring toStdWString(char* ansi, int size, const unsigned int code_page)
{
#if defined (_WIN32) || defined (_WIN64)
std::string sCodePage;
for (int i = 0; i < UNICODE_CONVERTER_ENCODINGS_COUNT; ++i)
{
if (code_page == NSUnicodeConverter::Encodings[i].WindowsCodePage)
{
sCodePage = NSUnicodeConverter::Encodings[i].Name;
break;
}
}
if (!sCodePage.empty())
{
NSUnicodeConverter::CUnicodeConverter oConverter;
return oConverter.toUnicode(ansi, size, sCodePage.c_str());
}
#if defined (_WIN32) || defined (_WIN64)
const int nSize = MultiByteToWideChar(code_page, 0, ansi, size, NULL, 0);
wchar_t *sTemp = new wchar_t[nSize];
......
......@@ -99,6 +99,11 @@ void Font::readFields(CFRecord& record)
{
record >> fontName;
}
if (global_info->fonts_charsets.find(bCharSet) == global_info->fonts_charsets.end())
{
global_info->fonts_charsets.insert(global_info->fonts_charsets.begin(), std::pair<int,int>(bCharSet, bFamily));
}
}
int Font::serialize(std::wostream & stream)
......
......@@ -66,7 +66,7 @@ void Label::readFields(CFRecord& record)
record >> cell;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
if (global_info_->Version < 0x0600)
{
LPAnsiString name;
record >> name;
......
......@@ -87,7 +87,9 @@ public:
boost::unordered_map<BorderInfo, int> border_x_ids;
boost::unordered_map<FillInfo, int> fill_x_ids;
std::map<int, FillInfoExt> fonts_color_ext;
std::map<int, int> fonts_charsets;
std::map<int, std::wstring> colors_palette;
std::vector<BaseObjectPtr> *m_arFonts;
......
......@@ -98,6 +98,42 @@
namespace XLS
{;
static const int aCodePages[][2] = {
//charset codepage
0, 1252, //ANSI
1, 0,//Default
2, 42,//Symbol
77, 10000,//Mac Roman
78, 10001,//Mac Shift Jis
79, 10003,//Mac Hangul
80, 10008,//Mac GB2312
81, 10002,//Mac Big5
83, 10005,//Mac Hebrew
84, 10004,//Mac Arabic
85, 10006,//Mac Greek
86, 10081,//Mac Turkish
87, 10021,//Mac Thai
88, 10029,//Mac East Europe
89, 10007,//Mac Russian
128, 932,//Shift JIS
129, 949,//Hangul
130, 1361,//Johab
134, 936,//GB2312
136, 950,//Big5
238, 1250,//Greek
161, 1253,//Greek
162, 1254,//Turkish
163, 1258,//Vietnamese
177, 1255,//Hebrew
178, 1256, //Arabic
186, 1257,//Baltic
204, 1251,//Russian
222, 874,//Thai
238, 1250,//Eastern European
254, 437,//PC 437
255, 850//OEM
};
GlobalsSubstream::GlobalsSubstream(const unsigned short code_page)
: code_page_(code_page)
{
......@@ -412,7 +448,25 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
proc.SkipRecord();
}break;
}
}
}
if (proc.getGlobalWorkbookInfo()->CodePage == 0)
{ //try from charsets ... todooo make local set on each record (aka Label)
//from ixfe -> ifnt from xf -> arFonts
for (std::map<int, int>::iterator it = proc.getGlobalWorkbookInfo()->fonts_charsets.begin()
; proc.getGlobalWorkbookInfo()->CodePage == 0 && it != proc.getGlobalWorkbookInfo()->fonts_charsets.end()
; it++)
{
for (int i = 0 ; i < sizeof(aCodePages) / 2; i++)
{
if (aCodePages[i][0] == it->first)
{
proc.getGlobalWorkbookInfo()->CodePage = aCodePages[i][1];
break;
}
}
}
}
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment