[Libreoffice-commits] core.git: sw/qa writerfilter/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jan 7 12:51:09 UTC 2020
sw/qa/extras/ooxmlexport/data/tdf77796.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 12 ++++++
writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 26 +++++++++++++++
writerfilter/source/dmapper/TblStylePrHandler.cxx | 22 ++++++++++++
4 files changed, 60 insertions(+)
New commits:
commit b71cace906bdce1d1b02b11a2d469e93622fd3af
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Mon Jan 6 19:56:03 2020 +0100
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Tue Jan 7 13:50:33 2020 +0100
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 at numbertext.org>
Tested-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf77796.docx b/sw/qa/extras/ooxmlexport/data/tdf77796.docx
new file mode 100644
index 000000000000..e42c37daa384
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf77796.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 216cdec15c3c..9e277928a8fb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -259,6 +259,18 @@ DECLARE_OOXMLEXPORT_TEST(testTdf129353, "tdf129353.docx")
aIndexString);
}
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf77796, "tdf77796.docx")
+{
+ xmlDocPtr pXml = parseExport("word/document.xml");
+ CPPUNIT_ASSERT(pXml);
+ // cell paddings from table style
+ assertXPath(pXml, "/w:document/w:body/w:tbl/w:tblPr/w:tblCellMar/w:start", "w", "5");
+ assertXPath(pXml, "/w:document/w:body/w:tbl/w:tblPr/w:tblCellMar/w:top", "w", "240");
+ assertXPath(pXml, "/w:document/w:body/w:tbl/w:tblPr/w:tblCellMar/w:bottom", "w", "480");
+ // not modified
+ assertXPath(pXml, "/w:document/w:body/w:tbl/w:tblPr/w:tblCellMar/w:end", "w", "108");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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>
@@ -167,6 +168,27 @@ void TblStylePrHandler::lcl_sprm(Sprm & rSprm)
aValue.Name = "tblHeader";
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:
More information about the Libreoffice-commits
mailing list