From 87d0df65a93db4d720e25e8ef5da4068380b5c58 Mon Sep 17 00:00:00 2001 From: Matus Uzak Date: Mon, 22 Feb 2016 15:54:35 +0100 Subject: tdf#62255,tdf#92058: PPTX import: Incorrect inheritance of default table style The default table style defined in tableStyles.xml file can be used when a table is initially inserted into a document. It must not be applied by default to any of the tables not referencing a table style explicitly from the tableStyleId element. Change-Id: I025cdfba352c87a32f9a1e297fbc8b9fc2c8c0a4 Reviewed-on: https://gerrit.libreoffice.org/22619 Reviewed-by: Katarina Behrens Tested-by: Katarina Behrens --- oox/source/drawingml/table/tableproperties.cxx | 5 +++-- sd/qa/unit/data/pptx/tdf62255.pptx | Bin 0 -> 31427 bytes sd/qa/unit/import-tests.cxx | 26 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 sd/qa/unit/data/pptx/tdf62255.pptx diff --git a/oox/source/drawingml/table/tableproperties.cxx b/oox/source/drawingml/table/tableproperties.cxx index d639c7c4de66..048e4204ec34 100644 --- a/oox/source/drawingml/table/tableproperties.cxx +++ b/oox/source/drawingml/table/tableproperties.cxx @@ -226,10 +226,11 @@ const TableStyle& TableProperties::getUsedTableStyle( const ::oox::core::XmlFilt TableStyle* pTableStyle = nullptr; if ( mpTableStyle ) pTableStyle = &*mpTableStyle; - else if ( rBase.getTableStyles() ) + else if ( !getStyleId().isEmpty() && rBase.getTableStyles() ) { const std::vector< TableStyle >& rTableStyles( rBase.getTableStyles()->getTableStyles() ); - const OUString aStyleId( getStyleId().isEmpty() ? rBase.getTableStyles()->getDefaultStyleId() : getStyleId() ); + const OUString aStyleId( getStyleId() ); + std::vector< TableStyle >::const_iterator aIter( rTableStyles.begin() ); while( aIter != rTableStyles.end() ) { diff --git a/sd/qa/unit/data/pptx/tdf62255.pptx b/sd/qa/unit/data/pptx/tdf62255.pptx new file mode 100644 index 000000000000..fc06a9ea7b4c Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf62255.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 8c53d6b41b36..c7e4f00d3df1 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -108,6 +108,7 @@ public: void testRowHeight(); void testTdf93830(); void testTdf93097(); + void testTdf62255(); CPPUNIT_TEST_SUITE(SdImportTest); @@ -150,6 +151,7 @@ public: CPPUNIT_TEST(testRowHeight); CPPUNIT_TEST(testTdf93830); CPPUNIT_TEST(testTdf93097); + CPPUNIT_TEST(testTdf62255); CPPUNIT_TEST_SUITE_END(); }; @@ -1166,6 +1168,30 @@ void SdImportTest::testTdf93097() xDocShRef->DoClose(); } +void SdImportTest::testTdf62255() +{ + sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/tdf62255.pptx"), PPTX); + const SdrPage *pPage = GetPage( 1, xDocShRef ); + + sdr::table::SdrTableObj *pTableObj; + pTableObj = dynamic_cast(pPage->GetObj(0)); + CPPUNIT_ASSERT( pTableObj ); + + css::uno::Any aAny; + uno::Reference< table::XCellRange > xTable; + uno::Reference< beans::XPropertySet > xCell; + xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW); + xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW); + aAny = xCell->getPropertyValue("FillStyle"); + + if (aAny.hasValue()) + { + drawing::FillStyle aFillStyle; + aAny >>= aFillStyle; + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, aFillStyle); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit v1.2.3