include/oox/export/shapes.hxx | 1 oox/source/export/shapes.cxx | 15 ++++++- sd/qa/unit/data/odp/Table_with_Cell_Fill.odp |binary sd/qa/unit/export-tests.cxx | 55 +++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-)
New commits: commit 63442ec636d637e05d7d585817df531dbbeb96d9 Author: Sushil Shinde <sushil.shi...@synerzip.com> Date: Tue Mar 3 19:14:25 2015 +0530 tdf#89806 : Fixed background fill export for table cell. 1. Table cell properties were exproted empty if file saved as .pptx file. 2. Now added code to export table cell fill properties in 'tcPr'(Table cell properties xml tag) 3. Added unit test to check exported table cell fill properties. Change-Id: Ica6005a65c7eefb8629c808f2a54764f98badb11 Reviewed-on: https://gerrit.libreoffice.org/14734 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: David Tardon <dtar...@redhat.com> Tested-by: David Tardon <dtar...@redhat.com> diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx index bca9ca6..7b5afb0 100644 --- a/include/oox/export/shapes.hxx +++ b/include/oox/export/shapes.hxx @@ -160,6 +160,7 @@ public: void WriteTable( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rXShape ); + void WriteTableCellProperties(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet); sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape ); sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape, ::oox::core::XmlFilterBase* pFB ); diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 4ef0838..95b0b37 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1004,7 +1004,9 @@ void ShapeExport::WriteTable( Reference< XShape > rXShape ) WriteTextBox( xCell, XML_a ); - mpFS->singleElementNS( XML_a, XML_tcPr, FSEND ); + Reference< XPropertySet > xCellPropSet(xCell, UNO_QUERY_THROW); + WriteTableCellProperties(xCellPropSet); + mpFS->endElementNS( XML_a, XML_tc ); } } @@ -1019,6 +1021,17 @@ void ShapeExport::WriteTable( Reference< XShape > rXShape ) mpFS->endElementNS( XML_a, XML_graphic ); } +void ShapeExport::WriteTableCellProperties(Reference< XPropertySet> xCellPropSet) +{ + mpFS->startElementNS( XML_a, XML_tcPr, FSEND ); + // Write background fill for table cell. + DrawingML::WriteFill(xCellPropSet); + // TODO + // tcW : Table cell width + // tcBorders : Table cell border values. + mpFS->endElementNS( XML_a, XML_tcPr ); +} + ShapeExport& ShapeExport::WriteTableShape( Reference< XShape > xShape ) { FSHelperPtr pFS = GetFS(); diff --git a/sd/qa/unit/data/odp/Table_with_Cell_Fill.odp b/sd/qa/unit/data/odp/Table_with_Cell_Fill.odp new file mode 100644 index 0000000..1a06f23 Binary files /dev/null and b/sd/qa/unit/data/odp/Table_with_Cell_Fill.odp differ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index ed02bc9..d6645dd 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -55,6 +55,8 @@ #include <com/sun/star/awt/XBitmap.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> +#include <svx/svdotable.hxx> #include <config_features.h> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> @@ -81,6 +83,7 @@ public: void testSwappedOutImageExport(); void testLinkedGraphicRT(); void testImageWithSpecialID(); + void testTableCellFillProperties(); #if !defined WNT void testBnc822341(); #endif @@ -103,6 +106,7 @@ public: CPPUNIT_TEST(testSwappedOutImageExport); CPPUNIT_TEST(testLinkedGraphicRT); CPPUNIT_TEST(testImageWithSpecialID); + CPPUNIT_TEST(testTableCellFillProperties); #if !defined WNT CPPUNIT_TEST(testBnc822341); #endif @@ -725,6 +729,57 @@ void SdExportTest::testImageWithSpecialID() xDocShRef->DoClose(); } } +void SdExportTest::testTableCellFillProperties() +{ + std::shared_ptr< comphelper::ConfigurationChanges > batch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), batch); + batch->commit(); + + // Load the original file + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/Table_with_Cell_Fill.odp"), ODP); + + // Export the document and import again for a check + uno::Reference< lang::XComponent > xComponent(xDocShRef->GetModel(), uno::UNO_QUERY); + uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY); + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OStringToOUString(OString(aFileFormats[PPTX].pFilterName), RTL_TEXTENCODING_UTF8); + + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + xComponent.set(xStorable, uno::UNO_QUERY); + xComponent->dispose(); + xDocShRef = loadURL(aTempFile.GetURL(), PPTX); + + SdDrawDocument *pDoc = xDocShRef->GetDoc(); + CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); + const SdrPage *pPage = pDoc->GetPage(1); + CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); + + sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0)); + CPPUNIT_ASSERT( pTableObj ); + uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW); + uno::Reference< beans::XPropertySet > xCell; + + // Test Solid fill color + sal_Int32 nColor; + xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW); + xCell->getPropertyValue("FillColor") >>= nColor; + CPPUNIT_ASSERT_EQUAL(sal_Int32(6750207), nColor); + + // Test Picture fill type for cell + drawing::FillStyle aFillStyle( drawing::FillStyle_NONE ); + xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW); + xCell->getPropertyValue("FillStyle") >>= aFillStyle; + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, aFillStyle); + + // Test Gradient fill type for cell + xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW); + xCell->getPropertyValue("FillStyle") >>= aFillStyle; + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, aFillStyle); + + xDocShRef->DoClose(); +} #if !defined WNT _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits