Apache OpenOffice (AOO) Bugzilla – Issue 30591
Calc's range selection listener doesn't work in Windows
Last modified: 2017-05-20 11:28:11 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
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
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
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
Additional data point - the range selection problem with an active dialog still occurs in OO 1.1.2.
Created attachment 16413 [details] mentioned bugdoc
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.
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.
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 ;-)
/mehopes this issue will receive enough love to get fixed. Kohei (I'm in CC)
Reset assigne to the default "issues@openoffice.apache.org".