tdf#136617 DOCX import: fix empty table paragraphs with direct formatting

Table paragraph styles applied on paragraphs without runs, i.e.
on empty paragraphs, despite their direct formatting, resulting
e.g. different font size, and after that different paragraph
i.e. cell height, breaking the original table layout.

Regression from commit bf3124cdf6
"tdf#135187 DOCX import: fix table style at character formatting".

Also clean-up commit 498d2b8218
"tdf#131546 DOCX import: fix performance regression at tables".

Change-Id: I41f8da61d49902c8c1683bd01632cce6d58aebd9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141052
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
László Németh
2022-10-07 16:59:44 +02:00
parent ea88911feb
commit 2a3e528bb9
5 changed files with 17 additions and 10 deletions
Binary file not shown.
@@ -1874,6 +1874,18 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf135187)
"false");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf136617)
{
loadAndSave("tdf136617.docx");
// This was 2
CPPUNIT_ASSERT_EQUAL(1, getPages());
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:p[2]/w:pPr/w:rPr/w:sz", "val",
"16");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf121597TrackedDeletionOfMultipleParagraphs)
{
loadAndSave("tdf121597.odt");
@@ -1112,14 +1112,6 @@ 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
@@ -1179,6 +1171,10 @@ void DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParag
uno::Reference< beans::XPropertyState > xParaProperties( xParagraph, uno::UNO_QUERY_THROW );
if ( xParaProperties->getPropertyState(sPropertyName) == css::beans::PropertyState_DEFAULT_VALUE )
{
// don't overwrite empty paragraph with table style, if it has a direct paragraph formatting
if ( bIsParaLevel && xParagraph->getString().getLength() == 0 )
continue;
if ( eId != PROP_FILL_COLOR )
{
// apply style setting when the paragraph doesn't modify it
@@ -2462,7 +2462,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
xParaCursor->gotoStartOfParagraph(false);
if (m_nTableDepth > 0)
{
TableParagraph aPending{xParaCursor, xCur, pParaContext, xParaProps, std::set<OUString>()};
TableParagraph aPending{xParaCursor, xCur, pParaContext, xParaProps};
getTableManager().getCurrentParagraphs()->push_back(aPending);
}
@@ -606,7 +606,6 @@ struct TableParagraph
css::uno::Reference<css::text::XTextRange> m_rEndParagraph;
PropertyMapPtr m_pPropertyMap;
css::uno::Reference<css::beans::XPropertySet> m_rPropertySet;
std::set<OUString> m_aParaOverrideApplied;
};
typedef std::shared_ptr< std::vector<TableParagraph> > TableParagraphVectorPtr;