[Libreoffice-commits] .: sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Dec 5 21:39:35 PST 2012


 sc/source/ui/inc/gridwin.hxx  |    4 +++-
 sc/source/ui/view/gridwin.cxx |   39 +++++++++++++++++++++++----------------
 2 files changed, 26 insertions(+), 17 deletions(-)

New commits:
commit abb1e3352b21d26e2ea00f504162540daa7d69f2
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Dec 6 00:32:22 2012 -0500

    Avoid activating window pane when launching popup window.
    
    Else, activating another window pane where the cursor is not would cause
    the pivot table field popup to immediately get dismissed after launch because
    ClickExtern() gets called from ActivatePart().
    
    For example, imagine a field popup button is on C2, the cell cursor is
    on E5, and the window is frozen between rows 2 and 3.  Clicking the popup
    button in C2 would launch it for a brief second and dismiss it immediately
    afterward.  Conceptually, launching a popup in another pane shouldn't
    activate that pane anyway. So it makes sense not to activate it for that
    scenario.
    
    Change-Id: Ib970cb898fb9c79d254411e2519cfce74c60b72f

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 055924a..fcd4dbf 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -93,6 +93,8 @@ private:
 
     boost::scoped_ptr<Rectangle> mpAutoFillRect;
 
+    struct MouseEventState;
+
     /**
      * Stores current visible column and row ranges, used to avoid expensive
      * operations on objects that are outside visible area.
@@ -228,7 +230,7 @@ private:
     sal_Int8        DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPosX, SCROW nDestPosY,
                                      const Point& rLogicPos, sal_Int8 nDndAction );
 
-    void            HandleMouseButtonDown( const MouseEvent& rMEvt );
+    void            HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventState& rState );
 
     bool            DrawMouseButtonDown(const MouseEvent& rMEvt);
     bool            DrawMouseButtonUp(const MouseEvent& rMEvt);
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index fba27b7..c116d43 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -155,6 +155,13 @@ extern SfxViewShell* pScActiveViewShell;            // global.cxx
 extern sal_uInt16 nScClickMouseModifier;                // global.cxx
 extern sal_uInt16 nScFillModeMouseModifier;             // global.cxx
 
+struct ScGridWindow::MouseEventState
+{
+    bool mbActivatePart;
+
+    MouseEventState() : mbActivatePart(false) {}
+};
+
 #define SC_FILTERLISTBOX_LINES  12
 
 // ============================================================================
@@ -1720,7 +1727,10 @@ void ScGridWindow::MouseButtonDown( const MouseEvent& rMEvt )
 {
     nNestedButtonState = SC_NESTEDBUTTON_DOWN;
 
-    HandleMouseButtonDown( rMEvt );
+    MouseEventState aState;
+    HandleMouseButtonDown(rMEvt, aState);
+    if (aState.mbActivatePart)
+        pViewData->GetView()->ActivatePart(eWhich);
 
     if ( nNestedButtonState == SC_NESTEDBUTTON_UP )
     {
@@ -1737,7 +1747,7 @@ void ScGridWindow::MouseButtonDown( const MouseEvent& rMEvt )
     nNestedButtonState = SC_NESTEDBUTTON_NONE;
 }
 
-void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt )
+void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventState& rState )
 {
     // We have to check if a context menu is shown and we have an UI
     // active inplace client. In that case we have to ignore the event.
@@ -1818,12 +1828,9 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt )
     if (!bDouble)
         nMouseStatus = SC_GM_NONE;
 
-    if (!bFormulaMode)
-    {
-        if ( pViewData->GetActivePart() != eWhich )
-            pViewData->GetView()->ActivatePart( eWhich );
-    }
-    else
+    rState.mbActivatePart = !bFormulaMode; // Don't activate when in formula mode.
+
+    if (bFormulaMode)
     {
         ScViewSelectionEngine* pSelEng = pViewData->GetView()->GetSelEngine();
         pSelEng->SetWindow(this);
@@ -1879,9 +1886,7 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt )
     {
         bRFMouse = true;        // die anderen Variablen sind oben initialisiert
 
-        if ( pViewData->GetActivePart() != eWhich )
-            pViewData->GetView()->ActivatePart( eWhich );   //! schon oben immer ???
-
+        rState.mbActivatePart = true; // always activate ?
         StartTracking();
         return;
     }
@@ -1892,7 +1897,7 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt )
         if ( bDouble )
             pViewData->GetView()->FillCrossDblClick();
         else
-        pScMod->InputEnterHandler();                                // Autofill etc.
+            pScMod->InputEnterHandler();                                // Autofill etc.
     }
 
     if ( !bCrossPointer )
@@ -1927,10 +1932,7 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt )
     SCTAB nTab = pViewData->GetTabNo();
     ScDocument* pDoc = pViewData->GetDocument();
 
-
-            //
-            //      AutoFilter buttons
-            //
+    // Auto filter / pivot table / data select popup.  This shouldn't activate the part.
 
     if ( !bDouble && !bFormulaMode && rMEvt.IsLeft() )
     {
@@ -1939,11 +1941,15 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt )
         if (pAttr->HasAutoFilter())
         {
             if (DoAutoFilterButton(nPosX, nPosY, rMEvt))
+            {
+                rState.mbActivatePart = false;
                 return;
+            }
         }
         if (pAttr->HasButton())
         {
             DoPushButton( nPosX, nPosY, rMEvt );    // setzt evtl. bPivotMouse / bDPMouse
+            rState.mbActivatePart = false;
             return;
         }
 
@@ -1958,6 +1964,7 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt )
 
                 nMouseStatus = SC_GM_FILTER;    // not set in DoAutoFilterMenue for bDataSelect
                 CaptureMouse();
+                rState.mbActivatePart = false;
                 return;
             }
         }


More information about the Libreoffice-commits mailing list