diff options
author | László Németh <nemeth@numbertext.org> | 2018-07-17 19:46:22 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2018-07-18 08:55:01 +0200 |
commit | dc0300eac3b755bc207cd1fe87217f4ebaeb9f58 (patch) | |
tree | 9f93828a5f17d86872cb7ecbd64e9478caf8131a | |
parent | 99e626dee48e08d59304c8abe8abe84e7a99af3a (diff) |
tdf#118521 DOCX import: fix paragraph margin from paragraph style
when the other (top or bottom) margin was set by direct formatting.
Change-Id: Ic4038397329374fb2d6cf974751310f7dd8e8b31
Reviewed-on: https://gerrit.libreoffice.org/57585
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 00effcd10081..e89417e99468 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1415,6 +1415,31 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap ) uno::makeAny( ConversionHelper::convertTwipToMM100(nSize))); } } + + // tdf#118521 set paragraph top or bottom margin based on the paragraph style + // if we already set the other margin with direct formatting + if (pParaContext && m_xPreviousParagraph.is() && + pParaContext->isSet(PROP_PARA_TOP_MARGIN) != pParaContext->isSet(PROP_PARA_BOTTOM_MARGIN)) + { + const StyleSheetEntryPtr pEntry = GetStyleSheetTable()->FindStyleSheetByConvertedStyleName( GetCurrentParaStyleName() ); + OSL_ENSURE( pEntry.get(), "no style sheet found" ); + const StyleSheetPropertyMap* pStyleSheetProperties = + dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr); + if (pStyleSheetProperties) { + boost::optional<PropertyMap::Property> oProperty; + if (pParaContext->isSet(PROP_PARA_TOP_MARGIN)) + { + if ( (oProperty = pStyleSheetProperties->getProperty(PROP_PARA_BOTTOM_MARGIN)) ) + m_xPreviousParagraph->setPropertyValue("ParaBottomMargin", oProperty->second); + } + else + { + if ( (oProperty = pStyleSheetProperties->getProperty(PROP_PARA_TOP_MARGIN)) ) + m_xPreviousParagraph->setPropertyValue("ParaTopMargin", oProperty->second); + } + } + } + } if( !bKeepLastParagraphProperties ) rAppendContext.pLastParagraphProperties = pToBeSavedProperties; |