mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-11 06:22:44 +08:00
98 lines
3.5 KiB
C++
98 lines
3.5 KiB
C++
#include "OOXtblPrReader.h"
|
|
#include "OOXTableRowReader.h"
|
|
#include "OOXTableReader.h"
|
|
|
|
bool OOXTableReader::Parse( ReaderParameter oParam, RtfTable& oOutputTable )
|
|
{
|
|
if (m_ooxTable == NULL) return false;
|
|
|
|
bool bExistTablPr = false;
|
|
//ñíà÷àëà ÷èòàåì ñâîéñòâà
|
|
if(m_ooxTable->m_oTableProperties )
|
|
{
|
|
OOXtblPrReader otblPrReader(m_ooxTable->m_oTableProperties);
|
|
otblPrReader.Parse( oParam, oOutputTable.m_oProperty);
|
|
bExistTablPr = true;
|
|
}
|
|
|
|
//ôîðìèðóåì âíåøíèé ñòèëü äëÿ âëîæåííûõ ýëåìåíòîâ
|
|
RtfTableStylePtr poTableStyle;
|
|
if( PROP_DEF != oOutputTable.m_oProperty.m_nStyle )
|
|
{
|
|
RtfStylePtr oTempStyle;
|
|
if( true == oParam.oRtf->m_oStyleTable.GetStyle(oOutputTable.m_oProperty.m_nStyle, oTempStyle) )
|
|
{
|
|
RtfStylePtr oResultStyle = oParam.oRtf->m_oStyleTable.GetStyleResulting( oTempStyle );
|
|
if( RtfStyle::stTable == oResultStyle->m_eType )
|
|
{
|
|
poTableStyle = boost::shared_static_cast<RtfTableStyle, RtfStyle>( oResultStyle );
|
|
poTableStyle->m_oTableProp = oOutputTable.m_oProperty; //TableProperty ñòàâèì êàê óæå ïðî÷èòàëè ÷òîáû íå òåðÿòü ïîðÿäîê ïðèìåíåíèÿ ñâîéñò
|
|
//íàïðèìåð èíäåíò ïîñëåäîâàòåëüíî çàòèðàåò äðóã äðóãà â ñòèëÿõ, numbering, ïðîñòî â ñâîéñòâàõ
|
|
}
|
|
}
|
|
}
|
|
else if( true == bExistTablPr )
|
|
{
|
|
RtfTableStylePtr poTableStyle = RtfTableStylePtr( new RtfTableStyle() );
|
|
poTableStyle->m_oTableProp.Merge( oOutputTable.m_oProperty );
|
|
}
|
|
|
|
if( m_ooxTable->m_oTblGrid.IsInit() )
|
|
{
|
|
for( int i = 0; i < m_ooxTable->m_oTblGrid->m_arrGridCol.size(); i++ )
|
|
{
|
|
if (m_ooxTable->m_oTblGrid->m_arrGridCol[i] && m_ooxTable->m_oTblGrid->m_arrGridCol[i]->m_oW.IsInit())
|
|
oOutputTable.m_aTableGrid.push_back( m_ooxTable->m_oTblGrid->m_arrGridCol[i]->m_oW->ToTwips() );
|
|
}
|
|
}
|
|
|
|
long nRowCount = m_ooxTable->m_nCountRow;
|
|
|
|
for( int i = 0; i < m_ooxTable->m_arrItems.size(); i++ )
|
|
{
|
|
if (m_ooxTable->m_arrItems[i] == NULL) continue;
|
|
if (m_ooxTable->m_arrItems[i]->getType() != OOX::et_w_tr) continue;
|
|
|
|
RtfTableRowPtr oNewRow( new RtfTableRow() );
|
|
//ïðèìåíÿåì ñâîéñòâà òàáëèöû ê êàæäîìó row
|
|
//ò.ê. â RTF íåò ñâîéñòâ òàáëèö è âñå ñâîéñòâà çàïèñûâàþòñÿ â ñâîéñòâà row
|
|
(*((RtfTableProperty*)&oNewRow->m_oProperty)).Merge( oOutputTable.m_oProperty );
|
|
|
|
OOX::Logic::CTr *ooxRow = dynamic_cast<OOX::Logic::CTr *>(m_ooxTable->m_arrItems[i]);
|
|
|
|
OOXTableRowReader oRowReader(ooxRow);
|
|
oRowReader.Parse( oParam, *oNewRow, i, nRowCount );
|
|
oOutputTable.AddItem( oNewRow );
|
|
}
|
|
oOutputTable.CalculateCellx( *oParam.oRtf );
|
|
ApplyParagraphProperty( oOutputTable );
|
|
return true;
|
|
}
|
|
//ïðèìåíÿåò ñâîéñòâà ïàðàãðàôà ñâÿçàííûå ñ ïîëîæåíèåì
|
|
void OOXTableReader::ApplyParagraphProperty( RtfTable& oOutputTable )
|
|
{
|
|
for( int i = 0; i < oOutputTable.GetCount(); i++ )
|
|
{
|
|
boost::shared_ptr<RtfTableRow> oCurRow ;
|
|
oOutputTable.GetItem(oCurRow,i);
|
|
if( oCurRow )
|
|
for( int j = 0; j < oCurRow->GetCount(); j++ )
|
|
{
|
|
boost::shared_ptr<RtfTableCell> oCurCell ;
|
|
oCurRow->GetItem( oCurCell, j );
|
|
if( oCurCell )
|
|
{
|
|
boost::shared_ptr<ITextItem> pCurTextItem;
|
|
for( int k = 0; k < oCurCell->GetCount(); k++ )
|
|
{
|
|
oCurCell->GetItem(pCurTextItem, k);
|
|
if( NULL != pCurTextItem && pCurTextItem->GetType() == TYPE_RTF_PARAGRAPH )
|
|
{
|
|
boost::shared_ptr<RtfParagraph> oCurParagraph = boost::shared_static_cast<RtfParagraph,ITextItem>( pCurTextItem );
|
|
oCurParagraph->m_oProperty.m_oFrame.ApplyParagraphProp( oOutputTable.m_oProperty );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |