summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oox/inc/drawingml/table/tablecell.hxx2
-rw-r--r--oox/source/drawingml/table/tablecell.cxx112
-rw-r--r--oox/source/drawingml/table/tableproperties.cxx16
-rw-r--r--sd/qa/unit/data/pptx/bnc480256-2.pptxbin0 -> 23387 bytes
-rw-r--r--sd/qa/unit/data/pptx/tdf135843_insideH.pptxbin0 -> 33449 bytes
-rw-r--r--sd/qa/unit/import-tests.cxx2
-rw-r--r--sd/qa/unit/layout-tests.cxx38
7 files changed, 158 insertions, 12 deletions
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 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;
}
diff --git a/sd/qa/unit/data/pptx/bnc480256-2.pptx b/sd/qa/unit/data/pptx/bnc480256-2.pptx
new file mode 100644
index 000000000000..a622d77acef0
--- /dev/null
+++ b/sd/qa/unit/data/pptx/bnc480256-2.pptx
Binary files differ
diff --git a/sd/qa/unit/data/pptx/tdf135843_insideH.pptx b/sd/qa/unit/data/pptx/tdf135843_insideH.pptx
new file mode 100644
index 000000000000..9b7864adb325
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf135843_insideH.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 215d668b2f3f..26abc2ece38c 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -1456,7 +1456,7 @@ void SdImportTest::testTableBorderLineStyle()
xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("TopBorder") >>= aBorderLine;
- if (aBorderLine.LineWidth > 0) {
+ if (aBorderLine.Color != -1) {
CPPUNIT_ASSERT_EQUAL(nObjBorderLineStyles[i], aBorderLine.LineStyle);
}
}
diff --git a/sd/qa/unit/layout-tests.cxx b/sd/qa/unit/layout-tests.cxx
index 25c70341ea1c..d73771e56843 100644
--- a/sd/qa/unit/layout-tests.cxx
+++ b/sd/qa/unit/layout-tests.cxx
@@ -317,6 +317,44 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf146731)
xDocShRef->DoClose();
}
+CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf135843_InsideHBorders)
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(
+ m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf135843_insideH.pptx"), PPTX);
+
+ std::shared_ptr<GDIMetaFile> xMetaFile = xDocShRef->GetPreviewMetaFile();
+ MetafileXmlDump dumper;
+
+ xmlDocUniquePtr pXmlDoc = XmlTestTools::dumpAndParse(dumper, *xMetaFile);
+ CPPUNIT_ASSERT(pXmlDoc);
+ // Without the fix, the test fails with:
+ //- Expected: 34
+ //- Actual : 36
+ // We shouldn't see two vertical borders inside the table on ui.
+
+ assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push", 34);
+ xDocShRef->DoClose();
+}
+
+CPPUNIT_TEST_FIXTURE(SdLayoutTest, testBnc480256)
+{
+ sd::DrawDocShellRef xDocShRef
+ = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/bnc480256-2.pptx"), PPTX);
+
+ std::shared_ptr<GDIMetaFile> xMetaFile = xDocShRef->GetPreviewMetaFile();
+ MetafileXmlDump dumper;
+
+ xmlDocUniquePtr pXmlDoc = XmlTestTools::dumpAndParse(dumper, *xMetaFile);
+ CPPUNIT_ASSERT(pXmlDoc);
+ // Without the fix, the test fails with:
+ //- Expected: #ff0000
+ //- Actual : #ffffff
+ // We should see the red vertical border inside the table.
+
+ assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[8]/linecolor[1]", "color", "#ff0000");
+ xDocShRef->DoClose();
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */