Issue 30591 - Calc's range selection listener doesn't work in Windows
Summary: Calc's range selection listener doesn't work in Windows
Status: CONFIRMED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All Windows 98
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL: http://homepages.paradise.net.nz/hill...
Keywords: oooqa
Depends on:
Blocks:
 
Reported: 2004-06-23 02:18 UTC by iannz
Modified: 2017-05-20 11:28 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
mentioned bugdoc (31.17 KB, application/vnd.sun.xml.calc)
2004-07-12 13:36 UTC, stephan.wunderlich
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description iannz 2004-06-23 02:18:06 UTC
The Range selection listener for Calc 1.1.1 and above doesn't work in Windows98
(from reports from other people possibly other versions of Windows as well) but
does work in Linux. In OOo1.0.1 range selection listeners did work to some
extent, if CloseOnMouseRelease was set to false - you could at least select a
single cell and using shift+click select a range of cells. In OOo1.1.1 and 1.1.2
for Windows no range selection listening appears to work, on clicking on a sheet
you simply hear a "not allowed" beep.

For a complete file see MyDataPilot.sxc available from:
http://homepages.paradise.net.nz/hillview/OOo/

Here is the OOo BASIC code that works in Linux but not in Windows:

sub subEventShrink (oEvent)
'Called when Rng button clicked
'Uses module variables: oSpreadsheetView, oDialog, oRangeSelectionListener,
oDestRange
dim mRangeSelection, sField as string

sField = oEvent.Source.getModel().Name
sField = right(sField,len(sField) - 13)	'13 = len("CommandButton")
oDestField = oDialog.getControl("TextField" & sField)
SetPropertyValue( mRangeSelection, "InitialValue", oDestField.text)
SetPropertyValue( mRangeSelection, "Title", oDialog.title & " " & sField )
SetPropertyValue( mRangeSelection, "CloseOnMouseRelease", false )

'The order of starting the range selection and hiding the dialog is important it
must be as follows
oSpreadsheetView = oDoc.CurrentController
oRangeSelectionListener = CreateUnoListener(
"RangeSelectionListener_","com.sun.star.sheet.XRangeSelectionListener" )
oSpreadsheetView.addRangeSelectionListener( oRangeSelectionListener ) ' Register
the listener
oSpreadsheetView.startRangeSelection(mRangeSelection )
oDialog.visible=false
end sub


Sub RangeSelectionListener_done(oRangeSelectionEvent as new
com.sun.star.sheet.RangeSelectionEvent)
'Uses module variables: oSpreadsheetView, oRangeSelectionListener, oDestField,
oDialog
'Called when the range selection is done (clicking the icon at right end)

oDestField.text= oRangeSelectionEvent.RangeDescriptor
oSpreadsheetView.removeRangeSelectionListener(oRangeSelectionListener)
oDialog.visible=true
end sub


Sub RangeSelectionListener_aborted(oRangeSelectionEvent as new
com.sun.star.sheet.RangeSelectionEvent)
'Uses module variables: oSpreadsheetView, oDialog, oRangeSelectionListener
'Called when the range selection is cancelled (clicking X at top right)

oSpreadsheetView.removeRangeSelectionListener(oRangeSelectionListener)
oDialog.visible=true
end sub


Sub SetPropertyValue( aPropertyValuesArray, cPropName As String, ByVal uValue )
   nPropIndex = FindPropertyIndex( aPropertyValuesArray, cPropName )
   ' Did we find it?
   If nPropIndex >= 0 Then
      ' Found, the PropertyValue is already in the array.
      ' Just modify its value.
      oProp = aPropertyValuesArray(nPropIndex) ' access array subscript
      oProp.Value = uValue ' set the property value.
      aPropertyValuesArray(nPropIndex) = oProp ' put it back into array
   Else
      ' Not found, the array contains no PropertyValue with this name.
      ' Append new element to array.
      nNumProperties = NumPropertyValues( aPropertyValuesArray )
      
      If nNumProperties = 0 Then
         aPropertyValuesArray = Array( MakePropertyValue( cPropName, uValue ) )
      Else
         ' Make array larger.
         Redim Preserve aPropertyValuesArray(nNumProperties)
         ' Assign new PropertyValue
         aPropertyValuesArray(nNumProperties) = MakePropertyValue( cPropName,
uValue )
      EndIf
   EndIf
End Sub
Comment 1 iannz 2004-06-30 16:25:53 UTC
The issue appears to be in relation to having a dialog, even if it is hidden and
disabled at the same time as range selection listener. A workaround is to
endExecute the dialog before activating the range selection listener, and having
a loop around the main dialog.execute to bring the dialog back again. The
following code works for OOo1.1.1 for Linux and Windows98.

'Code for displaying the dialog
do
	bDialogFinished = true
	oDialog.Execute()
loop until bDialogFinished

'Code to activate the listener
bSelecting = true
bDialogFinished = false
oDialog.endExecute
oSpreadsheetView.addRangeSelectionListener( oRangeSelectionListener )
oSpreadsheetView.startRangeSelection(mRangeSelection )
while bSelecting
wend
oSpreadsheetView.removeRangeSelectionListener(oRangeSelectionListener)


'RangeSelectionListenerEvents

Sub RangeSelectionListener_done(oRangeSelectionEvent as new
com.sun.star.sheet.RangeSelectionEvent)
oDestField.text = oRangeSelectionEvent.RangeDescriptor 'I.e. do something with range
bSelecting = false
end sub


Sub RangeSelectionListener_aborted(oRangeSelectionEvent as new
com.sun.star.sheet.RangeSelectionEvent)
bSelecting = false
end sub

Sub RangeSelectionListener_disposing()
end sub

Comment 2 stephan.wunderlich 2004-07-06 13:42:05 UTC
SW->iannz: since the dialog seems to be kind of essential to reproduce the
behaviour, coudl you please attach a document containing the complete macro,
including the dialog to this issue ... thank you
Comment 3 iannz 2004-07-06 22:54:12 UTC
Am I going stupid - I can't see how to attach a document anymore. I am obviously
logged in - but there isn't a link or button for attaching a document. So at
this point all I can do is repeat where the file can be found.

The file is MyDataPilot.sxc available from toward the bottom of the page:
http://homepages.paradise.net.nz/hillview/OOo/

There is a demo button on the sheet, that on clicking runs the macro. Range
selection buttons are labelled "Rng" on the locations tab of the dialog. The
relevant code is in library standard, module ModDPtextControls.

The code has been altered as per my last post so that it will work in both
Windows and Linux by disabling the dialog, while the range selection listener is
active. Given that this works it is possible that the issue could be closed, but
it does seem that creating a range selection listener is more difficult than it
should be.

Something I have not been able to work out is how to activate the range
selection listener by clicking on the sheet rather than having to click a button.

Sorry to sound whingey - I think you people are doing a fantastic job and I
would like to help in whatever way I can. Cheers - Ian
Comment 4 masato12610 2004-07-08 11:04:06 UTC
Additional data point - the range selection problem with an active dialog 
still occurs in OO 1.1.2.
Comment 5 stephan.wunderlich 2004-07-12 13:36:16 UTC
Created attachment 16413 [details]
mentioned bugdoc
Comment 6 stephan.wunderlich 2004-07-12 13:41:08 UTC
SW->NN: running the macro in the attached document by pressing the demo button,
enabled me to select one cell and then the dialog reappeared. when changing 

'oDialog.endExecute
oSpreadsheetView.addRangeSelectionListener( oRangeSelectionListener ) ' Register
the listener
oDialog.enable = false
oDialog.visible = false

to 

oDialog.endExecute
oSpreadsheetView.addRangeSelectionListener( oRangeSelectionListener ) ' Register
the listener
'oDialog.enable = false
'oDialog.visible = false

I was able to select an arbitrary range each time I pressed one of the
Rng-buttons in the appearing dialog.
Comment 7 christianjunker 2005-08-07 20:35:40 UTC
cyb->sw: 
So what to do with this issue? Did your answer mean that this is not really an
issue for OOo, as the user did not write correct code or is it indeed a defect?
forwarding to you, since this issue looks like it has lost any focus.
Comment 8 stephan.wunderlich 2005-08-09 13:07:04 UTC
sw-cyb: my remark ment that using the flags 'visible' and 'enable' seemed to
remove the listener somehow ... therefore I send it to nn, so he can have a
closer look. Full focused methinks ;-)
Comment 9 kyoshida 2005-11-01 02:40:10 UTC
/mehopes this issue will receive enough love to get fixed.

Kohei (I'm in CC)
Comment 10 Marcus 2017-05-20 11:28:11 UTC
Reset assigne to the default "issues@openoffice.apache.org".