svx/source/table/tablelayouter.cxx |   24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

New commits:
commit 3fa8f934195cabb9c6fa9cd09ee0a05c7ded46ab
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Sat Oct 6 17:49:34 2018 +0300
Commit:     Justin Luth <justin_l...@sil.org>
CommitDate: Fri Oct 12 05:55:10 2018 +0200

    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_l...@sil.org>

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
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to