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 <quikee@gmail.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> (cherry picked from commit a5a15bf521510530d33aa4f21a37f168ddc1bb68) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182727 Tested-by: Jenkins
This commit is contained in:
@@ -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);
|
||||
// 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;
|
||||
|
||||
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);
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user