oox/source/export/shapes.cxx | 14 +++++++++++ sd/qa/unit/data/pptx/n90223.pptx |binary sd/qa/unit/export-tests.cxx | 46 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-)
New commits: commit 636c5a63d67b52b0d2f9f21a863c45eca6ac9ff7 Author: yogesh.bharate001 <yogesh.bhar...@synerzip.com> Date: Thu Mar 26 10:48:15 2015 +0530 tdf#90223:PPTX table cell left and right margin is not exported. Problem Description : - After roundtripping, when we open .pptx in MSO2010 or LibreOffice, tcPr marL & marR values doesnot exported. - Due to this cell text formatting changes. XML difference: Original : <a:tcPr marL="45720" marR="45720"> After RT : <a:tcPr/> Solution : Added support for table cell left and right margin. Conflicts: sd/qa/unit/export-tests.cxx Change-Id: I45f7b796155fd4445acbf19133954aadaf70890d Reviewed-on: https://gerrit.libreoffice.org/15015 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index c95f99c..7caf3e9 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1028,7 +1028,19 @@ void ShapeExport::WriteTable( Reference< XShape > rXShape ) void ShapeExport::WriteTableCellProperties(Reference< XPropertySet> xCellPropSet) { - mpFS->startElementNS( XML_a, XML_tcPr, FSEND ); + sal_Int32 nLeftMargin(0), nRightMargin(0); + + Any aLeftMargin = xCellPropSet->getPropertyValue("TextLeftDistance"); + aLeftMargin >>= nLeftMargin; + + Any aRightMargin = xCellPropSet->getPropertyValue("TextRightDistance"); + aRightMargin >>= nRightMargin; + + mpFS->startElementNS( XML_a, XML_tcPr, + XML_marL, nLeftMargin > 0 ? I32S( oox::drawingml::convertHmmToEmu( nLeftMargin ) ) : NULL, + XML_marR, nRightMargin > 0 ? I32S( oox::drawingml::convertHmmToEmu( nRightMargin ) ): NULL, + FSEND ); + // Write background fill for table cell. DrawingML::WriteFill(xCellPropSet); // TODO diff --git a/sd/qa/unit/data/pptx/n90223.pptx b/sd/qa/unit/data/pptx/n90223.pptx new file mode 100755 index 0000000..0a9ee82 Binary files /dev/null and b/sd/qa/unit/data/pptx/n90223.pptx differ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 60a209b..8472ce1 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -24,6 +24,8 @@ #include <editeng/postitem.hxx> #include <editeng/bulletitem.hxx> +#include <oox/drawingml/drawingmltypes.hxx> + #include <rsc/rscsfx.hxx> #include <svx/svdoutl.hxx> @@ -57,6 +59,8 @@ #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/drawing/FillStyle.hpp> #include <svx/svdotable.hxx> +#include <com/sun/star/table/XTable.hpp> +#include <com/sun/star/table/XMergeableCell.hpp> #include <config_features.h> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> @@ -86,6 +90,8 @@ public: void testTableCellFillProperties(); void testBulletStartNumber(); void testLineStyle(); + void testCellLeftAndRightMargin(); + #if !defined WNT void testBnc822341(); #endif @@ -111,6 +117,7 @@ public: CPPUNIT_TEST(testTableCellFillProperties); CPPUNIT_TEST(testBulletStartNumber); CPPUNIT_TEST(testLineStyle); + CPPUNIT_TEST(testCellLeftAndRightMargin); #if !defined WNT CPPUNIT_TEST(testBnc822341); #endif @@ -868,6 +875,45 @@ void SdExportTest::testBnc822341() #endif +void SdExportTest::testCellLeftAndRightMargin() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("sd/qa/unit/data/pptx/n90223.pptx"), PPTX); + xDocShRef = saveAndReload( xDocShRef, PPTX ); + sal_Int32 nLeftMargin, nRightMargin; + + uno::Reference< drawing::XDrawPagesSupplier > xDoc( + xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW ); + + uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW ); + 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< com::sun::star::table::XTable > xTable (pTableObj->getTable(), uno::UNO_QUERY_THROW); + uno::Reference< com::sun::star::table::XMergeableCell > xCell( xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xCellPropSet(xCell, uno::UNO_QUERY_THROW); + + uno::Any aLeftMargin = xCellPropSet->getPropertyValue("TextLeftDistance"); + aLeftMargin >>= nLeftMargin ; + + uno::Any aRightMargin = xCellPropSet->getPropertyValue("TextRightDistance"); + aRightMargin >>= nRightMargin ; + + // Convert values to EMU + nLeftMargin = oox::drawingml::convertHmmToEmu( nLeftMargin ); + nRightMargin = oox::drawingml::convertHmmToEmu( nRightMargin ); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(45720), nLeftMargin); + CPPUNIT_ASSERT_EQUAL(sal_Int32(45720), nRightMargin); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); CPPUNIT_PLUGIN_IMPLEMENT();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits