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

Jim Raykowski (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 3 20:52:15 UTC 2021


 svx/source/inc/StylesPreviewWindow.hxx      |    3 +
 svx/source/tbxctrls/StylesPreviewWindow.cxx |   49 ++++++++++++++++++++++++----
 2 files changed, 44 insertions(+), 8 deletions(-)

New commits:
commit f16ab02c98b8d3483f6b6a7f8f10a4e41b545464
Author:     Jim Raykowski <raykowj at gmail.com>
AuthorDate: Fri Jan 22 20:38:21 2021 -0900
Commit:     Jim Raykowski <raykowj at gmail.com>
CommitDate: Wed Feb 3 21:51:21 2021 +0100

    tdf#137121 add popup menu to style items used in styles preview window
    
    Change-Id: Ib9bd6584416b24301d3d302165d12c89bcd1e178
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109838
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <raykowj at gmail.com>

diff --git a/svx/source/inc/StylesPreviewWindow.hxx b/svx/source/inc/StylesPreviewWindow.hxx
index 8381f3b72c49..9e90c4d36288 100644
--- a/svx/source/inc/StylesPreviewWindow.hxx
+++ b/svx/source/inc/StylesPreviewWindow.hxx
@@ -56,7 +56,8 @@ public:
 
     void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
 
-    bool MouseButtonDown(const MouseEvent&) override;
+    bool MouseButtonDown(const MouseEvent& rMEvt) override;
+    bool Command(const CommandEvent& rEvent) override;
 
     void SetStyle(const std::pair<OUString, OUString>& sStyleName);
 
diff --git a/svx/source/tbxctrls/StylesPreviewWindow.cxx b/svx/source/tbxctrls/StylesPreviewWindow.cxx
index 8ba7afe23ae4..48d12d2a67f2 100644
--- a/svx/source/tbxctrls/StylesPreviewWindow.cxx
+++ b/svx/source/tbxctrls/StylesPreviewWindow.cxx
@@ -52,6 +52,9 @@
 #include <com/sun/star/uno/Sequence.hxx>
 #include <cppuhelper/weak.hxx>
 
+#include <vcl/event.hxx>
+#include <vcl/commandevent.hxx>
+
 StyleStatusListener::StyleStatusListener(
     StylesPreviewWindow_Base* pPreviewControl,
     const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
@@ -100,15 +103,47 @@ void StyleItemController::Select(bool bSelect)
     Invalidate();
 }
 
-bool StyleItemController::MouseButtonDown(const MouseEvent&)
+bool StyleItemController::MouseButtonDown(const MouseEvent& rMEvt)
 {
-    css::uno::Sequence<css::beans::PropertyValue> aArgs(2);
-    aArgs[0].Value <<= m_aStyleName.second;
-    aArgs[1].Name = "Family";
-    aArgs[1].Value <<= sal_Int16(m_eStyleFamily);
+    if (rMEvt.IsLeft())
+    {
+        css::uno::Sequence<css::beans::PropertyValue> aArgs(2);
+        aArgs[0].Value <<= m_aStyleName.second;
+        aArgs[1].Name = "Family";
+        aArgs[1].Value <<= sal_Int16(m_eStyleFamily);
+
+        aArgs[0].Name = "Template";
+        SfxToolBoxControl::Dispatch(m_xDispatchProvider, ".uno:StyleApply", aArgs);
+    }
+
+    return false;
+}
 
-    aArgs[0].Name = "Template";
-    SfxToolBoxControl::Dispatch(m_xDispatchProvider, ".uno:StyleApply", aArgs);
+bool StyleItemController::Command(const CommandEvent& rEvent)
+{
+    if (rEvent.GetCommand() != CommandEventId::ContextMenu)
+        return CustomWidgetController::Command(rEvent);
+
+    std::unique_ptr<weld::Builder> xBuilder(
+        Application::CreateBuilder(GetDrawingArea(), "svx/ui/stylemenu.ui"));
+    std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu("menu"));
+    std::string_view rIdent = xMenu->popup_at_rect(
+        GetDrawingArea(), tools::Rectangle(rEvent.GetMousePosPixel(), Size(1, 1)));
+    if (rIdent == "update" || rIdent == "edit")
+    {
+        css::uno::Sequence<css::beans::PropertyValue> aArgs(2);
+        aArgs[0].Name = "Param";
+        aArgs[0].Value <<= m_aStyleName.second;
+        aArgs[1].Name = "Family";
+        aArgs[1].Value <<= sal_Int16(m_eStyleFamily);
+
+        SfxToolBoxControl::Dispatch(m_xDispatchProvider,
+                                    rIdent == "update" ? OUString(".uno:StyleUpdateByExample")
+                                                       : OUString(".uno:EditStyle"),
+                                    aArgs);
+
+        return true;
+    }
 
     return false;
 }


More information about the Libreoffice-commits mailing list