diff options
author | Tibor Nagy <nagy.tibor2@nisz.hu> | 2022-10-26 16:44:01 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2022-10-27 20:35:01 +0200 |
commit | d83a016823dceaeb48f34d4e94f9a230bebd9169 (patch) | |
tree | fcf8e453bb0b0e441a035d34ba8b898e63c86490 /oox | |
parent | ca482cf39f25941040596e50d0e1ab7fa25dc1dd (diff) |
tdf#151767 PPTX import: fix table border width
There is a "Clear Table" function in PP. In this case,
the table uses the default border value of MSO, which
was imported as missing table border.
(Note: commit ff0387e726b59e374029d2f635ce00308d99eff6
"tdf#135843: sd_export_tests-ooxml3: Add unittest for the
export part" If attachment from tdf#106011 is opened in
PowerPoint, the table is visible it, but was not in LO.
This patch fixed that. Therefore the borders of table are
not missing after export.)
Change-Id: I92dfe2e42f5f58b15af23cc24e931fb12d7c2794
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141880
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/table/predefined-table-styles.cxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablecell.cxx | 59 |
2 files changed, 39 insertions, 22 deletions
diff --git a/oox/source/drawingml/table/predefined-table-styles.cxx b/oox/source/drawingml/table/predefined-table-styles.cxx index 7d420038856a..531e20b14512 100644 --- a/oox/source/drawingml/table/predefined-table-styles.cxx +++ b/oox/source/drawingml/table/predefined-table-styles.cxx @@ -884,6 +884,8 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) // End to handle all style groups. // Create a TableStyle from handled properties. + pTableStyle->getStyleId() = styleId; + pTableStyle->getStyleName() = style_name; pTableStyle->getWholeTbl().getTextColor() = wholeTblTextColor; pTableStyle->getFirstRow().getTextColor() = firstRowTextColor; diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx index 77b69b8e4e3e..17b13526084d 100644 --- a/oox/source/drawingml/table/tablecell.cxx +++ b/oox/source/drawingml/table/tablecell.cxx @@ -61,26 +61,41 @@ TableCell::TableCell() { } -static void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase, - Reference< XPropertySet > const & rxPropSet, oox::drawingml::LineProperties const & rLineProperties, - sal_Int32 nPropId ) +static void applyLineAttributes(const ::oox::core::XmlFilterBase& rFilterBase, + Reference<XPropertySet> const& rxPropSet, + oox::drawingml::table::TableStyle const& rTableStyle, + oox::drawingml::LineProperties const& rLineProperties, + sal_Int32 nPropId) { BorderLine2 aBorderLine; - if ( rLineProperties.maLineFill.moFillType.has_value() && rLineProperties.maLineFill.moFillType.value() != XML_noFill ) + TableStyle& rTable(const_cast<TableStyle&>(rTableStyle)); + if (!rTable.getStyleId().isEmpty()) { Color aColor = rLineProperties.maLineFill.getBestSolidColor(); - aBorderLine.Color = sal_Int32(aColor.getColor( rFilterBase.getGraphicHelper() )); - aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.value_or( 0 ) ) / 4 ); - aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.value_or( 0 ) ) / 4 ); - aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.value_or( 0 ) ) / 2 ); + aBorderLine.Color = sal_Int32(aColor.getColor(rFilterBase.getGraphicHelper())); + aBorderLine.OuterLineWidth = static_cast<sal_Int16>(GetCoordinate(rLineProperties.moLineWidth.value_or(0)) / 4); + aBorderLine.InnerLineWidth = static_cast<sal_Int16>(GetCoordinate(rLineProperties.moLineWidth.value_or(0)) / 4); + aBorderLine.LineWidth = static_cast<sal_Int16>(GetCoordinate(rLineProperties.moLineWidth.value_or(0)) / 2); aBorderLine.LineDistance = 0; } else { - aBorderLine.Color = sal_Int32( COL_AUTO ); - aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.value_or( 0 ) ) / 4 ); - aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.value_or( 0 ) ) / 4 ); - aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.value_or( 0 ) ) / 2 ); + if (rLineProperties.maLineFill.moFillType.has_value()) + { + if (rLineProperties.maLineFill.moFillType.value() != XML_noFill) + { + Color aColor = rLineProperties.maLineFill.getBestSolidColor(); + aBorderLine.Color = sal_Int32(aColor.getColor(rFilterBase.getGraphicHelper())); + } + else + aBorderLine.Color = sal_Int32(COL_AUTO); + } + else + aBorderLine.Color = sal_Int32(COL_BLACK); + + aBorderLine.OuterLineWidth = static_cast<sal_Int16>(GetCoordinate(rLineProperties.moLineWidth.value_or(12700)) / 4); + aBorderLine.InnerLineWidth = static_cast<sal_Int16>(GetCoordinate(rLineProperties.moLineWidth.value_or(12700)) / 4); + aBorderLine.LineWidth = static_cast<sal_Int16>(GetCoordinate(rLineProperties.moLineWidth.value_or(12700)) / 2); aBorderLine.LineDistance = 0; } @@ -475,33 +490,33 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aLinePropertiesTopLeftToBottomRight.assignUsed( maLinePropertiesTopLeftToBottomRight ); aLinePropertiesBottomLeftToTopRight.assignUsed( maLinePropertiesBottomLeftToTopRight ); - applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesLeft, PROP_LeftBorder ); - applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesRight, PROP_RightBorder ); - applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesTop, PROP_TopBorder ); - applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesBottom, PROP_BottomBorder ); - applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesTopLeftToBottomRight, PROP_DiagonalTLBR ); - applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesBottomLeftToTopRight, PROP_DiagonalBLTR ); + applyLineAttributes( rFilterBase, xPropSet, rTable, aLinePropertiesLeft, PROP_LeftBorder ); + applyLineAttributes( rFilterBase, xPropSet, rTable, aLinePropertiesRight, PROP_RightBorder ); + applyLineAttributes( rFilterBase, xPropSet, rTable, aLinePropertiesTop, PROP_TopBorder ); + applyLineAttributes( rFilterBase, xPropSet, rTable, aLinePropertiesBottom, PROP_BottomBorder ); + applyLineAttributes( rFilterBase, xPropSet, rTable, aLinePropertiesTopLeftToBottomRight, PROP_DiagonalTLBR ); + applyLineAttributes( rFilterBase, xPropSet, rTable, 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 ); + applyLineAttributes( rFilterBase, xPropSet, rTable, aLinePropertiesInsideH, PROP_TopBorder ); } if(nRow != nMaxRow) { aLinePropertiesInsideH.assignUsed( aLinePropertiesBottom ); - applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideH, PROP_BottomBorder ); + applyLineAttributes( rFilterBase, xPropSet, rTable, aLinePropertiesInsideH, PROP_BottomBorder ); } if(nColumn != 0) { aLinePropertiesInsideV.assignUsed( aLinePropertiesLeft ); - applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideV, PROP_LeftBorder ); + applyLineAttributes( rFilterBase, xPropSet, rTable, aLinePropertiesInsideV, PROP_LeftBorder ); } if(nColumn != nMaxColumn) { aLinePropertiesInsideV.assignUsed( aLinePropertiesRight ); - applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideV, PROP_RightBorder ); + applyLineAttributes( rFilterBase, xPropSet, rTable, aLinePropertiesInsideV, PROP_RightBorder ); } if (rProperties.getBgColor().isUsed() && !maFillProperties.maFillColor.isUsed() && |