Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3210

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/10/3210/1

fix selection change event firing

Change-Id: I64e8b684dd5462e1a742ba47b5480951b4e3a4c4
---
M sc/inc/viewuno.hxx
M sc/source/ui/unoobj/viewuno.cxx
M vbahelper/source/msforms/vbacontrol.cxx
3 files changed, 51 insertions(+), 4 deletions(-)



diff --git a/sc/inc/viewuno.hxx b/sc/inc/viewuno.hxx
index da2f96c..6411979 100644
--- a/sc/inc/viewuno.hxx
+++ b/sc/inc/viewuno.hxx
@@ -205,7 +205,8 @@
     void                    EndMouseListening();
     void                    StartActivationListening();
     void                    EndActivationListening();
-
+    bool                    mbLeftMousePressed;
+    bool                    mbPendingSelectionChanged;
     ScTabViewObj(); // disabled
 public:
                             ScTabViewObj(ScTabViewShell* pViewSh);
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index b9f9541..b54a4ce 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -463,7 +463,9 @@
     aMouseClickHandlers( 0 ),
     aActivationListeners( 0 ),
     nPreviousTab( 0 ),
-    bDrawSelModeSet(false)
+    bDrawSelModeSet(false),
+    mbLeftMousePressed(false    ),
+    mbPendingSelectionChanged(false)
 {
     if (pViewSh)
         nPreviousTab = pViewSh->GetViewData()->GetTabNo();
@@ -1184,13 +1186,17 @@
     SCTAB nTab = pViewData->GetTabNo();
     return
         pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_RIGHTCLICK, true ) ||
-        pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_DOUBLECLICK, true );
+        pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_DOUBLECLICK, true ) ||
+        pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_SELECT, true );
+
 }
 
 sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e )
                                     throw (::uno::RuntimeException)
 {
     sal_Bool bReturn(false);
+    if ( e.Buttons == ::com::sun::star::awt::MouseButton::LEFT )
+        mbLeftMousePressed = true;
 
     uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
     if (!aMouseClickHandlers.empty() && xTarget.is())
@@ -1281,6 +1287,26 @@
 sal_Bool ScTabViewObj::MouseReleased( const awt::MouseEvent& e )
                                     throw (uno::RuntimeException)
 {
+    if ( e.Buttons == ::com::sun::star::awt::MouseButton::LEFT )
+    {
+        try
+        {
+            mbPendingSelectionChanged = false;
+            ScTabViewShell* pViewSh = GetViewShell();
+            ScViewData* pViewData = pViewSh->GetViewData();
+            ScDocShell* pDocSh = pViewData->GetDocShell();
+            ScDocument* pDoc = pDocSh->GetDocument();
+            uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( 
pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW );
+            uno::Sequence< uno::Any > aArgs( 1 );
+            aArgs[ 0 ] <<= getSelection();
+            xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_SELECT 
), aArgs );
+        }
+        catch( uno::Exception& )
+        {
+        }
+        mbLeftMousePressed = false;
+    }
+
     sal_Bool bReturn(false);
 
     if (!aMouseClickHandlers.empty())
@@ -1746,7 +1772,24 @@
             /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, 
aOutArgs );
         }
     }
-    // Removed Sun/Oracle code intentionally, it doesn't work properly ( selection should be fired 
after mouse release )
+    if ( !mbLeftMousePressed ) // selection still in progress
+    {
+        mbPendingSelectionChanged = false;
+        try
+        {
+            uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( 
pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW );
+            uno::Sequence< uno::Any > aArgs( 1 );
+            aArgs[ 0 ] <<= getSelection();
+            xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_SELECT 
), aArgs );
+        }
+        catch( uno::Exception& )
+        {
+        }
+    }
+    else
+    {
+        mbPendingSelectionChanged = true;
+    }
 }
 
 
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index e9be040..b788368 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -192,11 +192,14 @@
 sal_Bool SAL_CALL ScVbaControl::getVisible() throw (uno::RuntimeException)
 {
     sal_Bool bVisible( sal_True );
+    m_xProps->getPropertyValue ( "EnableVisible" ) >>= bVisible;
     uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY );
     if ( xControlShape.is() )
     {
+        bool bEnableVisible = bVisible;
         uno::Reference< beans::XPropertySet > xProps( m_xControl, uno::UNO_QUERY_THROW );
         xProps->getPropertyValue ( "Visible" ) >>= bVisible;
+        bVisible = bVisible && bEnableVisible;
     }
     else
         m_xProps->getPropertyValue ( "EnableVisible" ) >>= bVisible;

-- 
To view, visit https://gerrit.libreoffice.org/3210
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I64e8b684dd5462e1a742ba47b5480951b4e3a4c4
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Noel Power <noel.power@suse.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.