Commit e39beba4 authored by ElenaSubbotina's avatar ElenaSubbotina

RtfFormatReader/Writer

parent 21d10ffa
......@@ -364,6 +364,10 @@
<Filter
Name="Drawing"
>
<File
RelativePath="..\source\Reader\OOXDrawingGraphicReader.cpp"
>
</File>
<File
RelativePath="..\source\Reader\OOXPictureAnchorReader.h"
>
......
......@@ -302,7 +302,8 @@ public:
if( m_ooxAnchor->m_oGraphic.IsInit() )
{
OOXPictureGraphicReader oGraphicReader(m_ooxAnchor->m_oGraphic.GetPointer());
oGraphicReader.Parse( oParam, *oOutput.m_oPicture );
oGraphicReader.Parse( oParam, oOutput );
}
//изменяем scale в соответсявии с выходным размером
if( PROP_DEF != nWidth && PROP_DEF != oOutput.m_oPicture->m_nWidthGoal )
......
......@@ -51,54 +51,7 @@ public:
{
m_ooxGraphic = ooxGraphic;
}
bool Parse( ReaderParameter oParam , RtfPicture& oOutput)
{
if (m_ooxGraphic == NULL) return false;
switch(m_ooxGraphic->m_eGraphicType)
{
case OOX::Drawing::graphictypePicture:
//собственно тока этот объект пока и есть (
break;
case OOX::Drawing::graphictypeLockedCanvas:
case OOX::Drawing::graphictypeChart:
case OOX::Drawing::graphictypeDiagram:
case OOX::Drawing::graphictypeShape:
case OOX::Drawing::graphictypeGroupShape:
///todooo воткнуть конвертацию pptx->ppt->vml !!!
break;
}
for (long i=0; i < m_ooxGraphic->m_arrItems.size(); i++)
{
if (m_ooxGraphic->m_arrItems[i] == NULL) continue;
if (m_ooxGraphic->m_arrItems[i]->getType() == OOX::et_pic_pic)
{
OOX::Drawing::CPicture *picture = dynamic_cast<OOX::Drawing::CPicture *>(m_ooxGraphic->m_arrItems[i]);
if ( (picture) && (picture->m_oBlipFill.m_oBlip.IsInit()))
{
CString sImageId = picture->m_oBlipFill.m_oBlip->m_oEmbed.GetValue();
if (oParam.oReader->m_currentContainer)
{
smart_ptr<OOX::File> oFile = oParam.oReader->m_currentContainer->Find(sImageId);
if ( oFile.IsInit() && (OOX::FileTypes::Image == oFile->type()))
{
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
CString sImagePath = pImage->filename().GetPath();
WriteDataToPicture( sImagePath, oOutput, _T("") );
}
}
}
}
}
return true;
}
bool Parse( ReaderParameter oParam , RtfShape& oOutput);
static bool WriteDataToPicture( CString sPath, RtfPicture& oOutput, CString sTempPath )
{
OOX::CPath ooxPath = sPath; //для target
......
......@@ -83,7 +83,7 @@ public:
if(m_ooxInline->m_oGraphic.IsInit())
{
OOXPictureGraphicReader oGraphicReader(m_ooxInline->m_oGraphic.GetPointer());
oGraphicReader.Parse( oParam, *oOutput.m_oPicture );
oGraphicReader.Parse( oParam, oOutput);
}
//изменяем scale в соответсявии с выходным размером
if( PROP_DEF != nWidth && PROP_DEF != oOutput.m_oPicture->m_nWidthGoal )
......
......@@ -460,6 +460,13 @@ bool OOXShapeReader::ParseStyle(RtfShape& oShape, SimpleTypes::Vml::CCssProperty
case SimpleTypes::Vml::cssptMsoPositionHorizontalRelative :
{
oShape.m_nPositionHRelative = prop->get_Value().eMsoPosHorRel;
switch(prop->get_Value().eMsoPosHorRel)
{
case SimpleTypes::Vml::cssmsoposhorrelMargin: oShape.m_eXAnchor = RtfShape::ax_margin; break;
case SimpleTypes::Vml::cssmsoposhorrelPage: oShape.m_eXAnchor = RtfShape::ax_page; break;
case SimpleTypes::Vml::cssmsoposhorrelText:
case SimpleTypes::Vml::cssmsoposhorrelChar: break;//inline
}
}break;
case SimpleTypes::Vml::cssptMsoPositionVertical:
{
......@@ -468,6 +475,13 @@ bool OOXShapeReader::ParseStyle(RtfShape& oShape, SimpleTypes::Vml::CCssProperty
case SimpleTypes::Vml::cssptMsoPositionVerticalRelative :
{
oShape.m_nPositionVRelative = prop->get_Value().eMsoPosVerRel;
switch(prop->get_Value().eMsoPosVerRel)
{
case SimpleTypes::Vml::cssmsoposverrelMargin: oShape.m_eYAnchor = RtfShape::ay_margin; break;
case SimpleTypes::Vml::cssmsoposverrelPage: oShape.m_eYAnchor = RtfShape::ay_page; break;
case SimpleTypes::Vml::cssmsoposverrelText:
case SimpleTypes::Vml::cssmsoposverrelLine: break;//inline
}
}break;
case SimpleTypes::Vml::cssptMsoWrapDistanceBottom:
{
......@@ -518,7 +532,19 @@ bool OOXShapeReader::ParseStyle(RtfShape& oShape, SimpleTypes::Vml::CCssProperty
{
oShape.m_nGtextSize = prop->get_Value().oValue.dValue;
}break;
case SimpleTypes::Vml::cssptVTextAnchor:
{
oShape.m_nAnchorText = prop->get_Value().eVTextAnchor;//совпдает
oShape.m_bFitShapeToText = 0;
}break;
case SimpleTypes::Vml::csspctMsoWidthPercent:
{
oShape.m_nPctWidth = prop->get_Value().oValue.dValue;
}break;
case SimpleTypes::Vml::csspctMsoHeightPercent:
{
oShape.m_nPctHeight = prop->get_Value().oValue.dValue;
}break;
case SimpleTypes::Vml::cssptDirection : break;
case SimpleTypes::Vml::cssptLayoutFlow : break;
case SimpleTypes::Vml::cssptMsoDirectionAlt : break;
......@@ -528,7 +554,6 @@ bool OOXShapeReader::ParseStyle(RtfShape& oShape, SimpleTypes::Vml::CCssProperty
case SimpleTypes::Vml::cssptMsoNextTextbox : break;
case SimpleTypes::Vml::cssptMsoRotate : break;
case SimpleTypes::Vml::cssptMsoTextScale : break;
case SimpleTypes::Vml::cssptVTextAnchor : break;
case SimpleTypes::Vml::cssptFont : break;
case SimpleTypes::Vml::cssptFontStyle : break;
case SimpleTypes::Vml::cssptFontVariant : break;
......@@ -544,60 +569,6 @@ bool OOXShapeReader::ParseStyle(RtfShape& oShape, SimpleTypes::Vml::CCssProperty
case SimpleTypes::Vml::cssptVTextSpacing : break;
}
//else if( _T("mso-left-percent") == sProperty )
// oShape.m_nPositionHPct = Strings::ToInteger( sValue );
//else if( _T("mso-position-horizontal-relative") == sProperty )
//{
// if( _T("page") == sValue )
// oShape.m_eXAnchor = RtfShape::ax_page;
// else if( _T("margin") == sValue )
// oShape.m_eXAnchor = RtfShape::ax_margin;
// else if( _T("text") == sValue )
// oShape.m_eXAnchor = RtfShape::ax_column;
//}
//else if( _T("mso-top-percent") == sProperty )
// oShape.m_nPositionVPct = Strings::ToInteger( sValue );
//else if( _T("mso-position-vertical-relative") == sProperty )
//{
// if( _T("page") == sValue )
// oShape.m_eYAnchor = RtfShape::ay_page;
// else if( _T("margin") == sValue )
// oShape.m_eYAnchor = RtfShape::ay_margin;
// else if( _T("text") == sValue )
// oShape.m_eYAnchor = RtfShape::ay_margin;
//}
//else if( _T("mso-width-relative") == sProperty )
//{
// if( _T("margin") == sValue )
// oShape.m_nPctWidthRelative = 0;
// else if( _T("page") == sValue )
// oShape.m_nPctWidthRelative = 1;
// else if( _T("left-margin-area") == sValue )
// oShape.m_nPctWidthRelative = 2;
// else if( _T("right-margin-area") == sValue )
// oShape.m_nPctWidthRelative = 3;
// else if( _T("inner-margin-area") == sValue )
// oShape.m_nPctWidthRelative = 4;
// else if( _T("outer-margin-area") == sValue )
// oShape.m_nPctWidthRelative = 5;
//}
//else if( _T("mso-height-relative") == sProperty )
//{
// if( _T("margin") == sValue )
// oShape.m_nPctHeightRelative = 0;
// else if( _T("page") == sValue )
// oShape.m_nPctHeightRelative = 1;
// else if( _T("top-margin-area") == sValue )
// oShape.m_nPctHeightRelative = 2;
// else if( _T("bottom-margin-area") == sValue )
// oShape.m_nPctHeightRelative = 3;
// else if( _T("inner-margin-area") == sValue )
// oShape.m_nPctHeightRelative = 4;
// else if( _T("outer-margin-area") == sValue )
// oShape.m_nPctHeightRelative = 5;
//}
return true;
}
......@@ -227,41 +227,41 @@ public:
CString sResult;
switch( m_eType )
{
case rsc_chdate: sResult.Append( _T("") );break;
case rsc_chdpl: sResult.Append( _T("") );break;
case rsc_chdpa: sResult.Append( _T("") );break;
case rsc_chtime: sResult.Append( _T("") );break;
case rsc_chpgn: sResult.Append( _T("<w:pgNum />") );break;
case rsc_sectnum: sResult.Append( _T("") );break;
case rsc_chftn: sResult.Append( _T("<w:footnoteRef/>") );break;
case rsc_chftnEnd: sResult.Append( _T("<w:endnoteRef/>") );break;
case rsc_chatn: sResult.Append( _T("<w:annotationRef />") );break;
case rsc_chftnsep: sResult.Append( _T("<w:separator />") );break;
case rsc_chftnsepc: sResult.Append( _T("<w:continuationSeparator/>") );break;
case rsc_page: sResult.Append( _T("<w:br w:type=\"page\"/>") );break;
case rsc_column: sResult.Append( _T("<w:br w:type=\"column\"/>") );break;
case rsc_chdate: sResult.Append( _T("") ); break;
case rsc_chdpl: sResult.Append( _T("") ); break;
case rsc_chdpa: sResult.Append( _T("") ); break;
case rsc_chtime: sResult.Append( _T("") ); break;
case rsc_chpgn: sResult.Append( _T("<w:pgNum />") ); break;
case rsc_sectnum: sResult.Append( _T("") ); break;
case rsc_chftn: sResult.Append( _T("<w:footnoteRef/>") ); break;
case rsc_chftnEnd: sResult.Append( _T("<w:endnoteRef/>") ); break;
case rsc_chatn: sResult.Append( _T("<w:annotationRef />") ); break;
case rsc_chftnsep: sResult.Append( _T("<w:separator />") ); break;
case rsc_chftnsepc: sResult.Append( _T("<w:continuationSeparator/>") ); break;
case rsc_page: sResult.Append( _T("<w:br w:type=\"page\"/>") ); break;
case rsc_column: sResult.Append( _T("<w:br w:type=\"column\"/>") ); break;
case rsc_line: sResult.Append( _T("<w:br w:type=\"textWrapping\" w:clear=\"none\"/>") );break;
case rsc_softpage: sResult.Append( _T("") );break;
case rsc_softcol: sResult.Append( _T("") );break;
case rsc_softline: sResult.Append( _T("") );break;
case rsc_tab: sResult.Append( _T("<w:tab/>") );break;
case rsc_emspace: sResult.Append( _T("") );break;
case rsc_qmspace: sResult.Append( _T("") );break;
case rsc_Formula: sResult.Append( _T("") );break;
case rsc_softpage: sResult.Append( _T("") ); break;
case rsc_softcol: sResult.Append( _T("") ); break;
case rsc_softline: sResult.Append( _T("") ); break;
case rsc_tab: sResult.Append( _T("<w:tab/>") ); break;
case rsc_emspace: sResult.Append( _T("") ); break;
case rsc_qmspace: sResult.Append( _T("") ); break;
case rsc_Formula: sResult.Append( _T("") ); break;
case rsc_OptHyphen: sResult.Append( _T("<w:t xml:space=\"preserve\">-</w:t>") );break;//<w:softHyphen/>
case rsc_NonBrHyphen: sResult.Append( _T("<w:t xml:space=\"preserve\">-</w:t>") );break;//<w:nonBreakHyphen/>
case rsc_NonBrSpace: sResult.Append( _T("<w:t xml:space=\"preserve\"> </w:t>") );break;
case rsc_zwbo: sResult.Append( _T("") );break;
case rsc_zwnbo: sResult.Append( _T("") );break;
case rsc_zwj: sResult.Append( _T("") );break;
case rsc_zwnj: sResult.Append( _T("") );break;
case rsc_zwbo: sResult.Append( _T("") ); break;
case rsc_zwnbo: sResult.Append( _T("") ); break;
case rsc_zwj: sResult.Append( _T("") ); break;
case rsc_zwnj: sResult.Append( _T("") ); break;
}
switch ( m_nTextWrapBreak )
{
case 0: sResult.Append( _T("<w:br w:type=\"textWrapping\" w:clear=\"none\"/>") );break;
case 1: sResult.Append( _T("<w:br w:type=\"textWrapping\" w:clear=\"left\"/>") );break;
case 2: sResult.Append( _T("<w:br w:type=\"textWrapping\" w:clear=\"right\"/>") );break;
case 3: sResult.Append( _T("<w:br w:type=\"textWrapping\" w:clear=\"all\"/>") );break;
case 0: sResult.Append( _T("<w:br w:type=\"textWrapping\" w:clear=\"none\"/>") ); break;
case 1: sResult.Append( _T("<w:br w:type=\"textWrapping\" w:clear=\"left\"/>") ); break;
case 2: sResult.Append( _T("<w:br w:type=\"textWrapping\" w:clear=\"right\"/>") ); break;
case 3: sResult.Append( _T("<w:br w:type=\"textWrapping\" w:clear=\"all\"/>") ); break;
}
return sResult;
}
......
......@@ -55,22 +55,22 @@ public:
CString RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
sResult.Append(_T("{\\field "));
sResult += _T("{\\field ");
RENDER_RTF_BOOL( m_bDirty, sResult, _T("flddirty") )
RENDER_RTF_BOOL( m_bLock, sResult, _T("fldlock") )
sResult.Append(_T("{\\*\\fldinst"));
sResult.Append( m_oCharProp.RenderToRtf(oRenderParameter) );
sResult += _T("{\\*\\fldinst");
sResult += m_oCharProp.RenderToRtf(oRenderParameter);
return sResult;
}
CString RenderToOOX(RenderParameter oRenderParameter)
{
CString sResult;
sResult.Append( _T("<w:r>") );
sResult.Append( _T("<w:fldChar w:fldCharType=\"separate\"") );
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.Append( _T("/>") );
sResult.Append( _T("</w:r>") );
sResult += _T("/>");
sResult += _T("</w:r>");
return sResult;
}
};
......@@ -93,13 +93,16 @@ public: CString RenderToOOX(RenderParameter oRenderParameter)
if( NULL != m_oText )
{
CString sResult;
sResult.Append( _T("<w:r>") );
sResult.Append( _T("<w:instrText>") );
sResult += _T("<w:r>");
sResult += _T("<w:instrText>");
oRenderParameter.nType = RENDER_TO_RTF_PARAM_CHAR;
oRenderParameter.nValue = RENDER_TO_RTF_PARAM_NO_PAR;
sResult.Append( m_oText->RenderToOOX( oRenderParameter ) );
sResult.Append( _T("</w:instrText>") );
sResult.Append( _T("</w:r>") );
sResult += m_oText->RenderToOOX( oRenderParameter );
sResult += _T("</w:instrText>");
sResult += _T("</w:r>");
return sResult;
}
else
......@@ -191,31 +194,35 @@ public: void SetDefault()
public: CString RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
sResult.Append(_T("{\\field "));
sResult += _T("{\\field ");
if( fm_none != m_eMode )
{
switch( m_eMode )
{
case fm_flddirty: sResult.Append(_T("{\\flddirty "));break;
case fm_fldedit: sResult.Append(_T("{\\fldedit "));break;
case fm_fldlock: sResult.Append(_T("{\\fldlock "));break;
case fm_fldpriv: sResult.Append(_T("{\\fldpriv "));break;
}
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;
}
}
sResult.Append(_T("{\\*\\fldinst "));
sResult += _T("{\\*\\fldinst ");
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_RTF_PARAM_CHAR;
oNewParam.nValue = RENDER_TO_RTF_PARAM_NO_PAR;
sResult.Append( m_oInsert->RenderToRtf( oNewParam ) );
sResult += m_oInsert->RenderToRtf( oNewParam );
if( true == m_bReferenceToEndnote )
sResult.Append( _T("\\fldalt") );
sResult += _T("\\fldalt");
if( false == m_sData.IsEmpty() )
sResult.AppendFormat( _T("{\\*\\datafield %ls}"), m_sData.GetBuffer());
sResult.Append(_T("}"));
sResult += _T("}");
CString str = m_oResult->RenderToRtf( oRenderParameter ) ;
sResult.AppendFormat(_T("{\\fldrslt %ls}"), str.GetBuffer());
sResult.Append(_T("}"));
sResult += _T("}");
return sResult;
}
public: CString RenderToOOX(RenderParameter oRenderParameter)
......@@ -225,7 +232,7 @@ public: CString RenderToOOX(RenderParameter oRenderParameter)
{
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
sResult.Append(m_oResult->RenderToOOX(oNewParam));
sResult += m_oResult->RenderToOOX(oNewParam);
}
else
{
......@@ -257,8 +264,9 @@ public: CString RenderToOOX(RenderParameter oRenderParameter)
//добавляем гиперссылку в документ
sResult.AppendFormat( _T("<w:hyperlink r:id=\"%ls\" >"), sId.GetBuffer() );
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
sResult.Append(m_oResult->RenderToOOX(oNewParam));
sResult.Append( _T("</w:hyperlink>") );
sResult += m_oResult->RenderToOOX(oNewParam);
sResult += _T("</w:hyperlink>");
}
else
{
......@@ -267,45 +275,51 @@ public: CString RenderToOOX(RenderParameter oRenderParameter)
{
RenderParameter oNewParametr = oRenderParameter;
oNewParametr.nType = RENDER_TO_OOX_PARAM_PLAIN;
//sResult.Append(_T("<w:r>"));
//sResult += _T("<w:r>"));
CString str = Utils::PrepareToXML( m_oInsert->RenderToOOX(oNewParametr) ).Trim();
sResult.AppendFormat(_T("<w:fldSimple w:instr=\"%ls\">"), str.GetBuffer() );
sResult += _T("<w:fldSimple w:instr=\"");
sResult += str;
sResult += _T("\">");
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
sResult.Append(m_oResult->RenderToOOX(oNewParam));
sResult += m_oResult->RenderToOOX(oNewParam);
sResult.AppendFormat(_T("</w:fldSimple>"));
//sResult.Append(_T("</w:r>"));
//sResult += _T("</w:r>"));
}
else
{
//так добавляются лишние параграфы
RenderParameter oNewParametr = oRenderParameter;
oNewParametr.nType = RENDER_TO_OOX_PARAM_PLAIN;
sResult.Append(_T("<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>"));
sResult += _T("<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>");
CString str = Utils::PrepareToXML( m_oInsert->RenderToOOX(oNewParametr) );
sResult.AppendFormat(_T("<w:r><w:instrText xml:space=\"preserve\">%ls</w:instrText></w:r>"), str.GetBuffer());
sResult.Append(_T("<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>"));
sResult += _T("<w:r><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.Append(_T("</w:p>"));
sResult += _T("</w:p>");
//пишем параграфы содержания
oNewParametr.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
sResult.Append(m_oResult->RenderToOOX(oNewParametr));
sResult += m_oResult->RenderToOOX(oNewParametr);
//заканчиваем Field
sResult.Append(_T("<w:p>"));
sResult.Append(_T("<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>"));
sResult += _T("<w:p>");
sResult += _T("<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>");
////пишем параграфы содержания
//RenderParameter oNewParametr = oRenderParameter;
//oNewParametr.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
//sResult.Append(m_oResult->RenderToOOX(oNewParametr));
//sResult += m_oResult->RenderToOOX(oNewParametr));
//CString sFieldBegin;
//sFieldBegin.Append(_T("<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>"));
//sFieldBegin += _T("<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>");
//sFieldBegin.AppendFormat(_T("<w:r><w:instrText xml:space=\"preserve\">%ls</w:instrText></w:r>"), Utils::PrepareToXML( m_oInsert->RenderToOOX(oNewParametr) ));
//sFieldBegin.Append(_T("<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>"));
//sFieldBegin += _T("<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>");
////пишем после первого w:pPr
//CString sFindStr = _T("</w:pPr>");
//int nIndex = sResult.Find( sFindStr );
......@@ -319,9 +333,9 @@ public: CString RenderToOOX(RenderParameter oRenderParameter)
// sResult.Inset( sFieldBegin, nIndex + sFindStr.GetLength() );
//}
//CString sFieldEnd;
//sFieldEnd.Append(_T("<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>"));
//sFieldEnd += _T("<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>");
//sFieldEnd.AppendFormat(_T("<w:r><w:instrText xml:space=\"preserve\">%ls</w:instrText></w:r>"), Utils::PrepareToXML( m_oInsert->RenderToOOX(oNewParametr) ));
//sFieldEnd.Append(_T("<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>"));
//sFieldEnd += _T("<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>");
////пишем после последнего w:pPr
}
}
......
......@@ -70,6 +70,7 @@ class RtfParagraph : public ITextItem, public ItemContainer< IDocumentElementPtr
public:
RtfParagraphProperty m_oProperty;
RtfOldListPtr m_oOldList;
int GetType( )
{
return TYPE_RTF_PARAGRAPH;
......@@ -102,20 +103,27 @@ public:
if( RENDER_TO_RTF_PARAM_CHAR == oRenderParameter.nType )
{
for( int i = 0; i < (int)m_aArray.size(); i++ )
sResult.Append( m_aArray[i]->RenderToRtf( oRenderParameter ) );
{
sResult += m_aArray[i]->RenderToRtf( oRenderParameter );
}
}
else
{
sResult.Append(_T("\\pard\\plain"));
sResult.Append( m_oProperty.RenderToRtf( oRenderParameter ) );
sResult += _T("\\pard\\plain");
sResult += m_oProperty.RenderToRtf( oRenderParameter ) ;
if( NULL != m_oOldList )
sResult.Append( m_oOldList->RenderToRtf( oRenderParameter ) );
sResult += m_oOldList->RenderToRtf( oRenderParameter ) ;
for( int i = 0; i < (int)m_aArray.size(); i++ )
sResult.Append( m_aArray[i]->RenderToRtf( oRenderParameter ) );
sResult.Append( m_oProperty.m_oCharProperty.RenderToRtf( oRenderParameter ) );
{
sResult += m_aArray[i]->RenderToRtf( oRenderParameter );
}
sResult += m_oProperty.m_oCharProperty.RenderToRtf( oRenderParameter );
//if( RENDER_TO_RTF_PARAM_NO_PAR != oRenderParameter.nValue )
// sResult.Append(_T("\\par"));
// sResult += T("\\par");
}
return sResult;
}
......@@ -126,25 +134,31 @@ public:
if( RENDER_TO_OOX_PARAM_PLAIN == oRenderParameter.nType )
{
for( int i = 0; i < (int)m_aArray.size(); i++ )
sResult.Append( m_aArray[i]->RenderToOOX(oRenderParameter) );
{
sResult += m_aArray[i]->RenderToOOX(oRenderParameter);
}
}
else if( RENDER_TO_OOX_PARAM_RUN == oRenderParameter.nType )
{
for( int i = 0; i < (int)m_aArray.size(); i++ )
sResult.Append( m_aArray[i]->RenderToOOX(oRenderParameter) );
{
sResult += m_aArray[i]->RenderToOOX(oRenderParameter);
}
}
else if( RENDER_TO_OOX_PARAM_MATH == oRenderParameter.nType )
{
if (m_aArray.size() < 1)
{
sResult.Append( _T("<w:rPr>") );
sResult.Append( m_oProperty.m_oCharProperty.RenderToOOX(oRenderParameter) );
sResult.Append( _T("</w:rPr>") );
sResult += _T("<w:rPr>");
sResult += m_oProperty.m_oCharProperty.RenderToOOX(oRenderParameter);
sResult += _T("</w:rPr>");
}
else
{
for( int i = 0; i < (int)m_aArray.size(); i++ )
sResult.Append( m_aArray[i]->RenderToOOX(oRenderParameter) );
{
sResult += m_aArray[i]->RenderToOOX(oRenderParameter);
}
}
}
else
......@@ -153,17 +167,17 @@ public:
if( NULL != m_oOldList )
bCanConvertToNumbering = m_oOldList->CanConvertToNumbering();
sResult.Append( _T("<w:p>") );
sResult.Append( _T("<w:pPr>") );
sResult.Append( m_oProperty.RenderToOOX(oRenderParameter) );
sResult += _T("<w:p>");
sResult += _T("<w:pPr>");
sResult += m_oProperty.RenderToOOX(oRenderParameter);
if( NULL != m_oOldList )
{
//для OldList
if( true == bCanConvertToNumbering )
sResult.Append( m_oOldList->RenderToOOX( oRenderParameter ) );
sResult += m_oOldList->RenderToOOX( oRenderParameter );
}
sResult.Append( _T("</w:pPr>") );
sResult += _T("</w:pPr>");
if( NULL != m_oOldList )
{
......@@ -179,22 +193,25 @@ public:
for( int i = 0; i < m_oOldList->m_oText->GetCount(); i++ )
{
sResult.Append( _T("<w:r>") );
sResult.Append( _T("<w:rPr>") );
sResult.Append( oCharProp.RenderToOOX(oRenderParameter) );
sResult.Append( _T("</w:rPr>") );
sResult += _T("<w:r>");
sResult += _T("<w:rPr>");
sResult += oCharProp.RenderToOOX(oRenderParameter);
sResult += _T("</w:rPr>");
sResult.Append( m_oOldList->m_oText->m_aArray[ i ]->RenderToOOX(oNewParam) );
sResult.Append( _T("</w:r>") );
sResult += m_oOldList->m_oText->m_aArray[ i ]->RenderToOOX(oNewParam);
sResult += _T("</w:r>");
}
}
}
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
for( int i = 0; i < (int)m_aArray.size(); i++ )
sResult.Append( m_aArray[i]->RenderToOOX(oNewParam) );
sResult.Append( _T("</w:p>") );
{
sResult += m_aArray[i]->RenderToOOX(oNewParam);
}
sResult += _T("</w:p>");
}
return sResult;
}
......
......@@ -120,6 +120,8 @@
sResult.AppendFormat( _T("%d"), prop );\
}
class RtfSection;
typedef boost::shared_ptr<RtfSection> RtfSectionPtr;
class RtfFont : public IRenderableProperty
{
......@@ -260,14 +262,14 @@ public:
return m_byteRed == oColor.m_byteRed && m_byteGreen == oColor.m_byteGreen && m_byteBlue == oColor.m_byteBlue &&
m_byteTint == oColor.m_byteTint && m_byteShade == oColor.m_byteShade && m_eTheme == oColor.m_eTheme;
}
void SetHEX(int color)
void SetHEX(int color)
{
SetDefault();
m_byteRed= (color&0xFF0000) >>16;
m_byteGreen = (color&0xFF00) >>4;
m_byteBlue = (color&0xFF);
m_byteRed = (color&0xFF0000) >> 16;
m_byteGreen = (color&0xFF00) >> 8;
m_byteBlue = (color&0xFF);
}
void SetRGB(BYTE red, BYTE green, BYTE blue)
void SetRGB(BYTE red, BYTE green, BYTE blue)
{
SetDefault();
m_byteRed = red;
......@@ -361,7 +363,7 @@ public:
else
SetDefault();
}
CString ToHexColor()
CString ToHexColor(bool bBGR = false)
{
BYTE byteRed = SetShade( m_byteRed );
byteRed = SetTint( byteRed );
......@@ -384,7 +386,9 @@ public:
sBlue.AppendFormat( _T("0%x"), byteBlue );
else
sBlue.AppendFormat( _T("%x"), byteBlue );
return sRed + sGreen + sBlue;
if (bBGR) return sBlue + sGreen + sRed ;
else return sRed + sGreen + sBlue ;
}
int ToInt()const
......@@ -779,10 +783,10 @@ public:
//свойство должно быть как единое целое, поэтому если oBorPr задано, то переписыватся целиком
if( st_none != oParPr.m_eType || PROP_DEF != oParPr.m_nValue || PROP_DEF != oParPr.m_nForeColor || PROP_DEF != oParPr.m_nBackColor )
{
m_eType = oParPr.m_eType;
m_nValue = oParPr.m_nValue;
m_nForeColor = oParPr.m_nForeColor;
m_nBackColor = oParPr.m_nBackColor;
m_eType = oParPr.m_eType;
m_nValue = oParPr.m_nValue;
m_nForeColor = oParPr.m_nForeColor;
m_nBackColor = oParPr.m_nBackColor;
}
}
CString RenderToOOX(RenderParameter oRenderParameter);
......@@ -2667,7 +2671,7 @@ public:
int m_bStyleSWCell;//\tscswcell SW cell.
int m_bStyleSECell;//\tscsecell SE cell.
RtfCharProperty m_oCharProperty;
RtfCharProperty m_oCharProperty;
RtfParagraphProperty()
{
......
......@@ -621,51 +621,52 @@ public:
}
CString RenderToRtf(RenderParameter oRenderParameter);
CString RenderToOOX(RenderParameter oRenderParameter);
private: CString SaveFile( TextItemContainerPtr oTarget, RenderParameter oRenderParameter, bool bHeader);
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
typedef boost::shared_ptr<RtfSectionProperty> RtfSectionPropertyPtr;
typedef boost::shared_ptr<RtfDocumentProperty> RtfDocumentPropertyPtr;
class RtfSection : public TextItemContainer
{
public: RtfSectionProperty m_oProperty;
public:
RtfSectionProperty m_oProperty;
RtfSection()
{
}
int GetType()
{
return TYPE_RTF_SECTION;
}
CString RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
sResult.Append( m_oProperty.RenderToRtf( oRenderParameter ) );
if( RENDER_TO_RTF_PARAM_NO_SECT != oRenderParameter.nType )
sResult.Append(_T("\\sectd"));
for( int i = 0; i < (int)m_aArray.size(); i++ )
sResult.Append( m_aArray[i]->RenderToRtf( oRenderParameter ) );
return sResult;
}
CString RenderToOOX(RenderParameter oRenderParameter)
bool m_bFinalize;
RtfSection()
{
m_bFinalize = false;
}
int GetType()
{
return TYPE_RTF_SECTION;
}
CString RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
sResult.Append( m_oProperty.RenderToRtf( oRenderParameter ) );
if( RENDER_TO_RTF_PARAM_NO_SECT != oRenderParameter.nType )
sResult.Append(_T("\\sectd"));
for( int i = 0; i < (int)m_aArray.size(); i++ )
{
//CString sResult;
// CString sSectProp;
// RenderParameter oNewParam = oRenderParameter;
// oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
// sSectProp.Append(m_oProperty.RenderToOOX(oNewParam));
// CString sParagraphs;
// for( int i = 0; i < (int)m_aArray.size(); i++ )
// {
// sParagraphs.Append( m_aArray[i]->RenderToOOX(oNewParam) );
// }
//if( oRenderParameter.nType == RENDER_TO_OOX_PARAM_LAST )
// return sParagraphs + sSectProp;
//else
// return _T("<w:p><w:pPr>") + sSectProp + _T("</w:pPr></w:p>") + sParagraphs;
return _T("");
sResult += m_aArray[i]->RenderToRtf( oRenderParameter );
}
return sResult;
}
CString RenderToOOX(RenderParameter oRenderParameter)
{
if (!m_bFinalize) return L"";
m_bFinalize = false; // тут .. чтобы не повторилось при конвертации колонтитулов
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
return m_oProperty.RenderToOOX(oNewParam);
}
};
typedef boost::shared_ptr<RtfSection> RtfSectionPtr;
......@@ -108,11 +108,16 @@ public:
int m_bHidden; //Do not display or print (only set through Visual Basic for Applications). Boolean FALSE
//Text box
int m_nAnchorText;
int m_nTexpLeft; //dxTextLeft Left internal margin of the text box. EMU 91,440
int m_nTexpTop; //
int m_nTexpRight; //
int m_nTexpBottom; //
int m_bFitShapeToText;
int m_bFitTextToShape;
int m_nCcol; //columns
int m_nTxdir; //bidi
int m_nWrapText;
//Geometry
int m_nAdjustValue; //adjustValue First adjust value from an adjust handle. The interpretation varies with the shape type. Adjust values alter the geometry of the shape in smart ways. Integer 0
int m_nAdjustValue2;
......
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