[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sw/qa sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Aug 31 07:54:31 UTC 2018


 sw/qa/extras/rtfexport/data/tdf116436_tableBackground.odt |binary
 sw/qa/extras/rtfexport/rtfexport3.cxx                     |   16 ++++++++
 sw/source/filter/ww8/rtfattributeoutput.cxx               |   28 +++++++++++---
 3 files changed, 39 insertions(+), 5 deletions(-)

New commits:
commit 3d81af669ea0886fb16282d29048f08025ace344
Author:     Justin Luth <justin_luth at sil.org>
AuthorDate: Sat Aug 18 11:41:35 2018 +0300
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Fri Aug 31 09:54:06 2018 +0200

    tdf#116436 rtf 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 RTF
    format.  (I did add it to DOCX since it was so easy to find.)
    
    Change-Id: I7fe7723fb1603bc60608762aea79ff3b8122e073
    Reviewed-on: https://gerrit.libreoffice.org/59282
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 1a4bc964f15003c6aaec84989e3e47501b7f72df)
    Reviewed-on: https://gerrit.libreoffice.org/59667

diff --git a/sw/qa/extras/rtfexport/data/tdf116436_tableBackground.odt b/sw/qa/extras/rtfexport/data/tdf116436_tableBackground.odt
new file mode 100644
index 000000000000..1ae65f788d4b
Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf116436_tableBackground.odt differ
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx
index d27eec82fea9..45be1c450cb4 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -60,6 +60,22 @@ DECLARE_RTFEXPORT_TEST(testTdf108949_footnote, "tdf108949_footnote.rtf")
                                  getProperty<sal_Int32>(xFootnote->getAnchor(), "CharColor"));
 }
 
+DECLARE_RTFEXPORT_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");
+    if (mbExported)
+        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"));
+    if (mbExported)
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFBCC), getProperty<sal_Int32>(xCell, "BackColor"));
+}
+
 DECLARE_RTFEXPORT_TEST(testTdf104035, "tdf104035.rtf")
 {
     auto aTabStops = getProperty<uno::Sequence<style::TabStop>>(getParagraph(1), "ParaTabStops");
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 99b283f92e9c..edd2830bc6e9 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -727,6 +727,21 @@ void RtfAttributeOutput::TableDefaultBorders(
 void RtfAttributeOutput::TableBackgrounds(
     ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
 {
+    const SwTable* pTable = pTableTextNodeInfoInner->getTable();
+    const SwTableBox* pTableBox = pTableTextNodeInfoInner->getTableBox();
+    const SwTableLine* pTableLine = pTableBox->GetUpper();
+
+    Color aColor = COL_AUTO;
+    const SvxBrushItem* pTableColorProp
+        = pTable->GetFrameFormat()->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
+    if (pTableColorProp)
+        aColor = pTableColorProp->GetColor();
+
+    const SvxBrushItem* pRowColorProp
+        = pTableLine->GetFrameFormat()->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
+    if (pRowColorProp && pRowColorProp->GetColor() != COL_AUTO)
+        aColor = pRowColorProp->GetColor();
+
     const SwWriteTableRows& aRows = m_pTableWrt->GetRows();
     SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()];
     const SwWriteTableCell* const pCell
@@ -736,11 +751,14 @@ void RtfAttributeOutput::TableBackgrounds(
     if (pCellFormat->GetAttrSet().HasItem(RES_BACKGROUND, &pItem))
     {
         auto& rBack = static_cast<const SvxBrushItem&>(*pItem);
-        if (!rBack.GetColor().GetTransparency())
-        {
-            m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLCBPAT);
-            m_aRowDefs.append(static_cast<sal_Int32>(m_rExport.GetColor(rBack.GetColor())));
-        }
+        if (rBack.GetColor() != COL_AUTO)
+            aColor = rBack.GetColor();
+    }
+
+    if (!aColor.GetTransparency())
+    {
+        m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLCBPAT);
+        m_aRowDefs.append(static_cast<sal_Int32>(m_rExport.GetColor(aColor)));
     }
 }
 


More information about the Libreoffice-commits mailing list