add a way to get an awt::XPopupMenu from a PopupMenu

Change-Id: Ia1cde3b60b71ed9e4d0b7dc8d9ad0b2899d60b98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107229
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2020-12-04 17:48:20 +01:00
parent d087459826
commit d97a819abe
6 changed files with 31 additions and 6 deletions
+3
View File
@@ -50,6 +50,7 @@ class MenuBarWindow;
struct SystemMenuData;
enum class FloatWinPopupFlags;
namespace com::sun::star::awt { class XPopupMenu; }
namespace com::sun::star::accessibility { class XAccessible; }
namespace com::sun::star::frame { class XFrame; }
@@ -521,6 +522,8 @@ public:
virtual void SelectItem(sal_uInt16 nId) override;
void SetSelectedEntry( sal_uInt16 nId ); // for use by native submenu only
css::uno::Reference<css::awt::XPopupMenu> CreateMenuInterface();
static bool IsInExecute();
static PopupMenu* GetActivePopupMenu();
+7 -2
View File
@@ -30,10 +30,12 @@
#include <vcl/vclptr.hxx>
namespace vcl { class Window; }
class OutputDevice;
class Menu;
class OutputDevice;
class PopupMenu;
namespace com::sun::star::awt {
class XGraphics;
class XPopupMenu;
class XToolkit;
class XWindow;
class XWindowPeer;
@@ -55,10 +57,13 @@ public:
virtual void ReleaseAllGraphics( OutputDevice* pOutDev ) = 0;
// Window
virtual css::uno::Reference< css::awt::XWindowPeer> GetWindowInterface( vcl::Window* pWindow ) = 0;
virtual css::uno::Reference<css::awt::XWindowPeer> GetWindowInterface( vcl::Window* pWindow ) = 0;
virtual void SetWindowInterface( vcl::Window* pWindow, css::uno::Reference< css::awt::XWindowPeer > xIFace ) = 0;
virtual VclPtr<vcl::Window> GetWindow(const css::uno::Reference<css::awt::XWindow>& rxWindow) = 0;
// PopupMenu
virtual css::uno::Reference<css::awt::XPopupMenu> CreateMenuInterface( PopupMenu* pPopupMenu ) = 0;
virtual void WindowDestroyed( vcl::Window* pWindow ) = 0;
// Accessibility
+4 -4
View File
@@ -9,11 +9,11 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
#include <toolkit/awt/vclxmenu.hxx>
#include <vcl/builderfactory.hxx>
#include <vcl/menu.hxx>
#include <vcl/menubtn.hxx>
#include <com/sun/star/awt/XPopupMenu.hpp>
#include <com/sun/star/frame/theDesktop.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/frame/thePopupMenuControllerFactory.hpp>
@@ -31,7 +31,7 @@ public:
void dispose() override;
private:
rtl::Reference<VCLXPopupMenu> m_xPopupMenu;
css::uno::Reference<css::awt::XPopupMenu> m_xPopupMenu;
css::uno::Reference<css::frame::XPopupMenuController> m_xPopupController;
};
@@ -71,7 +71,7 @@ void ManagedMenuButton::Activate()
}
if (!m_xPopupMenu.is())
m_xPopupMenu.set(new VCLXPopupMenu(GetPopupMenu()));
m_xPopupMenu = GetPopupMenu()->CreateMenuInterface();
// FIXME: get the frame from the parent VclBuilder.
css::uno::Reference<css::uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
@@ -112,7 +112,7 @@ void ManagedMenuButton::Activate()
"com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), css::uno::UNO_QUERY);
if (m_xPopupController.is())
m_xPopupController->setPopupMenu(m_xPopupMenu.get());
m_xPopupController->setPopupMenu(m_xPopupMenu);
}
}
+3
View File
@@ -55,6 +55,9 @@ public:
virtual void SetWindowInterface( vcl::Window* pWindow, css::uno::Reference< css::awt::XWindowPeer> xIFace ) override;
virtual VclPtr<vcl::Window> GetWindow(const css::uno::Reference<css::awt::XWindow>& rxWindow) override;
// Menu
virtual css::uno::Reference<css::awt::XPopupMenu> CreateMenuInterface( PopupMenu* pPopupMenu ) override;
void WindowDestroyed( vcl::Window* pWindow ) override;
// Accessibility
+6
View File
@@ -21,6 +21,7 @@
#include <toolkit/awt/vclxwindow.hxx>
#include <toolkit/awt/vclxwindows.hxx>
#include <toolkit/awt/vclxcontainer.hxx>
#include <toolkit/awt/vclxmenu.hxx>
#include <toolkit/awt/vclxtopwindow.hxx>
#include <awt/vclxgraphics.hxx>
@@ -179,6 +180,11 @@ void UnoWrapper::SetWindowInterface( vcl::Window* pWindow, css::uno::Reference<
pWindow->SetWindowPeer( xIFace, pVCLXWindow );
}
css::uno::Reference<css::awt::XPopupMenu> UnoWrapper::CreateMenuInterface( PopupMenu* pPopupMenu )
{
return new VCLXPopupMenu(pPopupMenu);
}
css::uno::Reference< css::awt::XGraphics> UnoWrapper::CreateGraphics( OutputDevice* pOutDev )
{
css::uno::Reference< css::awt::XGraphics> xGrf;
+8
View File
@@ -3113,6 +3113,14 @@ tools::Long PopupMenu::ImplCalcHeight( sal_uInt16 nEntries ) const
return nHeight;
}
css::uno::Reference<css::awt::XPopupMenu> PopupMenu::CreateMenuInterface()
{
UnoWrapperBase* pWrapper = UnoWrapperBase::GetUnoWrapper();
if ( pWrapper )
return pWrapper->CreateMenuInterface(this);
return nullptr;
}
ImplMenuDelData::ImplMenuDelData( const Menu* pMenu )
: mpNext( nullptr )
, mpMenu( nullptr )