diff options
author | Akshay Deep <akshaydeepiitr@gmail.com> | 2017-07-20 19:08:28 +0530 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2017-07-25 21:26:39 +0200 |
commit | 06aacee86ec9e53928cc0c31906a8922babfe2b6 (patch) | |
tree | c0559e52b5c3b599f18b5b0fa5bdbaf07b161981 /sfx2 | |
parent | 987f8824b4f229590b54b11482da431d451412f1 (diff) |
Clear Recent View and Fav view using Right Click
Conflicts:
sfx2/inc/doc.hrc
sfx2/source/doc/doc.src
Change-Id: I0aa2919815a3fa63ee180b808834a8aa760af649
Reviewed-on: https://gerrit.libreoffice.org/40234
Reviewed-by: Akshay Deep <akshaydeepiitr@gmail.com>
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/charwin.cxx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/sfx2/source/control/charwin.cxx b/sfx2/source/control/charwin.cxx index 36f6eb15c581..184c841fbe09 100644 --- a/sfx2/source/control/charwin.cxx +++ b/sfx2/source/control/charwin.cxx @@ -24,6 +24,8 @@ #include <comphelper/dispatchcommand.hxx> #include <comphelper/processfactory.hxx> #include <sfx2/app.hxx> +#include <sfx2/sfxresid.hxx> +#include <sfx2/strings.hrc> using namespace com::sun::star; @@ -31,6 +33,7 @@ using namespace com::sun::star; SvxCharView::SvxCharView(vcl::Window* pParent) : Control(pParent, WB_TABSTOP | WB_BORDER) , mnY(0) + , maPosition(0,0) { } @@ -49,6 +52,20 @@ void SvxCharView::MouseButtonDown( const MouseEvent& rMEvt ) maMouseClickHdl.Call(this); } + + if(rMEvt.IsRight()) + { + Point aPosition (rMEvt.GetPosPixel()); + maPosition = aPosition; + GrabFocus(); + Invalidate(); + createContextMenu(); + } +} + +Point SvxCharView::GetClickPosition() const +{ + return maPosition; } void SvxCharView::KeyInput( const KeyEvent& rKEvt ) @@ -82,6 +99,34 @@ void SvxCharView::InsertCharToDoc() comphelper::dispatchCommand(".uno:InsertSymbol", aArgs); } +void SvxCharView::createContextMenu() +{ + ScopedVclPtrInstance<PopupMenu> pItemMenu; + pItemMenu->InsertItem(0,SfxResId(STR_CLEAR_CHAR)); + pItemMenu->InsertItem(1,SfxResId(STR_CLEAR_ALL_CHAR)); + pItemMenu->SetSelectHdl(LINK(this, SvxCharView, ContextMenuSelectHdl)); + pItemMenu->Execute(this, tools::Rectangle(maPosition,Size(1,1)), PopupMenuFlags::ExecuteDown); + Invalidate(); +} + +IMPL_LINK(SvxCharView, ContextMenuSelectHdl, Menu*, pMenu, bool) +{ + sal_uInt16 nMenuId = pMenu->GetCurItemId(); + + switch(nMenuId) + { + case 0: + maClearClickHdl.Call(this); + break; + case 1: + maClearAllClickHdl.Call(this); + break; + default: + break; + } + return false; +} + void SvxCharView::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle&) { rRenderContext.SetFont(maFont); @@ -171,6 +216,16 @@ void SvxCharView::setMouseClickHdl(const Link<SvxCharView*,void> &rLink) maMouseClickHdl = rLink; } +void SvxCharView::setClearClickHdl(const Link<SvxCharView*,void> &rLink) +{ + maClearClickHdl = rLink; +} + +void SvxCharView::setClearAllClickHdl(const Link<SvxCharView*,void> &rLink) +{ + maClearAllClickHdl = rLink; +} + void SvxCharView::SetFont( const vcl::Font& rFont ) { long nWinHeight = GetOutputSizePixel().Height(); |