summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2015-11-19 20:48:14 +1000
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-12-09 13:11:48 +0000
commit769dc61fcaea382518f014c24dffb702b7a50fc6 (patch)
tree1bacd98cb3c68ce0a98748830b1f6d85893b099d /writerfilter
parent9d2a1c48b4a39967bc21776b471f1a4eca735cb6 (diff)
tdf#95755: Don't discard table properties in endOfRowAction()
In the beginning of endOfRowAction(), the current value of m_aTmpTableProperties.back( ) is stored in a temporary variable. Then, the width of table may be put into m_aTmpTableProperties.back( ). In the end, this temp variable is assigned to TableManager::mState.mTableProps and the m_aTmpTableProperties.back( ) is reset. In the middle, the m_aTmpTableProperties.back( ) may be replaced in endLevel()/startLevel() sequence (if new table is started). In that case, the width calculations go to a different object than stored in temp var. Consequently, that value will be discarded and replaced with initial stored in temp var. Fixed that by directly operating with temp var instead of m_aTmpTableProperties.back( ). Also, the value of m_nCell was not kept over endLevel()/startLevel() sequence and that prevented from calculating width. Fixed that. Also, removed leftovers from commit cbd0fbc287051f918e4adb32b3e9b58dfbf8059d. Change-Id: If85dbb715e7c60f60043f9d60d6a3c3d02277add Reviewed-on: https://gerrit.libreoffice.org/20052 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.cxx26
1 files changed, 12 insertions, 14 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 64199398d874..61988b67c87d 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -177,9 +177,8 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
(See 17.18.87 of the ISO/IEC 29500-1:2011.)
*/
bool bFixed = true;
- sal_Int32 nRowFixedWidth = 0;
IntVectorPtr pCellWidths = getCurrentCellWidths();
- // Step 1. Check whether all cells have fixed widths in the given row of table.
+ // Check whether all cells have fixed widths in the given row of table.
for (std::vector<sal_Int32>::const_iterator aValIter = pCellWidths->begin(); aValIter != pCellWidths->end(); ++aValIter)
{
if (*aValIter == -1)
@@ -187,14 +186,11 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
bFixed = false;
break;
}
- // Sum the width of cells to find the total width of given row
- nRowFixedWidth += (*aValIter);
}
- // Check whether the total width of given row is compared with the maximum value of rows (m_nMaxFixedWidth).
if (!bFixed)
{
- // Set the width type of table with 'Auto' and set the width value to 100(%)
+ // Set the width type of table with 'Auto' and set the width value to 0 (as per grid values)
pPropMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::VARIABLE );
pPropMap->setValue( TablePropertyMap::TABLE_WIDTH, 0 );
}
@@ -523,7 +519,7 @@ void DomainMapperTableManager::endOfRowAction()
// into two tables if those are different. We surely don't want to do anything
// if we don't have any row yet.
TablePositionHandlerPtr pTmpPosition = m_aTmpPosition.back();
- TablePropertyMapPtr pTmpTableProperties = m_aTmpTableProperties.back( );
+ TablePropertyMapPtr pTablePropMap = m_aTmpTableProperties.back( );
TablePositionHandlerPtr pCurrentPosition = m_aTablePositions.back();
bool bSamePosition = ( pTmpPosition == pCurrentPosition ) ||
( pTmpPosition && pCurrentPosition && *pTmpPosition == *pCurrentPosition );
@@ -533,6 +529,7 @@ void DomainMapperTableManager::endOfRowAction()
IntVectorPtr pTmpTableGrid = m_aTableGrid.back();
IntVectorPtr pTmpGridSpans = m_aGridSpans.back();
IntVectorPtr pTmpCellWidths = m_aCellWidths.back();
+ sal_uInt32 nTmpCell = m_nCell.back();
// endLevel and startLevel are taking care of the non finished row
// to carry it over to the next table
@@ -544,9 +541,11 @@ void DomainMapperTableManager::endOfRowAction()
m_aTableGrid.pop_back();
m_aGridSpans.pop_back();
m_aCellWidths.pop_back();
+ m_nCell.pop_back();
m_aTableGrid.push_back(pTmpTableGrid);
m_aGridSpans.push_back(pTmpGridSpans);
m_aCellWidths.push_back(pTmpCellWidths);
+ m_nCell.push_back(nTmpCell);
}
// Push the tmp position now that we compared it
@@ -633,21 +632,20 @@ void DomainMapperTableManager::endOfRowAction()
* If table width property set earlier is smaller than the current table width,
* then replace the TABLE_WIDTH property, set earlier.
*/
- TablePropertyMapPtr propMap = m_aTmpTableProperties.back();
sal_Int32 nTableWidth(0);
sal_Int32 nTableWidthType(text::SizeType::VARIABLE);
- propMap->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth );
- propMap->getValue( TablePropertyMap::TABLE_WIDTH_TYPE, nTableWidthType );
+ pTablePropMap->getValue(TablePropertyMap::TABLE_WIDTH, nTableWidth);
+ pTablePropMap->getValue(TablePropertyMap::TABLE_WIDTH_TYPE, nTableWidthType);
if ((nTableWidthType == text::SizeType::FIX) && (nTableWidth < m_nTableWidth))
{
- propMap->setValue( TablePropertyMap::TABLE_WIDTH, m_nTableWidth );
+ pTablePropMap->setValue(TablePropertyMap::TABLE_WIDTH, m_nTableWidth);
}
if (nTableWidthType == text::SizeType::VARIABLE )
{
if(nTableWidth > 100 || nTableWidth <= 0)
{
- propMap->setValue( TablePropertyMap::TABLE_WIDTH, m_nTableWidth);
- propMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::FIX);
+ pTablePropMap->setValue(TablePropertyMap::TABLE_WIDTH, m_nTableWidth);
+ pTablePropMap->setValue(TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::FIX);
}
}
uno::Sequence< text::TableColumnSeparator > aSeparators( m_nCell.back( ) - 1 );
@@ -734,7 +732,7 @@ void DomainMapperTableManager::endOfRowAction()
}
// Now that potentially opened table is closed, save the table properties
- TableManager::insertTableProps( pTmpTableProperties );
+ TableManager::insertTableProps(pTablePropMap);
m_aTmpTableProperties.pop_back();
TablePropertyMapPtr pEmptyTableProps( new TablePropertyMap() );