tdf#144092 tdf#139511: revert parts of tdf#91762 tdf#137949 tdf#139511

Reverts parts that have wrong assumptions wrt layouting a table in svx.

The problems reverted commits solved previously, were refixed by commits:
- tdf#144092 pptx import: correct table height during import
  (a5126a21351c87138ff86a6636326eb6cd6a0f8c)
- tdf#144092 pptx import: fix import of empty cell and shape text properties
  (57f9b4b7d1ad164c56af12009ef1dafbc1be8369)

So hopefully, reverting these now won't cause many regressions.

Change-Id: Ie96293810b033dc86e41c200f10cf63326511cea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138653
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sd/qa/uitest/impress_tests2/tdf91762.py b/sd/qa/uitest/impress_tests2/tdf91762.py
index 56a1596..2b32824 100644
--- a/sd/qa/uitest/impress_tests2/tdf91762.py
+++ b/sd/qa/uitest/impress_tests2/tdf91762.py
@@ -39,8 +39,8 @@ class tdf91762(UITestCase):
                xEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))

            # tdf#138011: Without the fix in place, this test would have failed with
            # AssertionError: 5494 != 3559
            self.assertEqual(5494, document.DrawPages[0].getByIndex(1).BoundRect.Height)
            # AssertionError: 5504 != 3559
            self.assertEqual(5504, document.DrawPages[0].getByIndex(1).BoundRect.Height)


# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx
index d323804..72c692c 100644
--- a/svx/source/table/tablelayouter.cxx
+++ b/svx/source/table/tablelayouter.cxx
@@ -743,14 +743,9 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit )
    sal_Int32 nCol, nRow;
    for( nRow = 0; nRow < nRowCount; ++nRow )
    {
        Reference< XPropertySet > xRowSet( xRows->getByIndex(nRow), UNO_QUERY_THROW );
        sal_Int32 nRowPropHeight = 0;
        xRowSet->getPropertyValue( gsSize ) >>= nRowPropHeight;
        sal_Int32 nMinHeight = 0;

        bool bIsEmpty = true; // check if all cells in this row are merged
        bool bRowHasText = false;
        bool bRowHasCellInEditMode = false;

        for( nCol = 0; nCol < nColCount; ++nCol )
        {
@@ -767,39 +762,7 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit )
                }
                else
                {
                    // WARNING: tdf#144092 / tdf#139511 suggest this entire section is invalid.
                    // Empty cells should not be ignored in regards to row height,
                    // especially MS formats, despite this code being added to import MS files...
                    // The problem is getMinimumHeight can give wrong values for empty cells.

                    bool bCellHasText = xCell->hasText();
                    bool bCellInEditMode = xCell->IsTextEditActive();

                    if (!bRowHasCellInEditMode && bCellInEditMode)
                        bRowHasCellInEditMode = true;

                    if ((bRowHasText == bCellHasText) || (bRowHasText && bCellInEditMode))
                    {
                        nMinHeight = std::max( nMinHeight, xCell->getMinimumHeight() );
                    }
                    else if ( !bRowHasText && bCellHasText )
                    {
                        bRowHasText = true;
                        nMinHeight = xCell->getMinimumHeight();
                    }

                    // tdf#137949  We should consider "Height" property while calculating minimum height.
                    // This control decides when we use "Height" property value instead of calculated minimum height
                    //     Case 1: * Row has "Height" property
                    //             * Calculated minimum height is smaller than Height property value.
                    //     Case 2: * Row has "Height" property
                    //             * Calculated minimum height is bigger than Height property value and
                    //             * Row has not any text of any cell in edit mode in the row (means completely empty)
                    if ((nMinHeight < nRowPropHeight && nRowPropHeight > 0 && (bRowHasText || bRowHasCellInEditMode)) ||
                        (nMinHeight > nRowPropHeight && nRowPropHeight > 0 && (!bRowHasText && !bRowHasCellInEditMode)))
                    {
                        nMinHeight = nRowPropHeight;
                    }
                    nMinHeight = std::max( nMinHeight, xCell->getMinimumHeight() );
                }
            }
        }
@@ -813,6 +776,7 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit )
        else
        {
            sal_Int32 nRowHeight = 0;
            Reference<XPropertySet> xRowSet(xRows->getByIndex(nRow), UNO_QUERY_THROW);

            bool bOptimal = false;
            xRowSet->getPropertyValue( sOptimalSize ) >>= bOptimal;