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

Armin Le Grand Armin.Le.Grand at cib.de
Tue Apr 26 10:34:08 UTC 2016


 sd/source/ui/annotations/annotationmanager.cxx |   17 +++++++++++++++++
 sd/source/ui/annotations/annotationtag.cxx     |   16 ++++++++++++----
 sd/source/ui/annotations/annotationwindow.cxx  |    1 +
 sd/source/ui/annotations/annotationwindow.hxx  |    5 +++++
 4 files changed, 35 insertions(+), 4 deletions(-)

New commits:
commit ed42a984099b8847aedbdd638c7e20e0b68a9290
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Thu Apr 21 16:05:38 2016 +0200

    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 at libreoffice.org>
    Reviewed-by: Armin Le Grand <Armin.Le.Grand at cib.de>

diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 154f694..baee94a 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 827ece4..0096af1 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 a33e043..2998292 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 0ce3197..6aed9ec 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;


More information about the Libreoffice-commits mailing list