diff options
author | Gülşah Köse <gulsah.kose@collabora.com> | 2020-11-06 21:18:24 +0300 |
---|---|---|
committer | Gülşah Köse <gulsah.kose@collabora.com> | 2020-11-09 12:36:07 +0100 |
commit | b7b05dd36403af50b20fe06cbf8a10d8defb28a9 (patch) | |
tree | c7a7f03abdd68d89207bbb84a87a93f08ddd0734 /svx | |
parent | 6e7d4c1185a9a70ea795b6959fbd87ac8e84480c (diff) |
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 <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/table/tablelayouter.cxx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx index 1c369e6d08b4..6859d0a2eee8 100644 --- a/svx/source/table/tablelayouter.cxx +++ b/svx/source/table/tablelayouter.cxx @@ -725,6 +725,7 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit ) { const sal_Int32 nColCount = getColumnCount(); const sal_Int32 nRowCount = getRowCount(); + if( nRowCount == 0 ) return; @@ -741,10 +742,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 ) { @@ -762,7 +767,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() ); } @@ -771,6 +781,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; + } } } } @@ -784,7 +807,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; |