libreoffice/bsc1192616.patch
2022-04-14 06:51:23 +00:00

437 lines
21 KiB
Diff

From d2a2d16b4836bf62db7c32faffa0c5b6d0d30a5e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCl=C5=9Fah=20K=C3=B6se?= <gulsah.kose@collabora.com>
Date: Mon, 11 Apr 2022 18:33:30 +0300
Subject: [PATCH] Revert "Revert "tdf#135843 Implement inside horizontal
vertical borders.""
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit ea5a3e0247b1230c1fe7e2cb0afc597e56d0b4c2.
Change-Id: Ibd333c1e7b1530a2b6d9b8c5efbf4d9c822fa058
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132885
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
---
oox/inc/drawingml/table/tablecell.hxx | 2 +
oox/source/drawingml/table/tablecell.cxx | 112 ++++++++++++++++--
.../drawingml/table/tableproperties.cxx | 16 ++-
sd/qa/unit/data/pptx/bnc480256-2.pptx | Bin 0 -> 23387 bytes
sd/qa/unit/data/pptx/tdf135843_insideH.pptx | Bin 0 -> 33449 bytes
sd/qa/unit/import-tests.cxx | 2 +-
sd/qa/unit/layout-tests.cxx | 38 ++++++
7 files changed, 158 insertions(+), 12 deletions(-)
create mode 100644 sd/qa/unit/data/pptx/bnc480256-2.pptx
create mode 100644 sd/qa/unit/data/pptx/tdf135843_insideH.pptx
diff --git a/oox/inc/drawingml/table/tablecell.hxx b/oox/inc/drawingml/table/tablecell.hxx
index d6e91da042f7..988b0d057a13 100644
--- a/oox/inc/drawingml/table/tablecell.hxx
+++ b/oox/inc/drawingml/table/tablecell.hxx
@@ -82,6 +82,8 @@ private:
oox::drawingml::LineProperties maLinePropertiesRight;
oox::drawingml::LineProperties maLinePropertiesTop;
oox::drawingml::LineProperties maLinePropertiesBottom;
+ oox::drawingml::LineProperties maLinePropertiesInsideH;
+ oox::drawingml::LineProperties maLinePropertiesInsideV;
oox::drawingml::LineProperties maLinePropertiesTopLeftToBottomRight;
oox::drawingml::LineProperties maLinePropertiesBottomLeftToTopRight;
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 1622b8fc22ca..2c45004b3357 100644
--- a/oox/source/drawingml/table/tableproperties.cxx
+++ b/oox/source/drawingml/table/tableproperties.cxx
@@ -143,7 +143,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++)
{
@@ -169,6 +170,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);
@@ -190,11 +194,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;
}
--
2.34.1
From 6bf805ffb62a13f2f44a26f47f732f05c954ef49 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCl=C5=9Fah=20K=C3=B6se?= <gulsah.kose@collabora.com>
Date: Mon, 14 Mar 2022 14:52:59 +0300
Subject: [PATCH] tdf#147766 Export empty lines as line with noFill
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We have a case that 0 width line but has auto color. If that case
exported there is no line over there, LO handles normally but MSO draws
back borders as default. To prevent this we have to export them as line
with noFill.
testTableBorderLineStyle change reverts a workaround for
3faf005a367cbd28077403bf93810bbaf4805851
testBnc480256 Cell(1,0) still invisible. We are just checking
this with another way.
Change-Id: If5f6d2dbdba5c295d58307fcfe3b37629ede8a8e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131532
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132886
---
oox/source/drawingml/table/tablecell.cxx | 10 +---------
oox/source/export/shapes.cxx | 6 ++++++
sd/qa/unit/export-tests.cxx | 3 ++-
sd/qa/unit/import-tests.cxx | 2 +-
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx
index 15ab06303e3b..fdf7950dcf2c 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -73,20 +73,12 @@ static void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase,
aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 2 );
aBorderLine.LineDistance = 0;
}
- else if ( rLineProperties.moLineWidth.get(0)!=0 )
- {
- 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 = 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.LineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 2 );
aBorderLine.LineDistance = 0;
}
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 138106938ee2..97d09ca1be2e 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1975,6 +1975,12 @@ void ShapeExport::WriteBorderLine(const sal_Int32 XML_line, const BorderLine2& r
DrawingML::WriteSolidFill( ::Color(ColorTransparency, rBorderLine.Color) );
mpFS->endElementNS( XML_a, XML_line );
}
+ else if( nBorderWidth == 0)
+ {
+ mpFS->startElementNS(XML_a, XML_line);
+ mpFS->singleElementNS(XML_a, XML_noFill);
+ mpFS->endElementNS( XML_a, XML_line );
+ }
}
void ShapeExport::WriteTableCellBorders(const Reference< XPropertySet>& xCellPropSet)
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index f1d0281aab0d..729d9f154b12 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -602,9 +602,10 @@ void SdExportTest::testBnc480256()
xCell->getPropertyValue("FillColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0x4697e0), nColor);
+ // This border should be invisible.
xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("BottomBorder") >>= aBorderLine;
- CPPUNIT_ASSERT_EQUAL(COL_AUTO, Color(ColorTransparency, aBorderLine.Color));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), sal_Int32(aBorderLine.LineWidth));
xDocShRef->DoClose();
}
--
2.34.1