Commit 98cf29a1 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62230 954022d7-b5bf-4e40-9824-e11837661b57
parent c862e534
...@@ -120,4 +120,10 @@ else{ ...@@ -120,4 +120,10 @@ else{
unix:!macx: LIBS += -lxml2 unix:!macx: LIBS += -lxml2
unix:!macx: LIBS += -L$$PWD/../../../../../../../usr/local/lib/ -lboost_locale
unix:!macx: PRE_TARGETDEPS += $$PWD/../../../../../../../usr/local/lib/libboost_locale.a
unix:!macx: LIBS += -L$$PWD/../../../../../../../usr/local/lib/ -lboost_system
unix:!macx: PRE_TARGETDEPS += $$PWD/../../../../../../../usr/local/lib/libboost_system.a
######################################################## ########################################################
...@@ -2865,8 +2865,12 @@ public: ...@@ -2865,8 +2865,12 @@ public:
else if( _T("ansicpg") == sCommand ) else if( _T("ansicpg") == sCommand )
{ {
oDocument.m_oProperty.m_eCodePage = RtfDocumentProperty::cp_ansi; oDocument.m_oProperty.m_eCodePage = RtfDocumentProperty::cp_ansi;
if( true == hasParameter )
if( true == hasParameter )
{
oDocument.m_oProperty.m_nAnsiCodePage = parameter; oDocument.m_oProperty.m_nAnsiCodePage = parameter;
oDocument.m_oProperty.m_sAnsiCodePage = RtfUtility::GetCodepageName(oDocument.m_oProperty.m_nAnsiCodePage);
}
} }
else if( _T("deff") == sCommand ) else if( _T("deff") == sCommand )
{ {
......
...@@ -124,7 +124,7 @@ public: ...@@ -124,7 +124,7 @@ public:
{ {
m_oFileWriter = NULL; m_oFileWriter = NULL;
m_nReadBufSize = 1024 * 1024 * 5; // 5мб m_nReadBufSize = 1024 * 1024 * 5; // 5мб
m_caReadBuffer = (char*)new char[m_nReadBufSize]; m_caReadBuffer = new char[m_nReadBufSize];
} }
~RtfLex() ~RtfLex()
{ {
...@@ -200,9 +200,10 @@ public: ...@@ -200,9 +200,10 @@ public:
private: private:
void parseKeyword(RtfToken& token) void parseKeyword(RtfToken& token)
{ {
CStringA palabraClave; std::string palabraClave;
palabraClave.GetBuffer( 20 );
palabraClave.ReleaseBuffer(); // palabraClave.GetBuffer( 20 );
// palabraClave.ReleaseBuffer();
CString parametroStr ; CString parametroStr ;
int parametroInt = 0; int parametroInt = 0;
...@@ -225,23 +226,23 @@ private: ...@@ -225,23 +226,23 @@ private:
if( c == '\t' ) if( c == '\t' )
{ {
token.Type = RtfToken::Keyword; token.Type = RtfToken::Keyword;
token.Key = CStringA("tab"); token.Key = std::string("tab");
} }
else if( c == '\n' ) else if( c == '\n' )
{ {
token.Type = RtfToken::Keyword; token.Type = RtfToken::Keyword;
token.Key = CStringA("par"); token.Key = std::string("par");
} }
else else
{ {
token.Type = RtfToken::Text; token.Type = RtfToken::Text;
token.Key = ""; token.Key = std::string("");
} }
} }
else else
{ {
token.Type = RtfToken::Control; token.Type = RtfToken::Control;
token.Key = Convert::ToString(c); token.Key = (char)c/* std::to_string(c)*/;
if (c == '\'') if (c == '\'')
{ {
...@@ -255,8 +256,8 @@ private: ...@@ -255,8 +256,8 @@ private:
else if( c == '|' || c == '~' || c == '-' || c == '_' || c == ':' ) else if( c == '|' || c == '~' || c == '-' || c == '_' || c == ':' )
{ {
token.Type = RtfToken::Keyword; token.Type = RtfToken::Keyword;
token.Key.Empty(); token.Key.erase();
token.Key.AppendChar( c ); token.Key += (char)c ;
} }
} }
return; return;
...@@ -267,7 +268,7 @@ private: ...@@ -267,7 +268,7 @@ private:
while (RtfUtility::IsAlpha(c)) while (RtfUtility::IsAlpha(c))
{ {
m_oStream.getc(); m_oStream.getc();
palabraClave.AppendChar(c); palabraClave += (char)c;
c = m_oStream.getc(); c = m_oStream.getc();
m_oStream.ungetc(); m_oStream.ungetc();
...@@ -278,7 +279,7 @@ private: ...@@ -278,7 +279,7 @@ private:
token.Key = palabraClave; token.Key = palabraClave;
//Se comprueba si la palabra clave tiene parбmetro //Se comprueba si la palabra clave tiene parбmetro
if (RtfUtility::IsDigit(c) || c == '-') if (RtfUtility::IsDigit((char)c) || c == '-')
{ {
token.HasParameter = true; token.HasParameter = true;
...@@ -322,15 +323,17 @@ private: ...@@ -322,15 +323,17 @@ private:
//while ((isalnum(c) || c == '"'|| c == ':'|| c == '/' || c == '.') &&c != '\\' && c != '}' && c != '{' && c != Eof) // иправиЃEЃEрвьD усЃEвиЃE //while ((isalnum(c) || c == '"'|| c == ':'|| c == '/' || c == '.') &&c != '\\' && c != '}' && c != '{' && c != Eof) // иправиЃEЃEрвьD усЃEвиЃE
//while (c != '\\' && c != '}' && c != '{' && c != Eof) //while (c != '\\' && c != '}' && c != '{' && c != Eof)
//while (c != ';' &&c ! = '\\' && c != '}' && c != '{' && c != EOF) //while (c != ';' &&c ! = '\\' && c != '}' && c != '{' && c != EOF)
token.Key.empty();
while (c != '\\' && c != '}' && c != '{' && c != EOF) while (c != '\\' && c != '}' && c != '{' && c != EOF)
{ {
if( nTempBufPos >= m_nReadBufSize ) if( nTempBufPos >= m_nReadBufSize )
{ {
m_caReadBuffer[nTempBufPos++] = '\0'; m_caReadBuffer[nTempBufPos++] = '\0';
token.Key.Append( m_caReadBuffer ); token.Key += m_caReadBuffer ;
nTempBufPos = 0; nTempBufPos = 0;
} }
m_caReadBuffer[nTempBufPos++] = c; m_caReadBuffer[nTempBufPos++] = (char)c;
c = m_oStream.getc(); c = m_oStream.getc();
//Se ignoran los retornos de carro, tabuladores y caracteres nulos //Se ignoran los retornos de carro, tabuladores y caracteres nulos
...@@ -341,8 +344,9 @@ private: ...@@ -341,8 +344,9 @@ private:
if( nTempBufPos > 0 ) if( nTempBufPos > 0 )
{ {
m_caReadBuffer[nTempBufPos++] = '\0'; m_caReadBuffer[nTempBufPos++] = '\0';
token.Key.Append( m_caReadBuffer ); token.Key += m_caReadBuffer ;
} nTempBufPos = 0;
}
} }
bool GetNextChar( int& nChar ) bool GetNextChar( int& nChar )
{ {
...@@ -395,6 +399,5 @@ private: ...@@ -395,6 +399,5 @@ private:
{ {
} }
} }
} }
}; };
...@@ -177,7 +177,7 @@ CString RtfFont::RenderToOOX(RenderParameter oRenderParameter) ...@@ -177,7 +177,7 @@ CString RtfFont::RenderToOOX(RenderParameter oRenderParameter)
//?? нужно ли описывать default??? todooo //?? нужно ли описывать default??? todooo
} }
sResult.AppendFormat(_T("<w:rFonts w:ascii=\"%ls\" w:eastAsia=\"%ls\" w:hAnsi=\"%ls\" w:cs=\"%ls\"%ls/>"), sResult.AppendFormat(_T("<w:rFonts w:ascii=\"%ls\" w:eastAsia=\"%ls\" w:hAnsi=\"%ls\" w:cs=\"%ls\"%ls/>"),
sFontName.GetBuffer(), sFontName.GetBuffer(), sFontName.GetBuffer(), sFontName.GetBuffer(), sHint); sFontName.GetBuffer(), sFontName.GetBuffer(), sFontName.GetBuffer(), sFontName.GetBuffer(), sHint.GetBuffer());
} }
} }
} }
......
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
#include "Writer/OOXWriter.h" #include "Writer/OOXWriter.h"
#include "DestinationCommand.h" #include "DestinationCommand.h"
#if !defined (_WIN32) && !defined(_WIN64)
#include <boost/locale.hpp>
#include <locale>
typedef std::codecvt<wchar_t, char, mbstate_t> codecvt_type;
#endif
RtfReader::RtfReader(RtfDocument& oDocument, CString sFilename ):m_oDocument(oDocument),m_sFilename(sFilename) RtfReader::RtfReader(RtfDocument& oDocument, CString sFilename ):m_oDocument(oDocument),m_sFilename(sFilename)
{ {
m_oState = ReaderStatePtr(new ReaderState()); m_oState = ReaderStatePtr(new ReaderState());
...@@ -38,4 +44,93 @@ void RtfReader::PopState() ...@@ -38,4 +44,93 @@ void RtfReader::PopState()
if( 0 != m_oState->psave ) if( 0 != m_oState->psave )
m_oState = m_oState->psave; m_oState = m_oState->psave;
//delete psaveOld; //delete psaveOld;
} }
\ No newline at end of file
CString RtfAbstractReader::ExecuteTextInternalCodePage( std::string& sCharString, RtfDocument& oDocument, RtfReader& oReader)
{
CString sResult;
if( false == sCharString.empty())
{
int nCodepage = -1;
std::string sCodepage;
//применяем параметры codepage от текущего шрифта todo associated fonts.
RtfFont oFont;
if( true == oDocument.m_oFontTable.GetFont( oReader.m_oState->m_oCharProp.m_nFont, oFont ) )
{
if( PROP_DEF != oFont.m_nCharset )
{
nCodepage = RtfUtility::CharsetToCodepage( oFont.m_nCharset );
}
else if( PROP_DEF != oFont.m_nCodePage )
{
nCodepage = oFont.m_nCodePage;
}
}
//от настроек документа
if( -1 == nCodepage && RtfDocumentProperty::cp_none != oDocument.m_oProperty.m_eCodePage )
{
switch ( oDocument.m_oProperty.m_eCodePage )
{
case RtfDocumentProperty::cp_ansi:
{
if( PROP_DEF != oDocument.m_oProperty.m_nAnsiCodePage )
{
nCodepage = oDocument.m_oProperty.m_nAnsiCodePage;
sCodepage = oDocument.m_oProperty.m_sAnsiCodePage;
}
else
nCodepage = CP_ACP;
break;
}
case RtfDocumentProperty::cp_mac: nCodepage = CP_MACCP; sCodepage = "macintosh"; break; //?? todooo
case RtfDocumentProperty::cp_pc: nCodepage = 437; sCodepage = "IBM437"; break; //ms dos latin us
case RtfDocumentProperty::cp_pca: nCodepage = 850; sCodepage = "ibm850"; break; //ms dos latin eu
}
}
//если ничего нет ставим ANSI
if( -1 == nCodepage )
nCodepage = CP_ACP;
#if defined (_WIN32) || defined (_WIN64)
int nLengthW ;
nLengthW = MultiByteToWideChar(nCodepage, 0, sCharString, -1, NULL, NULL);
MultiByteToWideChar(nCodepage, 0, sCharString, -1, sResult.GetBuffer( nLengthW ), nLengthW);
sResult.ReleaseBuffer();
#else
if (nCodepage > 0)
{
std::mbstate_t state;
boost::locale::generator gen;
std::locale loc(gen(sCodepage.c_str()));
const codecvt_type& cdcvt = std::use_facet<codecvt_type>(loc);
wchar_t * wchars = new wchar_t [sCharString.size()+ 1];
const char *in_next = 0;
wchar_t *out_next = 0;
std::codecvt_base::result r;
r = cdcvt.in (state, sCharString.c_str(), sCharString.c_str() + sCharString.length(), in_next,
wchars, wchars + sCharString.size() + 1, out_next);
*out_next = '\0';
sResult = CString(wchars);
delete [] wchars;
}
else
{
//ansi
std::wstring s(sCharString.begin(), sCharString.end());
sResult = std_string2string(s);
}
#endif
}
return sResult;
}
...@@ -24,7 +24,7 @@ public: ...@@ -24,7 +24,7 @@ public:
RtfOldList m_oCurOldList; RtfOldList m_oCurOldList;
// RtfSectionProperty m_oSectionProp; // RtfSectionProperty m_oSectionProp;
ReaderStatePtr psave; ReaderStatePtr psave;
CStringA m_sCurText; std::string m_sCurText;
ReaderState() ReaderState()
{ {
...@@ -127,10 +127,10 @@ public: ...@@ -127,10 +127,10 @@ public:
if( m_oTok.Key == "42" ) if( m_oTok.Key == "42" )
m_bSkip = true; m_bSkip = true;
if( m_oTok.Key == "39" && true == m_oTok.HasParameter ) if( m_oTok.Key == "39" && true == m_oTok.HasParameter )
oReader.m_oState->m_sCurText.AppendChar( m_oTok.Parameter ); oReader.m_oState->m_sCurText += m_oTok.Parameter ;
break; break;
case RtfToken::Text: case RtfToken::Text:
oReader.m_oState->m_sCurText.Append( m_oTok.Key ); oReader.m_oState->m_sCurText += m_oTok.Key;
break; break;
} }
if( false == m_bStopReader) if( false == m_bStopReader)
...@@ -202,7 +202,7 @@ public: ...@@ -202,7 +202,7 @@ public:
virtual void ExitReader2( RtfDocument& oDocument, RtfReader& oReader ) virtual void ExitReader2( RtfDocument& oDocument, RtfReader& oReader )
{ {
} }
static CString ExecuteTextInternal( RtfDocument& oDocument, RtfReader& oReader, CStringA& sKey, bool bHasPar, int nPar, int& nSkipChars) static CString ExecuteTextInternal( RtfDocument& oDocument, RtfReader& oReader, std::string & sKey, bool bHasPar, int nPar, int& nSkipChars)
{ {
CString sResult; CString sResult;
...@@ -213,11 +213,11 @@ public: ...@@ -213,11 +213,11 @@ public:
} }
else else
{ {
CStringA sCharString; std::string sCharString;
if( "39" == sKey ) if( "39" == sKey )
{ {
if( true == bHasPar ) if( true == bHasPar )
sCharString.AppendChar( nPar ); sCharString += nPar ;
} }
else else
sCharString = sKey; sCharString = sKey;
...@@ -228,21 +228,21 @@ public: ...@@ -228,21 +228,21 @@ public:
return sResult; return sResult;
} }
void ExecuteTextInternal2( RtfDocument& oDocument, RtfReader& oReader, CStringA& sKey, int& nSkipChars) void ExecuteTextInternal2( RtfDocument& oDocument, RtfReader& oReader, std::string & sKey, int& nSkipChars)
{ {
if(oReader.m_oState->m_sCurText.GetLength() > 0) if(oReader.m_oState->m_sCurText.length() > 0)
{ {
CString sResult = ExecuteTextInternalCodePage(oReader.m_oState->m_sCurText, oDocument, oReader); CString sResult = ExecuteTextInternalCodePage(oReader.m_oState->m_sCurText, oDocument, oReader);
oReader.m_oState->m_sCurText.Empty(); oReader.m_oState->m_sCurText.erase();
if(sResult.GetLength() > 0) if(sResult.GetLength() > 0)
{ {
CStringA str; std::string str;
ExecuteTextInternalSkipChars(sResult, oReader, str, nSkipChars); ExecuteTextInternalSkipChars(sResult, oReader, str, nSkipChars);
ExecuteText( oDocument, oReader, sResult); ExecuteText( oDocument, oReader, sResult);
} }
} }
} }
static void ExecuteTextInternalSkipChars(CString & sResult, RtfReader& oReader, CStringA& sKey, int& nSkipChars) static void ExecuteTextInternalSkipChars(CString & sResult, RtfReader& oReader, std::string & sKey, int& nSkipChars)
{ {
//удаляем символы вслед за юникодом //удаляем символы вслед за юникодом
if( nSkipChars > 0 ) if( nSkipChars > 0 )
...@@ -251,7 +251,7 @@ public: ...@@ -251,7 +251,7 @@ public:
if( nSkipChars >= nLength ) if( nSkipChars >= nLength )
{ {
nSkipChars -= nLength; nSkipChars -= nLength;
sResult.Empty(); sResult.Empty();
} }
else else
{ {
...@@ -265,60 +265,9 @@ public: ...@@ -265,60 +265,9 @@ public:
nSkipChars = oReader.m_oState->m_nUD; nSkipChars = oReader.m_oState->m_nUD;
} }
} }
static CString ExecuteTextInternalCodePage( CStringA& sCharString, RtfDocument& oDocument, RtfReader& oReader) static CString ExecuteTextInternalCodePage( std::string & sCharString, RtfDocument & oDocument, RtfReader & oReader);
{
CString sResult;
if( false == sCharString.IsEmpty() )
{
int nCodepage = -1;
//применяем параметры codepage от текущего шрифта todo associated fonts.
RtfFont oFont;
if( true == oDocument.m_oFontTable.GetFont( oReader.m_oState->m_oCharProp.m_nFont, oFont ) )
{
if( PROP_DEF != oFont.m_nCharset )
nCodepage = RtfUtility::CharsetToCodepage( oFont.m_nCharset );
else if( PROP_DEF != oFont.m_nCodePage )
nCodepage = oFont.m_nCodePage;
}
//от настроек документа
if( -1 == nCodepage && RtfDocumentProperty::cp_none != oDocument.m_oProperty.m_eCodePage )
{
switch ( oDocument.m_oProperty.m_eCodePage )
{
case RtfDocumentProperty::cp_ansi:
{
if( PROP_DEF != oDocument.m_oProperty.m_nAnsiCodePage )
nCodepage = oDocument.m_oProperty.m_nAnsiCodePage;
else
nCodepage = CP_ACP;
break;
}
case RtfDocumentProperty::cp_mac: nCodepage = CP_MACCP; break;
case RtfDocumentProperty::cp_pc: nCodepage = 437; break; //ms dos latin us
case RtfDocumentProperty::cp_pca: nCodepage = 850; break; //ms dos latin eu
}
}
//если ничего нет ставим ANSI
if( -1 == nCodepage )
nCodepage = CP_ACP;
#if defined (_WIN32) || defined (_WIN64) private:
int nLengthW ;
nLengthW = MultiByteToWideChar(nCodepage, 0, sCharString, -1, NULL, NULL);
MultiByteToWideChar(nCodepage, 0, sCharString, -1, sResult.GetBuffer( nLengthW ), nLengthW);
sResult.ReleaseBuffer();
#else
//todooo расширить до других codepages (щас тока анси)
std::string sAnsi(sCharString.GetBuffer());
std::wstring s(sAnsi.begin(), sAnsi.end());
sResult = std_string2string(s);
#endif
//sResult = sKey;
}
return sResult;
}
private:
RtfToken m_oTok; RtfToken m_oTok;
bool m_bCanStartNewReader; bool m_bCanStartNewReader;
......
...@@ -176,8 +176,9 @@ CString RtfDocumentProperty::RenderToOOX(RenderParameter oRenderParameter) ...@@ -176,8 +176,9 @@ CString RtfDocumentProperty::RenderToOOX(RenderParameter oRenderParameter)
sResult.AppendFormat( _T("<w:footnotePr>%ls</w:footnotePr>"), sFootnoteProp.GetBuffer() ); sResult.AppendFormat( _T("<w:footnotePr>%ls</w:footnotePr>"), sFootnoteProp.GetBuffer() );
CString sEndnoteProp; CString sEndnoteProp;
for( int i = 0; i < (int)m_aSpecialEndnotes.size(); i++ ) //todooo проверить id
sEndnoteProp.AppendFormat( _T("<w:endnote w:id=\"%d\" />"), m_aSpecialEndnotes[i] ); for( int i = 0; i < (int)m_aSpecialEndnotes.size(); i++ )
sEndnoteProp.AppendFormat( _T("<w:endnote w:id=\"%l\" />"), m_aSpecialEndnotes[i] );
if( PROP_DEF != m_nFootnoteNumberingFormat ) if( PROP_DEF != m_nFootnoteNumberingFormat )
sFootnoteProp.AppendFormat( _T("<w:numRestart w:val=\"%ls\" />"), RtfListLevelProperty::GetFormat( m_nFootnoteNumberingFormat ).GetBuffer() ); sFootnoteProp.AppendFormat( _T("<w:numRestart w:val=\"%ls\" />"), RtfListLevelProperty::GetFormat( m_nFootnoteNumberingFormat ).GetBuffer() );
RENDER_OOX_INT( m_nEndnoteStart, sEndnoteProp, _T("w:numStart") ); RENDER_OOX_INT( m_nEndnoteStart, sEndnoteProp, _T("w:numStart") );
......
...@@ -14,7 +14,9 @@ public: ...@@ -14,7 +14,9 @@ public:
}CodePage; }CodePage;
CodePage m_eCodePage; CodePage m_eCodePage;
int m_nAnsiCodePage;
std::string m_sAnsiCodePage;
int m_nAnsiCodePage;
int m_nDeffFont; int m_nDeffFont;
int m_bHypCaps;//(doNotHyphenateCaps)\hyphcaps* Switches hyphenation of capitalized words (default is on). Append 1 or leave control word by itself to toggle property on; append 0 to turn it off. int m_bHypCaps;//(doNotHyphenateCaps)\hyphcaps* Switches hyphenation of capitalized words (default is on). Append 1 or leave control word by itself to toggle property on; append 0 to turn it off.
int m_bAutoHyp;//(autoHyphenation)\hyphauto* Switches automatic hyphenation (default is off). Append 1 or leave control word by itself to toggle property on; append 0 to turn it off. int m_bAutoHyp;//(autoHyphenation)\hyphauto* Switches automatic hyphenation (default is off). Append 1 or leave control word by itself to toggle property on; append 0 to turn it off.
......
#pragma once #pragma once
#ifdef _WIN32 #include <string>
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
class RtfToken class RtfToken
{ {
...@@ -13,7 +8,7 @@ public: ...@@ -13,7 +8,7 @@ public:
typedef enum {None ,Keyword,Control ,Text ,Eof,GroupStart ,GroupEnd} RtfTokenType; typedef enum {None ,Keyword,Control ,Text ,Eof,GroupStart ,GroupEnd} RtfTokenType;
RtfTokenType Type; RtfTokenType Type;
CStringA Key; std::string Key;
bool HasParameter; bool HasParameter;
int Parameter; int Parameter;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#ifndef CP_SYMBOL //Symbol #ifndef CP_SYMBOL //Symbol
#define CP_SYMBOL 42 #define CP_SYMBOL 42
#endif #endif
namespace Strings namespace Strings
{ {
static int ToDigit(TCHAR c) static int ToDigit(TCHAR c)
...@@ -183,6 +184,155 @@ static const int aCodePages[][2] = { ...@@ -183,6 +184,155 @@ static const int aCodePages[][2] = {
254, 437,//PC 437 254, 437,//PC 437
255, 850//OEM 255, 850//OEM
}; };
static const struct
{
int id;
std::string name;
} aCodePagesNames[] =
{
{ 37 , "IBM037" },
{ 437 , "IBM437" },
{ 500 , "IBM500" },
{ 708 , "ASMO-708" },
{ 720 , "DOS-720" },
{ 737 , "ibm737" },
{ 775 , "ibm775" },
{ 850 , "ibm850" },
{ 852 , "ibm852" },
{ 855 , "IBM855" },
{ 857 , "ibm857" },
{ 858 , "IBM00858" },
{ 860 , "IBM860" },
{ 861 , "ibm861" },
{ 862 , "DOS-862" },
{ 863 , "IBM863" },
{ 864 , "IBM864" },
{ 865 , "IBM865" },
{ 866 , "cp866" },
{ 869 , "ibm869" },
{ 870 , "IBM870" },
{ 874 , "windows-874" },
{ 875 , "cp875" },
{ 932 , "shift_jis" },
{ 936 , "gb2312" },
{ 949 , "KS_C_5601-1987" },
{ 950 , "big5" },
{ 1026 , "IBM1026" },
{ 1047 , "IBM01047" },
{ 1140 , "IBM01140" },
{ 1141 , "IBM01141" },
{ 1142 , "IBM01142" },
{ 1143 , "IBM01143" },
{ 1144 , "IBM01144" },
{ 1145 , "IBM01145" },
{ 1146 , "IBM01146" },
{ 1147 , "IBM01147" },
{ 1148 , "IBM01148" },
{ 1149 , "IBM01149" },
{ 1200 , "utf-16" },
{ 1201 , "unicodeFFFE" },
{ 1250 , "windows-1250" },
{ 1251 , "windows-1251" },
{ 1252 , "windows-1252" },
{ 1253 , "windows-1253" },
{ 1254 , "windows-1254" },
{ 1255 , "windows-1255" },
{ 1256 , "windows-1256" },
{ 1257 , "windows-1257" },
{ 1258 , "windows-1258" },
{ 1361 , "Johab" },
{ 10000 , "macintosh" },
{ 10001 , "x-mac-japanese" },
{ 10002 , "x-mac-chinesetrad" },
{ 10003 , "x-mac-korean" },
{ 10004 , "x-mac-arabic" },
{ 10005 , "x-mac-hebrew" },
{ 10006 , "x-mac-greek" },
{ 10007 , "x-mac-cyrillic" },
{ 10008 , "x-mac-chinesesimp" },
{ 10010 , "x-mac-romanian" },
{ 10017 , "x-mac-ukrainian" },
{ 10021 , "x-mac-thai" },
{ 10029 , "x-mac-ce" },
{ 10079 , "x-mac-icelandic" },
{ 10081 , "x-mac-turkish" },
{ 10082 , "x-mac-croatian" },
{ 12000 , "utf-32" },
{ 12001 , "utf-32BE" },
{ 20000 , "x-Chinese_CNS" },
{ 20001 , "x-cp20001" },
{ 20002 , "x_Chinese-Eten" },
{ 20003 , "x-cp20003" },
{ 20004 , "x-cp20004" },
{ 20005 , "x-cp20005" },
{ 20105 , "x-IA5" },
{ 20106 , "x-IA5-German" },
{ 20107 , "x-IA5-Swedish" },
{ 20108 , "x-IA5-Norwegian" },
{ 20127 , "us-ascii" },
{ 20261 , "x-cp20261" },
{ 20269 , "x-cp20269" },
{ 20273 , "IBM273" },
{ 20277 , "IBM277" },
{ 20278 , "IBM278" },
{ 20280 , "IBM280" },
{ 20284 , "IBM284" },
{ 20285 , "IBM285" },
{ 20290 , "IBM290" },
{ 20297 , "IBM297" },
{ 20420 , "IBM420" },
{ 20423 , "IBM423" },
{ 20424 , "IBM424" },
{ 20833 , "x-EBCDIC-KoreanExtended" },
{ 20838 , "IBM-Thai" },
{ 20866 , "koi8-r" },
{ 20871 , "IBM871" },
{ 20880 , "IBM880" },
{ 20905 , "IBM905" },
{ 20924 , "IBM00924" },
{ 20932 , "EUC-JP" },
{ 20936 , "x-cp20936" },
{ 20949 , "x-cp20949" },
{ 21025 , "cp1025" },
{ 21866 , "koi8-u" },
{ 28591 , "iso-8859-1" },
{ 28592 , "iso-8859-2" },
{ 28593 , "iso-8859-3" },
{ 28594 , "iso-8859-4" },
{ 28595 , "iso-8859-5" },
{ 28596 , "iso-8859-6" },
{ 28597 , "iso-8859-7" },
{ 28598 , "iso-8859-8" },
{ 28599 , "iso-8859-9" },
{ 28603 , "iso-8859-13" },
{ 28605 , "iso-8859-15" },
{ 29001 , "x-Europa" },
{ 38598 , "iso-8859-8-i" },
{ 50220 , "iso-2022-jp" },
{ 50221 , "csISO2022JP" },
{ 50222 , "iso-2022-jp" },
{ 50225 , "iso-2022-kr" },
{ 50227 , "x-cp50227" },
{ 51932 , "euc-jp" },
{ 51936 , "EUC-CN" },
{ 51949 , "euc-kr" },
{ 52936 , "hz-gb-2312" },
{ 54936 , "GB18030" },
{ 57002 , "x-iscii-de" },
{ 57003 , "x-iscii-be" },
{ 57004 , "x-iscii-ta" },
{ 57005 , "x-iscii-te" },
{ 57006 , "x-iscii-as" },
{ 57007 , "x-iscii-or" },
{ 57008 , "x-iscii-ka" },
{ 57009 , "x-iscii-ma" },
{ 57010 , "x-iscii-gu" },
{ 57011 , "x-iscii-pa" },
{ 65000 , "utf-7" },
{ 65001 , "utf-8" }
};
class RtfUtility class RtfUtility
{ {
public: public:
...@@ -450,6 +600,18 @@ public: ...@@ -450,6 +600,18 @@ public:
; ;
return sResult; return sResult;
} }
static std::string GetCodepageName( int nCodepage )
{
int nCodePagesLength = 140;
for( int i = 0; i < nCodePagesLength; i++ )
if( aCodePagesNames[i].id == nCodepage )
return aCodePagesNames[i].name;
return "";
}
static int CharsetToCodepage( int nCharset ) static int CharsetToCodepage( int nCharset )
{ {
#if defined (_WIN32) || defined(_WIN64) #if defined (_WIN32) || defined(_WIN64)
...@@ -457,27 +619,32 @@ public: ...@@ -457,27 +619,32 @@ public:
DWORD* dwAcp = (DWORD*)nCharset; DWORD* dwAcp = (DWORD*)nCharset;
if( TRUE == TranslateCharsetInfo(dwAcp, &Info, TCI_SRCCHARSET) ) if( TRUE == TranslateCharsetInfo(dwAcp, &Info, TCI_SRCCHARSET) )
return Info.ciACP; return Info.ciACP;
#endif
int nCodePagesLength = sizeof( aCodePages ) / ( sizeof( int ) );
int nCodePagesLength = sizeof( aCodePages ) / ( sizeof( int ) );
for( int i = 0; i < nCodePagesLength; i++ ) for( int i = 0; i < nCodePagesLength; i++ )
if( aCodePages[i][0] == nCharset ) if( aCodePages[i][0] == nCharset )
return aCodePages[i][1]; return aCodePages[i][1];
#endif
return 1252;//ANSI return 1252;//ANSI
} }
// static int CodepageToCharset( int nCodepage ) static int CodepageToCharset( int nCodepage )
// { {
// CHARSETINFO Info; #if defined (_WIN32) || defined(_WIN64)
// DWORD* dwAcp = (DWORD*)nCodepage; CHARSETINFO Info;
// if( TRUE == TranslateCharsetInfo(dwAcp, &Info, TCI_SRCCODEPAGE) ) DWORD* dwAcp = (DWORD*)nCodepage;
// return Info.ciCharset; if( TRUE == TranslateCharsetInfo(dwAcp, &Info, TCI_SRCCODEPAGE) )
return Info.ciCharset;
// int CodePagesLength = sizeof( aCodePages ) / ( sizeof( int ) ); #endif
// for( int i = 0; i < nCodePagesLength; i++ ) int nCodePagesLength = sizeof( aCodePages ) / ( sizeof( int ) );
// if( aCodePages[i][1] == nCodepage )
// return aCodePages[i][0]; for( int i = 0; i < nCodePagesLength; i++ )
// return 0;//ANSI if( aCodePages[i][1] == nCodepage )
// } return aCodePages[i][0];
return 0;//ANSI
}
static bool IsMacCharset( int nCharset ) static bool IsMacCharset( int nCharset )
{ {
return nCharset == 77 || nCharset == 78 || nCharset == 79 || nCharset == 80 || return nCharset == 77 || nCharset == 78 || nCharset == 79 || nCharset == 80 ||
......
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