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

RtfFormatReader - поправлена конвертация стилей математических формул и...

RtfFormatReader - поправлена конвертация стилей математических формул и глобальные математические свойства документа
parent 1a1b7c62
......@@ -1198,7 +1198,7 @@ bool ParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfReader&
if( true == bResult )
return true;
bResult = RtfCharPropCommand::ExecuteCommand( oDocument, oReader,sCommand, hasParameter, parameter );
bResult = RtfCharPropCommand::ExecuteCommand( oDocument, oReader,sCommand, hasParameter, parameter, oReader.m_oState->m_oCharProp );
if( true == bResult )
return true;
......
......@@ -298,7 +298,12 @@ public:
else if(RENDER_TO_OOX_PARAM_TEXT == oRenderParameter.nType)
sResult = renderTextToXML( _T("Text") );
else if( RENDER_TO_OOX_PARAM_MATH == oRenderParameter.nType)
sResult = renderTextToXML( _T("Math") );
{
sResult.Append(_T("<m:r>"));
sResult.Append( m_oProperty.RenderToOOX(oRenderParameter) );//w:rPr внутри
sResult.Append( renderTextToXML( _T("Math")) );
sResult.Append(_T("</m:r>"));
}
else if( RENDER_TO_OOX_PARAM_PLAIN == oRenderParameter.nType)
sResult = m_sChars;
return sResult;
......@@ -345,11 +350,9 @@ private:
}
else if( _T("Math") == sParam && !m_sChars.IsEmpty())
{
sResult.Append( _T("<m:r>"));
sResult.Append( _T("<m:t>"));
sResult += Utils::PrepareToXML( m_sChars );
sResult.Append( _T("</m:t>"));
sResult.Append( _T("</m:r>"));
sResult.Append( _T("<m:t>"));
sResult += Utils::PrepareToXML( m_sChars );
sResult.Append( _T("</m:t>"));
}
return sResult;
}
......
......@@ -41,7 +41,7 @@ bool RtfMath::IsRtfControlWord( CString sControlW )
L"mgroupChrPr", L"mgroupChr", L"mlimLowPr", L"mlimLow",L"mlimUppPr", L"mlimUpp", L"mmathPr", L"mmcPr", L"mmc",
L"mmcs", L"mmPr", L"mmr", L"mm", L"mnaryPr", L"mnary", L"mphantPr", L"mphant", L"mmRun", L"mmDel",
L"mmIns", L"mradPr", L"mrad", /*MRPr",*/ L"msPrePr", L"msPre", L"msSubPr", L"msSub", L"msSubSupPr",
L"msSubSup", L"msSupPr", L"msSup", L"msub", L"msup", L"mden", L"mlim", L"mnum", L"mdeg"/*mmText",*/, L"mfName" };
L"msSubSup", L"msSupPr", L"msSup", L"msub", L"msup", L"mden", L"mlim", L"mnum", L"mdeg"/*mmText",*/, L"mfName", L"mscr", L"mrPr" };
int mc_nRtfControlWordsSize = sizeof( mc_aRtfControlWords ) / sizeof( TCHAR* );
......@@ -111,6 +111,8 @@ CString RtfMath::RenderToRtf(RenderParameter oRenderParameter)
}
CString RtfMath::RenderToOOX(RenderParameter oRenderParameter)
{
if (m_sOOXName.IsEmpty()) return L"";
CString sResult;
CString sContent;
CString sProp;
......@@ -131,6 +133,12 @@ CString RtfMath::RenderToOOX(RenderParameter oRenderParameter)
{
sVal += m_aArray[i]->RenderToOOX(oNewParam);
}
if (sVal.IsEmpty())
{
oNewParam.nType = RENDER_TO_OOX_PARAM_PLAIN;
sVal = m_oVal.RenderToOOX(oNewParam);
}
}
else
{
......
......@@ -7,16 +7,15 @@
class RtfMath : public IDocumentElement, public ItemContainer<IDocumentElementPtr>
{
private:
public:
CString m_sRtfName;
CString m_sOOXName;
public:
bool m_bHeader; //чтобы отличать заголовок от вложенных групп
bool m_bIsVal;
bool m_bIsBool;
//RtfMathSpecProp m_oProperty;
RtfParagraph m_oVal;
RtfShapePtr m_oPicture;
......@@ -58,11 +57,12 @@ public:
void SetRtfName(CString sName)
{
m_sRtfName = sName;
m_sOOXName = sName;
m_sOOXName.Insert(1, _T(":"));
}
void SetOOXType (int type);
void SetOOXType (int type);
CString RenderToRtf (RenderParameter oRenderParameter);
CString RenderToOOX (RenderParameter oRenderParameter);
};
......
......@@ -3036,181 +3036,6 @@ public:
};
class RtfMathProperty: public IRenderableProperty
{
public:
int mbrkBin;
int mbrkBinSub;
int mdefJc;
int mdispDef;
int minterSp;
int mintraSp;
int mlMargin;
int mmathFont;
int mnaryLim;
int mpostSp;
int mpreSp;
int mrMargin;
int msmallFrac;
int mwrapIndent;
int mwrapRight;
int mintLim;
RtfMathProperty()
{
SetDefault();
}
//bool IsValid()
//{
// return PROP_DEF != mbrkBin || PROP_DEF != mbrkBinSub || PROP_DEF != mdispDef || PROP_DEF != minterSp ||
// PROP_DEF != mintraSp || PROP_DEF != mlMargin || PROP_DEF != mmathFont || PROP_DEF != mnaryLim ||
// PROP_DEF != mpostSp || PROP_DEF != mpreSp || PROP_DEF != mrMargin || PROP_DEF != msmallFrac ||
// PROP_DEF != mwrapIndent || PROP_DEF != mwrapRight ;
//}
void SetDefaultRtf()
{
SetDefault();
}
void SetDefaultOOX()
{
SetDefault();
}
void SetDefault()
{
DEFAULT_PROPERTY( mintLim )
DEFAULT_PROPERTY( mbrkBin )
DEFAULT_PROPERTY( mbrkBinSub )
mdefJc = 1; //centered as a group
DEFAULT_PROPERTY( mdispDef )
DEFAULT_PROPERTY( minterSp )
DEFAULT_PROPERTY( mintraSp )
DEFAULT_PROPERTY( mlMargin )
DEFAULT_PROPERTY( mmathFont )
DEFAULT_PROPERTY( mnaryLim )
DEFAULT_PROPERTY( mpostSp )
DEFAULT_PROPERTY( mpreSp )
DEFAULT_PROPERTY( mrMargin )
DEFAULT_PROPERTY( msmallFrac )
DEFAULT_PROPERTY( mwrapIndent )
DEFAULT_PROPERTY( mwrapRight )
}
CString RenderToRtf(RenderParameter oRenderParameter);
CString RenderToOOX(RenderParameter oRenderParameter);
};
class RtfMathSpecProp: public IRenderableProperty
{
public:
int moMathParaPr;//moMathParaPr
int Font; //moMath
int Break; //mboxPr
int RowSpacing; //meqArrPr
int RowSpacingRule; //mmPr
int CellGap;
int CellGapRule;
int CellSpacing;
int malnScr; //msSubSupPr
int HideLeft; //borderBoxPrp
int HideTop;
int HideRight;
int HideBottom;
int StrikeHor;
int StrikeVer;
int StrikeLR;
int StrikeRL;
int Alignment; //boxPrp
int Differential;
int NoBreak;
int Emulator;
int NormalText; //mrPr
int mscr;
int msty;
int mlit;
int mshow; //phantPrp
int mtransp;
int mzeroAsc;
int mzeroDesc;
int mzeroWid;
int mchr; //mchr
RtfCharProperty m_oCharProp; //charProp
RtfMathSpecProp()
{
SetDefault();
}
bool IsValid()
{
return true;
}
void SetDefaultRtf()
{
SetDefault();
}
void SetDefaultOOX()
{
SetDefault();
}
void SetDefault()
{
DEFAULT_PROPERTY( moMathParaPr )
DEFAULT_PROPERTY( Font )
DEFAULT_PROPERTY( Break )
DEFAULT_PROPERTY( RowSpacing )
DEFAULT_PROPERTY( RowSpacingRule )
DEFAULT_PROPERTY( CellGap )
DEFAULT_PROPERTY( CellGapRule )
DEFAULT_PROPERTY( CellSpacing )
DEFAULT_PROPERTY( malnScr )
DEFAULT_PROPERTY( HideLeft )
DEFAULT_PROPERTY( HideTop )
DEFAULT_PROPERTY( HideRight )
DEFAULT_PROPERTY( HideBottom )
DEFAULT_PROPERTY( StrikeHor )
DEFAULT_PROPERTY( StrikeVer )
DEFAULT_PROPERTY( StrikeLR )
DEFAULT_PROPERTY( StrikeRL )
DEFAULT_PROPERTY( Alignment )
DEFAULT_PROPERTY( Differential )
DEFAULT_PROPERTY( NoBreak )
DEFAULT_PROPERTY( Emulator )
DEFAULT_PROPERTY( NormalText )
DEFAULT_PROPERTY( mscr )
DEFAULT_PROPERTY( msty )
DEFAULT_PROPERTY( mlit )
DEFAULT_PROPERTY( mshow )
DEFAULT_PROPERTY( mtransp )
DEFAULT_PROPERTY( mzeroAsc )
DEFAULT_PROPERTY( mzeroDesc )
DEFAULT_PROPERTY( mzeroWid )
DEFAULT_PROPERTY( mchr )
m_oCharProp.SetDefault();
}
CString RenderToRtf(RenderParameter oRenderParameter);
CString RenderToOOX(RenderParameter oRenderParameter);
};
typedef boost::shared_ptr<RtfMathSpecProp> RtfMathSpecPropPtr;
typedef boost::shared_ptr<RtfMathProperty> RtfMathPropertyPtr;
//typedef boost::shared_ptr<RtfTableStyleProperty> RtfTableStylePropertyPtr;
typedef boost::shared_ptr<RtfCharStyle> RtfCharStylePtr;
typedef boost::shared_ptr<RtfParagraphStyle> RtfParagraphStylePtr;
......
......@@ -17,6 +17,7 @@ public:
int m_nAnsiCodePage;
int m_nDeffFont;
int m_nDeffMathFont;
int m_bRtlGutter;
int m_bRtl;
......@@ -133,16 +134,16 @@ public:
void SetDefault()
{
//todo
m_eCodePage = cp_ansi;
m_nTabWidth = 720; //todo -1
m_nDeffFont = PROP_DEF;
m_bHypCaps = PROP_DEF;
m_bAutoHyp = PROP_DEF;
m_nMaxHypen = PROP_DEF;
m_eCodePage = cp_ansi;
m_nTabWidth = 720; //todo -1
m_nDeffFont = PROP_DEF;
m_nDeffMathFont = PROP_DEF;
m_bHypCaps = PROP_DEF;
m_bAutoHyp = PROP_DEF;
m_nMaxHypen = PROP_DEF;
m_nHyphenationRight = PROP_DEF;
m_nZoom = 100;
m_nAnsiCodePage = CP_ACP;
m_nZoom = 100;
m_nAnsiCodePage = CP_ACP;
m_bDorderSurroundHeader = PROP_DEF;
m_bDorderSurroundFotter = PROP_DEF;
......
......@@ -89,7 +89,7 @@ CString OOXDocumentWriter::CreateXmlEnd( )
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
poSettingsWriter->AddContent( m_oDocument.m_oProperty.RenderToOOX(oNewParam) );
//poSettingsWriter->AddContent( m_oDocument.m_oColorSchemeMapping.RenderToOOX(oNewParam) );
//poSettingsWriter->AddContent( m_oDocument.m_oMathProp.RenderToOOX(oNewParam) );
poSettingsWriter->AddContent( m_oDocument.m_oMathProp.RenderToOOX(oNewParam) );
//numbering.xml
OOXNumberingWriter* poNumberingWriter = static_cast<OOXNumberingWriter*>( m_oWriter.m_poNumberingWriter );
......
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