diff options
author | Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr> | 2012-09-20 13:28:37 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-09-21 17:18:16 +0200 |
commit | b14b0f2b953b68612b8c230dbf3cabc15247c72d (patch) | |
tree | afaa80af1f367be9f0db0039fa49a72525c26cd3 | |
parent | 9b0198b2442bc749491d0f1e5e2c811346e5d568 (diff) |
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
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableManager.cxx | 24 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableManager.hxx | 2 |
2 files changed, 14 insertions, 12 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index bdcaa7003380..2753d7f2a65a 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -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(); diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx index a005c2e41690..e9255f7afaca 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx @@ -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 |