summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-01-06 19:56:03 +0100
committerLászló Németh <nemeth@numbertext.org>2020-01-07 13:50:33 +0100
commitb71cace906bdce1d1b02b11a2d469e93622fd3af (patch)
treeebbd004db66a85530a539ffe5d39fac9a05dfd9e /writerfilter
parent4d2a95f6d296c871533db536a43492534a4e2f8c (diff)
tdf#77796 DOCX: import table style based cell padding
Change-Id: Ib86ed45fe816d7e273539798cdebdbb95d575518 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86295 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx26
-rw-r--r--writerfilter/source/dmapper/TblStylePrHandler.cxx22
2 files changed, 48 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 77bf9e3f901a..9f376b3c07e8 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -464,6 +464,32 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
m_aTableProperties->Erase( aTblLook->first );
}
+ // apply cell margin settings of the table style
+ const o3tl::optional<PropertyMap::Property> oLeftMargin = m_aTableProperties->getProperty(META_PROP_CELL_MAR_LEFT);
+ if (oLeftMargin)
+ {
+ oLeftMargin->second >>= rInfo.nLeftBorderDistance;
+ m_aTableProperties->Erase(oLeftMargin->first);
+ }
+ const o3tl::optional<PropertyMap::Property> oRightMargin = m_aTableProperties->getProperty(META_PROP_CELL_MAR_RIGHT);
+ if (oRightMargin)
+ {
+ oRightMargin->second >>= rInfo.nRightBorderDistance;
+ m_aTableProperties->Erase(oRightMargin->first);
+ }
+ const o3tl::optional<PropertyMap::Property> oTopMargin = m_aTableProperties->getProperty(META_PROP_CELL_MAR_TOP);
+ if (oTopMargin)
+ {
+ oTopMargin->second >>= rInfo.nTopBorderDistance;
+ m_aTableProperties->Erase(oTopMargin->first);
+ }
+ const o3tl::optional<PropertyMap::Property> oBottomMargin = m_aTableProperties->getProperty(META_PROP_CELL_MAR_BOTTOM);
+ if (oBottomMargin)
+ {
+ oBottomMargin->second >>= rInfo.nBottomBorderDistance;
+ m_aTableProperties->Erase(oBottomMargin->first);
+ }
+
// Set the table default attributes for the cells
rInfo.pTableDefaults->InsertProps(m_aTableProperties.get());
diff --git a/writerfilter/source/dmapper/TblStylePrHandler.cxx b/writerfilter/source/dmapper/TblStylePrHandler.cxx
index 674bb5bd2250..beff017d19a8 100644
--- a/writerfilter/source/dmapper/TblStylePrHandler.cxx
+++ b/writerfilter/source/dmapper/TblStylePrHandler.cxx
@@ -18,6 +18,7 @@
*/
#include "TblStylePrHandler.hxx"
+#include "CellMarginHandler.hxx"
#include "PropertyMap.hxx"
#include <ooxml/resourceids.hxx>
#include <comphelper/sequence.hxx>
@@ -168,6 +169,27 @@ void TblStylePrHandler::lcl_sprm(Sprm & rSprm)
aValue.Value <<= true;
m_aInteropGrabBag.push_back(aValue);
}
+ break;
+ case NS_ooxml::LN_CT_TblPrBase_tblCellMar:
+ {
+ writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
+ if ( pProperties.get() )
+ {
+ std::shared_ptr<CellMarginHandler> pCellMarginHandler(new CellMarginHandler);
+ pCellMarginHandler->enableInteropGrabBag("tblCellMar");
+ pProperties->resolve( *pCellMarginHandler );
+ m_aInteropGrabBag.push_back(pCellMarginHandler->getInteropGrabBag());
+
+ if( pCellMarginHandler->m_bTopMarginValid )
+ m_pProperties->Insert( META_PROP_CELL_MAR_TOP, uno::makeAny(pCellMarginHandler->m_nTopMargin) );
+ if( pCellMarginHandler->m_bBottomMarginValid )
+ m_pProperties->Insert( META_PROP_CELL_MAR_BOTTOM, uno::makeAny(pCellMarginHandler->m_nBottomMargin) );
+ if( pCellMarginHandler->m_bLeftMarginValid )
+ m_pProperties->Insert( META_PROP_CELL_MAR_LEFT, uno::makeAny(pCellMarginHandler->m_nLeftMargin) );
+ if( pCellMarginHandler->m_bRightMarginValid )
+ m_pProperties->Insert( META_PROP_CELL_MAR_RIGHT, uno::makeAny(pCellMarginHandler->m_nRightMargin) );
+ }
+ }
break;
default:
// Tables specific properties have to handled here