Kaydet (Commit) b576ab50 authored tarafından Justin Luth's avatar Justin Luth

tdf#116436 doc export: add missing table background fill

MS formats only have support for Table and Cell fill.

Interestingly, MS Word doesn't let the cells inherit from
the Table fill setting,
so that value also needs to be written out into every cell.

Since Word apparently ignores the table color, I didn't
bother trying to search out how to export that in DOC
format.  (I did add it to DOCX since it was so easy to find.)

Change-Id: I8946f07b45f72fed5959369182882a7bf013b1d0
Reviewed-on: https://gerrit.libreoffice.org/59281
Tested-by: Jenkins
Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
üst 8cc753d5
...@@ -67,6 +67,19 @@ DECLARE_WW8EXPORT_TEST(testTdf55528_relativeTableWidth, "tdf55528_relativeTableW ...@@ -67,6 +67,19 @@ DECLARE_WW8EXPORT_TEST(testTdf55528_relativeTableWidth, "tdf55528_relativeTableW
CPPUNIT_ASSERT_EQUAL_MESSAGE("Table relative width percent", sal_Int16(98), getProperty<sal_Int16>(xTable, "RelativeWidth")); CPPUNIT_ASSERT_EQUAL_MESSAGE("Table relative width percent", sal_Int16(98), getProperty<sal_Int16>(xTable, "RelativeWidth"));
} }
DECLARE_WW8EXPORT_TEST(testTdf116436_tableBackground, "tdf116436_tableBackground.odt")
{
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Reference<table::XCell> xCell = xTable->getCellByName("A1");
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xF8DF7C), getProperty<sal_Int32>(xCell, "BackColor"));
xCell.set(xTable->getCellByName("A6"));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x81D41A), getProperty<sal_Int32>(xCell, "BackColor"));
xCell.set(xTable->getCellByName("B6"));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFBCC), getProperty<sal_Int32>(xCell, "BackColor"));
}
DECLARE_WW8EXPORT_TEST(testTdf37153, "tdf37153_considerWrapOnObjPos.doc") DECLARE_WW8EXPORT_TEST(testTdf37153, "tdf37153_considerWrapOnObjPos.doc")
{ {
CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH, getProperty<text::WrapTextMode>(getShape(1), "Surround")); CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH, getProperty<text::WrapTextMode>(getShape(1), "Surround"));
......
...@@ -2582,6 +2582,7 @@ void WW8AttributeOutput::TableCellBorders( ...@@ -2582,6 +2582,7 @@ void WW8AttributeOutput::TableCellBorders(
void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
{ {
const SwTable * pTab = pTableTextNodeInfoInner->getTable();
const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
const SwTableLine * pTabLine = pTabBox->GetUpper(); const SwTableLine * pTabLine = pTabBox->GetUpper();
const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes(); const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes();
...@@ -2590,19 +2591,24 @@ void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t ...@@ -2590,19 +2591,24 @@ void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t
m_rWW8Export.InsUInt16( NS_sprm::sprmTDefTableShd80 ); m_rWW8Export.InsUInt16( NS_sprm::sprmTDefTableShd80 );
m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(nBoxes * 2) ); // Len m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(nBoxes * 2) ); // Len
Color aRowColor = COL_AUTO;
const SvxBrushItem *pTableColorProp = pTab->GetFrameFormat()->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
if ( pTableColorProp )
aRowColor = pTableColorProp->GetColor();
const SvxBrushItem *pRowColorProp = pTabLine->GetFrameFormat()->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
if ( pRowColorProp && pRowColorProp->GetColor() != COL_AUTO )
aRowColor = pRowColorProp->GetColor();
for ( sal_uInt8 n = 0; n < nBoxes; n++ ) for ( sal_uInt8 n = 0; n < nBoxes; n++ )
{ {
const SwTableBox * pBox1 = rTabBoxes[n]; const SwTableBox * pBox1 = rTabBoxes[n];
const SwFrameFormat * pFrameFormat = pBox1->GetFrameFormat(); const SwFrameFormat * pFrameFormat = pBox1->GetFrameFormat();
const SfxPoolItem * pI = nullptr; Color aColor = aRowColor;
Color aColor;
if ( SfxItemState::SET == pFrameFormat->GetAttrSet().GetItemState( RES_BACKGROUND, false, &pI ) ) const SvxBrushItem *pCellColorProp = pFrameFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
{ if ( pCellColorProp && pCellColorProp->GetColor() != COL_AUTO )
aColor = dynamic_cast<const SvxBrushItem *>(pI)->GetColor(); aColor = pCellColorProp->GetColor();
}
else
aColor = COL_AUTO;
WW8_SHD aShd; WW8_SHD aShd;
WW8Export::TransBrush( aColor, aShd ); WW8Export::TransBrush( aColor, aShd );
...@@ -2624,17 +2630,11 @@ void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t ...@@ -2624,17 +2630,11 @@ void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t
{ {
const SwTableBox * pBox1 = rTabBoxes[n]; const SwTableBox * pBox1 = rTabBoxes[n];
const SwFrameFormat * pFrameFormat = pBox1->GetFrameFormat(); const SwFrameFormat * pFrameFormat = pBox1->GetFrameFormat();
const SfxPoolItem * pI = nullptr; Color aColor = aRowColor;
Color aColor;
if ( SfxItemState::SET == const SvxBrushItem *pCellColorProp = pFrameFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
pFrameFormat->GetAttrSet(). if ( pCellColorProp && pCellColorProp->GetColor() != COL_AUTO )
GetItemState( RES_BACKGROUND, false, &pI ) ) aColor = pCellColorProp->GetColor();
{
aColor = dynamic_cast<const SvxBrushItem *>(pI)->GetColor();
}
else
aColor = COL_AUTO;
WW8SHDLong aSHD; WW8SHDLong aSHD;
aSHD.setCvFore( 0xFF000000 ); aSHD.setCvFore( 0xFF000000 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment