summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-07-06 08:13:40 +0200
committerMiklos Vajna <vmiklos@collabora.com>2023-07-06 09:19:37 +0200
commit9ac864159b241d2093e86f664ab6f4b76c69196d (patch)
tree3dee786ae567ca72b6ffee8d960f6d3708ccada1
parent9239c50a3a154ef6725d6ad36641279cf6f69752 (diff)
tdf#156059 sw floattable: fix lost 0 bottom margin of anchor in ftn from DOCX
The bottom margin of floating table anchor paragraph in the footnotes was non-zero, which meant that the document had 2 pages in Writer, but only 1 in Word. What happened here is that commit d1ac8df139a2a65db45d1970ccc0b80e17d827f6 (tdf#146346 DOCX import: fix table margins in footnotes, 2022-05-03) fixed this, but only for the case when the floating table conversion was delayed and not in the instant conversion case. Then later commit c50bf5a5daaae3d40f89ea0784a75a8a571c208d (sw floattable: remove no longer needed DOCX import heuristics, 2023-04-12) made all floating table conversions instant, so the problem was re-introduced. Fix the problem by now fixing the problem in DomainMapperTableHandler::endTable(), restoring code that was removed from SectionPropertyMap::CloseSectionGroup(). There was a disabled testcase for this, so just enable that. Change-Id: Ifb7c8fe2bdc70625d3e334cea0893b8e563664ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154088 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport14.cxx9
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx26
2 files changed, 33 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 5edb4dcdcd11..4718837981cc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1366,8 +1366,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf146346, "tdf146346.docx")
assertXPath(pXmlDoc, "/root/page[1]//anchored/fly", 8);
assertXPath(pXmlDoc, "/root/page[1]//anchored/fly/tab", 8);
- // FIXME no second page (regression since multi-page floating tables?)
- //assertXPath(pXmlDoc, "/root/page[2]", 0);
+ // No second page.
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 0
+ // - Actual : 1
+ // i.e. unwanted lower margin in the floating table's anchor paragraph in the footnote created a
+ // second page.
+ assertXPath(pXmlDoc, "/root/page[2]", 0);
}
#endif
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 2bd77f3f13ea..370a89c0442f 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1617,6 +1617,32 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab
uno::Reference<text::XTextContent> xContent = xTextAppendAndConvert->convertToTextFrame(xStart, xEnd, comphelper::containerToSequence(aFrameProperties));
xFrameAnchor.set(xContent->getAnchor(), uno::UNO_QUERY);
+ bool bConvertToFloatingInFootnote = false;
+ if (xContent.is() && xContent->getAnchor().is())
+ {
+ uno::Reference<lang::XServiceInfo> xText(xContent->getAnchor()->getText(), uno::UNO_QUERY);
+ if (xText.is())
+ {
+ bConvertToFloatingInFootnote = xText->supportsService("com.sun.star.text.Footnote");
+ }
+ }
+
+ // paragraph of the anchoring point of the floating table needs zero top and bottom
+ // margins, if the table was a not floating table in the footnote, otherwise
+ // docDefault margins could result bigger vertical spaces around the table
+ if ( bConvertToFloatingInFootnote && xContent.is() )
+ {
+ uno::Reference<beans::XPropertySet> xParagraph(
+ xContent->getAnchor(), uno::UNO_QUERY);
+ if ( xParagraph.is() )
+ {
+ xParagraph->setPropertyValue("ParaTopMargin",
+ uno::Any(static_cast<sal_Int32>(0)));
+ xParagraph->setPropertyValue("ParaBottomMargin",
+ uno::Any(static_cast<sal_Int32>(0)));
+ }
+ }
+
AfterConvertToTextFrame(m_rDMapper_Impl, aFramedRedlines, redPos, redLen, redCell, redTable);
}