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

New commits:
commit a5a15bf521510530d33aa4f21a37f168ddc1bb68
Author:     Rashesh <rashesh.pa...@collabora.com>
AuthorDate: Sat Mar 8 21:27:41 2025 +0530
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Mon Mar 10 10:23:12 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>

diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx 
b/sd/source/ui/sidebar/MasterPagesSelector.cxx
index 85a1746eae45..4d329228036d 100644
--- a/sd/source/ui/sidebar/MasterPagesSelector.cxx
+++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx
@@ -584,16 +584,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