summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper/DomainMapperTableManager.cxx
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2019-12-05 09:47:18 +0100
committerLászló Németh <nemeth@numbertext.org>2019-12-08 15:54:01 +0100
commitb2c6d2d961a6113d0f111fab45ae12a40d389a23 (patch)
tree316cf6e0472f5c57a4d49d61d40ca5f3cc52e84d /writerfilter/source/dmapper/DomainMapperTableManager.cxx
parentda1f71edfc72928b07a569b98e2766a8a7de9d2a (diff)
fdo#38414 tdf#44986: DOCX table import: handle gridBefore/After
without serious regressions, ie. losing the import of complex forms with multiple or nested tables. Complete the fix for tdf#116194 (DOCX import: fix missing tables with w:gridBefore) with handling gridAfter on DomainMapper level. This consists of also rejections (except their unit tests) of commit cf33af732ed0d3d553bb74636e3b14c55d44c153 (handle w:gridBefore by faking cells (fdo#38414)) and commit 1d1748d143ab4270a2ca1b5117852b1b1bb4c526 (Related: tdf#44986 DOCX import: handle w:gridAfter by faking cells) Change-Id: I31fa1de03bcdf42424fa5507fb5a3e06aa47107d Reviewed-on: https://gerrit.libreoffice.org/84517 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapperTableManager.cxx')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.cxx28
1 files changed, 19 insertions, 9 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 03486feba082..ef26bd6f288d 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -48,7 +48,7 @@ DomainMapperTableManager::DomainMapperTableManager() :
m_nCell(),
m_nGridSpan(1),
m_aGridBefore(),
- m_nGridAfter(0),
+ m_aGridAfter(),
m_nHeaderRepeat(0),
m_nTableWidth(0),
m_bIsInShape(false),
@@ -357,7 +357,7 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
m_aGridBefore.back( ) = nIntValue;
break;
case NS_ooxml::LN_CT_TrPrBase_gridAfter:
- m_nGridAfter = nIntValue;
+ m_aGridAfter.back() = nIntValue;
break;
case NS_ooxml::LN_CT_TblPrBase_tblCaption:
// To-Do: Not yet preserved
@@ -399,6 +399,11 @@ sal_uInt32 DomainMapperTableManager::getCurrentGridBefore( )
return m_aGridBefore.back( );
}
+sal_uInt32 DomainMapperTableManager::getCurrentGridAfter( )
+{
+ return m_aGridAfter.back( );
+}
+
bool DomainMapperTableManager::hasCurrentSpans() const
{
return !m_aGridSpans.empty();
@@ -462,6 +467,7 @@ void DomainMapperTableManager::startLevel( )
m_aTmpTableProperties.push_back( pTmpProperties );
m_nCell.push_back( 0 );
m_aGridBefore.push_back( 0 );
+ m_aGridAfter.push_back( 0 );
m_nTableWidth = 0;
m_nLayoutType = 0;
@@ -492,6 +498,7 @@ void DomainMapperTableManager::endLevel( )
m_nCell.pop_back( );
m_aGridBefore.pop_back( );
+ m_aGridAfter.pop_back( );
m_nTableWidth = 0;
m_nLayoutType = 0;
@@ -548,6 +555,7 @@ void DomainMapperTableManager::endOfRowAction()
IntVectorPtr pTmpCellWidths = m_aCellWidths.back();
sal_uInt32 nTmpCell = m_nCell.back();
sal_uInt32 nTmpGridBefore = m_aGridBefore.back();
+ sal_uInt32 nTmpGridAfter = m_aGridAfter.back();
// endLevel and startLevel are taking care of the non finished row
// to carry it over to the next table
@@ -561,11 +569,13 @@ void DomainMapperTableManager::endOfRowAction()
m_aCellWidths.pop_back();
m_nCell.pop_back();
m_aGridBefore.pop_back();
+ m_aGridAfter.pop_back();
m_aTableGrid.push_back(pTmpTableGrid);
m_aGridSpans.push_back(pTmpGridSpans);
m_aCellWidths.push_back(pTmpCellWidths);
m_nCell.push_back(nTmpCell);
m_aGridBefore.push_back(nTmpGridBefore);
+ m_aGridAfter.push_back(nTmpGridAfter);
}
// Push the tmp position now that we compared it
@@ -612,10 +622,10 @@ void DomainMapperTableManager::endOfRowAction()
//fill missing gridBefore elements with '1'
pCurrentSpans->insert( pCurrentSpans->begin( ), m_aGridBefore.back(), 1 );
}
- if( pCurrentSpans->size() < m_aGridBefore.back() + m_nCell.back( ))
+ if( pCurrentSpans->size() < m_aGridBefore.back() + m_nCell.back( ) + m_aGridAfter.back() )
{
//fill missing elements with '1'
- pCurrentSpans->insert( pCurrentSpans->end( ), m_aGridBefore.back() + m_nCell.back( ) - pCurrentSpans->size(), 1 );
+ pCurrentSpans->insert( pCurrentSpans->end( ), m_aGridBefore.back() + m_nCell.back( ) + m_aGridAfter.back() - pCurrentSpans->size(), 1 );
}
#ifdef DBG_UTIL
@@ -642,7 +652,7 @@ void DomainMapperTableManager::endOfRowAction()
for (int i : (*pTableGrid))
nFullWidthRelative = o3tl::saturating_add(nFullWidthRelative, i);
- if( pTableGrid->size() == ( nGrids + m_nGridAfter ) && m_nCell.back( ) > 0 )
+ if( pTableGrid->size() == nGrids && m_nCell.back( ) > 0 )
{
/*
* If table width property set earlier is smaller than the current table width,
@@ -672,12 +682,12 @@ void DomainMapperTableManager::endOfRowAction()
}
}
}
- uno::Sequence< text::TableColumnSeparator > aSeparators( m_aGridBefore.back() + m_nCell.back( ) - 1 );
+ uno::Sequence< text::TableColumnSeparator > aSeparators( m_aGridBefore.back() + m_nCell.back( ) + m_aGridAfter.back() - 1 );
text::TableColumnSeparator* pSeparators = aSeparators.getArray();
double nLastRelPos = 0.0;
sal_uInt32 nBorderGridIndex = 0;
- size_t nWidthsBound = m_aGridBefore.back() + m_nCell.back() - 1;
+ size_t nWidthsBound = m_aGridBefore.back() + m_nCell.back() + m_aGridAfter.back() - 1;
if (nWidthsBound)
{
if (nFullWidthRelative == 0)
@@ -710,7 +720,7 @@ void DomainMapperTableManager::endOfRowAction()
}
else if ( !pCellWidths->empty() &&
( m_nLayoutType == NS_ooxml::LN_Value_doc_ST_TblLayout_fixed
- || pCellWidths->size() == ( nGrids + m_nGridAfter ) )
+ || pCellWidths->size() == nGrids )
)
{
// If we're here, then the number of cells does not equal to the amount
@@ -765,11 +775,11 @@ void DomainMapperTableManager::endOfRowAction()
++m_nRow;
m_nCell.back( ) = 0;
m_aGridBefore.back( ) = 0;
+ m_aGridAfter.back( ) = 0;
getCurrentGrid()->clear();
pCurrentSpans->clear();
pCellWidths->clear();
- m_nGridAfter = 0;
m_bTableSizeTypeInserted = false;
#ifdef DBG_UTIL