summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-06-29 12:33:07 +0300
committerMiklos Vajna <vmiklos@collabora.com>2021-03-04 18:30:03 +0100
commit0225526f7bb3b10ceef687dfa98b6cc010627f59 (patch)
tree119fbad0cd7a67177efa1f2c21a7181ba15a6351
parenttdf#116194 DOCX import: fix missing tables with w:gridBefore (diff)
downloadcore-0225526f7bb3b10ceef687dfa98b6cc010627f59.tar.gz
core-0225526f7bb3b10ceef687dfa98b6cc010627f59.zip
tdf#129452 writerfilter: preserve gridBefore longer than currentRow
It is a fairly common thing for table operations to need to compare items in the same column (like merged cells for example). In order to determine column information, each row's gridBefore (and merged cells) need to be known. So save that information in the row data - and don't just throw it away after the current row has been analyzed. Good grief. (cherry picked from commit 2ad32b39af2e00ef253a2ef99e033feef416808f) Conflicts: writerfilter/source/dmapper/DomainMapperTableManager.cxx writerfilter/source/dmapper/DomainMapperTableManager.hxx writerfilter/source/dmapper/TableManager.cxx Change-Id: Ie305477f0e3468a4a923095d76f520d97fe99ffe
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.cxx26
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.hxx2
-rw-r--r--writerfilter/source/dmapper/TableData.hxx11
-rw-r--r--writerfilter/source/dmapper/TableManager.cxx11
-rw-r--r--writerfilter/source/dmapper/TableManager.hxx2
5 files changed, 30 insertions, 22 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 7d050ae545a3..68db4d01ec81 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -47,7 +47,6 @@ DomainMapperTableManager::DomainMapperTableManager() :
m_nRow(0),
m_nCell(),
m_nGridSpan(1),
- m_aGridBefore(),
m_nGridAfter(0),
m_nHeaderRepeat(0),
m_nTableWidth(0),
@@ -367,7 +366,7 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
}
break;
case NS_ooxml::LN_CT_TrPrBase_gridBefore:
- m_aGridBefore.back( ) = nIntValue;
+ setCurrentGridBefore( nIntValue );
break;
case NS_ooxml::LN_CT_TrPrBase_gridAfter:
m_nGridAfter = nIntValue;
@@ -407,11 +406,6 @@ std::shared_ptr< vector<sal_Int32> > const & DomainMapperTableManager::getCurren
return m_aTableGrid.back( );
}
-sal_uInt32 DomainMapperTableManager::getCurrentGridBefore( )
-{
- return m_aGridBefore.back( );
-}
-
bool DomainMapperTableManager::hasCurrentSpans() const
{
return !m_aGridSpans.empty();
@@ -474,7 +468,6 @@ void DomainMapperTableManager::startLevel( )
m_aTmpPosition.push_back( pTmpPosition );
m_aTmpTableProperties.push_back( pTmpProperties );
m_nCell.push_back( 0 );
- m_aGridBefore.push_back( 0 );
m_nTableWidth = 0;
m_nLayoutType = 0;
@@ -504,7 +497,6 @@ void DomainMapperTableManager::endLevel( )
m_aCellWidths.back()->push_back(*oCurrentWidth);
m_nCell.pop_back( );
- m_aGridBefore.pop_back( );
m_nTableWidth = 0;
m_nLayoutType = 0;
@@ -560,7 +552,6 @@ void DomainMapperTableManager::endOfRowAction()
IntVectorPtr pTmpGridSpans = m_aGridSpans.back();
IntVectorPtr pTmpCellWidths = m_aCellWidths.back();
sal_uInt32 nTmpCell = m_nCell.back();
- sal_uInt32 nTmpGridBefore = m_aGridBefore.back();
// endLevel and startLevel are taking care of the non finished row
// to carry it over to the next table
@@ -573,12 +564,10 @@ void DomainMapperTableManager::endOfRowAction()
m_aGridSpans.pop_back();
m_aCellWidths.pop_back();
m_nCell.pop_back();
- m_aGridBefore.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);
}
// Push the tmp position now that we compared it
@@ -620,15 +609,15 @@ void DomainMapperTableManager::endOfRowAction()
IntVectorPtr pCurrentSpans = getCurrentSpans( );
- if( m_aGridBefore.back() > 0 )
+ if ( getCurrentGridBefore() )
{
//fill missing gridBefore elements with '1'
- pCurrentSpans->insert( pCurrentSpans->begin( ), m_aGridBefore.back(), 1 );
+ pCurrentSpans->insert( pCurrentSpans->begin(), getCurrentGridBefore(), 1 );
}
- if( pCurrentSpans->size() < m_aGridBefore.back() + m_nCell.back( ))
+ if ( pCurrentSpans->size() < getCurrentGridBefore() + m_nCell.back() )
{
//fill missing elements with '1'
- pCurrentSpans->insert( pCurrentSpans->end( ), m_aGridBefore.back() + m_nCell.back( ) - pCurrentSpans->size(), 1 );
+ pCurrentSpans->insert( pCurrentSpans->end(), getCurrentGridBefore() + m_nCell.back() - pCurrentSpans->size(), 1 );
}
#ifdef DEBUG_WRITERFILTER
@@ -677,12 +666,12 @@ void DomainMapperTableManager::endOfRowAction()
pTablePropMap->setValue(TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::FIX);
}
}
- uno::Sequence< text::TableColumnSeparator > aSeparators( m_aGridBefore.back() + m_nCell.back( ) - 1 );
+ uno::Sequence< text::TableColumnSeparator > aSeparators( getCurrentGridBefore() + m_nCell.back() - 1 );
text::TableColumnSeparator* pSeparators = aSeparators.getArray();
sal_Int16 nLastRelPos = 0;
sal_uInt32 nBorderGridIndex = 0;
- size_t nWidthsBound = m_aGridBefore.back() + m_nCell.back() - 1;
+ size_t nWidthsBound = getCurrentGridBefore() + m_nCell.back() - 1;
if (nWidthsBound)
{
if (nFullWidthRelative == 0)
@@ -770,7 +759,6 @@ void DomainMapperTableManager::endOfRowAction()
++m_nRow;
m_nCell.back( ) = 0;
- m_aGridBefore.back( ) = 0;
getCurrentGrid()->clear();
pCurrentSpans->clear();
pCellWidths->clear();
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
index 1d2f54bf474c..6a175dc79e0a 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
@@ -42,7 +42,6 @@ class DomainMapperTableManager : public TableManager
sal_uInt32 m_nRow;
::std::vector< sal_uInt32 > m_nCell;
sal_uInt32 m_nGridSpan;
- ::std::vector< sal_uInt32 > m_aGridBefore; ///< number of grid columns in the parent table's table grid which must be skipped before the contents of this table row are added to the parent table
sal_uInt32 m_nGridAfter; ///< number of grid columns in the parent table's table grid which shall be left after the last cell in the table row
sal_Int32 m_nHeaderRepeat; //counter of repeated headers - if == -1 then the repeating stops
sal_Int32 m_nTableWidth; //might be set directly or has to be calculated from the column positions
@@ -97,7 +96,6 @@ public:
bool hasCurrentSpans() const;
IntVectorPtr const & getCurrentSpans( );
IntVectorPtr const & getCurrentCellWidths( );
- sal_uInt32 getCurrentGridBefore( );
/// Turn the attributes collected so far in m_aTableLook into a property and clear the container.
void finishTableLook();
diff --git a/writerfilter/source/dmapper/TableData.hxx b/writerfilter/source/dmapper/TableData.hxx
index 423e837cc336..3dc068b43c17 100644
--- a/writerfilter/source/dmapper/TableData.hxx
+++ b/writerfilter/source/dmapper/TableData.hxx
@@ -115,13 +115,19 @@ class RowData final : public virtual SvRefBase
*/
mutable TablePropertyMapPtr mpProperties;
+ sal_uInt32 m_nGridBefore; ///< number of grid columns in the parent table's table grid which must be skipped before the contents of this table row are added to the parent table
+
public:
typedef tools::SvRef<RowData> Pointer_t;
- RowData() {}
+ RowData()
+ : m_nGridBefore(0)
+ {
+ }
RowData(const RowData& rRowData)
: SvRefBase(), mCells(rRowData.mCells), mpProperties(rRowData.mpProperties)
+ , m_nGridBefore(rRowData.m_nGridBefore)
{
}
@@ -226,6 +232,9 @@ public:
{
return mpProperties;
}
+
+ sal_uInt32 getGridBefore() { return m_nGridBefore; }
+ void setGridBefore(sal_uInt32 nSkipGrids) { m_nGridBefore = nSkipGrids; }
};
/**
diff --git a/writerfilter/source/dmapper/TableManager.cxx b/writerfilter/source/dmapper/TableManager.cxx
index 76dae9aff965..748dc50d655d 100644
--- a/writerfilter/source/dmapper/TableManager.cxx
+++ b/writerfilter/source/dmapper/TableManager.cxx
@@ -58,6 +58,16 @@ void TableManager::endOfRowAction()
{
}
+sal_uInt32 TableManager::getCurrentGridBefore()
+{
+ return mTableDataStack.top()->getCurrentRow()->getGridBefore();
+}
+
+void TableManager::setCurrentGridBefore(sal_uInt32 nSkipGrids)
+{
+ mTableDataStack.top()->getCurrentRow()->setGridBefore(nSkipGrids);
+}
+
void TableManager::endOfCellAction()
{
}
@@ -371,6 +381,7 @@ void TableManager::startLevel()
pTableData2->addCell(mpUnfinishedRow->getCellStart(i), mpUnfinishedRow->getCellProperties(i));
pTableData2->endCell(mpUnfinishedRow->getCellEnd(i));
}
+ pTableData2->getCurrentRow()->setGridBefore(mpUnfinishedRow->getGridBefore());
mpUnfinishedRow.clear();
}
diff --git a/writerfilter/source/dmapper/TableManager.hxx b/writerfilter/source/dmapper/TableManager.hxx
index 15d9da8c3bc1..25687a051c30 100644
--- a/writerfilter/source/dmapper/TableManager.hxx
+++ b/writerfilter/source/dmapper/TableManager.hxx
@@ -465,6 +465,8 @@ public:
*/
bool isIgnore() const;
+ sal_uInt32 getCurrentGridBefore();
+ void setCurrentGridBefore( sal_uInt32 nSkipGrids );
void setTableStartsAtCellStart(bool bTableStartsAtCellStart);
void setCellLastParaAfterAutospacing(bool bIsAfterAutospacing);