Resolves: tdf#155140 gallery right click for context menu doesn't consume event

Change-Id: I13b6d62561e3d9eed47f81c4268a6a32ff108b40
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151355
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/svx/inc/galbrws2.hxx b/svx/inc/galbrws2.hxx
index 9cfb5c7..d5ca8a5 100644
--- a/svx/inc/galbrws2.hxx
+++ b/svx/inc/galbrws2.hxx
@@ -143,7 +143,7 @@ public:
    sal_Int8            ExecuteDrop( const ExecuteDropEvent& rEvt );
    bool                StartDrag();
    void                TogglePreview();
    void                ShowContextMenu(const CommandEvent& rCEvt);
    bool                ShowContextMenu(const CommandEvent& rCEvt);
    bool                KeyInput(const KeyEvent& rEvt);
    bool                ViewBoxHasFocus() const;

diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx
index 52c0551..8285419 100644
--- a/svx/source/gallery2/galbrws2.cxx
+++ b/svx/source/gallery2/galbrws2.cxx
@@ -486,20 +486,20 @@ void GalleryBrowser2::TogglePreview()
    GetViewWindow()->grab_focus();
}

void GalleryBrowser2::ShowContextMenu(const CommandEvent& rCEvt)
bool GalleryBrowser2::ShowContextMenu(const CommandEvent& rCEvt)
{
    Point aMousePos = rCEvt.GetMousePosPixel();
    Point aSelPos;
    const sal_uInt32 nItemId = ImplGetSelectedItemId( rCEvt.IsMouseEvent() ? &aMousePos : nullptr, aSelPos );

    if( !(mpCurTheme && nItemId && ( nItemId <= mpCurTheme->GetObjectCount() )) )
        return;
        return false;

    ImplSelectItemId( nItemId );

    css::uno::Reference< css::frame::XFrame > xFrame( GetFrame() );
    if ( !xFrame.is() )
        return;
        return false;

    weld::Widget* pParent = GetViewWindow();
    mnCurActionPos = nItemId - 1;
@@ -511,6 +511,7 @@ void GalleryBrowser2::ShowContextMenu(const CommandEvent& rCEvt)
            GALLERYBROWSERMODE_PREVIEW == GetMode(),
            this ) );
    xPopup->ExecutePopup(pParent, aSelPos);
    return true;
}

bool GalleryBrowser2::ViewBoxHasFocus() const
diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx
index ae9de1c..716a198 100644
--- a/svx/source/gallery2/galctrl.cxx
+++ b/svx/source/gallery2/galctrl.cxx
@@ -384,9 +384,9 @@ bool GalleryIconView::Command(const CommandEvent& rCEvt)
{
    bool bRet = ValueSet::Command(rCEvt);

    if (rCEvt.GetCommand() == CommandEventId::ContextMenu)
    if (!bRet && rCEvt.GetCommand() == CommandEventId::ContextMenu)
    {
        mpParent->ShowContextMenu(rCEvt);
        bRet = mpParent->ShowContextMenu(rCEvt);
    }

    return bRet;