tdf#117982 Writer: fix invisible cell content due to spacing

If the cell content with its bottom paragraph spacing
is greater than the fix cell height, the content was
invisible.

Change-Id: I5922941dc0941950912a7ea2cec0aedf1079544c
Reviewed-on: https://gerrit.libreoffice.org/84010
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/qa/extras/layout/data/tdf117982.docx b/sw/qa/extras/layout/data/tdf117982.docx
new file mode 100644
index 0000000..f588621
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf117982.docx
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index f02a69a..8524a4e 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3543,6 +3543,18 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf105481)
    CPPUNIT_ASSERT_LESSEQUAL(nTxtBottom, nFormula2Bottom);
}

CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf117982)
{
    SwDoc* pDocument = createDoc("tdf117982.docx");
    SwDocShell* pShell = pDocument->GetDocShell();
    std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
    MetafileXmlDump dumper;
    xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
    assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/textarray[1]/text", "FOO AAA");
    //The first cell must be "FOO AAA". If not, this means the first cell content not visible in
    //the source document.
}

CPPUNIT_PLUGIN_IMPLEMENT();

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
old mode 100644
new mode 100755
index 4f589ca..3eb055879
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -1945,6 +1945,21 @@ void SwTextFrame::Format( vcl::RenderContext* pRenderContext, const SwBorderAttr
    CalcBaseOfstForFly();
    CalcHeightOfLastLine(); // i#11860 - Adjust spacing implementation for
                             // object positioning - Compatibility to MS Word
    // tdf#117982 -- Fix cell spacing hides content
    // Check if the cell's content has greater size than the row height
    if (IsInTab() && GetUpper() && ((GetUpper()->getFramePrintArea().Height() < getFramePrintArea().Height())
            || (getFramePrintArea().Height() <= 0)))
    {
           SAL_INFO("sw.core", "Warn: Cell content has greater size than cell height!");
           //get font size...
           SwTwips aTmpHeight = getFrameArea().Height();
           //...and push it into the text frame
           SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
           //if only bottom margin what we have:
           if (GetTopMargin() == 0)
               //set the frame to its original location
               aPrt.SetTopAndHeight(0, aTmpHeight);
    }
}

// bForceQuickFormat is set if GetFormatted() has been called during the