diff options
author | Gülşah Köse <gulsah.kose@collabora.com> | 2022-02-01 16:03:14 +0300 |
---|---|---|
committer | Gülşah Köse <gulsah.kose@collabora.com> | 2022-03-02 11:57:25 +0100 |
commit | 3faf005a367cbd28077403bf93810bbaf4805851 (patch) | |
tree | 2fcee7f03bc52dfc6dbcafac55c77822c5da2b19 /oox/source/drawingml | |
parent | e8a004d54dc939b257b2851a78c324269e2a3973 (diff) |
tdf#135843 Implement inside horizontal vertical borders.
wholeTbl as TableStylePart should be handled in different way. Before
left border of the whole table was handling like all cells left
border but it should be left border of the first column.
insideV and and insideH properties are imported but never handled. I
added the inside vertical and horizontal borders handling.
Change-Id: I5aea5cbefc746db637eac6c1438fa70a7d741bc0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128971
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
Diffstat (limited to 'oox/source/drawingml')
-rw-r--r-- | oox/source/drawingml/table/tablecell.cxx | 112 | ||||
-rw-r--r-- | oox/source/drawingml/table/tableproperties.cxx | 16 |
2 files changed, 117 insertions, 11 deletions
diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx index e5ab3372d42e..15ab06303e3b 100644 --- a/oox/source/drawingml/table/tablecell.cxx +++ b/oox/source/drawingml/table/tablecell.cxx @@ -81,6 +81,14 @@ static void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase, aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 2 ); aBorderLine.LineDistance = 0; } + else + { + aBorderLine.Color = sal_Int32( COL_AUTO ); + aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 4 ); + aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 4 ); + aBorderLine.LineWidth = 12700; + aBorderLine.LineDistance = 0; + } if ( rLineProperties.moPresetDash.has() ) { @@ -150,9 +158,16 @@ static void applyTableStylePart( const ::oox::core::XmlFilterBase& rFilterBase, oox::drawingml::LineProperties& rRightBorder, oox::drawingml::LineProperties& rTopBorder, oox::drawingml::LineProperties& rBottomBorder, + oox::drawingml::LineProperties& rInsideHBorder, + oox::drawingml::LineProperties& rInsideVBorder, oox::drawingml::LineProperties& rTopLeftToBottomRightBorder, oox::drawingml::LineProperties& rBottomLeftToTopRightBorder, - TableStylePart& rTableStylePart ) + TableStylePart& rTableStylePart, + bool bIsWholeTable = false, + sal_Int32 nCol = 0, + sal_Int32 nMaxCol = 0, + sal_Int32 nRow = 0, + sal_Int32 nMaxRow = 0) { ::oox::drawingml::FillPropertiesPtr& rPartFillPropertiesPtr( rTableStylePart.getFillProperties() ); if ( rPartFillPropertiesPtr ) @@ -169,12 +184,35 @@ static void applyTableStylePart( const ::oox::core::XmlFilterBase& rFilterBase, } } - applyBorder( rFilterBase, rTableStylePart, XML_left, rLeftBorder ); - applyBorder( rFilterBase, rTableStylePart, XML_right, rRightBorder ); - applyBorder( rFilterBase, rTableStylePart, XML_top, rTopBorder ); - applyBorder( rFilterBase, rTableStylePart, XML_bottom, rBottomBorder ); - applyBorder( rFilterBase, rTableStylePart, XML_tl2br, rTopLeftToBottomRightBorder ); - applyBorder( rFilterBase, rTableStylePart, XML_tr2bl, rBottomLeftToTopRightBorder ); + // Left, right, top and bottom side of the whole table should be mean outer frame of the whole table. + // Without this check it means left top right and bottom of whole cells of whole table. + if (bIsWholeTable) + { + if (nCol == 0) + applyBorder( rFilterBase, rTableStylePart, XML_left, rLeftBorder ); + if (nCol == nMaxCol) + applyBorder( rFilterBase, rTableStylePart, XML_right, rRightBorder ); + if (nRow == 0) + applyBorder( rFilterBase, rTableStylePart, XML_top, rTopBorder ); + if (nRow == nMaxRow) + applyBorder( rFilterBase, rTableStylePart, XML_bottom, rBottomBorder ); + + applyBorder( rFilterBase, rTableStylePart, XML_insideH, rInsideHBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_insideV, rInsideVBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_tl2br, rTopLeftToBottomRightBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_tr2bl, rBottomLeftToTopRightBorder ); + } + else + { + applyBorder( rFilterBase, rTableStylePart, XML_left, rLeftBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_right, rRightBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_top, rTopBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_bottom, rBottomBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_tl2br, rTopLeftToBottomRightBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_tr2bl, rBottomLeftToTopRightBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_insideH, rInsideHBorder ); + applyBorder( rFilterBase, rTableStylePart, XML_insideV, rInsideVBorder ); + } aTextCharProps.maLatinFont = rTableStylePart.getLatinFont(); aTextCharProps.maAsianFont = rTableStylePart.getAsianFont(); @@ -233,6 +271,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons oox::drawingml::LineProperties aLinePropertiesRight; oox::drawingml::LineProperties aLinePropertiesTop; oox::drawingml::LineProperties aLinePropertiesBottom; + oox::drawingml::LineProperties aLinePropertiesInsideH; + oox::drawingml::LineProperties aLinePropertiesInsideV; oox::drawingml::LineProperties aLinePropertiesTopLeftToBottomRight; oox::drawingml::LineProperties aLinePropertiesBottomLeftToTopRight; @@ -241,9 +281,16 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, - rTable.getWholeTbl() ); + rTable.getWholeTbl(), + true, + nColumn, + nMaxColumn, + nRow, + nMaxRow ); if ( rProperties.isFirstRow() && ( nRow == 0 ) ) { @@ -252,6 +299,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, rTable.getFirstRow() ); @@ -263,6 +312,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, rTable.getLastRow() ); @@ -274,6 +325,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, rTable.getFirstCol() ); @@ -285,6 +338,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, rTable.getLastCol() ); @@ -306,6 +361,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, rTable.getBand2H() ); @@ -317,6 +374,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, rTable.getBand1H() ); @@ -330,6 +389,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, rTable.getNwCell() ); @@ -341,6 +402,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, rTable.getSwCell() ); @@ -352,6 +415,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, rTable.getNeCell() ); @@ -363,6 +428,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, rTable.getSeCell() ); @@ -384,6 +451,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, rTable.getBand2V() ); @@ -395,6 +464,8 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight, aLinePropertiesTop, aLinePropertiesBottom, + aLinePropertiesInsideH, + aLinePropertiesInsideV, aLinePropertiesTopLeftToBottomRight, aLinePropertiesBottomLeftToTopRight, rTable.getBand1V() ); @@ -405,8 +476,11 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesRight.assignUsed( maLinePropertiesRight ); aLinePropertiesTop.assignUsed( maLinePropertiesTop ); aLinePropertiesBottom.assignUsed( maLinePropertiesBottom ); + aLinePropertiesInsideH.assignUsed( maLinePropertiesInsideH ); + aLinePropertiesInsideV.assignUsed( maLinePropertiesInsideV ); aLinePropertiesTopLeftToBottomRight.assignUsed( maLinePropertiesTopLeftToBottomRight ); aLinePropertiesBottomLeftToTopRight.assignUsed( maLinePropertiesBottomLeftToTopRight ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesLeft, PROP_LeftBorder ); applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesRight, PROP_RightBorder ); applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesTop, PROP_TopBorder ); @@ -414,6 +488,28 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesTopLeftToBottomRight, PROP_DiagonalTLBR ); applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesBottomLeftToTopRight, PROP_DiagonalBLTR ); + // Convert insideH to Top and Bottom, InsideV to Left and Right. Exclude the outer borders. + if(nRow != 0) + { + aLinePropertiesInsideH.assignUsed( aLinePropertiesTop ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideH, PROP_TopBorder ); + } + if(nRow != nMaxRow) + { + aLinePropertiesInsideH.assignUsed( aLinePropertiesBottom ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideH, PROP_BottomBorder ); + } + if(nColumn != 0) + { + aLinePropertiesInsideV.assignUsed( aLinePropertiesLeft ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideV, PROP_LeftBorder ); + } + if(nColumn != nMaxColumn) + { + aLinePropertiesInsideV.assignUsed( aLinePropertiesRight ); + applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideV, PROP_RightBorder ); + } + if (rProperties.getBgColor().isUsed() && !maFillProperties.maFillColor.isUsed() && maFillProperties.moFillType.get() == XML_noFill) { maFillProperties.moFillType = XML_solidFill; diff --git a/oox/source/drawingml/table/tableproperties.cxx b/oox/source/drawingml/table/tableproperties.cxx index 07f670df1976..38f655af1e5c 100644 --- a/oox/source/drawingml/table/tableproperties.cxx +++ b/oox/source/drawingml/table/tableproperties.cxx @@ -141,7 +141,8 @@ void TableProperties::pushToPropSet(const ::oox::core::XmlFilterBase& rFilterBas { sal_Int32 nColumn = 0; sal_Int32 nColumnSize = tableRow.getTableCells().size(); - sal_Int32 nRemovedColumn = 0; // + sal_Int32 nRemovedColumn = 0; + sal_Int32 nRemovedRow = 0; for (sal_Int32 nColIndex = 0; nColIndex < nColumnSize; nColIndex++) { @@ -167,6 +168,9 @@ void TableProperties::pushToPropSet(const ::oox::core::XmlFilterBase& rFilterBas // props with pushToXCell. bMerged = true; } + + if (rTableCell.getRowSpan() > 1) + nRemovedRow = (rTableCell.getRowSpan() - 1); } Reference<XCellRange> xCellRange(xTable, UNO_QUERY_THROW); @@ -188,11 +192,17 @@ void TableProperties::pushToPropSet(const ::oox::core::XmlFilterBase& rFilterBas else xCell = xCellRange->getCellByPosition(nColumn, nRow); + + sal_Int32 nMaxCol = tableRow.getTableCells().size() - nRemovedColumn - 1; + sal_Int32 nMaxRow = mvTableRows.size() - nRemovedRow - 1; + rTableCell.pushToXCell(rFilterBase, pMasterTextListStyle, xCell, *this, rTableStyle, - nColumn, tableRow.getTableCells().size() - 1, nRow, - mvTableRows.size() - 1); + nColumn, nMaxCol, nRow, nMaxRow); + if (bMerged) nColumn += nRemovedColumn; + + nRemovedRow = 0; } ++nColumn; } |