vcl: Switch MenuBar::ImplCreate param to MenuBarWindow*

This avoids the need to do a dynamic_cast and makes
clear that this method always gets called with either
a window of a proper type or nullptr.

Change-Id: I8ca4020476c806ad423379c7c7ee6fdc6ceccd3a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177697
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn 2024-12-02 14:20:20 +01:00
parent 88a6a8eb9a
commit 185f7fa290
3 changed files with 10 additions and 8 deletions

View file

@ -421,7 +421,7 @@ class VCL_DLLPUBLIC MenuBar final : public Menu
friend class MenuBarWindow;
friend class SystemWindow;
SAL_DLLPRIVATE static VclPtr<vcl::Window> ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, MenuBar* pMenu);
SAL_DLLPRIVATE static VclPtr<MenuBarWindow> ImplCreate(vcl::Window* pParent, MenuBarWindow* pWindow, MenuBar* pMenu);
SAL_DLLPRIVATE static void ImplDestroy(MenuBar* pMenu, bool bDelete);
SAL_DLLPRIVATE bool ImplHandleKeyEvent(const KeyEvent& rKEvent);
SAL_DLLPRIVATE bool ImplHandleCmdEvent(const CommandEvent& rCEvent);

View file

@ -2483,9 +2483,9 @@ void MenuBar::SetDisplayable( bool bDisplayable )
}
}
VclPtr<vcl::Window> MenuBar::ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, MenuBar* pMenu)
VclPtr<MenuBarWindow> MenuBar::ImplCreate(vcl::Window* pParent, MenuBarWindow* pWindow, MenuBar* pMenu)
{
VclPtr<MenuBarWindow> pMenuBarWindow = dynamic_cast<MenuBarWindow*>(pWindow);
VclPtr<MenuBarWindow> pMenuBarWindow = pWindow;
if (!pMenuBarWindow)
{
pMenuBarWindow = VclPtr<MenuBarWindow>::Create(pParent);

View file

@ -19,6 +19,8 @@
#include <memory>
#include "menubarwindow.hxx"
#include <o3tl/safeint.hxx>
#include <sal/config.h>
#include <sal/log.hxx>
@ -844,14 +846,14 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar)
return;
MenuBar* pOldMenuBar = mpMenuBar;
vcl::Window* pOldWindow = nullptr;
VclPtr<vcl::Window> pNewWindow;
MenuBarWindow* pOldWindow = nullptr;
VclPtr<MenuBarWindow> pNewWindow;
mpMenuBar = pMenuBar;
if ( mpWindowImpl->mpBorderWindow && (mpWindowImpl->mpBorderWindow->GetType() == WindowType::BORDERWINDOW) )
{
if ( pOldMenuBar )
pOldWindow = pOldMenuBar->GetWindow();
pOldWindow = pOldMenuBar->getMenuBarWindow();
else
pOldWindow = nullptr;
if ( pOldWindow )
@ -888,9 +890,9 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar)
else
{
if( pMenuBar )
pNewWindow = pMenuBar->GetWindow();
pNewWindow = pMenuBar->getMenuBarWindow();
if( pOldMenuBar )
pOldWindow = pOldMenuBar->GetWindow();
pOldWindow = pOldMenuBar->getMenuBarWindow();
}
// update taskpane list to make menubar accessible