[Libreoffice-commits] core.git: sd/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 21 08:46:11 UTC 2020


 sd/source/ui/sidebar/LayoutMenu.cxx |   36 +++++++++++++-----------------------
 sd/source/ui/sidebar/LayoutMenu.hxx |    3 +--
 2 files changed, 14 insertions(+), 25 deletions(-)

New commits:
commit ea43bfcf5543e5593e73725e9fc9db541ce7fdd6
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Dec 20 20:36:23 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Dec 21 09:45:28 2020 +0100

    weld impress layoutmenu
    
    Change-Id: Ibc8038b37f8ff689050d9abb4ec0d2fac2eaadf9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108066
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx
index 57835e1b848f..96a2fcecb447 100644
--- a/sd/source/ui/sidebar/LayoutMenu.cxx
+++ b/sd/source/ui/sidebar/LayoutMenu.cxx
@@ -31,6 +31,7 @@
 #include <sdresid.hxx>
 #include <unokywds.hxx>
 #include <bitmaps.hlst>
+#include <tools/gen.hxx>
 #include <tools/SlotStateListener.hxx>
 #include <DrawController.hxx>
 #include <DrawDocShell.hxx>
@@ -50,7 +51,7 @@
 #include <svl/intitem.hxx>
 #include <vcl/commandevent.hxx>
 #include <vcl/image.hxx>
-#include <vcl/floatwin.hxx>
+#include <vcl/weldutils.hxx>
 #include <xmloff/autolayout.hxx>
 
 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
@@ -600,13 +601,10 @@ void LayoutMenu::ShowContextMenu(const Point* pPos)
     }
 
     // Setup the menu.
-    VclBuilder aBuilder(nullptr, AllSettings::GetUIRootDir(), "modules/simpress/ui/layoutmenu.ui", "");
-    VclPtr<PopupMenu> pMenu(aBuilder.get_menu("menu"));
-    FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow());
-    if (pMenuWindow != nullptr)
-        pMenuWindow->SetPopupModeFlags(
-            pMenuWindow->GetPopupModeFlags() | FloatWinPopupFlags::NoMouseUpClose);
-    pMenu->SetSelectHdl(LINK(this, LayoutMenu, OnMenuItemSelected));
+    ::tools::Rectangle aRect(aMenuPosition, Size(1, 1));
+    weld::Window* pPopupParent = weld::GetPopupParent(*this, aRect);
+    std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, "modules/simpress/ui/layoutmenu.ui"));
+    std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu("menu"));
 
     // Disable the SID_INSERTPAGE_LAYOUT_MENU item when
     // the document is read-only.
@@ -614,10 +612,10 @@ void LayoutMenu::ShowContextMenu(const Point* pPos)
     const SfxItemState aState (
         mrBase.GetViewFrame()->GetDispatcher()->QueryState(SID_INSERTPAGE, pItem));
     if (aState == SfxItemState::DISABLED)
-        pMenu->EnableItem(SID_INSERTPAGE_LAYOUT_MENU, false);
+        xMenu->set_sensitive("insert", false);
 
     // Show the menu.
-    pMenu->Execute(this, ::tools::Rectangle(aMenuPosition,Size(1,1)), PopupMenuFlags::ExecuteDown);
+    OnMenuItemSelected(xMenu->popup_at_rect(pPopupParent, aRect));
 }
 
 IMPL_LINK_NOARG(LayoutMenu, StateChangeHandler, const OUString&, void)
@@ -625,29 +623,21 @@ IMPL_LINK_NOARG(LayoutMenu, StateChangeHandler, const OUString&, void)
     InvalidateContent();
 }
 
-IMPL_LINK(LayoutMenu, OnMenuItemSelected, Menu*, pMenu, bool)
+void LayoutMenu::OnMenuItemSelected(std::string_view ident)
 {
-    if (pMenu == nullptr)
-    {
-        OSL_ENSURE(pMenu!=nullptr, "LayoutMenu::OnMenuItemSelected: illegal menu!");
-        return false;
-    }
-
-    pMenu->Deactivate();
-    OString sIdent = pMenu->GetCurItemIdent();
+    if (ident.empty())
+        return;
 
-    if (sIdent == "apply")
+    if (ident == "apply")
     {
         AssignLayoutToSelectedSlides(GetSelectedAutoLayout());
     }
-    else if (sIdent == "insert")
+    else if (ident == "insert")
     {
         // Add arguments to this slot and forward it to the main view
         // shell.
         InsertPageWithLayout(GetSelectedAutoLayout());
     }
-
-    return false;
 }
 
 // Selects an appropriate layout of the slide inside control.
diff --git a/sd/source/ui/sidebar/LayoutMenu.hxx b/sd/source/ui/sidebar/LayoutMenu.hxx
index c6326fd7be57..b6f6388483ac 100644
--- a/sd/source/ui/sidebar/LayoutMenu.hxx
+++ b/sd/source/ui/sidebar/LayoutMenu.hxx
@@ -24,7 +24,6 @@
 #include <sfx2/sidebar/PanelLayout.hxx>
 
 #include <svtools/valueset.hxx>
-#include <vcl/menu.hxx>
 #include <sfx2/request.hxx>
 #include <xmloff/autolayout.hxx>
 
@@ -170,7 +169,7 @@ private:
     DECL_LINK(StateChangeHandler, const OUString&, void);
     DECL_LINK(EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent&, void);
     DECL_LINK(WindowEventHandler, VclWindowEvent&, void);
-    DECL_LINK(OnMenuItemSelected, Menu*, bool);
+    void OnMenuItemSelected(std::string_view ident);
 };
 
 } // end of namespace ::sd::toolpanel


More information about the Libreoffice-commits mailing list