Commit d3f5dd3d authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

RtfFormat - исправлен парсинг таблицы цветов (Romanization_Armenian.rtf)

parent b21d7628
......@@ -363,26 +363,26 @@ public:
if( _T("plain") == sCommand )
oReader.m_oState->m_oCharProp.SetDefaultRtf();
COMMAND_RTF_INT( _T("animtext"), oReader.m_oState->m_oCharProp.m_nAnimated, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("uc"), oReader.m_oState->m_nUD, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("b"), oReader.m_oState->m_oCharProp.m_bBold, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("caps"), oReader.m_oState->m_oCharProp.m_bCaps, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("animtext") , oReader.m_oState->m_oCharProp.m_nAnimated, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("uc") , oReader.m_oState->m_nUD, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("b") , oReader.m_oState->m_oCharProp.m_bBold, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("caps") , oReader.m_oState->m_oCharProp.m_bCaps, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("charscalex"), oReader.m_oState->m_oCharProp.m_nScalex, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("cs"), oReader.m_oState->m_oCharProp.m_nCharStyle, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("down"), oReader.m_oState->m_oCharProp.m_nDown, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("embo"), oReader.m_oState->m_oCharProp.m_bEmbo, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("expndtw"), oReader.m_oState->m_oCharProp.m_nCharacterSpacing, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("cs") , oReader.m_oState->m_oCharProp.m_nCharStyle, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("down") , oReader.m_oState->m_oCharProp.m_nDown, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("embo") , oReader.m_oState->m_oCharProp.m_bEmbo, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("expndtw") , oReader.m_oState->m_oCharProp.m_nCharacterSpacing, sCommand, hasParameter, parameter)
else if( _T("expnd") == sCommand )
{
if( true == hasParameter )
oReader.m_oState->m_oCharProp.m_nCharacterSpacing = 5 * parameter; //quater -points
}
COMMAND_RTF_INT( _T("fittext"), oReader.m_oState->m_oCharProp.m_nFitText, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("f"), oReader.m_oState->m_oCharProp.m_nFont, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("fs"), oReader.m_oState->m_oCharProp.m_nFontSize, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("i"), oReader.m_oState->m_oCharProp.m_bItalic, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("impr"), oReader.m_oState->m_oCharProp.m_bImprint, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("kerning"), oReader.m_oState->m_oCharProp.m_nKerning, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("fittext") , oReader.m_oState->m_oCharProp.m_nFitText, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("f") , oReader.m_oState->m_oCharProp.m_nFont, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("fs") , oReader.m_oState->m_oCharProp.m_nFontSize, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("i") , oReader.m_oState->m_oCharProp.m_bItalic, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("impr") , oReader.m_oState->m_oCharProp.m_bImprint, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("kerning") , oReader.m_oState->m_oCharProp.m_nKerning, sCommand, hasParameter, parameter)
else if( _T("ltrch") == sCommand )
{
......@@ -392,17 +392,17 @@ public:
oReader.m_oState->m_oCharProp.m_bRightToLeft = 1;
}
COMMAND_RTF_BOOL( _T("rtlch"), oReader.m_oState->m_oCharProp.m_bRightToLeft, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("lang"), oReader.m_oState->m_oCharProp.m_nLanguage, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("lang"), oReader.m_oState->m_oCharProp.m_nLanguage , sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("cs"), oReader.m_oState->m_oCharProp.m_nComplexScript, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("outl"), oReader.m_oState->m_oCharProp.m_bOutline, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("scaps"), oReader.m_oState->m_oCharProp.m_bScaps, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("shad"), oReader.m_oState->m_oCharProp.m_bShadow, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("strike"), oReader.m_oState->m_oCharProp.m_bStrike, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("striked"), oReader.m_oState->m_oCharProp.m_nStriked, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("sub"), oReader.m_oState->m_oCharProp.m_bSub, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("super"), oReader.m_oState->m_oCharProp.m_bSuper, sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("highlight"), oReader.m_oState->m_oCharProp.m_nHightlited, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("outl"), oReader.m_oState->m_oCharProp.m_bOutline , sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("scaps"), oReader.m_oState->m_oCharProp.m_bScaps , sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("shad"), oReader.m_oState->m_oCharProp.m_bShadow , sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("strike"), oReader.m_oState->m_oCharProp.m_bStrike , sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("striked"), oReader.m_oState->m_oCharProp.m_nStriked , sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("sub"), oReader.m_oState->m_oCharProp.m_bSub , sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( _T("super"), oReader.m_oState->m_oCharProp.m_bSuper , sCommand, hasParameter, parameter)
COMMAND_RTF_INT( _T("highlight"), oReader.m_oState->m_oCharProp.m_nHightlited , sCommand, hasParameter, parameter)
else if( _T("cf") == sCommand )
{
if( true == hasParameter )
......@@ -755,10 +755,12 @@ public:
class RtfColorTableReader : public RtfAbstractReader
{
private: RtfColor oCurColor;
bool m_bIsSet;
private:
RtfColor oCurColor;
bool m_bIsSet;
public: RtfColorTableReader()
public:
RtfColorTableReader()
{
oCurColor.SetDefaultRtf();
m_bIsSet = false;
......@@ -819,15 +821,30 @@ public: RtfColorTableReader()
}
void ExecuteText( RtfDocument& oDocument, RtfReader& oReader, CString oText )
{
//Romanization_Armenian.rtf
//{\colortbl\red0\blue159\green82;\red0\blue0\green0;\red255\blue255\green255;\red0\blue156\green90;\red169\blue86\green0;}
//{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;
if( oText.Find(';') != -1)
{
if( true == m_bIsSet )
{
oDocument.m_oColorTable.DirectAddItem( oCurColor );
}
else
{
//Romanization_Armenian.rtf
//{\colortbl\red0\blue159\green82;\red0\blue0\green0;\red255\blue255\green255;\red0\blue156\green90;\red169\blue86\green0;}
//{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;
oCurColor.SetAuto();
oDocument.m_oColorTable.DirectAddItem( oCurColor );
}
oCurColor.SetDefaultRtf();
m_bIsSet = false;
}
else
;//ATLASSERT(false);
{
}
}
};
class RtfDefCharPropReader: public RtfAbstractReader
......
......@@ -61,14 +61,12 @@ public:
}
bool GetColor( int nId, RtfColor& oColor)
{
//0 - ID автоцвет
nId--;
if( nId >= 0 && nId < (int)m_aArray.size() )
{
if( nId >= 0 && nId < (int)m_aArray.size() )
{
oColor = m_aArray[nId];
return true;
}
return false;
}
return false;
}
bool GetColor( RtfColor::ThemeColor oTheme, RtfColor& oColor)
{
......@@ -87,22 +85,26 @@ public:
if( true == RtfColor::GetThemeByString(sTheme,oTheme ) )
{
for( int i = 0; i < (int)m_aArray.size(); i++ )
if( oTheme == m_aArray[i].m_eTheme )
{
oColor = m_aArray[i];
{
if( oTheme == m_aArray[i].m_eTheme )
{
oColor = m_aArray[i];
return true;
}
}
}
}
return false;
}
bool GetColor( RtfColor oColor , int & nId)
{
for( int i = 0; i < (int)m_aArray.size(); i++ )
{
if( m_aArray[i] == oColor )
{
nId = i + 1;
return true;
}
}
return false;
}
CString RenderToRtf(RenderParameter oRenderParameter)
......
......@@ -280,9 +280,13 @@ CString RtfColor::RenderToOOX(RenderParameter oRenderParameter)
{
sResult.AppendFormat( _T("<w:color %ls/>"),WriteOOXAttribute(oRenderParameter.sValue).GetBuffer() );
}
else if (m_bAuto)
{
sResult.Append( _T("<w:color w:val=\"auto\"/>"));
}
else
{
sResult.AppendFormat( _T("<w:color w:val=\"%ls\"/>"),ToHexColor().GetBuffer());
sResult.AppendFormat( _T("<w:color w:val=\"%ls\"/>"),ToHexColor().GetBuffer());
}
return sResult;
}
......@@ -293,18 +297,18 @@ CString RtfShadingChar::RenderToRtf(RenderParameter oRenderParameter)
RENDER_RTF_INT( m_nValue, sResult, _T("chshdng") )
switch( m_eType )
{
case st_chbghoriz:sResult.Append(_T("\\chbghoriz"));break;
case st_chbgvert:sResult.Append(_T("\\chbgvert"));break;
case st_chbgfdiag:sResult.Append(_T("\\chbgfdiag"));break;
case st_chbgbdiag:sResult.Append(_T("\\chbgbdiag"));break;
case st_chbgcross:sResult.Append(_T("\\chbgcross"));break;
case st_chbgdcross:sResult.Append(_T("\\chbgdcross"));break;
case st_chbgdkhoriz:sResult.Append(_T("\\chbgdkhoriz"));break;
case st_chbgdkvert:sResult.Append(_T("\\chbgdkvert"));break;
case st_chbgdkfdiag:sResult.Append(_T("\\chbgdkfdiag"));break;
case st_chbgdkbdiag:sResult.Append(_T("\\chbgdkbdiag"));break;
case st_chbgdkcross:sResult.Append(_T("\\chbgdkcross"));break;
case st_chbgdkdcross:sResult.Append(_T("\\chbgdkdcross"));break;
case st_chbghoriz: sResult.Append(_T("\\chbghoriz")); break;
case st_chbgvert: sResult.Append(_T("\\chbgvert")); break;
case st_chbgfdiag: sResult.Append(_T("\\chbgfdiag")); break;
case st_chbgbdiag: sResult.Append(_T("\\chbgbdiag")); break;
case st_chbgcross: sResult.Append(_T("\\chbgcross")); break;
case st_chbgdcross: sResult.Append(_T("\\chbgdcross")); break;
case st_chbgdkhoriz: sResult.Append(_T("\\chbgdkhoriz"));break;
case st_chbgdkvert: sResult.Append(_T("\\chbgdkvert")); break;
case st_chbgdkfdiag: sResult.Append(_T("\\chbgdkfdiag"));break;
case st_chbgdkbdiag: sResult.Append(_T("\\chbgdkbdiag"));break;
case st_chbgdkcross: sResult.Append(_T("\\chbgdkcross"));break;
case st_chbgdkdcross: sResult.Append(_T("\\chbgdkdcross"));break;
}
RENDER_RTF_INT( m_nForeColor, sResult, _T("chcfpat") )
RENDER_RTF_INT( m_nBackColor, sResult, _T("chcbpat") )
......@@ -688,6 +692,7 @@ CString RtfCharProperty::RenderToOOX(RenderParameter oRenderParameter)
CString sResult;
RtfDocument* poRtfDocument = static_cast<RtfDocument*>(oRenderParameter.poDocument);
OOXWriter* poOOXWriter = static_cast<OOXWriter*>(oRenderParameter.poWriter);
switch( m_nAnimated )
{
case 0:sResult.Append(_T("<w:effect w:val=\"none\"/>"));break;
......
......@@ -159,22 +159,27 @@ class RtfColor : public IRenderableProperty
public:
typedef enum {TC_NONE,cmaindarkone ,cmainlightone ,cmaindarktwo ,cmainlighttwo ,caccentone ,caccenttwo ,caccentthree ,caccentfour ,caccentfive ,caccentsix ,chyperlink ,cfollowedhyperlink ,cbackgroundone ,ctextone ,cbackgroundtwo ,ctexttwo} ThemeColor;
ThemeColor m_eTheme;
BYTE m_byteRed;
BYTE m_byteGreen;
BYTE m_byteBlue;
BYTE m_byteTint;
BYTE m_byteShade;
bool m_bAuto;
ThemeColor m_eTheme;
BYTE m_byteRed;
BYTE m_byteGreen;
BYTE m_byteBlue;
BYTE m_byteTint;
BYTE m_byteShade;
//--------------------------------------------------------
RtfColor()
{
SetDefault();
}
RtfColor(int nHex)
RtfColor(int nHex)
{
SetHEX( nHex );
}
RtfColor(BYTE r, BYTE g, BYTE b)
RtfColor(BYTE r, BYTE g, BYTE b)
{
SetRGB( r, g, b );
}
......@@ -186,14 +191,19 @@ public:
{
SetDefault();
}
void SetAuto()
{
m_bAuto = true;
}
void SetDefault()
{
m_byteRed = 0;
m_bAuto = false;
m_byteRed = 0;
m_byteGreen = 0;
m_byteBlue = 0;
m_byteTint = 255;
m_byteBlue = 0;
m_byteTint = 255;
m_byteShade = 0;
m_eTheme = TC_NONE;
m_eTheme = TC_NONE;
}
BYTE GetR()
{
......
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