tdf#127237 fix table background color in Impress import

When the background color is set at the table level in PPTX,
instead of at cell level, the background color fails to
show up in Impress.

Change-Id: I2838e5b56e4a2414494ee99c0f8975b7256ac6dc
Reviewed-on: https://gerrit.libreoffice.org/78377
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/oox/inc/drawingml/table/tableproperties.hxx b/oox/inc/drawingml/table/tableproperties.hxx
index dd50cd7..010fc67 100644
--- a/oox/inc/drawingml/table/tableproperties.hxx
+++ b/oox/inc/drawingml/table/tableproperties.hxx
@@ -54,6 +54,7 @@ public:
    void                                setBandRow(bool b)  { mbBandRow = b; };
    bool                                isBandCol() const   { return mbBandCol; };
    void                                setBandCol(bool b)  { mbBandCol = b; };
    Color&                              getBgColor(){ return maBgColor; };

    void pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase,
        const css::uno::Reference < css::beans::XPropertySet > & xPropSet,
@@ -70,6 +71,7 @@ private:
    std::shared_ptr< TableStyle >       mpTableStyle;           // or the complete TableStyle
    std::vector< sal_Int32 >            mvTableGrid;
    std::vector< TableRow >             mvTableRows;
    Color                               maBgColor;

    bool                                mbFirstRow;
    bool                                mbFirstCol;
diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx
index 48f73b2..24e1a5f 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -424,6 +424,12 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons
    applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesTopLeftToBottomRight, PROP_DiagonalTLBR );
    applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesBottomLeftToTopRight, PROP_DiagonalBLTR );

    if (rProperties.getBgColor().isUsed() && !maFillProperties.maFillColor.isUsed() && maFillProperties.moFillType.get() == XML_noFill)
    {
        maFillProperties.moFillType = XML_solidFill;
        maFillProperties.maFillColor = rProperties.getBgColor();
    }

    aFillProperties.assignUsed( maFillProperties );
    ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper() );

diff --git a/oox/source/drawingml/table/tablecontext.cxx b/oox/source/drawingml/table/tablecontext.cxx
index 3371e10..90191f6 100644
--- a/oox/source/drawingml/table/tablecontext.cxx
+++ b/oox/source/drawingml/table/tablecontext.cxx
@@ -57,6 +57,8 @@ TableContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& r
            mrTableProperties.setBandCol( rAttribs.getBool( XML_bandCol, false ) );
        }
        break;
    case A_TOKEN(solidFill):
        return new ColorContext(*this, mrTableProperties.getBgColor());
    case A_TOKEN( tableStyle ):         // CT_TableStyle
        {
            std::shared_ptr< TableStyle >& rTableStyle = mrTableProperties.getTableStyle();
diff --git a/oox/source/drawingml/table/tableproperties.cxx b/oox/source/drawingml/table/tableproperties.cxx
index b6d8bf3..b58439e 100644
--- a/oox/source/drawingml/table/tableproperties.cxx
+++ b/oox/source/drawingml/table/tableproperties.cxx
@@ -49,6 +49,7 @@ TableProperties::TableProperties()
, mbBandRow( false )
, mbBandCol( false )
{
    maBgColor.setUnused();
}

static void CreateTableRows( const uno::Reference< XTableRows >& xTableRows, const std::vector< TableRow >& rvTableRows )
diff --git a/sd/qa/unit/data/pptx/tdf127237.pptx b/sd/qa/unit/data/pptx/tdf127237.pptx
new file mode 100644
index 0000000..f63423c
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf127237.pptx
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index 79b18b7..769bf6e 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -55,6 +55,7 @@ class SdOOXMLExportTest1 : public SdModelTestBaseXML
{
public:
    void testFdo90607();
    void testTdf127237();
    void testBnc870233_1();
    void testBnc870233_2();
    void testN828390_4();
@@ -93,6 +94,7 @@ public:
    CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);

    CPPUNIT_TEST(testFdo90607);
    CPPUNIT_TEST(testTdf127237);
    CPPUNIT_TEST(testBnc870233_1);
    CPPUNIT_TEST(testBnc870233_2);
    CPPUNIT_TEST(testN828390_4);
@@ -180,6 +182,26 @@ void checkFontAttributes( const SdrTextObj* pObj, ItemValue nVal)

}

void SdOOXMLExportTest1::testTdf127237()
{
    sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf127237.pptx"), PPTX );
    xDocShRef = saveAndReload(xDocShRef.get(), ODP);

    const SdrPage* pPage = GetPage(1, xDocShRef);
    CPPUNIT_ASSERT(pPage != nullptr);

    sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
    CPPUNIT_ASSERT(pTableObj != nullptr);
    uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);

    sal_Int32 nFillColor = 0;
    uno::Reference< beans::XPropertySet > xCell(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
    xCell->getPropertyValue("FillColor") >>= nFillColor;
    CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0070C0), nFillColor);

    xDocShRef->DoClose();
}

void SdOOXMLExportTest1::testBnc870233_1()
{
    ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_1.pptx"), PPTX);