diff options
author | László Németh <nemeth@numbertext.org> | 2021-01-25 15:48:46 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-01-26 13:06:14 +0100 |
commit | 9e21215d45b2eea31019711282445580fad0d753 (patch) | |
tree | ccc2fc544bf1366f68e8a6d770bc8e80d57e9349 | |
parent | d4d87c35e7e166cc6df92aa5be83eb3a65c2d02a (diff) |
tdf#137655 DOCX table import: fix zero para top margin
when only w:beforeAutospacing=0 was specified, but not
PARA_TOP_MARGIN (see default_spacing = -1 in processing
of LN_CT_Spacing_beforeAutospacing).
Follow-up of commit 61821277ed4974debd05af89cb7284602512088f
(tdf#104354 writerfilter: rewrite Autospacing).
Change-Id: I5fff7a8b62450ebaf8ef6b552ecbb2b1cfb24381
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109914
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf137655.docx | bin | 0 -> 33098 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 18 |
3 files changed, 23 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf137655.docx b/sw/qa/extras/ooxmlexport/data/tdf137655.docx Binary files differnew file mode 100644 index 000000000000..d87d434b324d --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf137655.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 936c7d03d348..a74bc0eed6a0 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -546,6 +546,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf113258_noBeforeAutospacing, "tdf113258_noBeforeA getProperty<sal_Int32>(xShape->getStart(), "ParaTopMargin")); } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf137655, "tdf137655.docx") +{ + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + // These were 280. + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:p[1]/w:pPr/w:spacing", "before", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:p[1]/w:pPr/w:spacing", "before", "0"); +} + DECLARE_OOXMLEXPORT_TEST(testTdf120511_eatenSection, "tdf120511_eatenSection.docx") { xmlDocUniquePtr pXmlDoc = parseLayoutDump(); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index a7d488b47a89..d0ed6bcb10b2 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1542,12 +1542,23 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con const bool bAllowAdjustments = !GetSettingsTable()->GetDoNotUseHTMLParagraphAutoSpacing(); sal_Int32 nBeforeAutospacing = -1; bool bIsAutoSet = pParaContext && pParaContext->isSet(PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING); + bool bIsZeroAutospacingWithoutTopmargin = false; + const bool bNoTopmargin = pParaContext && !pParaContext->isSet(PROP_PARA_TOP_MARGIN); // apply INHERITED autospacing only if top margin is not set - if ( bIsAutoSet || (pParaContext && !pParaContext->isSet(PROP_PARA_TOP_MARGIN)) ) + if ( bIsAutoSet || bNoTopmargin ) + { GetAnyProperty(PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING, pPropertyMap) >>= nBeforeAutospacing; + // tdf#137655 only w:beforeAutospacing=0 was specified, but not PARA_TOP_MARGIN + // (see default_spacing = -1 in processing of LN_CT_Spacing_beforeAutospacing) + if ( bNoTopmargin && nBeforeAutospacing == ConversionHelper::convertTwipToMM100(-1) ) + { + nBeforeAutospacing = 0; + bIsZeroAutospacingWithoutTopmargin = true; + } + } if ( nBeforeAutospacing > -1 && pParaContext ) { - if ( bAllowAdjustments ) + if ( bAllowAdjustments && !bIsZeroAutospacingWithoutTopmargin ) { if ( GetIsFirstParagraphInShape() || (GetIsFirstParagraphInSection() && GetSectionContext() && GetSectionContext()->IsFirstSection()) || @@ -1559,7 +1570,8 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con pParaContext->Insert( PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING, uno::makeAny( sal_Int32(0) ),true, PARA_GRAB_BAG ); } } - pParaContext->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny(nBeforeAutospacing)); + if ( !bIsZeroAutospacingWithoutTopmargin || (m_nTableDepth > 0 && m_nTableDepth == m_nTableCellDepth) ) + pParaContext->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny(nBeforeAutospacing)); } sal_Int32 nAfterAutospacing = -1; |