Kaydet (Commit) 63442ec6 authored tarafından Sushil Shinde's avatar Sushil Shinde Kaydeden (comit) David Tardon

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/14734Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst 5f904b26
...@@ -160,6 +160,7 @@ public: ...@@ -160,6 +160,7 @@ public:
void WriteTable( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rXShape ); 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 );
sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape, ::oox::core::XmlFilterBase* pFB ); sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape, ::oox::core::XmlFilterBase* pFB );
......
...@@ -1004,7 +1004,9 @@ void ShapeExport::WriteTable( Reference< XShape > rXShape ) ...@@ -1004,7 +1004,9 @@ void ShapeExport::WriteTable( Reference< XShape > rXShape )
WriteTextBox( xCell, XML_a ); 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 ); mpFS->endElementNS( XML_a, XML_tc );
} }
} }
...@@ -1019,6 +1021,17 @@ void ShapeExport::WriteTable( Reference< XShape > rXShape ) ...@@ -1019,6 +1021,17 @@ void ShapeExport::WriteTable( Reference< XShape > rXShape )
mpFS->endElementNS( XML_a, XML_graphic ); 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 ) ShapeExport& ShapeExport::WriteTableShape( Reference< XShape > xShape )
{ {
FSHelperPtr pFS = GetFS(); FSHelperPtr pFS = GetFS();
......
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
#include <com/sun/star/awt/XBitmap.hpp> #include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <svx/svdotable.hxx>
#include <config_features.h> #include <config_features.h>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
...@@ -81,6 +83,7 @@ public: ...@@ -81,6 +83,7 @@ public:
void testSwappedOutImageExport(); void testSwappedOutImageExport();
void testLinkedGraphicRT(); void testLinkedGraphicRT();
void testImageWithSpecialID(); void testImageWithSpecialID();
void testTableCellFillProperties();
#if !defined WNT #if !defined WNT
void testBnc822341(); void testBnc822341();
#endif #endif
...@@ -103,6 +106,7 @@ public: ...@@ -103,6 +106,7 @@ public:
CPPUNIT_TEST(testSwappedOutImageExport); CPPUNIT_TEST(testSwappedOutImageExport);
CPPUNIT_TEST(testLinkedGraphicRT); CPPUNIT_TEST(testLinkedGraphicRT);
CPPUNIT_TEST(testImageWithSpecialID); CPPUNIT_TEST(testImageWithSpecialID);
CPPUNIT_TEST(testTableCellFillProperties);
#if !defined WNT #if !defined WNT
CPPUNIT_TEST(testBnc822341); CPPUNIT_TEST(testBnc822341);
#endif #endif
...@@ -725,6 +729,57 @@ void SdExportTest::testImageWithSpecialID() ...@@ -725,6 +729,57 @@ void SdExportTest::testImageWithSpecialID()
xDocShRef->DoClose(); 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 #if !defined WNT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment