vcl/source/window/menu.cxx | 2 +- vcl/source/window/menufloatingwindow.cxx | 16 +++++++++------- vcl/source/window/menufloatingwindow.hxx | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-)
New commits: commit 44f6a3e9583357ac882f1660285214231961204a Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Dec 2 11:45:22 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Mon Dec 2 15:19:54 2024 +0100 vcl: Use existing PopupMenu::ImplGetFloatingWindow ... instead of manually casting the `m_pWindow` member in another place. While at it, also just call GetWindow() in PopupMenu::ImplGetFloatingWindow, not explicitly the base class Menu::ImplGetFloatingWindow. Both are the same, as this is a non-virtual method only implemented in the base class. Change-Id: I12debc7c5bad8b21722fabb093cbc4a7a669dff1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177672 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 80f14042b0b7..300ecf535980 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2727,7 +2727,7 @@ int MenuBar::GetMenuBarHeight() const // bool PopupMenu::bAnyPopupInExecute = false; MenuFloatingWindow * PopupMenu::ImplGetFloatingWindow() const { - return static_cast<MenuFloatingWindow *>(Menu::GetWindow()); + return static_cast<MenuFloatingWindow*>(GetWindow()); } PopupMenu::PopupMenu() diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx index 64fba7d7a4f6..0d6a60689c35 100644 --- a/vcl/source/window/menufloatingwindow.cxx +++ b/vcl/source/window/menufloatingwindow.cxx @@ -482,9 +482,11 @@ void MenuFloatingWindow::KillActivePopup( PopupMenu* pThisOnly ) if ( !pActivePopup || ( pThisOnly && ( pThisOnly != pActivePopup ) ) ) return; - if (pActivePopup->m_pWindow) - if (static_cast<FloatingWindow *>(pActivePopup->m_pWindow.get())->IsInCleanUp()) + if (MenuFloatingWindow* pFloatWin = pActivePopup->ImplGetFloatingWindow()) + { + if (pFloatWin->IsInCleanUp()) return; // kill it later + } if ( pActivePopup->bInCallback ) pActivePopup->bCanceled = true; commit 1336fc1713f50d743cc151c78ead4621d48ecfb9 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Dec 2 11:25:38 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Mon Dec 2 15:19:48 2024 +0100 vcl: Use VclPtr<PopupMenu> and reduce casting MenuFloatingWindow::pMenu is always a PopupMenu, so use a VclPtr<PopupMenu> for it, instead of a VclPtr<Menu> and casting in multiple places. Change-Id: I004fc57063fc1cd50e5f14463367af3063a247b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177671 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx index 4597a993e7f0..64fba7d7a4f6 100644 --- a/vcl/source/window/menufloatingwindow.cxx +++ b/vcl/source/window/menufloatingwindow.cxx @@ -29,7 +29,7 @@ #include <vcl/settings.hxx> #include <window.h> -MenuFloatingWindow::MenuFloatingWindow( Menu* pMen, vcl::Window* pParent, WinBits nStyle ) : +MenuFloatingWindow::MenuFloatingWindow(PopupMenu* pMen, vcl::Window* pParent, WinBits nStyle ) : FloatingWindow( pParent, nStyle ), pMenu(pMen), aHighlightChangedTimer("vcl::MenuFloatingWindow aHighlightChangedTimer"), @@ -451,7 +451,7 @@ void MenuFloatingWindow::Execute() { ImplSVData* pSVData = ImplGetSVData(); - pSVData->maAppData.mpActivePopupMenu = static_cast<PopupMenu*>(pMenu.get()); + pSVData->maAppData.mpActivePopupMenu = pMenu.get(); Start(); @@ -679,7 +679,7 @@ void MenuFloatingWindow::ImplScroll( bool bUp ) tools::Long nHeight = GetOutputSizePixel().Height(); sal_uInt16 nLastVisible; - static_cast<PopupMenu*>(pMenu.get())->ImplCalcVisEntries( nHeight, nFirstEntry, &nLastVisible ); + pMenu->ImplCalcVisEntries(nHeight, nFirstEntry, &nLastVisible); if ( pMenu->ImplGetNextVisible( nLastVisible ) == ITEMPOS_INVALID ) { bScrollDown = false; @@ -1015,11 +1015,11 @@ void MenuFloatingWindow::ImplCursorUpDown( bool bUp, bool bHomeEnd ) Size aOutSz = GetOutputSizePixel(); sal_uInt16 nLastVisible; - static_cast<PopupMenu*>(pMenu.get())->ImplCalcVisEntries( aOutSz.Height(), nFirstEntry, &nLastVisible ); + pMenu->ImplCalcVisEntries(aOutSz.Height(), nFirstEntry, &nLastVisible); while ( n > nLastVisible ) { ImplScroll( false ); - static_cast<PopupMenu*>(pMenu.get())->ImplCalcVisEntries( aOutSz.Height(), nFirstEntry, &nLastVisible ); + pMenu->ImplCalcVisEntries(aOutSz.Height(), nFirstEntry, &nLastVisible); } } ChangeHighlightItem( n, false ); diff --git a/vcl/source/window/menufloatingwindow.hxx b/vcl/source/window/menufloatingwindow.hxx index f26fb50373ca..5324197aa8bd 100644 --- a/vcl/source/window/menufloatingwindow.hxx +++ b/vcl/source/window/menufloatingwindow.hxx @@ -35,7 +35,7 @@ class MenuFloatingWindow : public FloatingWindow, public MenuWindow friend void Menu::dispose(); private: - VclPtr<Menu> pMenu; + VclPtr<PopupMenu> pMenu; VclPtr<PopupMenu> pActivePopup; Timer aHighlightChangedTimer; Timer aSubmenuCloseTimer; @@ -83,7 +83,7 @@ protected: void InvalidateItem( sal_uInt16 nPos ); public: - MenuFloatingWindow(Menu* pMenu, vcl::Window* pParent, WinBits nStyle); + MenuFloatingWindow(PopupMenu* pMenu, vcl::Window* pParent, WinBits nStyle); virtual ~MenuFloatingWindow() override; virtual void dispose() override;