summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-02-04 12:54:34 +0100
committerLászló Németh <nemeth@numbertext.org>2020-02-12 12:53:24 +0100
commitc90b6a208d867a00252ad58d8eeab2fd12516157 (patch)
tree4e7917033e0a73eccf53c927463f45c4e785434a
parentc50e3f57d9098c7c7058c464e572cf7e70e3808d (diff)
Revert "revert obsolete writerfilter hacks for tdf#119054 and tdf#128752"
This reverts commit 749fd6508504cf3b2e3822eca52a67fa36d75fb8. Change-Id: Iad4cd836e2908e2c21e70013f88af213b3a1822d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88142 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx38
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.hxx2
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx8
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx10
4 files changed, 58 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 6a546f60e6a0..e753852985a7 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -863,6 +863,9 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl
// Remove properties from style/row that aren't allowed in cells
pAllCellProps->Erase( PROP_HEADER_ROW_COUNT );
pAllCellProps->Erase( PROP_TBL_HEADER );
+ // Remove paragraph properties from style/row that paragraph style can overwrite
+ pAllCellProps->Erase( PROP_PARA_BOTTOM_MARGIN );
+ pAllCellProps->Erase( PROP_PARA_LINE_SPACING );
// Then add the cell properties
pAllCellProps->InsertProps(*aCellIterator);
@@ -1061,6 +1064,36 @@ css::uno::Sequence<css::beans::PropertyValues> DomainMapperTableHandler::endTabl
return aRowProperties;
}
+// table style has got bigger precedence than docDefault style,
+// but lower precedence than the paragraph styles and direct paragraph formatting
+void DomainMapperTableHandler::ApplyParaProperty(css::beans::PropertyValues aTableProperties, PropertyIds eId)
+{
+ OUString sPropertyName = getPropertyName(eId);
+ auto pTableProp = std::find_if(aTableProperties.begin(), aTableProperties.end(),
+ [&](const beans::PropertyValue& rProp) { return rProp.Name == sPropertyName; });
+ if (pTableProp != aTableProperties.end())
+ {
+ uno::Any aValue = pTableProp->Value;
+ for (const auto& rParaProp : m_rDMapper_Impl.m_aParagraphsToEndTable)
+ {
+ // there is no direct paragraph formatting
+ if (!rParaProp.m_pPropertyMap->isSet(eId))
+ {
+ OUString sParaStyleName;
+ rParaProp.m_rPropertySet->getPropertyValue("ParaStyleName") >>= sParaStyleName;
+ StyleSheetEntryPtr pEntry = m_rDMapper_Impl.GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(sParaStyleName);
+ uno::Any aMargin = m_rDMapper_Impl.GetPropertyFromStyleSheet(eId, pEntry, true, true);
+ uno::Any aMarginDocDefault = m_rDMapper_Impl.GetPropertyFromStyleSheet(eId, nullptr, true, true);
+ // use table style only when 1) both values are empty (no docDefault and paragraph style definitions) or
+ // 2) both non-empty values are equal (docDefault paragraph properties are copied to the base paragraph style during import)
+ // TODO check the case, when two parent styles modify the docDefault and the last one set back the docDefault value
+ if (aMargin == aMarginDocDefault)
+ rParaProp.m_rPropertySet->setPropertyValue(sPropertyName, aValue);
+ }
+ }
+ }
+}
+
void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTableStartsAtCellStart)
{
#ifdef DBG_UTIL
@@ -1158,6 +1191,10 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab
}
}
}
+
+ // OOXML table style may container paragraph properties, apply these now.
+ ApplyParaProperty(aTableInfo.aTableProperties, PROP_PARA_BOTTOM_MARGIN);
+ ApplyParaProperty(aTableInfo.aTableProperties, PROP_PARA_LINE_SPACING);
}
}
catch ( const lang::IllegalArgumentException & )
@@ -1235,6 +1272,7 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab
m_aCellProperties.clear();
m_aRowProperties.clear();
m_bHadFootOrEndnote = false;
+ m_rDMapper_Impl.m_aParagraphsToEndTable.clear();
#ifdef DBG_UTIL
TagLogger::getInstance().endElement();
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
index 41b6339506f9..16d2a0cc37cc 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
@@ -91,6 +91,8 @@ public:
*/
void startTable(const TablePropertyMapPtr& pProps);
+ void ApplyParaProperty(css::beans::PropertyValues aTableProperties, PropertyIds eId);
+
/// Handle end of table.
void endTable(unsigned int nestedTableLevel, bool bTableStartsAtCellStart);
/**
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index ebe2aa875709..2f3e79ec852e 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1738,6 +1738,14 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
css::uno::Reference<css::beans::XPropertySet> xParaProps(xTextRange, uno::UNO_QUERY);
+ // table style has got bigger precedence than docDefault style
+ // collect these pending paragraph properties to process in endTable()
+ if (xParaProps && m_nTableDepth > 0)
+ {
+ TableParagraph aPending{pParaContext, xParaProps};
+ m_aParagraphsToEndTable.push_back(aPending);
+ }
+
// tdf#118521 set paragraph top or bottom margin based on the paragraph style
// if we already set the other margin with direct formatting
if (xParaProps)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 2a512eb44f8e..bc688a463cd7 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -430,6 +430,13 @@ struct SymbolData
{ }
};
+/// Information about a paragraph to be finished after a table end.
+struct TableParagraph
+{
+ PropertyMapPtr m_pPropertyMap;
+ css::uno::Reference<css::beans::XPropertySet> m_rPropertySet;
+};
+
class DomainMapper;
class DomainMapper_Impl final
{
@@ -1064,6 +1071,9 @@ public:
bool m_bIsActualParagraphFramed;
std::vector<css::uno::Any> aFramedRedlines;
+ /// Table paragraph properties may need style update based on table style
+ std::vector<TableParagraph> m_aParagraphsToEndTable;
+
private:
void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType);
// Start a new index section; if needed, finish current paragraph