diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2016-04-21 16:05:38 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2016-04-26 10:33:41 +0000 |
commit | ed42a984099b8847aedbdd638c7e20e0b68a9290 (patch) | |
tree | b2660781d18ee5533aa6912898982716300462cb | |
parent | f91674bd4b5022a63dc5e6a89fe9a1b832d96798 (diff) |
tdf#99388 suppress close comment when PopupMenu is active
With comments in draw/impress these use vcl::windows of type
AnnotationWindow. When the PopupMenu bottom-right is used,
this gets a LoseFocus event and gets closed since this is the
standard mechanism this window closes. This is fatal when
the PopupMenu is open since it uses it as parent window.
To avoid this, a flag is added to the AnnotationWindow
to avoid triggering the close event in that state.
Change-Id: Ic27782e56d192c0963868d9ca560945f8a34394f
Reviewed-on: https://gerrit.libreoffice.org/24280
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
-rw-r--r-- | sd/source/ui/annotations/annotationmanager.cxx | 17 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationtag.cxx | 16 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationwindow.cxx | 1 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationwindow.hxx | 5 |
4 files changed, 35 insertions, 4 deletions
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 154f694687de..baee94a6ab61 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -996,7 +996,24 @@ void AnnotationManagerImpl::ExecuteAnnotationContextMenu( const Reference< XAnno } } + AnnotationWindow* pParentAnnotationWindow = dynamic_cast< AnnotationWindow* >( pParent ); + + if(pParentAnnotationWindow) + { + // tdf#99388 make known that PopupMenu is active at parent + // to allow suppressing closing of that window if needed + pParentAnnotationWindow->setPopupMenuActive(true); + } + nId = pMenu->Execute( pParent, rContextRect, PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose ); + + if(pParentAnnotationWindow) + { + // tdf#99388 reset flag, need to be done before reacting + // since closing it is one possible reaction + pParentAnnotationWindow->setPopupMenuActive(false); + } + switch( nId ) { case SID_REPLYTO_POSTIT: diff --git a/sd/source/ui/annotations/annotationtag.cxx b/sd/source/ui/annotations/annotationtag.cxx index 827ece454c84..0096af14385c 100644 --- a/sd/source/ui/annotations/annotationtag.cxx +++ b/sd/source/ui/annotations/annotationtag.cxx @@ -602,7 +602,7 @@ void AnnotationTag::OpenPopup( bool bEdit ) void AnnotationTag::ClosePopup() { - if( mpAnnotationWindow.get() ) + if( mpAnnotationWindow.get()) { mpAnnotationWindow->RemoveEventListener( LINK(this, AnnotationTag, WindowEventHandler)); mpAnnotationWindow->Deactivate(); @@ -620,10 +620,18 @@ IMPL_LINK_TYPED(AnnotationTag, WindowEventHandler, VclWindowEvent&, rEvent, void { if( rEvent.GetId() == VCLEVENT_WINDOW_DEACTIVATE ) { - if( mnClosePopupEvent ) - Application::RemoveUserEvent( mnClosePopupEvent ); + if(mpAnnotationWindow->getPopupMenuActive()) + { + // tdf#99388 if PopupMenu is active, suppress deletion of the + // AnnotationWindow which is triggeded by it losing focus + } + else + { + if( mnClosePopupEvent ) + Application::RemoveUserEvent( mnClosePopupEvent ); - mnClosePopupEvent = Application::PostUserEvent( LINK( this, AnnotationTag, ClosePopupHdl ) ); + mnClosePopupEvent = Application::PostUserEvent( LINK( this, AnnotationTag, ClosePopupHdl ) ); + } } } else if( pWindow == mpListenWindow ) diff --git a/sd/source/ui/annotations/annotationwindow.cxx b/sd/source/ui/annotations/annotationwindow.cxx index a33e04309efe..2998292a717f 100644 --- a/sd/source/ui/annotations/annotationwindow.cxx +++ b/sd/source/ui/annotations/annotationwindow.cxx @@ -281,6 +281,7 @@ AnnotationWindow::AnnotationWindow( AnnotationManagerImpl& rManager, DrawDocShel , mbReadonly(pDocShell->IsReadOnly()) , mbProtected(false) , mbMouseOverButton(false) +, mbPopupMenuActive(false) , mpTextWindow(nullptr) , mpMeta(nullptr) { diff --git a/sd/source/ui/annotations/annotationwindow.hxx b/sd/source/ui/annotations/annotationwindow.hxx index 0ce319766afa..6aed9ec748f7 100644 --- a/sd/source/ui/annotations/annotationwindow.hxx +++ b/sd/source/ui/annotations/annotationwindow.hxx @@ -88,6 +88,7 @@ class AnnotationWindow : public FloatingWindow bool mbReadonly; bool mbProtected; bool mbMouseOverButton; + bool mbPopupMenuActive; VclPtr<AnnotationTextWindow> mpTextWindow; VclPtr<MultiLineEdit> mpMeta; Rectangle maRectMetaButton; @@ -133,6 +134,10 @@ class AnnotationWindow : public FloatingWindow void ToggleInsMode(); + // tdf#99388 flag to transport if the PopupMenu is active + bool getPopupMenuActive() const { return mbPopupMenuActive; } + void setPopupMenuActive(bool bNew) { mbPopupMenuActive = bNew; } + virtual void Deactivate() override; virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect) override; virtual void MouseMove( const MouseEvent& rMEvt ) override; |