sd/source/ui/sidebar/MasterPageContainer.cxx | 15 +++++++++++++++ sd/source/ui/sidebar/MasterPageContainer.hxx | 2 ++ sd/source/ui/sidebar/MasterPagesSelector.cxx | 6 +++--- 3 files changed, 20 insertions(+), 3 deletions(-)
New commits: commit 60cfd11276d6cef6f796f7b45ae1da8a29bbe430 Author: Rashesh <rashesh.pa...@collabora.com> AuthorDate: Wed Mar 12 13:46:03 2025 +0530 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Thu Mar 20 10:42:51 2025 +0100 tdf#165606 fix: master slide panel doesn't resized correctly in gtk - follow up to 98b86bff2c73 - the problem was get_rect give 0 height when preview are loading. - this patch fixes the problem by taking image size from MasterPageContainer Change-Id: Ie4a3e25826e871ae5cbda58edba092e9a3eae193 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182806 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Jenkins diff --git a/sd/source/ui/sidebar/MasterPageContainer.cxx b/sd/source/ui/sidebar/MasterPageContainer.cxx index ed3445824153..fb404b765200 100644 --- a/sd/source/ui/sidebar/MasterPageContainer.cxx +++ b/sd/source/ui/sidebar/MasterPageContainer.cxx @@ -103,6 +103,8 @@ public: void ReleaseDescriptor (Token aToken); + const Size& GetPreviewSizePixel(PreviewSize pPreviewSize); + /** Called by the MasterPageContainerFiller to notify that all master pages from template documents have been added. */ @@ -444,6 +446,11 @@ void MasterPageContainer::InvalidatePreview (MasterPageContainer::Token aToken) mpImpl->InvalidatePreview(aToken); } +const Size& MasterPageContainer::GetPreviewSizePixel() +{ + return mpImpl->GetPreviewSizePixel(mePreviewSize); +} + Image MasterPageContainer::GetPreviewForToken (MasterPageContainer::Token aToken) { return mpImpl->GetPreviewForToken(aToken,mePreviewSize); @@ -809,6 +816,14 @@ SdDrawDocument* MasterPageContainer::Implementation::GetDocument() return mpDocument; } +const Size& MasterPageContainer::Implementation::GetPreviewSizePixel(PreviewSize pPreviewSize) +{ + if (pPreviewSize == PreviewSize::SMALL) + return maSmallPreviewSizePixel; + else + return maLargePreviewSizePixel; +} + Image MasterPageContainer::Implementation::GetPreviewSubstitution ( TranslateId pId, PreviewSize ePreviewSize) diff --git a/sd/source/ui/sidebar/MasterPageContainer.hxx b/sd/source/ui/sidebar/MasterPageContainer.hxx index 18e476c0303d..19b1e7bc9ab0 100644 --- a/sd/source/ui/sidebar/MasterPageContainer.hxx +++ b/sd/source/ui/sidebar/MasterPageContainer.hxx @@ -85,6 +85,8 @@ public: }; PreviewState GetPreviewState(Token aToken); + const Size& GetPreviewSizePixel(); + /** This method is typically called for entries in the container for which GetPreviewState() returns OS_CREATABLE. The creation of the preview is then scheduled to be executed asynchronously at a later diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx b/sd/source/ui/sidebar/MasterPagesSelector.cxx index 23f09a1d79fe..b40704c307de 100644 --- a/sd/source/ui/sidebar/MasterPagesSelector.cxx +++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx @@ -585,7 +585,8 @@ css::ui::LayoutSize MasterPagesSelector::GetHeightForWidth(const sal_Int32 nWidt { // there is no way to get margin of item programmatically, we use value provided in ui file. const int nMargin = 6; - sal_Int32 nColumnCount = nWidth / (mxPreviewIconView->get_item_width() + (5 * nMargin)); + const Size& previewSize = mpContainer->GetPreviewSizePixel(); + sal_Int32 nColumnCount = nWidth / (previewSize.Width() + (2 * nMargin)); if (nColumnCount < 1) nColumnCount = 1; @@ -594,8 +595,7 @@ css::ui::LayoutSize MasterPagesSelector::GetHeightForWidth(const sal_Int32 nWidt if (nRowCount < 1) nRowCount = 1; - sal_Int32 nPreferedHeight - = nRowCount * (mxPreviewIconView->get_rect(nTotalItems - 1).GetHeight() + (2 * nMargin)); + sal_Int32 nPreferedHeight = nRowCount * (previewSize.getHeight() + (4 * nMargin)); return css::ui::LayoutSize(nPreferedHeight, nPreferedHeight, nPreferedHeight); }