summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-07-10 17:27:51 +0300
committerJustin Luth <justin_luth@sil.org>2020-07-16 19:01:02 +0200
commitfafc6c0fc3c6d62f982b0deb9bc1d874c51dd6fe (patch)
treeb6f66dc2f0dde2d26bab3eadb4a7b263697ed9db /writerfilter
parent03803de58bd426eb0b726437dc205d92383e8e2e (diff)
tdf#134709 writerfilter: consider gridBefore for table borders
When the table itself defines borders, those borders should apply to the first cell in each row - even if some grids are skipped with gridBefore. (i.e. it won't be a straight line on the left side). Most of the changes here are just simplifications, since the original code import was overly complex. This commit depends on some refactoring done for bug 129452 in LO 7.1. A followup commit is needed do the same thing for gridAfter, but currently gridAfter is not yet populated, so some foundational work needs to be done first. Change-Id: Ic7dd17fa80422520f3ccf1b121a2abb288b88ccb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98534 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx25
-rw-r--r--writerfilter/source/dmapper/TableManager.cxx8
-rw-r--r--writerfilter/source/dmapper/TableManager.hxx1
3 files changed, 18 insertions, 16 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index b56323bd3190..ac8c0f52eb71 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -103,8 +103,9 @@ static void lcl_mergeBorder( PropertyIds nId, const PropertyMapPtr& pOrig, const
}
static void lcl_computeCellBorders( const PropertyMapPtr& pTableBorders, const PropertyMapPtr& pCellProps,
- sal_Int32 nCell, sal_Int32 nRow, bool bIsEndCol, bool bIsEndRow, bool bMergedVertically )
+ sal_uInt32 nCell, sal_uInt32 nFirstCell, sal_Int32 nRow, bool bIsEndCol, bool bIsEndRow, bool bMergedVertically )
{
+ const bool bIsStartCol = nCell == nFirstCell;
std::optional<PropertyMap::Property> pVerticalVal = pCellProps->getProperty(META_PROP_VERTICAL_BORDER);
std::optional<PropertyMap::Property> pHorizontalVal = pCellProps->getProperty(META_PROP_HORIZONTAL_BORDER);
@@ -135,28 +136,19 @@ static void lcl_computeCellBorders( const PropertyMapPtr& pTableBorders, const P
pCellProps->Erase( pHorizontalVal->first );
}
- if ( nCell == 0 )
- {
+ if ( bIsStartCol )
lcl_mergeBorder( PROP_LEFT_BORDER, pTableBorders, pCellProps );
- // <w:insideV> counts if there are multiple cells in this row.
- if (pVerticalVal && !bIsEndCol)
- pCellProps->Insert( PROP_RIGHT_BORDER, aVertProp, false );
- }
if ( bIsEndCol )
- {
lcl_mergeBorder( PROP_RIGHT_BORDER, pTableBorders, pCellProps );
- if ( pVerticalVal )
- pCellProps->Insert( PROP_LEFT_BORDER, aVertProp, false );
- }
- if ( nCell > 0 && !bIsEndCol )
+ // <w:insideV> counts if there are multiple cells in this row.
+ if ( pVerticalVal )
{
- if ( pVerticalVal )
- {
+ if ( !bIsEndCol && nCell >= nFirstCell )
pCellProps->Insert( PROP_RIGHT_BORDER, aVertProp, false );
+ if ( !bIsStartCol )
pCellProps->Insert( PROP_LEFT_BORDER, aVertProp, false );
- }
}
if ( nRow == 0 )
@@ -937,7 +929,8 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl
}
}
- lcl_computeCellBorders( rInfo.pTableBorders, *aCellIterator, nCell, nRow, bIsEndCol, bIsEndRow, bMergedVertically );
+ const sal_uInt32 nFirstCell = m_rDMapper_Impl.getTableManager().getGridBefore(nRow);
+ lcl_computeCellBorders( rInfo.pTableBorders, *aCellIterator, nCell, nFirstCell, nRow, bIsEndCol, bIsEndRow, bMergedVertically );
//now set the default left+right border distance TODO: there's an sprm containing the default distance!
aCellIterator->get()->Insert( PROP_LEFT_BORDER_DISTANCE,
diff --git a/writerfilter/source/dmapper/TableManager.cxx b/writerfilter/source/dmapper/TableManager.cxx
index 2649ee1120e2..9f29b2b437bf 100644
--- a/writerfilter/source/dmapper/TableManager.cxx
+++ b/writerfilter/source/dmapper/TableManager.cxx
@@ -49,6 +49,14 @@ void TableManager::openCell(const css::uno::Reference<css::text::XTextRange>& rH
bool TableManager::isIgnore() const { return isRowEnd(); }
+sal_uInt32 TableManager::getGridBefore(sal_uInt32 nRow)
+{
+ assert(isInTable());
+ if (nRow >= mTableDataStack.top()->getRowCount())
+ return 0;
+ return mTableDataStack.top()->getRow(nRow)->getGridBefore();
+}
+
sal_uInt32 TableManager::getCurrentGridBefore()
{
return mTableDataStack.top()->getCurrentRow()->getGridBefore();
diff --git a/writerfilter/source/dmapper/TableManager.hxx b/writerfilter/source/dmapper/TableManager.hxx
index 1cc7caaf958e..375cee7e30aa 100644
--- a/writerfilter/source/dmapper/TableManager.hxx
+++ b/writerfilter/source/dmapper/TableManager.hxx
@@ -500,6 +500,7 @@ public:
*/
bool isIgnore() const;
+ sal_uInt32 getGridBefore(sal_uInt32 nRow);
sal_uInt32 getCurrentGridBefore();
void setCurrentGridBefore( sal_uInt32 nSkipGrids );
std::vector<sal_uInt32> getCurrentGridSpans();