[Libreoffice-commits] core.git: sfx2/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri May 22 14:34:26 UTC 2020
sfx2/source/dialog/templdlg.cxx | 31 +++++++++++++++++++++++++++----
sfx2/source/inc/templdgi.hxx | 3 +++
2 files changed, 30 insertions(+), 4 deletions(-)
New commits:
commit 2a7bb352a9d6aa74495c03872c8c6150cbfc7a50
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri May 22 14:32:17 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri May 22 16:33:38 2020 +0200
Resolves: tdf#133183 select style under mouse on right click context menu
Change-Id: I4317f6702b7a0e172d059fe83614aab94845b201
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94690
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index cd54f9290867..18be2cd2e1c6 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -319,25 +319,48 @@ IMPL_LINK(SfxCommonTemplateDialog_Impl, PopupFlatMenuHdl, const CommandEvent&, r
if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
return false;
+ PrepareMenu(rCEvt.GetMousePosPixel());
+
if (mxFmtLb->count_selected_rows() <= 0)
{
EnableEdit(false);
EnableDel(false);
}
- return PopupTreeMenuHdl(rCEvt);
+ ShowMenu(rCEvt);
+
+ return true;
}
-IMPL_LINK(SfxCommonTemplateDialog_Impl, PopupTreeMenuHdl, const CommandEvent&, rCEvt, bool)
+void SfxCommonTemplateDialog_Impl::PrepareMenu(const Point& rPos)
{
- if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
- return false;
+ weld::TreeView* pTreeView = mxTreeBox->get_visible() ? mxTreeBox.get() : mxFmtLb.get();
+ std::unique_ptr<weld::TreeIter> xIter(pTreeView->make_iterator());
+ if (pTreeView->get_dest_row_at_pos(rPos, xIter.get()) && !pTreeView->is_selected(*xIter))
+ {
+ pTreeView->unselect_all();
+ pTreeView->select(*xIter);
+ FmtSelectHdl(*pTreeView);
+ }
+}
+void SfxCommonTemplateDialog_Impl::ShowMenu(const CommandEvent& rCEvt)
+{
CreateContextMenu();
weld::TreeView* pTreeView = mxTreeBox->get_visible() ? mxTreeBox.get() : mxFmtLb.get();
OString sCommand(mxMenu->popup_at_rect(pTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))));
MenuSelect(sCommand);
+}
+
+IMPL_LINK(SfxCommonTemplateDialog_Impl, PopupTreeMenuHdl, const CommandEvent&, rCEvt, bool)
+{
+ if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
+ return false;
+
+ PrepareMenu(rCEvt.GetMousePosPixel());
+
+ ShowMenu(rCEvt);
return true;
}
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index 05746df094fc..57b95edf9191 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -207,6 +207,9 @@ protected:
void SaveFactoryStyleFilter( SfxObjectShell const * i_pObjSh, sal_Int32 i_nFilter );
SfxObjectShell* SaveSelection();
+ void PrepareMenu(const Point& rPos);
+ void ShowMenu(const CommandEvent& rCEvt);
+
public:
SfxCommonTemplateDialog_Impl(SfxBindings* pB, vcl::Window*, weld::Builder* pBuilder);
More information about the Libreoffice-commits
mailing list