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;
}
......@@ -40,11 +40,11 @@ class RtfAbsPosTab : public IDocumentElement
public:
enum Leader
{ l_none,
l_ptablnone, //\ptablnone Absolute position tab with a blank leading (default).
l_ptabldot, //\ptabldot Absolute position tab with a leading that uses period symbols (.....).
l_ptablminus, //\ptablminus Absolute position tab with a leading that uses minus symbols (-----).
l_ptabluscore, //\ptabluscore Absolute position tab with a leading that uses underscore symbols (_____).
l_ptablmdot, //\ptablmdot Absolute position tab with a leading that uses middle dot symbols (•••••).
l_ptablnone, // ptablnone Absolute position tab with a blank leading (default).
l_ptabldot, // ptabldot Absolute position tab with a leading that uses period symbols (.....).
l_ptablminus, // ptablminus Absolute position tab with a leading that uses minus symbols (-----).
l_ptabluscore, // ptabluscore Absolute position tab with a leading that uses underscore symbols (_____).
l_ptablmdot, // ptablmdot Absolute position tab with a leading that uses middle dot symbols (•••••).
} ;
enum Alignment
{ a_none,
......@@ -127,43 +127,44 @@ public:
class RtfCharSpecial : public IDocumentElement
{
public:
typedef enum {
rsc_none,
rsc_chdate,//\chdate Current date (as in headers).
rsc_chdpl,//\chdpl Current date in long format (for example, Wednesday, February 20, 2008).
rsc_chdpa,//\chdpa Current date in abbreviated format (for example, Wed, Feb 20, 2008).
rsc_chtime,//\chtime Current time (as in headers).
rsc_chpgn,//\chpgn Current page number (as in headers).
rsc_sectnum,//\sectnum Current section number (as in headers).
rsc_chftn,//\chftn Automatic footnote reference (footnotes follow in a group).
rsc_chftnEnd,//Endnote
rsc_chatn,//\chatn Annotation reference (annotation text follows in a group).
rsc_chftnsep,//\chftnsep Anchoring character for footnote separator.
rsc_chftnsepc,//\chftnsepc Anchoring character for footnote continuation.
rsc_page,//\page Required page break.
rsc_column,//\column Required column break.
rsc_line,//\line Required line break (no paragraph break).
rsc_softpage,//\softpage Nonrequired page break. Emitted as it appears in galley view.
rsc_softcol,//\softcol Nonrequired column break. Emitted as it appears in galley view.
rsc_softline,//\softline Nonrequired line break. Emitted as it appears in galley view.
rsc_tab,//\tab Tab character.
rsc_emspace,//\emspace Non-breaking space equal to width of character “m” in current font. Some old RTF writers use the construct '{' \emspace ' }' (with two spaces before the closing brace) to trick readers unaware of \emspace into parsing a regular space. A reader should interpret this as an \emspace and a regular space.
rsc_enspace,//\enspace Nonbreaking space equal to width of character “n” in current font. Some old RTF writers use the construct '{' \enspace ' }' (with two spaces before the closing brace) to trick readers unaware of \enspace into parsing a regular space. A reader should interpret this as an \enspace and a regular space.
rsc_qmspace,//\qmspace One-quarter em space.
rsc_Formula,//\| Formula character. (Used by Word 5.1 for the Macintosh as the beginning delimiter for a string of formula typesetting commands.)
rsc_OptHyphen,//\- Optional hyphen.
rsc_NonBrHyphen,//\_ Non-breaking hyphen.
rsc_NonBrSpace,//\~ Non-breaking space.
rsc_SubEntry,//\: Specifies a subentry in an index entry.
rsc_zwbo,//\zwbo Zero-width break opportunity. Used to insert break opportunity between two characters.
rsc_zwnbo,//\zwnbo Zero-width non-break opportunity. Used to remove break opportunity between two characters.
rsc_zwj,//\zwj Zero-width joiner. This is used for ligating (joining) characters.
rsc_zwnj,//\zwnj Zero-width nonjoiner. This is used for unligating a character.
} RtfSpecChar;
enum _RtfSpecChar
{
rsc_none,
rsc_chdate, // chdate Current date (as in headers).
rsc_chdpl, // chdpl Current date in long format (for example, Wednesday, February 20, 2008).
rsc_chdpa, // chdpa Current date in abbreviated format (for example, Wed, Feb 20, 2008).
rsc_chtime, // chtime Current time (as in headers).
rsc_chpgn, // chpgn Current page number (as in headers).
rsc_sectnum, // sectnum Current section number (as in headers).
rsc_chftn, // chftn Automatic footnote reference (footnotes follow in a group).
rsc_chftnEnd, //Endnote
rsc_chatn, // chatn Annotation reference (annotation text follows in a group).
rsc_chftnsep, // chftnsep Anchoring character for footnote separator.
rsc_chftnsepc, // chftnsepc Anchoring character for footnote continuation.
rsc_page, // page Required page break.
rsc_column, // column Required column break.
rsc_line, // line Required line break (no paragraph break).
rsc_softpage, // softpage Nonrequired page break. Emitted as it appears in galley view.
rsc_softcol, // softcol Nonrequired column break. Emitted as it appears in galley view.
rsc_softline, // softline Nonrequired line break. Emitted as it appears in galley view.
rsc_tab, // tab Tab character.
rsc_emspace, // emspace Non-breaking space equal to width of character “m” in current font. Some old RTF writers use the construct '{' \emspace ' }' (with two spaces before the closing brace) to trick readers unaware of \emspace into parsing a regular space. A reader should interpret this as an \emspace and a regular space.
rsc_enspace, // enspace Nonbreaking space equal to width of character “n” in current font. Some old RTF writers use the construct '{' \enspace ' }' (with two spaces before the closing brace) to trick readers unaware of \enspace into parsing a regular space. A reader should interpret this as an \enspace and a regular space.
rsc_qmspace, // qmspace One-quarter em space.
rsc_Formula, // | Formula character. (Used by Word 5.1 for the Macintosh as the beginning delimiter for a string of formula typesetting commands.)
rsc_OptHyphen, // - Optional hyphen.
rsc_NonBrHyphen,// _ Non-breaking hyphen.
rsc_NonBrSpace, // ~ Non-breaking space.
rsc_SubEntry, // : Specifies a subentry in an index entry.
rsc_zwbo, // zwbo Zero-width break opportunity. Used to insert break opportunity between two characters.
rsc_zwnbo, // zwnbo Zero-width non-break opportunity. Used to remove break opportunity between two characters.
rsc_zwj, // zwj Zero-width joiner. This is used for ligating (joining) characters.
rsc_zwnj, // zwnj Zero-width nonjoiner. This is used for unligating a character.
};
int m_nTextWrapBreak;//\lbrN Text wrapping break of type
int m_nSoftHeight;//\softlheightN Nonrequired line height. This is emitted as a prefix to each line.
RtfSpecChar m_eType;
int m_nTextWrapBreak; // lbrN Text wrapping break of type
int m_nSoftHeight; // softlheightN Nonrequired line height. This is emitted as a prefix to each line.
_RtfSpecChar m_eType;
RtfCharProperty m_oProperty;
RtfCharSpecial()
......@@ -172,123 +173,16 @@ public:
m_nTextWrapBreak = PROP_DEF;
m_nSoftHeight = PROP_DEF;
}
CString 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;
}
CString _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 RenderToOOX(RenderParameter oRenderParameter)
{
CString sResult;
if(RENDER_TO_OOX_PARAM_RUN == oRenderParameter.nType)
{
sResult += L"<w:r>";
sResult += L"<w:rPr>";
sResult += m_oProperty.RenderToOOX(oRenderParameter);
sResult += L"</w:rPr>";
sResult += _RenderToOOX(oRenderParameter);
sResult += L"</w:r>";
}
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 RenderToRtf(RenderParameter oRenderParameter);
CString _RenderToOOX(RenderParameter oRenderParameter);
CString RenderToOOX(RenderParameter oRenderParameter);
};
typedef boost::shared_ptr<RtfCharSpecial> RtfCharSpecialPtr;
class RtfChar : public IDocumentElement
{
protected: CString m_sChars;
protected:
CString m_sChars;
public:
RtfChar()
{
......
......@@ -31,14 +31,16 @@
*/
#pragma once
#include "RtfParagraph.h"
#include "Writer/OOXWriter.h"
#include "Writer/OOXRelsWriter.h"
class OOXFieldBegin : public IDocumentElement
{
public:
int m_bDirty;
int m_bLock;
RtfCharProperty m_oCharProp;
int m_bDirty;
int m_bLock;
RtfCharProperty m_oCharProperty;
OOXFieldBegin()
{
SetDefault();
......@@ -49,163 +51,192 @@ public:
}
void SetDefault()
{
m_bDirty = PROP_DEF;
m_bLock = PROP_DEF;
m_bDirty = PROP_DEF;
m_bLock = PROP_DEF;
m_oCharProperty.SetDefault();
}
CString RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
sResult += _T("{\\field ");
RENDER_RTF_BOOL( m_bDirty, sResult, _T("flddirty") )
RENDER_RTF_BOOL( m_bLock, sResult, _T("fldlock") )
sResult += _T("{\\*\\fldinst");
sResult += m_oCharProp.RenderToRtf(oRenderParameter);
sResult += L"{\\field ";
RENDER_RTF_BOOL( m_bDirty, sResult, L"flddirty" )
RENDER_RTF_BOOL( m_bLock, sResult, L"fldlock" )
sResult += L"{\\*\\fldinst";
sResult += m_oCharProperty.RenderToRtf(oRenderParameter);
return sResult;
}
CString RenderToOOX(RenderParameter oRenderParameter)
{
CString sResult;
sResult += _T("<w:r>");
sResult += _T("<w:fldChar w:fldCharType=\"separate\"");
RENDER_OOX_INT_ATTRIBUTE( m_bDirty, sResult, _T("dirty") )
RENDER_OOX_INT_ATTRIBUTE( m_bLock, sResult, _T("fldLock") )
sResult += _T("/>");
sResult += _T("</w:r>");
sResult += L"<w:r>";
CString props = m_oCharProperty.RenderToOOX(oRenderParameter);
if (props.IsEmpty())
{
sResult += L"<w:rPr>";
sResult += props;
sResult += L"</w:rPr>";
}
sResult += L"<w:fldChar w:fldCharType=\"separate\"";
RENDER_OOX_INT_ATTRIBUTE( m_bDirty, sResult, L"dirty" )
RENDER_OOX_INT_ATTRIBUTE( m_bLock, sResult, L"fldLock" )
sResult += L"/>";
sResult += L"</w:r>";
return sResult;
}
};
class OOXFieldInsertText : public IDocumentElement
{
public: RtfCharPtr m_oText;
public: int GetType()
public:
RtfCharPtr m_oText;
int GetType()
{
return TYPE_OOX_FIELD;
}
public: CString RenderToRtf(RenderParameter oRenderParameter)
CString RenderToRtf(RenderParameter oRenderParameter)
{
if( NULL != m_oText )
return m_oText->RenderToRtf( oRenderParameter );
else
return _T("");
return L"";
}
public: CString RenderToOOX(RenderParameter oRenderParameter)
CString RenderToOOX(RenderParameter oRenderParameter)
{
if( NULL != m_oText )
{
CString sResult;
sResult += _T("<w:r>");
sResult += _T("<w:instrText>");
sResult += L"<w:r>";
sResult += L"<w:instrText>";
oRenderParameter.nType = RENDER_TO_RTF_PARAM_CHAR;
oRenderParameter.nValue = RENDER_TO_RTF_PARAM_NO_PAR;
oRenderParameter.nType = RENDER_TO_RTF_PARAM_CHAR;
oRenderParameter.nValue = RENDER_TO_RTF_PARAM_NO_PAR;
sResult += m_oText->RenderToOOX( oRenderParameter );
sResult += _T("</w:instrText>");
sResult += _T("</w:r>");
sResult += L"</w:instrText>";
sResult += L"</w:r>";
return sResult;
}
else
return _T("");
return L"";
}
};
class OOXFieldSeparate : public IDocumentElement
{
public: int GetType()
public:
int GetType()
{
return TYPE_OOX_FIELD;
}
public: CString RenderToRtf(RenderParameter oRenderParameter)
CString RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
return _T("}{\\fldrslt");
return L"}{\\fldrslt";
}
public: CString RenderToOOX(RenderParameter oRenderParameter)
CString RenderToOOX(RenderParameter oRenderParameter)
{
return _T("<w:fldChar w:fldCharType=\"separate\" />");
return L"<w:fldChar w:fldCharType=\"separate\"/>";
}
};
class OOXFieldEnd : public IDocumentElement
{
public: int GetType()
public:
int GetType()
{
return TYPE_OOX_FIELD;
}
public: CString RenderToRtf(RenderParameter oRenderParameter)
CString RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
return _T("}}");
return L"}}";
}
public: CString RenderToOOX(RenderParameter oRenderParameter)
CString RenderToOOX(RenderParameter oRenderParameter)
{
return _T("<w:fldChar w:fldCharType=\"end\" />");
return L"<w:fldChar w:fldCharType=\"end\"/>";
}
};
class RtfField : public IDocumentElement
{
public: typedef enum{
public:
enum _FieldMode
{
fm_none,
fm_flddirty,//\flddirty A formatting change has been made to the field result since the field was last updated.
fm_fldedit, //\fldedit Text has been added to, or removed from, the field result since the field was last updated.
fm_fldlock, //\fldlock Field is locked and cannot be updated.
fm_fldpriv //\fldpriv Result is not in a form suitable for display (for example, binary data used by fields whose result is a picture).
}FieldMode;
fm_flddirty, // flddirty A formatting change has been made to the field result since the field was last updated.
fm_fldedit, // fldedit Text has been added to, or removed from, the field result since the field was last updated.
fm_fldlock, // fldlock Field is locked and cannot be updated.
fm_fldpriv // fldpriv Result is not in a form suitable for display (for example, binary data used by fields whose result is a picture).
};
_FieldMode m_eMode;
TextItemContainerPtr m_oInsert;
bool m_bReferenceToEndnote;
CString m_sData;
TextItemContainerPtr m_oResult;
bool m_bTextOnly;
RtfCharProperty m_oCharProperty;
public: FieldMode m_eMode;
public: TextItemContainerPtr m_oInsert;
public: bool m_bReferenceToEndnote;
public: CString m_sData;
public: TextItemContainerPtr m_oResult;
public: bool m_bTextOnly;
public: RtfField()
RtfField()
{
SetDefault();
}
public: int GetType()
int GetType()
{
return TYPE_RTF_FIELD;
}
public: bool IsValid()
bool IsValid()
{
return true;
//return false == m_oInsert.IsValid() && false == m_oResult.IsValid();
}
public: void SetDefaultRtf()
void SetDefaultRtf()
{
SetDefault();
}
public: void SetDefaultOOX()
void SetDefaultOOX()
{
SetDefault();
}
public: void SetDefault()
void SetDefault()
{
m_eMode = fm_none;
m_bReferenceToEndnote = false;
m_sData = _T("");
m_oInsert = TextItemContainerPtr( new TextItemContainer() );
m_oResult = TextItemContainerPtr( new TextItemContainer() );
m_bTextOnly = false;
m_eMode = fm_none;
m_bReferenceToEndnote = false;
m_bTextOnly = false;
m_sData = L"";
m_oInsert = TextItemContainerPtr( new TextItemContainer() );
m_oResult = TextItemContainerPtr( new TextItemContainer() );
m_oCharProperty.SetDefault();
}
public: CString RenderToRtf(RenderParameter oRenderParameter)
CString RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
sResult += _T("{\\field ");
sResult += L"{\\field ";
if( fm_none != m_eMode )
{
switch( m_eMode )
{
case fm_flddirty: sResult += _T("{\\flddirty "); break;
case fm_fldedit: sResult += _T("{\\fldedit "); break;
case fm_fldlock: sResult += _T("{\\fldlock "); break;
case fm_fldpriv: sResult += _T("{\\fldpriv "); break;
case fm_flddirty: sResult += L"{\\flddirty "; break;
case fm_fldedit: sResult += L"{\\fldedit "; break;
case fm_fldlock: sResult += L"{\\fldlock "; break;
case fm_fldpriv: sResult += L"{\\fldpriv "; break;
}
}
sResult += _T("{\\*\\fldinst ");
sResult += L"{\\*\\fldinst ";
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_RTF_PARAM_PLAIN;//RENDER_TO_RTF_PARAM_CHAR;
oNewParam.nValue = RENDER_TO_RTF_PARAM_NO_PAR;
......@@ -213,111 +244,163 @@ public: CString RenderToRtf(RenderParameter oRenderParameter)
sResult += m_oInsert->RenderToRtf( oNewParam );
if( true == m_bReferenceToEndnote )
sResult += _T("\\fldalt");
sResult += L"\\fldalt";
if( !m_sData.IsEmpty() )
sResult += _T("{\\*\\datafield ") + m_sData + _T("}");
sResult += L"{\\*\\datafield " + m_sData + L"}";
sResult += _T("}");
sResult += L"}";
CString str = m_oResult->RenderToRtf( oRenderParameter ) ;
sResult += _T("{\\fldrslt ") + str + _T("}");
sResult += _T("}");
sResult += L"{\\fldrslt " + str + L"}";
sResult += L"}";
return sResult;
}
public: CString RenderToOOX(RenderParameter oRenderParameter)
CString RenderToOOX(RenderParameter oRenderParameter)
{
RtfDocument* poRtfDocument = static_cast<RtfDocument*> (oRenderParameter.poDocument);
OOXWriter* poOOXWriter = static_cast<OOXWriter*> (oRenderParameter.poWriter);
CString sResult;
if( true == m_bTextOnly )
{
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
sResult += m_oResult->RenderToOOX(oNewParam);
}
else
{
bool bInsert = false;
bool bDelete = false;
if (m_oCharProperty.m_nRevised != PROP_DEF)
{
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)
{
bDelete = true;
CString sAuthor = m_oCharProperty.m_nRevauthDel != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_oCharProperty.m_nRevauthDel ] : L"";
CString sDate(RtfUtility::convertDateTime(m_oCharProperty.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_oCharProperty.m_nDeleted = PROP_DEF;
}
//поверяем на наличие гиперссылки
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_PLAIN;
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_PLAIN;
CString sInsertText = m_oInsert->RenderToOOX( oNewParam );
int nIndex = sInsertText.Find( _T("HYPERLINK") );
int nIndex = sInsertText.Find( L"HYPERLINK" );
if( -1 != nIndex )
{
CString sHyperlink = sInsertText;
sHyperlink.Delete( nIndex, 9/*(int)_tcslen( _T("HYPERLINK") )*/ );
sHyperlink.Delete( nIndex, 9/*(int)_tcslen( L"HYPERLINK" )*/ );
int nSplash = sHyperlink.Find( _T("\\") );
int nSplash = sHyperlink.Find( L"\\" );
if (nSplash > 0)
{
sHyperlink = sHyperlink.Left(nSplash);
}
//оставляем только одну ссылку
//оставляем только одну ссылку
sHyperlink.Remove( '\"' );
sHyperlink.Trim();
//заменяем пробелы на %20
sHyperlink.Replace( _T(" "), _T("%20") );
//заменяем пробелы на %20
sHyperlink.Replace( L" ", L"%20" );
//добавляем в rels
//добавляем в rels
OOXRelsWriter* poRelsWriter = static_cast<OOXRelsWriter*>( oRenderParameter.poRels );
CString sId = poRelsWriter->AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"), Utils::PrepareToXML( sHyperlink ), false );
//добавляем гиперссылку в документ
sResult += _T("<w:hyperlink r:id=\"") + sId + _T("\" >");
CString sId = poRelsWriter->AddRelationship( L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", Utils::PrepareToXML( sHyperlink ), false );
//добавляем гиперссылку в документ
sResult += L"<w:hyperlink r:id=\"" + sId + L"\" >";
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
sResult += m_oResult->RenderToOOX(oNewParam);
sResult += _T("</w:hyperlink>");
sResult += L"</w:hyperlink>";
}
else
{
nIndex = sInsertText.Find( _T("PRIVATE") );
nIndex = sInsertText.Find( L"PRIVATE" );
if( m_oResult->GetCount() <= 1 && nIndex < 0)
{
RenderParameter oNewParametr = oRenderParameter;
oNewParametr.nType = RENDER_TO_OOX_PARAM_PLAIN;
//sResult += _T("<w:r>"));
RenderParameter oNewParametr = oRenderParameter;
oNewParametr.nType = RENDER_TO_OOX_PARAM_PLAIN;
//sResult += L"<w:r>");
CString str = Utils::PrepareToXML( m_oInsert->RenderToOOX(oNewParametr) ).Trim();
sResult += _T("<w:fldSimple w:instr=\"");
sResult += L"<w:fldSimple w:instr=\"";
sResult += str;
sResult += _T("\">");
sResult += L"\">";
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
sResult += m_oResult->RenderToOOX(oNewParam);
sResult.AppendFormat(_T("</w:fldSimple>"));
//sResult += _T("</w:r>"));
sResult.AppendFormat(L"</w:fldSimple>");
//sResult += L"</w:r>");
}
else
{
//так добавляются лишние параграфы
RenderParameter oNewParametr = oRenderParameter;
oNewParametr.nType = RENDER_TO_OOX_PARAM_PLAIN;
sResult += _T("<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>");
//так добавляются лишние параграфы
RenderParameter oNewParametr = oRenderParameter;
oNewParametr.nType = RENDER_TO_OOX_PARAM_PLAIN;
CString props = m_oCharProperty.RenderToOOX(oRenderParameter);
if (!props.IsEmpty()) props = L"<w:rPr>" + props + L"</w:rPr>";
sResult += L"<w:r>";
if (!props.IsEmpty())
sResult += props;
sResult += L"<w:fldChar w:fldCharType=\"begin\"/>";
sResult += L"</w:r>";
CString str = Utils::PrepareToXML( m_oInsert->RenderToOOX(oNewParametr) );
sResult += _T("<w:r><w:instrText xml:space=\"preserve\">");
sResult += L"<w:r>";
if (!props.IsEmpty())
sResult += props;
sResult += L"<w:instrText xml:space=\"preserve\">";
sResult += str;
sResult += _T("</w:instrText></w:r>");
sResult += _T("<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>");
sResult += L"</w:instrText></w:r>";
sResult += L"<w:r>";
if (!props.IsEmpty())
sResult += props;
sResult += L"<w:fldChar w:fldCharType=\"separate\"/></w:r>";
//заканчиваем этот параграф
sResult += _T("</w:p>");
//пишем параграфы содержания
sResult += L"</w:p>";
//пишем параграфы содержания
oNewParametr.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
sResult += m_oResult->RenderToOOX(oNewParametr);
//заканчиваем Field
sResult += _T("<w:p>");
sResult += _T("<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>");
sResult += L"<w:p>";
sResult += L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
}
}
if (bDelete)sResult += L"</w:del>";
if (bInsert)sResult += L"</w:ins>";
}
return sResult;
}
};
typedef boost::shared_ptr<RtfField> RtfFieldPtr;
typedef boost::shared_ptr<OOXFieldBegin> OOXFieldBeginPtr;
typedef boost::shared_ptr<OOXFieldInsertText> OOXFieldInsertTextPtr;
typedef boost::shared_ptr<OOXFieldSeparate> OOXFieldSeparatePtr;
typedef boost::shared_ptr<OOXFieldEnd> OOXFieldEndPtr;
typedef boost::shared_ptr<RtfField> RtfFieldPtr;
typedef boost::shared_ptr<OOXFieldBegin> OOXFieldBeginPtr;
typedef boost::shared_ptr<OOXFieldInsertText> OOXFieldInsertTextPtr;
typedef boost::shared_ptr<OOXFieldSeparate> OOXFieldSeparatePtr;
typedef boost::shared_ptr<OOXFieldEnd> OOXFieldEndPtr;
......@@ -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;
}
......
......@@ -187,10 +187,10 @@ public:
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;
enum _ThemeColor {TC_NONE,cmaindarkone ,cmainlightone ,cmaindarktwo ,cmainlighttwo ,caccentone ,caccenttwo ,caccentthree ,caccentfour ,caccentfive ,caccentsix ,chyperlink ,cfollowedhyperlink ,cbackgroundone ,ctextone ,cbackgroundtwo ,ctexttwo};
bool m_bAuto;
ThemeColor m_eTheme;
_ThemeColor m_eTheme;
BYTE m_byteRed;
BYTE m_byteGreen;
......@@ -228,6 +228,7 @@ public:
void SetDefault()
{
m_bAuto = false;
m_byteRed = 0;
m_byteGreen = 0;
m_byteBlue = 0;
......@@ -237,20 +238,20 @@ public:
}
BYTE GetR()
{
BYTE byteRed = SetShade( m_byteRed );
byteRed = SetTint( byteRed );
BYTE byteRed = SetShade( m_byteRed );
byteRed = SetTint( byteRed );
return byteRed;
}
BYTE GetG()
{
BYTE byteGreen = SetShade( m_byteGreen );
byteGreen = SetTint( byteGreen );
BYTE byteGreen = SetShade( m_byteGreen );
byteGreen = SetTint( byteGreen );
return byteGreen;
}
BYTE GetB()
{
BYTE byteBlue = SetShade( m_byteBlue );
byteBlue = SetTint( byteBlue );
BYTE byteBlue = SetShade( m_byteBlue );
byteBlue = SetTint( byteBlue );
return byteBlue;
}
......@@ -262,6 +263,7 @@ public:
void SetHEX(int color)
{
SetDefault();
m_byteRed = (color&0xFF0000) >> 16;
m_byteGreen = (color&0xFF00) >> 8;
m_byteBlue = (color&0xFF);
......@@ -269,15 +271,13 @@ public:
void SetRGB(BYTE red, BYTE green, BYTE blue)
{
SetDefault();
m_byteRed = red;
m_byteRed = red;
m_byteGreen = green;
m_byteBlue = blue;
m_byteBlue = blue;
}
void SetHSL(double nHue, double nSat, double nLum)
{
//// Given H,S,L in range of 0-1
//// Returns a Color (RGB struct) in range of 0-255
//public static ColorRGB HSL2RGB(double nHue, double nSat, double nLum)
{ // Given H,S,L in range of 0-1
double v;
double r,g,b;
r = nLum; // default to gray
......@@ -354,14 +354,16 @@ public:
SetDefault();
int color = Strings::ToColor(hex);
m_byteRed = (color&0xFF);
m_byteGreen = (color&0xFF00) >>8;
m_byteBlue = (color&0xFF0000) >>16;
m_byteGreen = (color&0xFF00) >> 8;
m_byteBlue = (color&0xFF0000) >> 16;
}
else
SetDefault();
}
CString ToHexColor(bool bBGR = false)
{
if (m_bAuto) return L"auto";
BYTE byteRed = SetShade( m_byteRed );
byteRed = SetTint( byteRed );
CString sRed;
......@@ -393,9 +395,11 @@ public:
CString sResult;
BYTE byteRed = SetShade( m_byteRed );
byteRed = SetTint( byteRed );
BYTE byteGreen = SetShade( m_byteGreen );
BYTE byteGreen = SetShade( m_byteGreen );
byteGreen = SetTint( byteGreen );
BYTE byteBlue = SetShade( m_byteBlue );
BYTE byteBlue = SetShade( m_byteBlue );
byteBlue = SetTint( byteBlue );
int nColor = (byteRed << 16) | (byteGreen << 8) | byteBlue;
......@@ -452,74 +456,57 @@ public:
else if ( oStr == L"gold" ) return RtfColor(255,215,0);
else if ( oStr == L"green" ) return RtfColor(0,128,0);
else if ( oStr == L"grey" ) return RtfColor(128,128,128);
else if ( oStr == L"red" ) return RtfColor(255,0,0);
else if ( oStr == L"yellow" ) return RtfColor(255,255,0);
else if ( oStr == L"red" ) return RtfColor(255,0,0);
else if ( oStr == L"yellow" ) return RtfColor(255,255,0);
return RtfColor(0,0,0);
}
static CString GetPresetByColor( RtfColor oCol ) //стр. 3320
{
if ( oCol == RtfColor(240,248,255)) return L"aliceBlue";
else if ( oCol == RtfColor(250,235,215)) return L"aniqueWhite";
else if ( oCol == RtfColor(0,255,255)) return L"aqua";
else if ( oCol == RtfColor(127,255,212)) return L"aquamarine";
else if ( oCol == RtfColor(240,255,255)) return L"azure";
else if ( oCol == RtfColor(245,245,220)) return L"beige";
else if ( oCol == RtfColor(255,228,196)) return L"bisque";
else if ( oCol == RtfColor(0,0,0)) return L"black";
else if ( oCol == RtfColor(255,235,205)) return L"blanchedAlmond";
else if ( oCol == RtfColor(138,43,226)) return L"blueViolet";
else if ( oCol == RtfColor(165,42,42)) return L"brown";
else if ( oCol == RtfColor(222,184,135)) return L"burlyWood";
else if ( oCol == RtfColor(0,255,255)) return L"cyan";
else if ( oCol == RtfColor(255,215,0)) return L"gold";
else if ( oCol == RtfColor(0,128,0)) return L"green";
else if ( oCol == RtfColor(128,128,128)) return L"grey";
else if ( oCol == RtfColor(255,0,0)) return L"red";
else if ( oCol == RtfColor(255,255,0)) return L"yellow";
else if ( oCol == RtfColor(250,235,215)) return L"aniqueWhite";
else if ( oCol == RtfColor(0,255,255)) return L"aqua";
else if ( oCol == RtfColor(127,255,212)) return L"aquamarine";
else if ( oCol == RtfColor(240,255,255)) return L"azure";
else if ( oCol == RtfColor(245,245,220)) return L"beige";
else if ( oCol == RtfColor(255,228,196)) return L"bisque";
else if ( oCol == RtfColor(0,0,0)) return L"black";
else if ( oCol == RtfColor(255,235,205)) return L"blanchedAlmond";
else if ( oCol == RtfColor(138,43,226)) return L"blueViolet";
else if ( oCol == RtfColor(165,42,42)) return L"brown";
else if ( oCol == RtfColor(222,184,135)) return L"burlyWood";
else if ( oCol == RtfColor(0,255,255)) return L"cyan";
else if ( oCol == RtfColor(255,215,0)) return L"gold";
else if ( oCol == RtfColor(0,128,0)) return L"green";
else if ( oCol == RtfColor(128,128,128)) return L"grey";
else if ( oCol == RtfColor(255,0,0)) return L"red";
else if ( oCol == RtfColor(255,255,0)) return L"yellow";
return L"black";
}
static bool GetThemeByString( CString sTheme ,ThemeColor & oOutTheme )
{
if ( sTheme == L"accent1" )
{oOutTheme = caccentone; return true;}
else if ( sTheme == L"accent2" )
{oOutTheme = caccenttwo; return true;}
else if ( sTheme == L"accent3" )
{oOutTheme = caccentthree; return true;}
else if ( sTheme == L"accent4" )
{oOutTheme = caccentfour; return true;}
else if ( sTheme == L"accent5" )
{oOutTheme = caccentfive; return true;}
else if ( sTheme == L"accent6" )
{oOutTheme = caccentsix; return true;}
else if ( sTheme == L"bg1" )
{oOutTheme = cbackgroundone; return true;}
else if ( sTheme == L"bg2" )
{oOutTheme = cbackgroundtwo; return true;}
else if ( sTheme == L"dk1" )
{oOutTheme = cmaindarkone; return true;}
else if ( sTheme == L"dk2" )
{oOutTheme = cmaindarktwo; return true;}
else if ( sTheme == L"folHlink" )
{oOutTheme = cfollowedhyperlink; return true;}
else if ( sTheme == L"hlink" )
{oOutTheme = chyperlink; return true;}
else if ( sTheme == L"lt1" )
{oOutTheme = cmainlightone; return true;}
else if ( sTheme == L"lt2" )
{oOutTheme = cmainlighttwo; return true;}
else if ( sTheme == L"phClr" )
{oOutTheme = cmainlighttwo; return true;}
else if ( sTheme == L"tx1" )
{oOutTheme = ctextone; return true;}
else if ( sTheme = L"tx2" )
{oOutTheme = ctexttwo; return true;}
static bool GetThemeByString( CString sTheme, _ThemeColor & oOutTheme )
{
if ( sTheme == L"accent1" ) {oOutTheme = caccentone; return true;}
else if ( sTheme == L"accent2" ) {oOutTheme = caccenttwo; return true;}
else if ( sTheme == L"accent3" ) {oOutTheme = caccentthree; return true;}
else if ( sTheme == L"accent4" ) {oOutTheme = caccentfour; return true;}
else if ( sTheme == L"accent5" ) {oOutTheme = caccentfive; return true;}
else if ( sTheme == L"accent6" ) {oOutTheme = caccentsix; return true;}
else if ( sTheme == L"bg1" ) {oOutTheme = cbackgroundone; return true;}
else if ( sTheme == L"bg2" ) {oOutTheme = cbackgroundtwo; return true;}
else if ( sTheme == L"dk1" ) {oOutTheme = cmaindarkone; return true;}
else if ( sTheme == L"dk2" ) {oOutTheme = cmaindarktwo; return true;}
else if ( sTheme == L"folHlink" ) {oOutTheme = cfollowedhyperlink;return true;}
else if ( sTheme == L"hlink" ) {oOutTheme = chyperlink; return true;}
else if ( sTheme == L"lt1" ) {oOutTheme = cmainlightone; return true;}
else if ( sTheme == L"lt2" ) {oOutTheme = cmainlighttwo; return true;}
else if ( sTheme == L"phClr" ) {oOutTheme = cmainlighttwo; return true;}
else if ( sTheme == L"tx1" ) {oOutTheme = ctextone; return true;}
else if ( sTheme = L"tx2" ) {oOutTheme = ctexttwo; return true;}
return false;
}
static bool GetThemeByOOX( SimpleTypes::EShemeColorVal val ,ThemeColor & oOutTheme )
static bool GetThemeByOOX( SimpleTypes::EShemeColorVal val, _ThemeColor & oOutTheme )
{
switch(val)
{
......@@ -545,46 +532,32 @@ public:
return false;
}
static bool GetStringByTheme( CString sTheme , ThemeColor& oOutTheme )
{
if ( L"accent1" == sTheme )
{oOutTheme = caccentone; return true;}
else if ( L"accent2" == sTheme )
{oOutTheme = caccenttwo; return true;}
else if ( L"accent3" == sTheme )
{oOutTheme = caccentthree; return true;}
else if ( L"accent4" == sTheme )
{oOutTheme = caccentfour; return true;}
else if ( L"accent5" == sTheme )
{oOutTheme = caccentfive; return true;}
else if ( L"accent6" == sTheme )
{oOutTheme = caccentsix; return true;}
else if ( L"bg1" == sTheme )
{oOutTheme = cbackgroundone; return true;}
else if ( L"bg2" == sTheme )
{oOutTheme = cbackgroundtwo; return true;}
else if ( L"dk1" == sTheme )
{oOutTheme = cmaindarkone; return true;}
else if ( L"dk2" == sTheme )
{oOutTheme = cmaindarktwo; return true;}
else if ( L"folHlink" == sTheme )
{oOutTheme = cfollowedhyperlink; return true;}
else if ( L"hlink" == sTheme )
{oOutTheme = chyperlink; return true;}
else if ( L"lt1" == sTheme )
{oOutTheme = cmainlightone; return true;}
else if ( L"lt2" == sTheme )
{oOutTheme = cmainlighttwo; return true;}
else if ( L"phClr" == sTheme )
{oOutTheme = cmainlighttwo; return true;}
else if ( L"tx1" == sTheme )
{oOutTheme = ctextone; return true;}
else if ( L"tx2" == sTheme )
{oOutTheme = ctexttwo; return true;}
static bool GetStringByTheme( CString sTheme , _ThemeColor& oOutTheme )
{
if ( L"accent1" == sTheme ) {oOutTheme = caccentone; return true;}
else if ( L"accent2" == sTheme ) {oOutTheme = caccenttwo; return true;}
else if ( L"accent3" == sTheme ) {oOutTheme = caccentthree; return true;}
else if ( L"accent4" == sTheme ) {oOutTheme = caccentfour; return true;}
else if ( L"accent5" == sTheme ) {oOutTheme = caccentfive; return true;}
else if ( L"accent6" == sTheme ) {oOutTheme = caccentsix; return true;}
else if ( L"bg1" == sTheme ) {oOutTheme = cbackgroundone; return true;}
else if ( L"bg2" == sTheme ) {oOutTheme = cbackgroundtwo; return true;}
else if ( L"dk1" == sTheme ) {oOutTheme = cmaindarkone; return true;}
else if ( L"dk2" == sTheme ) {oOutTheme = cmaindarktwo; return true;}
else if ( L"folHlink" == sTheme ) {oOutTheme = cfollowedhyperlink;return true;}
else if ( L"hlink" == sTheme ) {oOutTheme = chyperlink; return true;}
else if ( L"lt1" == sTheme ) {oOutTheme = cmainlightone; return true;}
else if ( L"lt2" == sTheme ) {oOutTheme = cmainlighttwo; return true;}
else if ( L"phClr" == sTheme ) {oOutTheme = cmainlighttwo; return true;}
else if ( L"tx1" == sTheme ) {oOutTheme = ctextone; return true;}
else if ( L"tx2" == sTheme ) {oOutTheme = ctexttwo; return true;}
return false;
}
CString GetHighLight()
{
if (m_bAuto) return L"auto";
std::vector< RtfColor > sColors;
sColors.push_back( RtfColor( 0x000000 ) );
......@@ -1761,7 +1734,7 @@ public:
enum _HRef
{
hr_none,
hr_phmrg, //\tphmrg Use margin as horizontal reference frame.
hr_phmrg, // tphmrg Use margin as horizontal reference frame.
hr_phpg, //tphpg Use page as horizontal reference frame.
hr_phcol //tphcol Use column as horizontal reference frame. This is the default if no horizontal table positioning information is given.
} ;
......@@ -1797,7 +1770,7 @@ public:
int m_nGraph; //trgaphN Half the space between the cells of a table row in twips.
int nTableIndent; //tblindN
int nTableIndentUnits; //\tblindtypeN
int nTableIndentUnits; // tblindtypeN
enum _RowJust
{
......@@ -2088,9 +2061,9 @@ public:
_TextWrap m_eWrap;
int m_DropcapType;
int m_DropcapLines;
int m_nHorSpace; //\dxfrtextN Distance in twips of a positioned paragraph from text in the main text flow in all directions.
int m_nVerSpace; //\dfrmtxtxN N is the horizontal distance in twips from text on both sides of the frame.
int m_nAllSpace; //\dfrmtxtyN N is the vertical distance in twips from text on both sides of the frame.
int m_nHorSpace; // dxfrtextN Distance in twips of a positioned paragraph from text in the main text flow in all directions.
int m_nVerSpace; // dfrmtxtxN N is the horizontal distance in twips from text on both sides of the frame.
int m_nAllSpace; // dfrmtxtyN N is the vertical distance in twips from text on both sides of the frame.
RtfFrame()
{
......@@ -2244,18 +2217,18 @@ public:
int m_nSpan;
//Table Style Specific
int m_bStyleFirstRow; //\tscfirstrow This cell is in the first row.
int m_bStyleLastRow; //\tsclastrow This cell is in the last row.
int m_bStyleFirstCol; //\tscfirstcol This cell is in the first column.
int m_bStyleLastCol; //\tsclastcol This cell is in the last column.
int m_bStyleOddRowBand; //\tscbandhorzodd This cell is in the odd row band.
int m_bStyleEvenRowBand; //\tscbandhorzeven This cell is in the even row band.
int m_bStyleOddColBand; //\tscbandvertodd This cell is in the odd column band.
int m_bStyleEvenColBand; //\tscbandverteven This cell is in the even column band.
int m_bStyleNWCell; //\tscnwcell This is the NW (north west) cell in the table (upper left).
int m_bStyleNECell; //\tscnecell NE cell
int m_bStyleSWCell; //\tscswcell SW cell.
int m_bStyleSECell; //\tscsecell SE cell.
int m_bStyleFirstRow; // tscfirstrow This cell is in the first row.
int m_bStyleLastRow; // tsclastrow This cell is in the last row.
int m_bStyleFirstCol; // tscfirstcol This cell is in the first column.
int m_bStyleLastCol; // tsclastcol This cell is in the last column.
int m_bStyleOddRowBand; // tscbandhorzodd This cell is in the odd row band.
int m_bStyleEvenRowBand; // tscbandhorzeven This cell is in the even row band.
int m_bStyleOddColBand; // tscbandvertodd This cell is in the odd column band.
int m_bStyleEvenColBand; // tscbandverteven This cell is in the even column band.
int m_bStyleNWCell; // tscnwcell This is the NW (north west) cell in the table (upper left).
int m_bStyleNECell; // tscnecell NE cell
int m_bStyleSWCell; // tscswcell SW cell.
int m_bStyleSECell; // tscsecell SE cell.
RtfCellProperty()
{
......@@ -2444,18 +2417,18 @@ public:
int m_nGridBefore; //для oox
int m_nGridAfter; //для oox
int m_bStyleFirstRow; //\tscfirstrow This cell is in the first row.
int m_bStyleLastRow; //\tsclastrow This cell is in the last row.
int m_bStyleFirstCol; //\tscfirstcol This cell is in the first column.
int m_bStyleLastCol; //\tsclastcol This cell is in the last column.
int m_bStyleOddRowBand; //\tscbandhorzodd This cell is in the odd row band.
int m_bStyleEvenRowBand; //\tscbandhorzeven This cell is in the even row band.
int m_bStyleOddColBand; //\tscbandvertodd This cell is in the odd column band.
int m_bStyleEvenColBand; //\tscbandverteven This cell is in the even column band.
int m_bStyleNWCell; //\tscnwcell This is the NW (north west) cell in the table (upper left).
int m_bStyleNECell; //\tscnecell NE cell
int m_bStyleSWCell; //\tscswcell SW cell.
int m_bStyleSECell; //\tscsecell SE cell.
int m_bStyleFirstRow; // tscfirstrow This cell is in the first row.
int m_bStyleLastRow; // tsclastrow This cell is in the last row.
int m_bStyleFirstCol; // tscfirstcol This cell is in the first column.
int m_bStyleLastCol; // tsclastcol This cell is in the last column.
int m_bStyleOddRowBand; // tscbandhorzodd This cell is in the odd row band.
int m_bStyleEvenRowBand; // tscbandhorzeven This cell is in the even row band.
int m_bStyleOddColBand; // tscbandvertodd This cell is in the odd column band.
int m_bStyleEvenColBand; // tscbandverteven This cell is in the even column band.
int m_bStyleNWCell; // tscnwcell This is the NW (north west) cell in the table (upper left).
int m_bStyleNECell; // tscnecell NE cell
int m_bStyleSWCell; // tscswcell SW cell.
int m_bStyleSECell; // tscsecell SE cell.
int m_nTrAuth;
int m_nTrDate;
......@@ -2583,7 +2556,7 @@ public:
int m_bKeep; //keep Keep paragraph intact (completely on one page if possible).
int m_bKeepNext; //keepn Keep paragraph with the next paragraph.
int m_bPageBB; //pagebb Break page before the paragraph.
int m_nOutlinelevel; //\outlinelevelN Outline level of paragraph. The N argument is a value from 0 to 8 representing the outline level of the paragraph. In the default case, no outline level is specified (same as body text).
int m_nOutlinelevel; // outlinelevelN Outline level of paragraph. The N argument is a value from 0 to 8 representing the outline level of the paragraph. In the default case, no outline level is specified (same as body text).
int m_nStyle; //sN Designates paragraph style. If a paragraph style is specified, style properties must be specified with the paragraph. N references an entry in the style sheet.
typedef enum
......@@ -2671,19 +2644,19 @@ public:
RtfTabs m_oTabs;
//Table Style Specific
int m_nTableStyle; //\ytsN Designates the table style handle that was applied to the row/cell.
int m_bStyleFirstRow; //\tscfirstrow This cell is in the first row.
int m_bStyleLastRow; //\tsclastrow This cell is in the last row.
int m_bStyleFirstCollumn; //\tscfirstcol This cell is in the first column.
int m_bStyleLastCollumn; //\tsclastcol This cell is in the last column.
int m_bStyleOddRowBand; //\tscbandhorzodd This cell is in the odd row band.
int m_bStyleEvenRowBand; //\tscbandhorzeven This cell is in the even row band.
int m_bStyleOddColBand; //\tscbandvertodd This cell is in the odd column band.
int m_bStyleEvenColBand; //\tscbandverteven This cell is in the even column band.
int m_bStyleNWCell; //\tscnwcell This is the NW (north west) cell in the table (upper left).
int m_bStyleNECell; //\tscnecell NE cell.
int m_bStyleSWCell; //\tscswcell SW cell.
int m_bStyleSECell; //\tscsecell SE cell.
int m_nTableStyle; // ytsN Designates the table style handle that was applied to the row/cell.
int m_bStyleFirstRow; // tscfirstrow This cell is in the first row.
int m_bStyleLastRow; // tsclastrow This cell is in the last row.
int m_bStyleFirstCollumn; // tscfirstcol This cell is in the first column.
int m_bStyleLastCollumn; // tsclastcol This cell is in the last column.
int m_bStyleOddRowBand; // tscbandhorzodd This cell is in the odd row band.
int m_bStyleEvenRowBand; // tscbandhorzeven This cell is in the even row band.
int m_bStyleOddColBand; // tscbandvertodd This cell is in the odd column band.
int m_bStyleEvenColBand; // tscbandverteven This cell is in the even column band.
int m_bStyleNWCell; // tscnwcell This is the NW (north west) cell in the table (upper left).
int m_bStyleNECell; // tscnecell NE cell.
int m_bStyleSWCell; // tscswcell SW cell.
int m_bStyleSECell; // tscsecell SE cell.
int m_nPrAuth;
int m_nPrDate;
......
......@@ -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