summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2018-08-10 11:49:14 +0200
committerLászló Németh <nemeth@numbertext.org>2018-09-02 13:13:15 +0200
commit5e2caf236091c71b2148970eba36b22655d8845a (patch)
treeb6afa44ceb4afcfce65c5464edd8d020e26fdfc7
parent307e84ac706345510a4d347fbaaf3d53f8249dea (diff)
tdf#119188 DOCX import: fix zero margins of numbered lines in cells
regression from 5c6bce38a01b21403a603acd3148cf3bbb4c685f (tdf#104354 DOCX import: fix paragraph auto spacing in tables). Change-Id: I486d155eb4463599ab922837fd2f4347b48e0851 Reviewed-on: https://gerrit.libreoffice.org/58818 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf119188_list_margin_in_cell.docxbin0 -> 13663 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx19
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx7
3 files changed, 23 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf119188_list_margin_in_cell.docx b/sw/qa/extras/ooxmlexport/data/tdf119188_list_margin_in_cell.docx
new file mode 100644
index 000000000000..02b538685f47
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf119188_list_margin_in_cell.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index e289d3a40dba..e412f8703c07 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -609,6 +609,25 @@ DECLARE_OOXMLEXPORT_TEST(testTdf113608_runAwayNumbering, "tdf113608_runAwayNumbe
CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(getParagraph(2), "NumberingStyleName"));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf119188_list_margin_in_cell, "tdf119188_list_margin_in_cell.docx")
+{
+ uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+ uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
+
+ // lists with auto margings in cells: top margin of the first paragraph is zero,
+ // but not the bottom margin of the last paragraph, also other list items have got
+ // zero margins.
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(2, xCell->getText()), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(2, xCell->getText()), "ParaBottomMargin"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(3, xCell->getText()), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraphOfText(3, xCell->getText()), "ParaBottomMargin"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index e881f279a83f..c1a579b308f8 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1323,6 +1323,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
}
}
std::vector<beans::PropertyValue> aProperties;
+ bool bNumberedParagraph = false;
if (pPropertyMap.get())
aProperties = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(pPropertyMap->GetPropertyValues());
if( !bIsDropCap )
@@ -1367,6 +1368,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
if (itNumberingRules != aProperties.end())
{
// This textnode has numbering. Look up the numbering style name of the current and previous paragraph.
+ bNumberedParagraph = true;
OUString aCurrentNumberingRuleName;
uno::Reference<container::XNamed> xCurrentNumberingRules(itNumberingRules->Value, uno::UNO_QUERY);
if (xCurrentNumberingRules.is())
@@ -1448,8 +1450,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
uno::Reference< text::XTextRange > xParaEnd( xCur, uno::UNO_QUERY );
CheckParaMarkerRedline( xParaEnd );
}
-
- // set top margin of the previous auto paragraph in cells, keeping zero bottom margin only at the first one
+ // set top margin of the previous auto paragraph in cells, keeping zero top margin only at the first one
if (m_nTableDepth > 0 && m_nTableDepth == m_nTableCellDepth && m_xPreviousParagraph.is())
{
bool bParaChangedTopMargin = std::any_of(aProperties.begin(), aProperties.end(), [](const beans::PropertyValue& rValue)
@@ -1467,7 +1468,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
if ((bPrevParaAutoBefore && !bParaChangedTopMargin) || (bParaChangedTopMargin && m_bParaAutoBefore))
{
- sal_Int32 nSize = m_bFirstParagraphInCell ? 0 : 280;
+ sal_Int32 nSize = (m_bFirstParagraphInCell || bNumberedParagraph) ? 0 : 280;
// Previous before spacing is set to auto, set previous before space to 280, except in the first paragraph.
m_xPreviousParagraph->setPropertyValue("ParaTopMargin",
uno::makeAny( ConversionHelper::convertTwipToMM100(nSize)));