Commit 5d14eb88 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

RtfFormatWriter - fix конвертации с секциями(колонками) и разрывами.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@67800 954022d7-b5bf-4e40-9824-e11837661b57
parent 280ec89d
......@@ -41,7 +41,7 @@ public:
CcnfStyle style;
if( true == opPrReader.Parse( oParam, oNewProperty, style, bStartNewSectoion ) )
if( true == opPrReader.Parse( oParam, oNewProperty, style) )
oParam.oRtf->m_oDefaultParagraphProp = oNewProperty;
}
return true;
......
......@@ -27,7 +27,8 @@ public:
m_poReader = oParam.oReader;
m_poDocument = oParam.oRtf;
oParam.oRtf->m_oStatusSection.start_new = false;
RtfSectionPtr oCurSection;
if( true == oParam.oRtf->GetItem( oCurSection ) )
......@@ -62,13 +63,16 @@ public:
if (m_ooxDocument->m_oSectPr.IsInit())// свойства последней секции
{
OOXSectionPropertyReader oSectReader(m_ooxDocument->m_oSectPr.GetPointer());
oSectReader.Parse( oParam, oCurSection->m_oProperty );
if (oSectReader.Parse( oParam, oCurSection->m_oProperty ))
{
}
}
RtfSectionPtr oFirstSection;
if( true == m_poDocument->GetItem( oFirstSection, 0 ) )
{
m_oTextItemReader.m_oTextItems = oFirstSection;
m_oTextItemReader.m_oTextItems = oFirstSection;
oParam.oRtf->m_oStatusSection.number = 1;
for (long i = 0; i < m_ooxDocument->m_arrItems.size(); i++)
{
......
......@@ -96,7 +96,7 @@ public:
bool bStartNewSectoion;
CcnfStyle style;
if( true == opPrReader.Parse( oParam, oNewProperty, style, bStartNewSectoion ) )
if( true == opPrReader.Parse( oParam, oNewProperty, style) )
{
oLevelProperty.m_nFirstIndent = oNewProperty.m_nIndFirstLine;
oLevelProperty.m_nIndent = oNewProperty.m_nIndLeft;
......
......@@ -7,7 +7,7 @@
#include "../RtfOle.h"
bool OOXParagraphReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle, bool& bStartNewSection )
bool OOXParagraphReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle )
{
if (m_ooxParagraph == NULL) return false;
......@@ -21,7 +21,7 @@ bool OOXParagraphReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputPa
if (m_ooxParagraph->m_oParagraphProperty)
{
OOXpPrReader opPrReader(m_ooxParagraph->m_oParagraphProperty);
opPrReader.Parse( oParam, oOutputParagraph.m_oProperty, oConditionalTableStyle, bStartNewSection);
opPrReader.Parse( oParam, oOutputParagraph.m_oProperty, oConditionalTableStyle);
oResultTableStyle = oConditionalTableStyle.ApplyTableStyle( oParam.poTableStyle );
}
else
......@@ -52,12 +52,15 @@ bool OOXParagraphReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputPa
}
m_ooxElement = dynamic_cast<OOX::WritingElementWithChilds<OOX::WritingElement>*>(m_ooxParagraph);
return Parse2(oParam ,oOutputParagraph, oConditionalTableStyle, bStartNewSection, poExternalStyle );
bool res = Parse2(oParam ,oOutputParagraph, oConditionalTableStyle, poExternalStyle );
return res;
}
bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle, bool& bStartNewSection, RtfStylePtr poStyle )
bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle, RtfStylePtr poStyle )
{
if (m_ooxElement == NULL) return false;
......@@ -121,8 +124,7 @@ bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputP
if (pFldSimple->m_arrItems.size() >0)
{
OOXParagraphReader oSubParReader(pFldSimple);
bool bStartNewSection;
oSubParReader.Parse2( oParam, *oNewResultParagraph, CcnfStyle(), bStartNewSection, poExternalStyle);
oSubParReader.Parse2( oParam, *oNewResultParagraph, CcnfStyle(), poExternalStyle);
oCurField->m_oResult->AddItem( oNewResultParagraph );
}
oOutputParagraph.AddItem( oCurField );
......@@ -187,8 +189,7 @@ bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputP
if (pHyperlink->m_arrItems.size() >0)
{
OOXParagraphReader oSubParReader(pHyperlink);
bool bStartNewSection;
oSubParReader.Parse2( oParam, *oNewResultParagraph, CcnfStyle(), bStartNewSection, poExternalStyle);
oSubParReader.Parse2( oParam, *oNewResultParagraph, CcnfStyle(), poExternalStyle);
oCurField->m_oResult->AddItem( oNewResultParagraph );
}
oOutputParagraph.AddItem( oCurField );
......@@ -226,8 +227,7 @@ bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputP
if (pHyperlink->m_arrItems.size() > 0)
{
OOXParagraphReader oSubParReader(pHyperlink);
bool bStartNewSection;
oSubParReader.Parse2( oParam, *oNewResultParagraph, CcnfStyle(), bStartNewSection, poExternalStyle);
oSubParReader.Parse2( oParam, *oNewResultParagraph, CcnfStyle(), poExternalStyle);
oCurField->m_oResult->AddItem( oNewResultParagraph );
}
oOutputParagraph.AddItem( oCurField );
......@@ -303,8 +303,7 @@ bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputP
if (pSdt->m_oSdtContent->m_arrItems.size() > 0)
{
OOXParagraphReader oStdReader(pSdt->m_oSdtContent.GetPointer());
bool bStartNewSection;
oStdReader.Parse2( oParam, oOutputParagraph, CcnfStyle(), bStartNewSection, poExternalStyle );
oStdReader.Parse2( oParam, oOutputParagraph, CcnfStyle(), poExternalStyle );
}
}
}break;
......@@ -653,8 +652,10 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
{
switch(ooxBr->m_oType.GetValue())
{
case SimpleTypes::brtypeColumn : oNewChar->m_eType = RtfCharSpecial::rsc_page; break;
case SimpleTypes::brtypePage : oNewChar->m_eType = RtfCharSpecial::rsc_column; break;
case SimpleTypes::brtypeColumn :
oNewChar->m_eType = RtfCharSpecial::rsc_column; break;
case SimpleTypes::brtypePage :
oNewChar->m_eType = RtfCharSpecial::rsc_page; break;
case SimpleTypes::brtypeTextWrapping :
switch(ooxBr->m_oClear.GetValue())
{
......@@ -734,7 +735,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}
bool OOXpPrReader::Parse( ReaderParameter oParam ,RtfParagraphProperty& oOutputProperty, CcnfStyle& oConditionalTableStyle, bool& bStartNewSection )
bool OOXpPrReader::Parse( ReaderParameter oParam ,RtfParagraphProperty& oOutputProperty, CcnfStyle& oConditionalTableStyle )
{
if (m_ooxParaProps == NULL) return false;
......@@ -1032,10 +1033,9 @@ bool OOXpPrReader::Parse( ReaderParameter oParam ,RtfParagraphProperty& oOutputP
oTabReader.Parse( oParam, oOutputProperty.m_oTabs );
}
if( m_ooxParaProps->m_oSectPr.IsInit())
{//todooo что то тут не тооооо
bStartNewSection = true;
//OOXSectionPropertyReader oSectReader;
//oSectReader.Parse( oParam, oParam.oReader->m_oCurSectionProp );
{
oParam.oRtf->m_oStatusSection.number++;
oParam.oRtf->m_oStatusSection.start_new = true;
}
if( m_ooxParaProps->m_oRPr.IsInit() )
......@@ -1368,6 +1368,8 @@ bool OOXSectionPropertyReader::Parse( ReaderParameter oParam , RtfSectionPropert
{
if(m_ooxSectionProperty->m_oCols->m_oNum.IsInit())
oOutput.m_nColumnNumber = m_ooxSectionProperty->m_oCols->m_oNum->GetValue();
else
oOutput.m_nColumnNumber = 1;
if(m_ooxSectionProperty->m_oCols->m_oSpace.IsInit())
oOutput.m_nColumnSpace = m_ooxSectionProperty->m_oCols->m_oSpace->ToTwips(); //todooo twips????
......
......@@ -24,6 +24,6 @@ public:
m_ooxParagraph = NULL;
m_ooxElement = ooxElement;
}
bool Parse( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle, bool& bStartNewSection );
bool Parse2( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle, bool& bStartNewSection, RtfStylePtr poStyle);
bool Parse( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle);
bool Parse2( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle, RtfStylePtr poStyle);
};
......@@ -88,9 +88,8 @@ public:
OOXpPrReader opPrReader(m_ooxStyle->m_oParPr.GetPointer());
opPrReader.m_bDefStyle = false;
bool bStartNewSection;
CcnfStyle style;
opPrReader.Parse( oParam, oNewParStyle->m_oParProp, style, bStartNewSection );
opPrReader.Parse( oParam, oNewParStyle->m_oParProp, style );
oNewParStyle->m_oParProp.m_nListId = PROP_DEF; //экспериментально вроде нельзя иметь numbering в параграф стиле
oNewParStyle->m_oParProp.m_nListLevel = PROP_DEF;
......@@ -254,10 +253,9 @@ public:
OOXpPrReader opPrReader(oox_tableStyle->m_oParPr.GetPointer());
opPrReader.m_bDefStyle = false;
bool bStartNewSection;
CcnfStyle style;
opPrReader.Parse( oParam, oNewParStyle->m_oParProp, style, bStartNewSection );
opPrReader.Parse( oParam, oNewParStyle->m_oParProp, style );
oNewParStyle->m_oParProp.m_nListId = PROP_DEF; //экспериментально вроде нельзя иметь numbering в параграф стиле
oNewParStyle->m_oParProp.m_nListLevel = PROP_DEF;
......
......@@ -47,8 +47,7 @@ public:
oNewParagraph->m_oProperty.m_oCharProperty = oParam.oRtf->m_oDefaultCharProp;
OOXParagraphReader oParagraphReader(pParagraph);
bool bStartNewSection;
oParagraphReader.Parse( oParam, (*oNewParagraph), oConditionalTableStyle, bStartNewSection );
oParagraphReader.Parse( oParam, (*oNewParagraph), oConditionalTableStyle );
//ставим стиль таблицы
if( NULL != oParam.poTableStyle )
......
......@@ -25,7 +25,7 @@ public:
case OOX::et_w_p:
{
OOX::Logic::CParagraph * pParagraph = dynamic_cast<OOX::Logic::CParagraph*>(ooxElement);
bool bStartNewSection = false;
OOXParagraphReader m_oParagraphReader(pParagraph);
RtfParagraphPtr oNewParagraph( new RtfParagraph() );
//применяем к новому параграфу default property
......@@ -33,17 +33,17 @@ public:
oNewParagraph->m_oProperty.m_oCharProperty = oParam.oRtf->m_oDefaultCharProp;
oNewParagraph->m_oProperty.m_nItap = 0;
if( true == m_oParagraphReader.Parse( oParam, (*oNewParagraph), CcnfStyle(), bStartNewSection ))
if( true == m_oParagraphReader.Parse( oParam, (*oNewParagraph), CcnfStyle() ))
{
m_oTextItems->AddItem( oNewParagraph );
if( true == bStartNewSection )
if( true == oParam.oRtf->m_oStatusSection.start_new )
{
RtfSectionPtr oCurSection;
//1 - т.к. секции удаляются когда полностью запишутся
if( true == oParam.oRtf->GetItem( oCurSection, 1 ) )
if( true == oParam.oRtf->GetItem( oCurSection, oParam.oRtf->m_oStatusSection.number - 1) )
{
m_oTextItems = oCurSection;
}
oParam.oRtf->m_oStatusSection.start_new = false;
}
}
}break;
......
......@@ -22,5 +22,5 @@ public:
m_bDefStyle = true;
m_ooxParaProps = ooxParaProps;
}
bool Parse( ReaderParameter oParam ,RtfParagraphProperty& oOutputProperty, CcnfStyle& oConditionalTableStyle, bool& bStartNewSection );
bool Parse( ReaderParameter oParam ,RtfParagraphProperty& oOutputProperty, CcnfStyle& oConditionalTableStyle);
};
......@@ -139,32 +139,32 @@ public: CString RenderToRtf(RenderParameter oRenderParameter)
sResult.Append( m_oProperty.RenderToRtf( oRenderParameter ) );
switch( m_eType )
{
case rsc_chdate: sResult.Append( _T("\\chdate") );break;
case rsc_chdpl: sResult.Append( _T("\\chdpl") );break;
case rsc_chdpa: sResult.Append( _T("\\chdpa") );break;
case rsc_chtime: sResult.Append( _T("\\chtime") );break;
case rsc_chpgn: sResult.Append( _T("\\chpgn") );break;
case rsc_sectnum: sResult.Append( _T("\\sectnum") );break;
case rsc_chftn: sResult.Append( _T("\\chftn") );break;
case rsc_chftnEnd: sResult.Append( _T("\\chftn") );break;
case rsc_chatn: sResult.Append( _T("\\chatn") );break;
case rsc_chftnsep: sResult.Append( _T("\\chftnsep") );break;
case rsc_chftnsepc: sResult.Append( _T("\\chftnsepc") );break;
case rsc_page: sResult.Append( _T("\\page") );break;
case rsc_column: sResult.Append( _T("\\column") );break;
case rsc_line: sResult.Append( _T("\\line") );break;
case rsc_softpage: sResult.Append( _T("\\softpage") );break;
case rsc_softcol: sResult.Append( _T("\\softcol") );break;
case rsc_softline: sResult.Append( _T("\\softline") );break;
case rsc_tab: sResult.Append( _T("\\tab") );break;
case rsc_Formula: sResult.Append( _T("\\|") );break;
case rsc_OptHyphen: sResult.Append( _T("\\-") );break;
case rsc_NonBrHyphen: sResult.Append( _T("\\_") );break;
case rsc_NonBrSpace: sResult.Append( _T("\\~") );break;
case rsc_zwbo: sResult.Append( _T("\\zwbo") );break;
case rsc_zwnbo: sResult.Append( _T("\\zwnbo") );break;
case rsc_zwj: sResult.Append( _T("\\zwj") );break;
case rsc_zwnj: sResult.Append( _T("\\zwnj") );break;
case rsc_chdate: sResult.Append( _T("\\chdate") ); break;
case rsc_chdpl: sResult.Append( _T("\\chdpl") ); break;
case rsc_chdpa: sResult.Append( _T("\\chdpa") ); break;
case rsc_chtime: sResult.Append( _T("\\chtime") ); break;
case rsc_chpgn: sResult.Append( _T("\\chpgn") ); break;
case rsc_sectnum: sResult.Append( _T("\\sectnum") ); break;
case rsc_chftn: sResult.Append( _T("\\chftn") ); break;
case rsc_chftnEnd: sResult.Append( _T("\\chftn") ); break;
case rsc_chatn: sResult.Append( _T("\\chatn") ); break;
case rsc_chftnsep: sResult.Append( _T("\\chftnsep") ); break;
case rsc_chftnsepc: sResult.Append( _T("\\chftnsepc") ); break;
case rsc_page: sResult.Append( _T("\\page") ); break;
case rsc_column: sResult.Append( _T("\\column") ); break;
case rsc_line: sResult.Append( _T("\\line") ); break;
case rsc_softpage: sResult.Append( _T("\\softpage") ); break;
case rsc_softcol: sResult.Append( _T("\\softcol") ); break;
case rsc_softline: sResult.Append( _T("\\softline") ); break;
case rsc_tab: sResult.Append( _T("\\tab") ); break;
case rsc_Formula: sResult.Append( _T("\\|") ); break;
case rsc_OptHyphen: sResult.Append( _T("\\-") ); break;
case rsc_NonBrHyphen: sResult.Append( _T("\\_") ); break;
case rsc_NonBrSpace: sResult.Append( _T("\\~") ); break;
case rsc_zwbo: sResult.Append( _T("\\zwbo") ); break;
case rsc_zwnbo: sResult.Append( _T("\\zwnbo") ); break;
case rsc_zwj: sResult.Append( _T("\\zwj") ); break;
case rsc_zwnj: sResult.Append( _T("\\zwnj") ); break;
}
if( PROP_DEF != m_nTextWrapBreak )
sResult.Append( _T("\\par") );
......@@ -187,34 +187,34 @@ public: CString _RenderToOOX(RenderParameter oRenderParameter)
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_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_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_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_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;
}
switch ( m_nTextWrapBreak )
{
......
......@@ -28,6 +28,12 @@ public:
//для того чтобы конвертировать старый формат List в Numbering
std::vector<RtfOldListPtr> m_aOldLists;
struct _status_section
{
bool start_new;
int number;
}m_oStatusSection;
private:
std::vector<int> m_aShapeId;
public:
......
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