Commit 231a3b7b authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

исправление багов в Rtf->docx

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62536 954022d7-b5bf-4e40-9824-e11837661b57
parent 6a122d93
...@@ -153,7 +153,7 @@ namespace MathEquation ...@@ -153,7 +153,7 @@ namespace MathEquation
m_oStream.WriteBOOL(true); m_oStream.WriteBOOL(true);
} }
CString sFontName; CString sFontName;
//sFontName.Format(_T("%S"), pFont->sName.c_str()); //sFontName.Format(_T("%lS"), pFont->sName.c_str());
sFontName.Insert(0, _T("Cambria Math")); sFontName.Insert(0, _T("Cambria Math"));
if (sFontName) if (sFontName)
{ {
......
...@@ -586,117 +586,130 @@ public: ...@@ -586,117 +586,130 @@ public:
class RtfFontTableReader: public RtfAbstractReader class RtfFontTableReader: public RtfAbstractReader
{ {
private: private:
RtfFont m_oFont; typedef enum { is_normal, is_panose, is_altname } InternalState;
typedef enum { is_normal, is_panose, is_altname } InternalState;
InternalState m_eInternalState; int m_nKeepGlobalCodepage;
RtfFont m_oFont;
InternalState m_eInternalState;
public: public:
RtfFontTableReader() RtfFontTableReader()
{ {
m_bUseGlobalCodepage = true; m_bUseGlobalCodepage = true;
m_nKeepGlobalCodepage = -1;
m_eInternalState = is_normal; m_eInternalState = is_normal;
m_oFont.SetDefaultOOX(); m_oFont.SetDefaultOOX();
} }
bool ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CString sCommand, bool hasParameter, int parameter)
{
if( _T("fonttbl") == sCommand )
;
else if( _T("flomajor") == sCommand )
m_oFont.m_eFontTheme = RtfFont::ft_flomajor;
else if( _T("fhimajor") == sCommand )
m_oFont.m_eFontTheme = RtfFont::ft_fhimajor;
else if( _T("fdbmajor") == sCommand )
m_oFont.m_eFontTheme = RtfFont::ft_fdbmajor;
else if( _T("fbimajor") == sCommand )
m_oFont.m_eFontTheme = RtfFont::ft_fbimajor;
else if( _T("flominor") == sCommand )
m_oFont.m_eFontTheme = RtfFont::ft_flominor;
else if( _T("fhiminor") == sCommand )
m_oFont.m_eFontTheme = RtfFont::ft_fhiminor;
else if( _T("fdbminor") == sCommand )
m_oFont.m_eFontTheme = RtfFont::ft_fdbminor;
else if( _T("fbiminor") == sCommand )
m_oFont.m_eFontTheme = RtfFont::ft_fbiminor;
else if( _T("fnil") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_fnil;
else if( _T("froman") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_froman;
else if( _T("fswiss") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_fswiss;
else if( _T("fmodern") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_fmodern;
else if( _T("fscript") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_fscript;
else if( _T("fdecor") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_fdecor;
else if( _T("ftech") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_ftech;
else if( _T("fbidi") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_fbidi;
else if( _T("panose") == sCommand )
m_eInternalState = is_panose;
else if( _T("falt") == sCommand )
m_eInternalState = is_altname;
else if( _T("f") == sCommand )
{
if( true == hasParameter )
m_oFont.m_nID = parameter;
}
else if( _T("fcharset") == sCommand )
{
if( true == hasParameter )
m_oFont.m_nCharset = parameter;
}
else if( _T("cpg") == sCommand )
{
if( true == hasParameter )
m_oFont.m_nCodePage = parameter;
}
else if( _T("fprq") == sCommand )
{
if( true == hasParameter )
m_oFont.m_nPitch = parameter;
}
else
{
return false;
//ATLASSERT( false );
}
return true;
} bool ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CString sCommand, bool hasParameter, int parameter)
void ExecuteText(RtfDocument& oDocument, RtfReader& oReader, CString sText) {
{ if (m_nKeepGlobalCodepage < 0)//для корректного отображения названий шрифта нужно использовать данные самого шрифта
if( is_panose == m_eInternalState ) m_nKeepGlobalCodepage = oDocument.m_oProperty.m_nAnsiCodePage;
m_oFont.m_sPanose += sText;
else if( is_altname == m_eInternalState ) if( _T("fonttbl") == sCommand )
m_oFont.m_sAltName += sText; ;
else if( is_normal == m_eInternalState && sText.GetLength() > 0) else if( _T("flomajor") == sCommand )
{ m_oFont.m_eFontTheme = RtfFont::ft_flomajor;
if( sText.Find(';') != -1 ) else if( _T("fhimajor") == sCommand )
{ m_oFont.m_eFontTheme = RtfFont::ft_fhimajor;
sText.Remove(';'); else if( _T("fdbmajor") == sCommand )
m_oFont.m_sName += sText; m_oFont.m_eFontTheme = RtfFont::ft_fdbmajor;
oDocument.m_oFontTable.DirectAddItem( m_oFont ); else if( _T("fbimajor") == sCommand )
m_oFont.SetDefaultRtf(); m_oFont.m_eFontTheme = RtfFont::ft_fbimajor;
} else if( _T("flominor") == sCommand )
else m_oFont.m_eFontTheme = RtfFont::ft_flominor;
{ else if( _T("fhiminor") == sCommand )
m_oFont.m_sName += sText; m_oFont.m_eFontTheme = RtfFont::ft_fhiminor;
} else if( _T("fdbminor") == sCommand )
} m_oFont.m_eFontTheme = RtfFont::ft_fdbminor;
} else if( _T("fbiminor") == sCommand )
void PopState(RtfDocument& oDocument, RtfReader& oReader) m_oFont.m_eFontTheme = RtfFont::ft_fbiminor;
{
RtfAbstractReader::PopState( oDocument, oReader ); else if( _T("fnil") == sCommand )
if( is_panose == m_eInternalState ) m_oFont.m_eFontFamily = RtfFont::ff_fnil;
m_eInternalState = is_normal; else if( _T("froman") == sCommand )
if( is_altname == m_eInternalState ) m_oFont.m_eFontFamily = RtfFont::ff_froman;
m_eInternalState = is_normal; else if( _T("fswiss") == sCommand )
} m_oFont.m_eFontFamily = RtfFont::ff_fswiss;
else if( _T("fmodern") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_fmodern;
else if( _T("fscript") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_fscript;
else if( _T("fdecor") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_fdecor;
else if( _T("ftech") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_ftech;
else if( _T("fbidi") == sCommand )
m_oFont.m_eFontFamily = RtfFont::ff_fbidi;
else if( _T("panose") == sCommand )
m_eInternalState = is_panose;
else if( _T("falt") == sCommand )
m_eInternalState = is_altname;
else if( _T("f") == sCommand )
{
if( true == hasParameter )
m_oFont.m_nID = parameter;
}
else if( _T("fcharset") == sCommand )
{
if( true == hasParameter )
{
m_oFont.m_nCharset = parameter;
}
}
else if( _T("cpg") == sCommand )
{
if( true == hasParameter )
{
oDocument.m_oProperty.m_nAnsiCodePage = m_oFont.m_nCodePage = parameter;
}
}
else if( _T("fprq") == sCommand )
{
if( true == hasParameter )
m_oFont.m_nPitch = parameter;
}
else
{
return false;
//ATLASSERT( false );
}
return true;
}
void ExecuteText(RtfDocument& oDocument, RtfReader& oReader, CString sText)
{
if( is_panose == m_eInternalState )
m_oFont.m_sPanose += sText;
else if( is_altname == m_eInternalState )
m_oFont.m_sAltName += sText;
else if( is_normal == m_eInternalState && sText.GetLength() > 0)
{
if( sText.Find(';') != -1 )
{
sText.Remove(';');
m_oFont.m_sName += sText;
oDocument.m_oFontTable.DirectAddItem( m_oFont );
m_oFont.SetDefaultRtf();
}
else
{
m_oFont.m_sName += sText;
}
}
oDocument.m_oProperty.m_nAnsiCodePage = m_nKeepGlobalCodepage;
}
void PopState(RtfDocument& oDocument, RtfReader& oReader)
{
RtfAbstractReader::PopState( oDocument, oReader );
if( is_panose == m_eInternalState )
m_eInternalState = is_normal;
if( is_altname == m_eInternalState )
m_eInternalState = is_normal;
}
}; };
......
...@@ -16,15 +16,15 @@ public: ...@@ -16,15 +16,15 @@ public:
class ReaderState class ReaderState
{ {
public: public:
int m_nUD; // количество символов игнорируемых за юникодом int m_nUD; // количество символов игнорируемых за юникодом
RtfCharProperty m_oCharProp; RtfCharProperty m_oCharProp;
RtfParagraphProperty m_oParagraphProp; RtfParagraphProperty m_oParagraphProp;
RtfRowProperty m_oRowProperty; RtfRowProperty m_oRowProperty;
RtfCellProperty m_oCellProperty; RtfCellProperty m_oCellProperty;
RtfOldList m_oCurOldList; RtfOldList m_oCurOldList;
// RtfSectionProperty m_oSectionProp; // RtfSectionProperty m_oSectionProp;
ReaderStatePtr psave; ReaderStatePtr psave;
std::string m_sCurText; std::string m_sCurText;
ReaderState() ReaderState()
{ {
...@@ -39,12 +39,12 @@ public: ...@@ -39,12 +39,12 @@ public:
}; };
//---------------------------------TextParser---------------------------------- //---------------------------------TextParser----------------------------------
ReaderStatePtr m_oState; ReaderStatePtr m_oState;
RtfSectionProperty m_oCurSectionProp; RtfSectionProperty m_oCurSectionProp;
RtfLex m_oLex; RtfLex m_oLex;
int m_nFootnote; //толко для симовола chftn. основано на том что вложенных footnote быть не может int m_nFootnote; //толко для симовола chftn. основано на том что вложенных footnote быть не может
int m_nDefFont; int m_nDefFont;
CString m_sTempFolder; CString m_sTempFolder;
RtfReader(RtfDocument& oDocument, std::wstring sFilename ); RtfReader(RtfDocument& oDocument, std::wstring sFilename );
~RtfReader() ~RtfReader()
......
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