diff options
author | Justin Luth <justin_luth@sil.org> | 2018-10-06 17:49:34 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2018-10-12 05:55:10 +0200 |
commit | 3fa8f934195cabb9c6fa9cd09ee0a05c7ded46ab (patch) | |
tree | aa231d47d906d3274172f46949eca3d48f774758 /svx | |
parent | ab18c17d70e1dcf5cf9db38256d35e6af479373e (diff) |
tdf#117721 draw ui: modify Optimize/Distribute RowHeight
Optimize row height: Adjust the height of the selected rows
to match the height of the tallest row in the selection
(fit to content), without shrinking the table.
(Optimize rows is a new feature for Draw. My initial
implementation was replaced by setMinimalRowHeight.
This option is now the same as minimizing row height and then
distributing rows evenly except that it adds the benefit of
preventing the table from shrinking.)
Distribute rows evenly: Adjusts the height of the selected rows
to match the height of the tallest row in the selection
(regardless of the content), causing the table to grow.
(Previously, Distribute rows worked like Optimize now does,
but the documentation indicates that it should work this way.)
Change-Id: I49b9f9b5d1f9d3e8d2267ba0d49a9901585b4095
Reviewed-on: https://gerrit.libreoffice.org/61473
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/table/tablelayouter.cxx | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx index 29cf6fe0253d..8231eaf9f7c4 100644 --- a/svx/source/table/tablelayouter.cxx +++ b/svx/source/table/tablelayouter.cxx @@ -1205,27 +1205,39 @@ void TableLayouter::DistributeRows( ::tools::Rectangle& rArea, return; sal_Int32 nAllHeight = 0; + sal_Int32 nMaxHeight = 0; for( sal_Int32 nRow = nFirstRow; nRow <= nLastRow; ++nRow ) { nMinHeight = std::max( maRows[nRow].mnMinSize, nMinHeight ); + nMaxHeight = std::max( maRows[nRow].mnSize, nMaxHeight ); nAllHeight += maRows[nRow].mnSize; } const sal_Int32 nRows = (nLastRow-nFirstRow+1); sal_Int32 nHeight = nAllHeight / nRows; - if ( !(bMinimize || bOptimize) && nHeight < nMinHeight ) + if ( !bMinimize && nHeight < nMaxHeight ) { - sal_Int32 nNeededHeight = nRows * nMinHeight; - rArea.AdjustBottom(nNeededHeight - nAllHeight ); - nHeight = nMinHeight; - nAllHeight = nRows * nMinHeight; + if ( !bOptimize ) + { + sal_Int32 nNeededHeight = nRows * nMaxHeight; + rArea.AdjustBottom(nNeededHeight - nAllHeight ); + nHeight = nMaxHeight; + nAllHeight = nRows * nMaxHeight; + } + else if ( nHeight < nMinHeight ) + { + sal_Int32 nNeededHeight = nRows * nMinHeight; + rArea.AdjustBottom(nNeededHeight - nAllHeight ); + nHeight = nMinHeight; + nAllHeight = nRows * nMinHeight; + } } for( sal_Int32 nRow = nFirstRow; nRow <= nLastRow; ++nRow ) { - if ( bMinimize || bOptimize ) + if ( bMinimize ) nHeight = maRows[nRow].mnMinSize; else if ( nRow == nLastRow ) nHeight = nAllHeight; // last row get round errors |