Kaydet (Commit) b14b0f2b authored tarafından Cédric Bosdonnat's avatar Cédric Bosdonnat Kaydeden (comit) Cédric Bosdonnat

n#779627: fixed writerfilter import of grid when there are nested tables

When a nested table is ended, it resets the m_nCell to 0... and thus the
filter forgets about the previous cells of the outer table row it is
importing. Using a vector to store the m_nCell values for each table
solves the problem

Change-Id: I8007960f4c95d713bfedc6b815d5783a5d25af23
üst 9b0198b2
......@@ -42,7 +42,7 @@ using namespace ::std;
DomainMapperTableManager::DomainMapperTableManager(bool bOOXML, bool bImplicitMerges) :
m_nRow(0),
m_nCell(0),
m_nCell(),
m_nGridSpan(1),
m_nCellBorderIndex(0),
m_nHeaderRepeat(0),
......@@ -343,6 +343,7 @@ void DomainMapperTableManager::startLevel( )
IntVectorPtr pNewSpans( new vector<sal_Int32> );
m_aTableGrid.push_back( pNewGrid );
m_aGridSpans.push_back( pNewSpans );
m_nCell.push_back( 0 );
m_nTableWidth = 0;
}
......@@ -350,6 +351,7 @@ void DomainMapperTableManager::endLevel( )
{
m_aTableGrid.pop_back( );
m_aGridSpans.pop_back( );
m_nCell.pop_back( );
m_nTableWidth = 0;
DomainMapperTableManager_Base_t::endLevel( );
......@@ -373,7 +375,7 @@ void DomainMapperTableManager::endOfCellAction()
getCurrentSpans()->push_back(m_nGridSpan);
m_nGridSpan = 1;
++m_nCell;
++m_nCell.back( );
}
......@@ -416,10 +418,10 @@ void DomainMapperTableManager::endOfRowAction()
}
IntVectorPtr pCurrentSpans = getCurrentSpans( );
if( pCurrentSpans->size() < m_nCell)
if( pCurrentSpans->size() < m_nCell.back( ) )
{
//fill missing elements with '1'
pCurrentSpans->insert( pCurrentSpans->end( ), m_nCell - pCurrentSpans->size(), 1 );
pCurrentSpans->insert( pCurrentSpans->end( ), m_nCell.back( ) - pCurrentSpans->size(), 1 );
}
#ifdef DEBUG_DOMAINMAPPER
......@@ -450,15 +452,15 @@ void DomainMapperTableManager::endOfRowAction()
double nFullWidth = m_nTableWidth;
//the positions have to be distibuted in a range of 10000
const double nFullWidthRelative = 10000.;
if( pTableGrid->size() == nGrids && m_nCell > 0 )
if( pTableGrid->size() == nGrids && m_nCell.back( ) > 0 )
{
uno::Sequence< text::TableColumnSeparator > aSeparators( m_nCell - 1 );
uno::Sequence< text::TableColumnSeparator > aSeparators( m_nCell.back( ) - 1 );
text::TableColumnSeparator* pSeparators = aSeparators.getArray();
sal_Int16 nLastRelPos = 0;
sal_uInt32 nBorderGridIndex = 0;
::std::vector< sal_Int32 >::const_iterator aSpansIter = pCurrentSpans->begin( );
for( sal_uInt32 nBorder = 0; nBorder < m_nCell - 1; ++nBorder )
for( sal_uInt32 nBorder = 0; nBorder < m_nCell.back( ) - 1; ++nBorder )
{
sal_Int32 nGridCount = *aSpansIter;
double fGridWidth = 0.;
......@@ -489,14 +491,14 @@ void DomainMapperTableManager::endOfRowAction()
{
// More grid than cells definitions? Then take the last ones.
// This feature is used by the RTF implicit horizontal cell merges.
uno::Sequence< text::TableColumnSeparator > aSeparators(m_nCell - 1);
uno::Sequence< text::TableColumnSeparator > aSeparators(m_nCell.back( ) - 1);
text::TableColumnSeparator* pSeparators = aSeparators.getArray();
sal_Int16 nSum = 0;
sal_uInt32 nPos = 0;
sal_uInt32 nSizeTableGrid = pTableGrid->size();
// Ignoring the i=0 case means we assume that the width of the last cell matches the table width
for (sal_uInt32 i = m_nCell; i > 1 && nSizeTableGrid >= i; i--)
for (sal_uInt32 i = m_nCell.back( ); i > 1 && nSizeTableGrid >= i; i--)
{
nSum += (*pTableGrid.get())[pTableGrid->size() - i]; // Size of the current cell
pSeparators[nPos].Position = nSum * nFullWidthRelative / nFullWidth; // Relative position
......@@ -515,7 +517,7 @@ void DomainMapperTableManager::endOfRowAction()
}
++m_nRow;
m_nCell = 0;
m_nCell.back( ) = 0;
m_nCellBorderIndex = 0;
pCurrentSpans->clear();
......@@ -527,7 +529,7 @@ void DomainMapperTableManager::endOfRowAction()
void DomainMapperTableManager::clearData()
{
m_nRow = m_nCell = m_nCellBorderIndex = m_nHeaderRepeat = m_nTableWidth = 0;
m_nRow = m_nCellBorderIndex = m_nHeaderRepeat = m_nTableWidth = 0;
m_sTableStyleName = OUString();
m_sTableVertAnchor = OUString();
m_pTableStyleTextProperies.reset();
......
......@@ -35,7 +35,7 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
typedef boost::shared_ptr< std::vector<sal_Int32> > IntVectorPtr;
sal_uInt32 m_nRow;
sal_uInt32 m_nCell;
::std::vector< sal_uInt32 > m_nCell;
sal_uInt32 m_nGridSpan;
sal_uInt32 m_nCellBorderIndex; //borders are provided for all cells and need counting
sal_Int32 m_nHeaderRepeat; //counter of repeated headers - if == -1 then the repeating stops
......
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