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
(cherry picked from commit 9ac864159b241d2093e86f664ab6f4b76c69196d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154121
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index a8beca7..67fba9e9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1383,8 +1383,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 cd77182..ab8e00e1 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1619,6 +1619,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);
            }