diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-12-02 14:20:20 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-12-02 19:27:56 +0100 |
commit | 185f7fa290d2d7e6f79b543acdc239323f727a5e (patch) | |
tree | 94a0f67cf2da64b91a12b62f7e81e233a7ca0504 | |
parent | 88a6a8eb9a0b30a25a6996cd8677b47a42f4822a (diff) |
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>
-rw-r--r-- | include/vcl/menu.hxx | 2 | ||||
-rw-r--r-- | vcl/source/window/menu.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/syswin.cxx | 12 |
3 files changed, 10 insertions, 8 deletions
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index b60cdc42b39b..36259d5ffb7f 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -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); diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index ff6581d207a9..6bc427ba28f3 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -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); diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index d4e1f9e51997..e92806e739fe 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -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 |