Commit 9318cdc0 authored by ElenaSubbotina's avatar ElenaSubbotina

RtfFormatReader - review ...

parent 23fa6786
......@@ -591,7 +591,6 @@ bool RtfSectionCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReade
//{
// static int nCount = 0;
// nCount++;
// ATLTRACE( "count %d\n", nCount );
//}
COMMAND_RTF_INT ( L"headery", oReader.m_oCurSectionProp.m_nHeaderTop, sCommand, hasParameter, parameter)
COMMAND_RTF_INT ( L"footery", oReader.m_oCurSectionProp.m_nFooterBottom, sCommand, hasParameter, parameter)
......@@ -621,6 +620,9 @@ bool RtfSectionCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReade
COMMAND_RTF_INT ( L"pgbrdropt", oReader.m_oCurSectionProp.m_nBorderMeasure, sCommand, hasParameter, parameter)
COMMAND_RTF_BOOL( L"pgbrdrsna", oReader.m_oCurSectionProp.m_nBorderAlign, sCommand, hasParameter, parameter)
COMMAND_RTF_INT ( L"srauth", oReader.m_oCurSectionProp.m_nSrAuth, sCommand, hasParameter, parameter)
COMMAND_RTF_INT ( L"srdate", oReader.m_oCurSectionProp.m_nSrDate, sCommand, hasParameter, parameter)
else if ( L"header" == sCommand || L"footer" == sCommand || L"headerl" == sCommand ||
L"headerr" == sCommand || L"headerf" == sCommand || L"footerl" == sCommand ||
L"footerr" == sCommand || L"footerf" == sCommand )
......@@ -628,7 +630,7 @@ bool RtfSectionCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReade
ParagraphReader oParagraphReader(sCommand, oReader);
oAbstrReader.StartSubReader( oParagraphReader, oDocument, oReader );
oParagraphReader.m_oParPropDest.Finalize(oReader/*, RtfSectionPtr()*/);
oParagraphReader.m_oParPropDest.Finalize( oReader );
TextItemContainerPtr oNewFooterHeader = oParagraphReader.m_oParPropDest.m_oTextItems;
......@@ -676,7 +678,7 @@ bool RtfShadingCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReade
else if ( L"bgdkbdiag" == sCommand ) oOutput.m_eType = RtfShading::st_chbgdkbdiag;
else if ( L"bgdkcross" == sCommand ) oOutput.m_eType = RtfShading::st_chbgdkcross;
else if ( L"bgdkdcross" == sCommand ) oOutput.m_eType = RtfShading::st_chbgdkdcross;
else if ( L"cfpat" == sCommand )
else if ( L"cfpat" == sCommand )
{
if ( hasParameter )
oOutput.m_nForeColor = parameter;
......@@ -722,15 +724,16 @@ bool RtfShadingCellCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oR
oOutput.m_eType = RtfShading::st_chbgdkcross;
else if ( L"rawclbgdkdcross" == sCommand || L"clbgdkdcross" == sCommand || L"tsbgdkdcross" == sCommand )
oOutput.m_eType = RtfShading::st_chbgdkdcross;
COMMAND_RTF_INT ( L"clcfpat", oOutput.m_nForeColor, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( L"clcbpat", oOutput.m_nBackColor, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( L"clcfpatraw", oOutput.m_nForeColor, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( L"clcbpatraw", oOutput.m_nBackColor, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( L"clcfpatraw", oOutput.m_nForeColor, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( L"clcbpatraw", oOutput.m_nBackColor, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( L"tscellcfpat", oOutput.m_nForeColor, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( L"tscellcbpat", oOutput.m_nBackColor, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( L"clshdng", oOutput.m_nValue, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( L"clshdngraw", oOutput.m_nValue, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( L"clshdngraw", oOutput.m_nValue, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( L"tscellpct", oOutput.m_nValue, sCommand, hasParameter, parameter )
else
return false;
......@@ -754,7 +757,8 @@ bool RtfShadingCharCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oR
else if ( L"chbgdkbdiag" == sCommand ) oOutput.m_eType = RtfShading::st_chbgdkbdiag;
else if ( L"chbgdkcross" == sCommand ) oOutput.m_eType = RtfShading::st_chbgdkcross;
else if ( L"chbgdkdcross" == sCommand ) oOutput.m_eType = RtfShading::st_chbgdkdcross;
else if ( L"chcfpat" == sCommand ) {
else if ( L"chcfpat" == sCommand )
{
if ( hasParameter )
oOutput.m_nForeColor = parameter;
}
......@@ -1602,7 +1606,9 @@ bool FieldReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CStr
//{\field{\*\fldinst...}{\*\fldrslt...}}{ ??? }
}
else
{
return false;
}
return true;
}
bool OleReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CString sCommand, bool hasParameter, int parameter)
......@@ -2490,8 +2496,11 @@ bool ParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfReader&
else if ( L"field" == sCommand )
{
RtfFieldPtr oNewField = RtfFieldPtr(new RtfField());
oNewField->m_oCharProperty = oReader.m_oState->m_oCharProp;
FieldReader oFieldReader( *oNewField );
oAbstrReader.StartSubReader( oFieldReader, oDocument, oReader );
if ( oNewField->IsValid() )
m_oCurParagraph->AddItem( oNewField );
}
......@@ -2603,24 +2612,24 @@ bool ParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfReader&
COMMAND_RTF_SPECIAL_CHAR( L"tab", m_oCurParagraph, sCommand, hasParameter, RtfCharSpecial::rsc_tab )
else if ( L"emdash" == sCommand )
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 151, 0xD0 ); //\bullet Word for Windows - 151 ; Apple Macintosh - 0xD0
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 151, 0xD0 ); // bullet Word for Windows - 151 ; Apple Macintosh - 0xD0
else if ( L"endash" == sCommand )
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 150, 0xD1 ); //\bullet Word for Windows - 150 ; Apple Macintosh - 0xD1
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 150, 0xD1 ); // bullet Word for Windows - 150 ; Apple Macintosh - 0xD1
COMMAND_RTF_SPECIAL_CHAR( L"emspace", m_oCurParagraph, sCommand, hasParameter, RtfCharSpecial::rsc_emspace )
COMMAND_RTF_SPECIAL_CHAR( L"enspace", m_oCurParagraph, sCommand, hasParameter, RtfCharSpecial::rsc_enspace )
COMMAND_RTF_SPECIAL_CHAR( L"qmspace", m_oCurParagraph, sCommand, hasParameter, RtfCharSpecial::rsc_qmspace )
else if ( L"bullet" == sCommand )
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 149, 0xA5 ); //\bullet Word for Windows - 149 ; Apple Macintosh - 0xA5
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 149, 0xA5 ); // bullet Word for Windows - 149 ; Apple Macintosh - 0xA5
else if ( L"lquote" == sCommand )
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 145, 0xD4 ); //\bullet Word for Windows - 145 ; Apple Macintosh - 0xD4
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 145, 0xD4 ); // bullet Word for Windows - 145 ; Apple Macintosh - 0xD4
else if ( L"rquote" == sCommand )
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 146, 0xD5 ); //\bullet Word for Windows - 146 ; Apple Macintosh - 0xD5
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 146, 0xD5 ); // bullet Word for Windows - 146 ; Apple Macintosh - 0xD5
else if ( L"ldblquote" == sCommand )
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 147, 0xD2 ); //\bullet Word for Windows - 147 ; Apple Macintosh - 0xD2
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 147, 0xD2 ); // bullet Word for Windows - 147 ; Apple Macintosh - 0xD2
else if ( L"rdblquote" == sCommand )
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 148, 0xD3 ); //\bullet Word for Windows - 148 ; Apple Macintosh - 0xD3
ExecuteNumberChar( oDocument, oReader, oAbstrReader, 148, 0xD3 ); // bullet Word for Windows - 148 ; Apple Macintosh - 0xD3
COMMAND_RTF_SPECIAL_CHAR( L"|", m_oCurParagraph, sCommand, hasParameter, RtfCharSpecial::rsc_Formula )
COMMAND_RTF_SPECIAL_CHAR( L"~", m_oCurParagraph, sCommand, hasParameter, RtfCharSpecial::rsc_NonBrSpace )
......@@ -2659,6 +2668,7 @@ bool ParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfReader&
if (oAbstrReader.StartSubReader( oOldPropReader, oDocument, oReader ))
{
oReader.m_oCurSectionProp.m_pOldSectionProp = props;
}
}
else if ( L"oldtprops" == sCommand )
......
......@@ -834,6 +834,8 @@ public:
PictureReader oPictureReader( oReader, m_oShape );
StartSubReader( oPictureReader, oDocument, oReader );
}
else
return false;
return true;
}
void PopState( RtfDocument& oDocument, RtfReader& oReader );
......
......@@ -58,7 +58,7 @@ public:
}
else if(ooxColor.getType() == OOX::Drawing::colorSheme)
{
RtfColor::ThemeColor oTheme;
RtfColor::_ThemeColor oTheme;
if( true == RtfColor::GetThemeByOOX( ooxColor.m_oShemeClr.m_oVal.GetValue(), oTheme ))
return oParam.oRtf->m_oColorTable.GetColor( oTheme, oOutputColor );
return false;
......
......@@ -397,7 +397,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
oNewField->m_bLock = ooxFldChar->m_oFldLock->ToBool();
if (ooxFldChar->m_oDirty.IsInit())
oNewField->m_bDirty = ooxFldChar->m_oDirty->ToBool();
oNewField->m_oCharProp = oNewProperty;
oNewField->m_oCharProperty = oNewProperty;
oOutputParagraph.AddItem( oNewField );
}break;
case SimpleTypes::fldchartypeEnd:
......
......@@ -45,6 +45,16 @@ CString RtfChar::RenderToOOX(RenderParameter oRenderParameter)
bool bInsert = false;
bool bDelete = false;
if (m_oProperty.m_nRevised != PROP_DEF)
{
bInsert = true;
CString sAuthor = m_oProperty.m_nRevauth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_oProperty.m_nRevauth] : L"";
CString sDate(RtfUtility::convertDateTime(m_oProperty.m_nRevdttm).c_str());
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_oProperty.m_nRevised = PROP_DEF;
}
if (m_oProperty.m_nDeleted != PROP_DEF)
{
bDelete = true;
......@@ -55,17 +65,6 @@ CString RtfChar::RenderToOOX(RenderParameter oRenderParameter)
sResult += L"<w:del w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_oProperty.m_nDeleted = PROP_DEF;
}
else if (m_oProperty.m_nRevised != PROP_DEF)
{
bInsert = true;
CString sAuthor = m_oProperty.m_nRevauth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_oProperty.m_nRevauth] : L"";
CString sDate(RtfUtility::convertDateTime(m_oProperty.m_nRevdttm).c_str());
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_oProperty.m_nRevised = PROP_DEF;
}
sResult += L"<w:r>";
sResult += L"<w:rPr>";
sResult += m_oProperty.RenderToOOX(oRenderParameter);
......@@ -73,8 +72,8 @@ CString RtfChar::RenderToOOX(RenderParameter oRenderParameter)
sResult += renderTextToXML(L"Text", bDelete );
sResult += L"</w:r>";
if (bInsert)sResult += L"</w:ins>";
if (bDelete)sResult += L"</w:del>";
if (bInsert)sResult += L"</w:ins>";
}
else if(RENDER_TO_OOX_PARAM_TEXT == oRenderParameter.nType)
{
......@@ -83,8 +82,34 @@ CString RtfChar::RenderToOOX(RenderParameter oRenderParameter)
else if( RENDER_TO_OOX_PARAM_MATH == oRenderParameter.nType)
{
sResult += L"<m:r>";
bool bInsert = false;
bool bDelete = false;
if (m_oProperty.m_nRevised != PROP_DEF)
{
bInsert = true;
CString sAuthor = m_oProperty.m_nRevauth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_oProperty.m_nRevauth] : L"";
CString sDate(RtfUtility::convertDateTime(m_oProperty.m_nRevdttm).c_str());
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_oProperty.m_nRevised = PROP_DEF;
}
if (m_oProperty.m_nDeleted != PROP_DEF)
{
bDelete = true;
CString sAuthor = m_oProperty.m_nRevauthDel != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_oProperty.m_nRevauthDel ] : L"";
CString sDate(RtfUtility::convertDateTime(m_oProperty.m_nRevdttmDel).c_str());
sResult += L"<w:del w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_oProperty.m_nDeleted = PROP_DEF;
}
sResult += m_oProperty.RenderToOOX(oRenderParameter);//w:rPr внутри
sResult += renderTextToXML( L"Math" );
if (bDelete)sResult += L"</w:del>";
if (bInsert)sResult += L"</w:ins>";
sResult += L"</m:r>";
}
else if( RENDER_TO_OOX_PARAM_PLAIN == oRenderParameter.nType)
......@@ -261,3 +286,147 @@ CString RtfChar::RenderToRtf(RenderParameter oRenderParameter)
}
return result;
}
CString RtfCharSpecial::_RenderToOOX(RenderParameter oRenderParameter)
{
CString sResult;
switch( m_eType )
{
case rsc_chdate: sResult += L""; break;
case rsc_chdpl: sResult += L""; break;
case rsc_chdpa: sResult += L""; break;
case rsc_chtime: sResult += L""; break;
case rsc_chpgn: sResult += L"<w:pgNum />"; break;
case rsc_sectnum: sResult += L""; break;
case rsc_chftn: sResult += L"<w:footnoteRef/>"; break;
case rsc_chftnEnd: sResult += L"<w:endnoteRef/>"; break;
case rsc_chatn: sResult += L"<w:annotationRef />"; break;
case rsc_chftnsep: sResult += L"<w:separator />"; break;
case rsc_chftnsepc: sResult += L"<w:continuationSeparator/>"; break;
case rsc_page: sResult += L"<w:br w:type=\"page\"/>"; break;
case rsc_column: sResult += L"<w:br w:type=\"column\"/>"; break;
case rsc_line: sResult += L"<w:br w:type=\"textWrapping\" w:clear=\"none\"/>";break;
case rsc_softpage: sResult += L""; break;
case rsc_softcol: sResult += L""; break;
case rsc_softline: sResult += L""; break;
case rsc_tab: sResult += L"<w:tab/>"; break;
case rsc_emspace: sResult += L""; break;
case rsc_qmspace: sResult += L""; break;
case rsc_Formula: sResult += L""; break;
case rsc_zwbo: sResult += L""; break;
case rsc_zwnbo: sResult += L""; break;
case rsc_zwj: sResult += L""; break;
case rsc_zwnj: sResult += L""; break;
case rsc_OptHyphen: sResult += L"<w:t xml:space=\"preserve\">-</w:t>"; break;//<w:softHyphen/>
case rsc_NonBrHyphen: sResult += L"<w:t xml:space=\"preserve\">-</w:t>"; break;//<w:nonBreakHyphen/>
case rsc_NonBrSpace: sResult += L"<w:t xml:space=\"preserve\"> </w:t>"; break;
}
switch ( m_nTextWrapBreak )
{
case 0: sResult += L"<w:br w:type=\"textWrapping\" w:clear=\"none\"/>"; break;
case 1: sResult += L"<w:br w:type=\"textWrapping\" w:clear=\"left\"/>"; break;
case 2: sResult += L"<w:br w:type=\"textWrapping\" w:clear=\"right\"/>"; break;
case 3: sResult += L"<w:br w:type=\"textWrapping\" w:clear=\"all\"/>"; break;
}
return sResult;
}
CString RtfCharSpecial::RenderToOOX(RenderParameter oRenderParameter)
{
RtfDocument* poRtfDocument = static_cast<RtfDocument*> (oRenderParameter.poDocument);
OOXWriter* poOOXWriter = static_cast<OOXWriter*> (oRenderParameter.poWriter);
CString sResult;
if(RENDER_TO_OOX_PARAM_RUN == oRenderParameter.nType)
{
bool bInsert = false;
bool bDelete = false;
if (m_oProperty.m_nRevised != PROP_DEF)
{
bInsert = true;
CString sAuthor = m_oProperty.m_nRevauth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_oProperty.m_nRevauth] : L"";
CString sDate(RtfUtility::convertDateTime(m_oProperty.m_nRevdttm).c_str());
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_oProperty.m_nRevised = PROP_DEF;
}
if (m_oProperty.m_nDeleted != PROP_DEF)
{
bDelete = true;
CString sAuthor = m_oProperty.m_nRevauthDel != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_oProperty.m_nRevauthDel ] : L"";
CString sDate(RtfUtility::convertDateTime(m_oProperty.m_nRevdttmDel).c_str());
sResult += L"<w:del w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_oProperty.m_nDeleted = PROP_DEF;
}
sResult += L"<w:r>";
sResult += L"<w:rPr>";
sResult += m_oProperty.RenderToOOX(oRenderParameter);
sResult += L"</w:rPr>";
sResult += _RenderToOOX(oRenderParameter);
sResult += L"</w:r>";
if (bDelete)sResult += L"</w:del>";
if (bInsert)sResult += L"</w:ins>";
}
else if(RENDER_TO_OOX_PARAM_TEXT == oRenderParameter.nType ||
RENDER_TO_OOX_PARAM_MATH == oRenderParameter.nType ||
RENDER_TO_OOX_PARAM_PLAIN == oRenderParameter.nType)
{
sResult += _RenderToOOX(oRenderParameter);
}
return sResult;
}
CString RtfCharSpecial::RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
sResult += L"{";
sResult += m_oProperty.RenderToRtf( oRenderParameter );
switch( m_eType )
{
case rsc_chdate: sResult += L"\\chdate"; break;
case rsc_chdpl: sResult += L"\\chdpl"; break;
case rsc_chdpa: sResult += L"\\chdpa"; break;
case rsc_chtime: sResult += L"\\chtime"; break;
case rsc_chpgn: sResult += L"\\chpgn"; break;
case rsc_sectnum: sResult += L"\\sectnum"; break;
case rsc_chftn: sResult += L"\\chftn"; break;
case rsc_chftnEnd: sResult += L"\\chftn"; break;
case rsc_chatn: sResult += L"\\chatn"; break;
case rsc_chftnsep: sResult += L"\\chftnsep"; break;
case rsc_chftnsepc: sResult += L"\\chftnsepc"; break;
case rsc_page: sResult += L"\\page"; break;
case rsc_column: sResult += L"\\column"; break;
case rsc_line: sResult += L"\\line"; break;
case rsc_softpage: sResult += L"\\softpage"; break;
case rsc_softcol: sResult += L"\\softcol"; break;
case rsc_softline: sResult += L"\\softline"; break;
case rsc_tab: sResult += L"\\tab"; break;
case rsc_Formula: sResult += L"\\|"; break;
case rsc_OptHyphen: sResult += L"\\-"; break;
case rsc_NonBrHyphen: sResult += L"\\_"; break;
case rsc_NonBrSpace: sResult += L"\\~"; break;
case rsc_zwbo: sResult += L"\\zwbo"; break;
case rsc_zwnbo: sResult += L"\\zwnbo"; break;
case rsc_zwj: sResult += L"\\zwj"; break;
case rsc_zwnj: sResult += L"\\zwnj"; break;
}
if( PROP_DEF != m_nTextWrapBreak )
sResult += L"\\par";
//switch ( m_nTextWrapBreak ) //не воспринимается word
//{
// case 0: sResult += L"\\lbr0";break;
// case 1: sResult += L"\\lbr1";break;
// case 2: sResult += L"\\lbr2";break;
// case 3: sResult += L"\\lbr3";break;
//}
if( PROP_DEF != m_nSoftHeight )
{
sResult.AppendFormat( L"\\softlheight%d", m_nSoftHeight );
}
sResult += L"}";
return sResult;
}
......@@ -99,7 +99,7 @@ public:
}
return false;
}
bool GetColor( RtfColor::ThemeColor oTheme, RtfColor& oColor)
bool GetColor( RtfColor::_ThemeColor oTheme, RtfColor& oColor)
{
for( int i = 0; i < (int)m_aArray.size(); i++ )
if( oTheme == m_aArray[i].m_eTheme )
......@@ -111,7 +111,7 @@ public:
}
bool GetColor( CString sTheme, RtfColor& oColor)
{
RtfColor::ThemeColor oTheme = RtfColor::TC_NONE;
RtfColor::_ThemeColor oTheme = RtfColor::TC_NONE;
if( true == RtfColor::GetThemeByString(sTheme,oTheme ) )
{
......
......@@ -59,8 +59,10 @@ bool RtfMath::IsRtfControlProperty( CString sControlW )
//можно бинарный поиск вставить
for( int i = 0; i < mc_nRtfControlWordsSize; i++ )
{
if( mc_aRtfControlWords[ i ] == sControlW )
return true;
}
return false;
}
......@@ -78,8 +80,10 @@ bool RtfMath::IsRtfControlWord( CString sControlW )
//можно бинарный поиск вставить
for( int i = 0; i < mc_nRtfControlWordsSize; i++ )
{
if( mc_aRtfControlWords[ i ] == sControlW )
return true;
}
return false;
}
......@@ -126,6 +130,7 @@ CString RtfMath::RenderToRtf(RenderParameter oRenderParameter)
sResult += L"}";// m_sRtfName
return sResult;
}
CString RtfMath::RenderToOOX(RenderParameter oRenderParameter)
{
if (m_sOOXName.IsEmpty()) return L"";
......@@ -154,7 +159,7 @@ CString RtfMath::RenderToOOX(RenderParameter oRenderParameter)
else
{
oNewParam.nType = RENDER_TO_OOX_PARAM_MATH;
for( int i = 0; i < (int)m_aArray.size(); i++ )
for( int i = 0; i < m_aArray.size(); i++ )
{
sContent += m_aArray[i]->RenderToOOX(oNewParam);
}
......@@ -176,7 +181,7 @@ CString RtfMath::RenderToOOX(RenderParameter oRenderParameter)
}
sResult += L">";
sResult += sProp;
sResult += sProp; //??
sResult += sContent;
......
......@@ -56,6 +56,16 @@ CString RtfOle::RenderToOOX(RenderParameter oRenderParameter)
bool bInsert = false;
bool bDelete = false;
if (pCharProps->m_nRevised != PROP_DEF)
{
bInsert = true;
CString sAuthor = pCharProps->m_nRevauth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ pCharProps->m_nRevauth] : L"";
CString sDate(RtfUtility::convertDateTime(pCharProps->m_nRevdttm).c_str());
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
pCharProps->m_nRevised = PROP_DEF;
}
if (pCharProps->m_nDeleted != PROP_DEF)
{
bDelete = true;
......@@ -66,16 +76,6 @@ CString RtfOle::RenderToOOX(RenderParameter oRenderParameter)
sResult += L"<w:del w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
pCharProps->m_nDeleted = PROP_DEF;
}
else if (pCharProps->m_nRevised != PROP_DEF)
{
bInsert = true;
CString sAuthor = pCharProps->m_nRevauth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ pCharProps->m_nRevauth] : L"";
CString sDate(RtfUtility::convertDateTime(pCharProps->m_nRevdttm).c_str());
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
pCharProps->m_nRevised = PROP_DEF;
}
//----------
sResult += _T("<w:r>");
......@@ -101,8 +101,8 @@ CString RtfOle::RenderToOOX(RenderParameter oRenderParameter)
sResult += _T("</w:object>");
sResult += _T("</w:r>");
if (bInsert)sResult += L"</w:ins>";
if (bDelete)sResult += L"</w:del>";
if (bInsert)sResult += L"</w:ins>";
}
return sResult;
}
......
......@@ -711,22 +711,47 @@ CString RtfCharProperty::RenderToOOX(RenderParameter oRenderParameter)
RtfDocument * poRtfDocument = static_cast<RtfDocument*> (oRenderParameter.poDocument);
OOXWriter * poOOXWriter = static_cast<OOXWriter*> (oRenderParameter.poWriter);
bool bInsert = false;
bool bDelete = false;
if( RENDER_TO_OOX_PARAM_MATH == oRenderParameter.nType)
{//w:rPr в m:ctrlPr
if (m_nRevised != PROP_DEF)
{
bInsert = true;
CString sAuthor = m_nRevauth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_nRevauth] : L"";
CString sDate(RtfUtility::convertDateTime( m_nRevdttm ).c_str());
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_nRevised = PROP_DEF;
}
if (m_nDeleted != PROP_DEF)
{
bDelete = true;
CString sAuthor = m_nRevauthDel != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_nRevauthDel ] : L"";
CString sDate(RtfUtility::convertDateTime( m_nRevdttmDel ).c_str());
sResult += L"<w:del w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_nDeleted = PROP_DEF;
}
sResult += L"<w:rPr>";
}
if ( PROP_DEF != m_nDeleted )
if ( PROP_DEF != m_nDeleted )//для rPr в pPr
{
CString sAuthor = m_nRevauthDel != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_nRevauthDel] : L"";
CString sDate(RtfUtility::convertDateTime(m_nRevdttmDel).c_str());
sResult += L"<w:del w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\"/>";
sResult += L"<w:del w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\"/>";
}
if ( PROP_DEF != m_nRevised )
{
CString sAuthor = m_nRevauth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_nRevauth] : L"";
CString sDate(RtfUtility::convertDateTime(m_nRevdttm).c_str());
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\"/>";
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\"/>";
}
switch( m_nAnimated )
......@@ -739,9 +764,9 @@ CString RtfCharProperty::RenderToOOX(RenderParameter oRenderParameter)
case 5: sResult += L"<w:effect w:val=\"antsRed\"/>"; break;
case 6: sResult += L"<w:effect w:val=\"shimmer\"/>"; break;
}
RENDER_OOX_BOOL( m_bBold, sResult, L"w:b" )
RENDER_OOX_BOOL( m_bCaps, sResult, L"w:caps" )
RENDER_OOX_INT( (int)m_nScalex, sResult, L"w:w" )
RENDER_OOX_BOOL ( m_bBold, sResult, L"w:b" )
RENDER_OOX_BOOL ( m_bCaps, sResult, L"w:caps" )
RENDER_OOX_INT ( (int)m_nScalex, sResult, L"w:w" )
if( PROP_DEF != m_nCharStyle )
{
......@@ -816,7 +841,10 @@ CString RtfCharProperty::RenderToOOX(RenderParameter oRenderParameter)
RtfColor oCurColor;
if( true == poRtfDocument->m_oColorTable.GetColor( m_nHightlited, oCurColor ) )
{
sResult += L"<w:highlight w:val=\"" + oCurColor.GetHighLight() + L"\"/>";
if (!oCurColor.m_bAuto)
{
sResult += L"<w:highlight w:val=\"" + oCurColor.GetHighLight() + L"\"/>";
}
}
}
......@@ -921,7 +949,12 @@ CString RtfCharProperty::RenderToOOX(RenderParameter oRenderParameter)
}
if( RENDER_TO_OOX_PARAM_MATH == oRenderParameter.nType)
{
sResult += L"</w:rPr>";
if (bDelete)sResult += L"</w:del>";
if (bInsert)sResult += L"</w:ins>";
}
return sResult;
}
......
......@@ -64,15 +64,15 @@ CString RtfDocumentProperty::RenderToRtf(RenderParameter oRenderParameter)
//Page Information
//эти свойства пишутся в первой секции
//public: int m_nPaperWidth; //\paperwN Paper width in twips (default is 12,240).
//public: int m_nPaperHeight; //\paperhN Paper height in twips (default is 15,840).
//public: int m_nMarginLeft; //\marglN Left margin in twips (default is 1800).
//public: int m_nMarginRight; //\margrN Right margin in twips (default is 1800).
//public: int m_nMarginTop; //\margtN Top margin in twips (default is 1440).
//public: int m_nMarginBottom; //\margbN Bottom margin in twips (default is 1440).
//public: int m_nPaperWidth; // paperwN Paper width in twips (default is 12,240).
//public: int m_nPaperHeight; // paperhN Paper height in twips (default is 15,840).
//public: int m_nMarginLeft; // marglN Left margin in twips (default is 1800).
//public: int m_nMarginRight; // margrN Right margin in twips (default is 1800).
//public: int m_nMarginTop; // margtN Top margin in twips (default is 1440).
//public: int m_nMarginBottom; // margbN Bottom margin in twips (default is 1440).
//public: int m_bFacingPage; //(mirrorMargins)\facingp Facing pages (activates odd/even headers and gutters).
//public: int m_nGutterWidth; //\gutterN Gutter width in twips (default is 0).
//public: int m_nGutterWidthOutside; //\ogutterN Outside gutter width (default is 0; not used by Word, but in 1987 RTF Spec)
//public: int m_nGutterWidth; // gutterN Gutter width in twips (default is 0).
//public: int m_nGutterWidthOutside; // ogutterN Outside gutter width (default is 0; not used by Word, but in 1987 RTF Spec)
// RENDER_RTF_BOOL( m_bLandScape, sResult, L"landscape" )
RENDER_RTF_BOOL( m_bGutterAtTop, sResult, L"gutterprl" )
......@@ -515,10 +515,15 @@ CString RtfSectionProperty::RenderToRtf(RenderParameter oRenderParameter)
}
CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter)
{
RtfDocument* poRtfDocument = static_cast<RtfDocument*> (oRenderParameter.poDocument);
OOXWriter* poOOXWriter = static_cast<OOXWriter*> (oRenderParameter.poWriter);
CString sResult;
sResult += L"<w:sectPr>";
if( 1 == m_bBidi )
sResult += L"<w:bidi/>";
CString sPaperSource;
if( PROP_DEF != m_nPaperSourceFirst )
sPaperSource.AppendFormat( L" w:first=\"%d\"", m_nPaperSourceFirst );
......@@ -806,7 +811,19 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter)
CString sId = SaveFile(m_oFooterRight,oRenderParameter, false);
sResult += L"<w:footerReference w:type=\"default\" r:id=\"" + sId + L"\"/>";
}
sResult.Append(L"</w:sectPr>");
if (m_pOldSectionProp)
{
CString sAuthor = m_nSrAuth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_nSrAuth] : L"";
CString sDate(RtfUtility::convertDateTime(m_nSrDate).c_str());
RenderParameter oRenderParameterNew = oRenderParameter;
oRenderParameterNew.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
sResult += L"<w:sectPrChange w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
sResult += m_pOldSectionProp->RenderToOOX(oRenderParameterNew);
sResult += L"</w:sectPrChange>";
}
sResult += L"</w:sectPr>";
return sResult;
}
CString RtfSectionProperty::SaveFile( TextItemContainerPtr oTarget, RenderParameter oRenderParameter, bool bHeader)
......
......@@ -282,6 +282,9 @@ private:
}
};
class RtfSectionProperty;
typedef boost::shared_ptr<RtfSectionProperty> RtfSectionPropertyPtr;
class RtfSectionProperty: public IRenderableProperty
{
//Bidirectional Controls
......@@ -291,7 +294,6 @@ public:
int m_nPaperSourceOther; // binsxnN N is the printer bin used for the pages of the section.
int m_bRtlGutter; // rtlgutter Gutter is positioned on the right.
int m_bEndnotes; // \endnhere Endnotes included in the section.
int m_nStyle; // \dsN Designates section style. If a section style is specified, style properties must be specified with the section.
......@@ -504,6 +506,11 @@ public:
CString m_sIDFooterFirst;
CString m_sIDFooterRight;
int m_nSrAuth;
int m_nSrDate;
RtfSectionPropertyPtr m_pOldSectionProp;
RtfSectionProperty()
{
SetDefault();
......@@ -625,6 +632,11 @@ public:
//m_oFooterLeft = TextItemContainerPtr();
//m_oFooterFirst = TextItemContainerPtr();
//m_oFooterRight = TextItemContainerPtr();
DEFAULT_PROPERTY( m_nSrAuth)
DEFAULT_PROPERTY( m_nSrDate)
m_pOldSectionProp = RtfSectionPropertyPtr(NULL);
}
CString RenderToRtf(RenderParameter oRenderParameter);
CString RenderToOOX(RenderParameter oRenderParameter);
......@@ -632,7 +644,6 @@ private:
CString SaveFile( TextItemContainerPtr oTarget, RenderParameter oRenderParameter, bool bHeader);
};
typedef boost::shared_ptr<RtfSectionProperty> RtfSectionPropertyPtr;
typedef boost::shared_ptr<RtfDocumentProperty> RtfDocumentPropertyPtr;
class RtfSection : public TextItemContainer
......
......@@ -712,6 +712,16 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
}
else
{//работает по умолчанию
if (m_oCharProperty.m_nRevised != PROP_DEF)
{
m_bInsert = true;
CString sAuthor = m_oCharProperty.m_nRevauth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_oCharProperty.m_nRevauth] : L"";
CString sDate(RtfUtility::convertDateTime(m_oCharProperty.m_nRevdttm).c_str());
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_oCharProperty.m_nRevised = PROP_DEF;
}
if (m_oCharProperty.m_nDeleted != PROP_DEF)
{
m_bDelete = true;
......@@ -722,16 +732,6 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
sResult += L"<w:del w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_oCharProperty.m_nDeleted = PROP_DEF;
}
else if (m_oCharProperty.m_nRevised != PROP_DEF)
{
m_bInsert = true;
CString sAuthor = m_oCharProperty.m_nRevauth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_oCharProperty.m_nRevauth] : L"";
CString sDate(RtfUtility::convertDateTime(m_oCharProperty.m_nRevdttm).c_str());
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_oCharProperty.m_nRevised = PROP_DEF;
}
CString sCharProp = m_oCharProperty.RenderToOOX(oRenderParameter);
sResult += L"<w:r>";
if (!sCharProp .IsEmpty())
......@@ -1333,8 +1333,8 @@ CString RtfShape::RenderToOOXEnd(RenderParameter oRenderParameter)
{
sResult += L"</w:pict></w:r>";//работает по умолчанию
if (m_bInsert) sResult += L"</w:ins>";
if (m_bDelete) sResult += L"</w:del>";
if (m_bInsert) sResult += L"</w:ins>";
}
return sResult;
}
......
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