From bf3124cdf61b40c94ba117a76f1b63dabdfd528e Mon Sep 17 00:00:00 2001 From: László Németh Date: Wed, 19 Aug 2020 13:00:58 +0200 Subject: tdf#135187 DOCX import: fix table style at character formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit applied also on paragraph level during import. Regression from commit 4d5c0eaf3e0d3d3bcd9e691fffee19b75f3d6631 (tdf#118812 DOCX import: fix table style preference – part 2) See also commit 5ac6f02fdc6015a5d78071570dee310febf95fc6 (tdf#105215 DOCX import: fix paragraph-length direct formatting). Change-Id: I14072c81fc4c54e376a004fa36ba76b56d2beb01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100996 Tested-by: László Németh Reviewed-by: László Németh --- writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 12 +++++++++++- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 4 +++- writerfilter/source/dmapper/PropertyMap.hxx | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'writerfilter') diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index b44325fa06d3..02baba345d58 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -1094,7 +1094,8 @@ void DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParag { // apply paragraph and character properties of the table style on table paragraphs // if there is no direct paragraph formatting - if ( !rParaProp.m_pPropertyMap->isSet(eId) ) + bool bIsParaLevel = rParaProp.m_pPropertyMap->isSet(eId); + if ( !bIsParaLevel || isCharacterProperty(eId) ) { if ( (eId == PROP_PARA_LEFT_MARGIN || eId == PROP_PARA_FIRST_LINE_INDENT) && rParaProp.m_pPropertyMap->isSet(PROP_NUMBERING_RULES) ) @@ -1104,6 +1105,15 @@ void DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParag } OUString sPropertyName = getPropertyName(eId); + + if ( bIsParaLevel && ( rParaProp.m_aParaOverrideApplied.find(sPropertyName) != rParaProp.m_aParaOverrideApplied.end() || + sPropertyName.startsWith("CharFontName") ) ) + { + // don't apply table style, if this character property was applied on paragraph level + // (or in the case of paragraph level font name settings to avoid regressions) + continue; + } + auto pCellProp = std::find_if(rCellProperties.begin(), rCellProperties.end(), [&](const beans::PropertyValue& rProp) { return rProp.Name == sPropertyName; }); // this cell applies the table style property diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 333f1170ea09..d720e53a2a53 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1877,7 +1877,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con xParaCursor->gotoStartOfParagraph(false); if (m_nTableDepth > 0) { - TableParagraph aPending{xParaCursor, xCur, pParaContext, xParaProps}; + TableParagraph aPending{xParaCursor, xCur, pParaContext, xParaProps, std::set()}; getTableManager().getCurrentParagraphs()->push_back(aPending); } @@ -1995,6 +1995,8 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con { uno::Reference xRunPropertySet(xCur, uno::UNO_QUERY); xParaProps->setPropertyValue( rParaProp.Name, xRunPropertySet->getPropertyValue(rParaProp.Name) ); + // remember this for table style handling + getTableManager().getCurrentParagraphs()->back().m_aParaOverrideApplied.insert(rParaProp.Name); } } diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx index 0ac658f7674d..c48d52803ee1 100644 --- a/writerfilter/source/dmapper/PropertyMap.hxx +++ b/writerfilter/source/dmapper/PropertyMap.hxx @@ -33,6 +33,7 @@ #include #include #include +#include namespace com::sun::star { namespace beans { @@ -594,6 +595,7 @@ struct TableParagraph css::uno::Reference m_rEndParagraph; PropertyMapPtr m_pPropertyMap; css::uno::Reference m_rPropertySet; + std::set m_aParaOverrideApplied; }; typedef std::shared_ptr< std::vector > TableParagraphVectorPtr; -- cgit