diff options
author | Justin Luth <justin_luth@sil.org> | 2018-08-17 14:35:51 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-08-28 18:29:22 +0200 |
commit | e7d3e0b101ff25bb7edd49df61e330ccb4b75a24 (patch) | |
tree | 9fae607411463ae2a8db1ee65835a67e0c14025e /sw/source/filter/ww8 | |
parent | 029951e6d3636d99b370568313b8b5c2da8b452d (diff) |
tdf#116436 docx 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 (even though LO docx import currently does),
so that value also needs to be written out into every cell.
Change-Id: Ib49fddf52758ff641428de747ea290d1fcb894f3
Reviewed-on: https://gerrit.libreoffice.org/59260
Reviewed-by: Justin Luth <justin_luth@sil.org>
Tested-by: Justin Luth <justin_luth@sil.org>
(cherry picked from commit 8cc753d54ad1834709c5802115580adf65def89e)
Reviewed-on: https://gerrit.libreoffice.org/59286
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/source/filter/ww8')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index c22ff5cdec4c..8529a06ad0bf 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3752,6 +3752,18 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t FSNS( XML_w, XML_val ), pJcVal, FSEND ); + // Output the table background color (although cell value still needs to be specified) + const SvxBrushItem *pColorProp = pTableFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND); + Color aColor = pColorProp ? pColorProp->GetColor() : COL_AUTO; + if ( aColor != COL_AUTO ) + { + OString sColor = msfilter::util::ConvertColor( aColor ); + m_pSerializer->singleElementNS( XML_w, XML_shd, + FSNS( XML_w, XML_fill ), sColor.getStr( ), + FSNS( XML_w, XML_val ), "clear", + FSEND ); + } + // Output the table borders TableDefaultBorders( pTableTextNodeInfoInner ); @@ -3814,12 +3826,25 @@ void DocxAttributeOutput::TableDefaultCellMargins( ww8::WW8TableNodeInfoInner::P void DocxAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { + const SwTable *pTable = pTableTextNodeInfoInner->getTable(); const SwTableBox *pTableBox = pTableTextNodeInfoInner->getTableBox( ); + const SwTableLine *pTableRow = pTableBox->GetUpper(); const SwFrameFormat *pFormat = pTableBox->GetFrameFormat( ); const SvxBrushItem *pColorProp = pFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND); Color aColor = pColorProp ? pColorProp->GetColor() : COL_AUTO; - OString sColor = msfilter::util::ConvertColor( aColor ); + + const SwFrameFormat *pRowFormat = pTableRow->GetFrameFormat( ); + const SvxBrushItem *pRowColorProp = pRowFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND); + if ( pRowColorProp && aColor == COL_AUTO) + aColor = pRowColorProp->GetColor(); + + const SwFrameFormat *pTableFormat = pTable->GetFrameFormat( ); + const SvxBrushItem *pTableColorProp = pTableFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND); + if ( pTableColorProp && aColor == COL_AUTO ) + aColor = pTableColorProp->GetColor(); + + const OString sColor = msfilter::util::ConvertColor( aColor ); std::map<OUString, css::uno::Any> aGrabBag = pFormat->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG)->GetGrabBag(); |