sd/source/ui/sidebar/MasterPagesSelector.cxx |   24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

New commits:
commit 221d889520bf508397eacac29e756bd43aee9270
Author:     Rashesh <rashesh.pa...@collabora.com>
AuthorDate: Sat Mar 8 21:27:41 2025 +0530
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Mar 20 21:41:01 2025 +0100

    tdf#165606 sd: fix master slide panel doesn't resized correctly
    
    Change-Id: Ifb26d80f431f0fe6c4e58e58621e170e5a33a718
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182671
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    (cherry picked from commit a5a15bf521510530d33aa4f21a37f168ddc1bb68)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182727
    Tested-by: Jenkins
    (cherry picked from commit 98b86bff2c7350ad9a22eb0db7f7696672c6db51)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182776
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx 
b/sd/source/ui/sidebar/MasterPagesSelector.cxx
index 2ee57bca11c3..b098486054ed 100644
--- a/sd/source/ui/sidebar/MasterPagesSelector.cxx
+++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx
@@ -582,16 +582,20 @@ void MasterPagesSelector::UpdateItemList 
(::std::unique_ptr<ItemList> && pNewIte
 
 css::ui::LayoutSize MasterPagesSelector::GetHeightForWidth(const sal_Int32 
nWidth)
 {
-    if (maIconViewId == "masterpageall_icons")
-        return css::ui::LayoutSize(-1, -1, -1);
-
-    const sal_uInt32 nItemWidth = mxPreviewIconView->get_item_width();
-    sal_Int32 nMinimumHeight = 
mxPreviewIconView->get_preferred_size().getHeight();
-    const sal_Int32 itemsInRows = floor(nWidth / nItemWidth);
-    sal_Int32 totalItems = mxPreviewIconView->n_children();
-    if (itemsInRows > 0)
-        nMinimumHeight = ((totalItems / itemsInRows) + 1) * nMinimumHeight;
-    return css::ui::LayoutSize(nMinimumHeight, nMinimumHeight, nMinimumHeight);
+    // there is no way to get margin of item programatically, we use value 
provided in ui file.
+    const int nMargin = 6;
+    sal_Int32 nColumnCount = nWidth / (mxPreviewIconView->get_item_width() + 
(5 * nMargin));
+    if (nColumnCount < 1)
+        nColumnCount = 1;
+
+    sal_Int32 nTotalItems = mxPreviewIconView->n_children();
+    sal_Int32 nRowCount = (nTotalItems + nColumnCount - 1) / nColumnCount;
+    if (nRowCount < 1)
+        nRowCount = 1;
+
+    sal_Int32 nPreferedHeight
+        = nRowCount * (mxPreviewIconView->get_rect(nTotalItems - 
1).GetHeight() + (2 * nMargin));
+    return css::ui::LayoutSize(nPreferedHeight, nPreferedHeight, 
nPreferedHeight);
 }
 
 } // end of namespace sd::sidebar

Reply via email to