summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSushil Shinde <sushil.shinde@synerzip.com>2015-03-03 19:14:25 +0530
committerDavid Tardon <dtardon@redhat.com>2015-03-20 08:13:00 +0000
commit63442ec636d637e05d7d585817df531dbbeb96d9 (patch)
tree7194425a0741d5be07c1c36533f1a9dc37ca47b0
parent5f904b2646771b5270efc59dd38bcf4122741c12 (diff)
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 <ci@libreoffice.org> Reviewed-by: David Tardon <dtardon@redhat.com> Tested-by: David Tardon <dtardon@redhat.com>
-rw-r--r--include/oox/export/shapes.hxx1
-rw-r--r--oox/source/export/shapes.cxx15
-rw-r--r--sd/qa/unit/data/odp/Table_with_Cell_Fill.odpbin0 -> 28869 bytes
-rw-r--r--sd/qa/unit/export-tests.cxx55
4 files changed, 70 insertions, 1 deletions
diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx
index bca9ca67ff4c..7b5afb01e62a 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 4ef0838f233f..95b0b37383ad 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 000000000000..1a06f235e1df
--- /dev/null
+++ b/sd/qa/unit/data/odp/Table_with_Cell_Fill.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index ed02bc99147b..d6645dd809e1 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