[Libreoffice-commits] core.git: include/vcl svtools/source toolkit/inc toolkit/source vcl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 4 16:49:16 UTC 2020


 include/vcl/menu.hxx                         |    3 +++
 include/vcl/toolkit/unowrap.hxx              |    9 +++++++--
 svtools/source/control/managedmenubutton.cxx |    8 ++++----
 toolkit/inc/helper/unowrapper.hxx            |    3 +++
 toolkit/source/helper/unowrapper.cxx         |    6 ++++++
 vcl/source/window/menu.cxx                   |    8 ++++++++
 6 files changed, 31 insertions(+), 6 deletions(-)

New commits:
commit d97a819abe84fe667f8b136b1c2adaec5ca7196e
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Dec 4 15:18:38 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Dec 4 17:48:20 2020 +0100

    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 at redhat.com>

diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index 7613f14f157c..3838395601ac 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -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();
 
diff --git a/include/vcl/toolkit/unowrap.hxx b/include/vcl/toolkit/unowrap.hxx
index ad528af0e0b3..c646dbccc882 100644
--- a/include/vcl/toolkit/unowrap.hxx
+++ b/include/vcl/toolkit/unowrap.hxx
@@ -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
diff --git a/svtools/source/control/managedmenubutton.cxx b/svtools/source/control/managedmenubutton.cxx
index 45e9d98ca1a8..4db9d2a1858b 100644
--- a/svtools/source/control/managedmenubutton.cxx
+++ b/svtools/source/control/managedmenubutton.cxx
@@ -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);
 }
 
 }
diff --git a/toolkit/inc/helper/unowrapper.hxx b/toolkit/inc/helper/unowrapper.hxx
index cfb890584c61..6e10e870506d 100644
--- a/toolkit/inc/helper/unowrapper.hxx
+++ b/toolkit/inc/helper/unowrapper.hxx
@@ -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
diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx
index eb37d4137419..edac7fe62b34 100644
--- a/toolkit/source/helper/unowrapper.cxx
+++ b/toolkit/source/helper/unowrapper.cxx
@@ -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;
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 1f13715a5e7f..ea08e0a05855 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -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 )


More information about the Libreoffice-commits mailing list