sd/qa/uitest/impress_tests/tdf91762.py | 3 +-- sd/qa/unit/data/pptx/tablescale.pptx |binary sd/qa/unit/import-tests.cxx | 20 +++++++++++++++++++- svx/source/table/tablelayouter.cxx | 26 ++++++++++++++++++++++++-- 4 files changed, 44 insertions(+), 5 deletions(-)
New commits: commit 5c37f0c0347d8cccda6fc6a2ca4dd28bb36823a9 Author: Gülşah Köse <gulsah.k...@collabora.com> AuthorDate: Fri Nov 6 21:18:24 2020 +0300 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Nov 9 15:35:24 2020 +0100 tdf#137949 Fix table row heigths. Consider "Height" property of the the table while calculating the minimum row height. Change-Id: I4dbb0f7f87517423fd3075515b4b9817d6a9a71a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105422 Tested-by: Jenkins Tested-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-by: Gülşah Köse <gulsah.k...@collabora.com> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105480 diff --git a/sd/qa/uitest/impress_tests/tdf91762.py b/sd/qa/uitest/impress_tests/tdf91762.py index 66e650b0bb2a..3c52b4ff9cf9 100644 --- a/sd/qa/uitest/impress_tests/tdf91762.py +++ b/sd/qa/uitest/impress_tests/tdf91762.py @@ -41,8 +41,7 @@ class tdf91762(UITestCase): xEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) # tdf#138011: Without the fix in place, this test would have failed with - # AssertionError: 5504 != 3559 - self.assertEqual(5504, document.DrawPages[0].getByIndex(1).BoundRect.Height) + self.assertEqual(5494, document.DrawPages[0].getByIndex(1).BoundRect.Height) self.ui_test.close_doc() diff --git a/sd/qa/unit/data/pptx/tablescale.pptx b/sd/qa/unit/data/pptx/tablescale.pptx new file mode 100644 index 000000000000..c4d946e5c619 Binary files /dev/null and b/sd/qa/unit/data/pptx/tablescale.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index b285b490894b..5d6157aa4051 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -1484,9 +1484,27 @@ void SdImportTest::testRowHeight() uno::Reference< css::table::XTableRows > xRows( xTable->getRows(), uno::UNO_SET_THROW); uno::Reference< beans::XPropertySet > xRefRow( xRows->getByIndex(0), uno::UNO_QUERY_THROW ); xRefRow->getPropertyValue( sHeight ) >>= nHeight; - CPPUNIT_ASSERT_EQUAL( sal_Int32(507), nHeight); + CPPUNIT_ASSERT_EQUAL( sal_Int32(508), nHeight); xDocShRef->DoClose(); + + sd::DrawDocShellRef xDocShRef2 = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tablescale.pptx"), PPTX ); + const SdrPage *pPage2 = GetPage( 1, xDocShRef2 ); + + sdr::table::SdrTableObj *pTableObj2 = dynamic_cast<sdr::table::SdrTableObj*>(pPage2->GetObj(0)); + CPPUNIT_ASSERT( pTableObj2 ); + + uno::Reference< css::table::XTable > xTable2(pTableObj2->getTable(), uno::UNO_SET_THROW); + uno::Reference< css::table::XTableRows > xRows2( xTable2->getRows(), uno::UNO_SET_THROW); + + for(sal_Int32 nRow = 0; nRow < 7; ++nRow) + { + uno::Reference< beans::XPropertySet > xRefRow2( xRows2->getByIndex(nRow), uno::UNO_QUERY_THROW ); + xRefRow2->getPropertyValue( "Height" ) >>= nHeight; + CPPUNIT_ASSERT_EQUAL( sal_Int32(800), nHeight); + } + + xDocShRef2->DoClose(); } void SdImportTest::testTdf93830() diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx index b5dddef4ddd1..2d0fc0f22a3f 100644 --- a/svx/source/table/tablelayouter.cxx +++ b/svx/source/table/tablelayouter.cxx @@ -724,6 +724,7 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit ) { const sal_Int32 nColCount = getColumnCount(); const sal_Int32 nRowCount = getRowCount(); + if( nRowCount == 0 ) return; @@ -740,10 +741,14 @@ 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 ) { @@ -761,7 +766,12 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit ) else { bool bCellHasText = xCell->hasText(); - if (bRowHasText == bCellHasText) + bool bCellInEditMode = xCell->IsTextEditActive(); + + if (!bRowHasCellInEditMode && bCellInEditMode) + bRowHasCellInEditMode = true; + + if ((bRowHasText == bCellHasText) || (bRowHasText && bCellInEditMode)) { nMinHeight = std::max( nMinHeight, xCell->getMinimumHeight() ); } @@ -770,6 +780,19 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit ) bRowHasText = true; nMinHeight = xCell->getMinimumHeight(); } + + // tdf#137949 We should consider "Heigth" property while calculating minimum height. + // This control decides when we use "Heigth" property value instead of calculated minimum height + // Case 1: * Row has "Heigth" property + // * Calculated minimum heigth is smaller than Height propery value. + // Case 2: * Row has "Heigth" property + // * Calculated minimum heigth is bigger than Height propery value and + // * Row has not any text of any cell in edit mode in the row (means completely empty) + if ((nMinHeight < nRowPropHeight && nRowPropHeight > 0 ) || + (nMinHeight > nRowPropHeight && nRowPropHeight > 0 && (!bRowHasText && !bRowHasCellInEditMode))) + { + nMinHeight = nRowPropHeight; + } } } } @@ -783,7 +806,6 @@ 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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits