summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-04-04 17:07:52 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-04-05 09:04:56 +0000
commit9779054cc12fa8025f85b5d7d36c13cd25982db1 (patch)
treecebfa7089d862e24249b9738285905861e201639 /sc
parentefa72855b187d52a7e3c9cd4c79d6a2348c3f5bc (diff)
fix selection change event firing
Change-Id: I64e8b684dd5462e1a742ba47b5480951b4e3a4c4 Reviewed-on: https://gerrit.libreoffice.org/3210 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/viewuno.hxx3
-rw-r--r--sc/source/ui/unoobj/viewuno.cxx49
2 files changed, 48 insertions, 4 deletions
diff --git a/sc/inc/viewuno.hxx b/sc/inc/viewuno.hxx
index da2f96c152a4..64119793ee77 100644
--- a/sc/inc/viewuno.hxx
+++ b/sc/inc/viewuno.hxx
@@ -205,7 +205,8 @@ private:
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 b9f9541c31fe..b54a4cef35d7 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -463,7 +463,9 @@ ScTabViewObj::ScTabViewObj( ScTabViewShell* pViewSh ) :
aMouseClickHandlers( 0 ),
aActivationListeners( 0 ),
nPreviousTab( 0 ),
- bDrawSelModeSet(false)
+ bDrawSelModeSet(false),
+ mbLeftMousePressed(false ),
+ mbPendingSelectionChanged(false)
{
if (pViewSh)
nPreviousTab = pViewSh->GetViewData()->GetTabNo();
@@ -1184,13 +1186,17 @@ bool ScTabViewObj::IsMouseListening() const
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::MousePressed( const awt::MouseEvent& e )
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 @@ void ScTabViewObj::SelectionChanged()
/*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;
+ }
}