Apache OpenOffice (AOO) Bugzilla – Issue 31766
.getReferencePosition() returns invalid data
Last modified: 2017-05-20 11:27:38 UTC
The .getReferencePosition() returns invalid data when used on an Calc workbook that was converted from Excel97. Function works correctly on a newly created Calc sheet. There are about 10 named ranges in this book on various sheets. When doing an 'insert names' to list their details, there are 3 range names that have no range details; these appear to be the names of user functions defined. Note that the original Excel document doesnt have these range names, just the functions. -------------------------------- REM The oNamedRange object supports the XNamedRange interface oNamedRange = ThisComponent.NamedRanges.getByName(rngname) Print "Named range content = " & oNamedRange.getContent() '#### CORRECT VALUE PRINTED REM a com.sun.star.table.CellAddress service is available from REM getReferencePosition(). oCellAddr = oNamedRange.getReferencePosition() print oCellAddr.Sheet,oCellAddr.Row,oCellAddr.Column '##### Prints 0 0 0 ------------------------------------ I can send the Excel & Calc files if desired.
Created attachment 16610 [details] Files to replicate error
sw->robberbaron: the attached file seems to be corrupted, could you try to attach it again please ?
Updated the scx file to remove the macro errors. It will show Msgboxes on load as it recalc formulas that have the problem.
Sorry, cant update the attachment..... how do I do this ? Also should lower priority to 4 as there is a workaround.
Rec'd via direct email, as robberbaron shows difficulty in creating additional attachment. (likely due to glitch reported in Issue 23650) Paste of robberbaron's comments from mail message: "I tried modifying the Issue on oo.org but could find how to add a new attachement. So replied to your msg. Hope this is Ok."
Created attachment 16668 [details] 3rd try upload of file for robberbaron. last try produced apache/tomcat error.
my experiences while trying to attach that file did not go very smoothly. The first time my connection died in the midst of the upload after a long wait, the second time the apache/tomcat error showed, and the third time there was a long wait between when the file finished uploading and when OOo came back at me. If it needs to be uploaded again, please give a shout. I'll try again. I was not able to add these notes then either, as things weren't handshaking well at all. Thought I'd try again in a few hours. Set priority from P2 to P3. Added myself to cc, in case more aid is needed with that attachment.
SW->NN: executing the macro in the attached document (its executed on load) shows that for the named ranges "trans_latest_issue" and "trans_top" the method "getContent" returns the correct value, but "getReferencePosition" returns 0,0,0
I'm seeing this as well. Named ranges on a sheet downloaded from http://www.boardgamegeek.com/fileinfo.php?fileid=15693 return 0 as the sheet number when calling getReferencePosition(). Deleting and re-adding the named range causes the function to work correctly. The function shown below causes an error when attempting to get the Cities named range from that sheet which is on the AST tab. It incorrectly goes to the instructions tab (tab 0) and fails to find the range. Function getNamedRange(rngname As String, Optional oDoc) Dim oSheet 'Sheet containing the named range Dim oNamedRange 'The named range object Dim oCellAddr 'Address of the upper left cell in the named range Dim oRanges 'All of the named ranges If IsMissing(oDoc) Then oDoc = ThisComponent oRanges = oDoc.NamedRanges If NOT oRanges.hasByName(rngname) Then MsgBox "Sorry, the named range " & rngname & _ " does not exist" & CHR$(10) & _ "Current named ranges = " & CHR$(10) & _ Join(oRanges.getElementNames(), CHR$(10)) Exit Function End If REM The oNamedRange object supports the XNamedRange interface oNamedRange = oRanges.getByName(rngname) Print rngname & " = " & oNamedRange.getContent() oCellAddr = oNamedRange.getReferencePosition() REM Now, get the sheet that matters! oSheet = oDoc.Sheets.getByIndex(oCellAddr.Sheet) Print "Is on Sheet " & oSheet.Name REM You can then use the current controller REM to select what must be selected. REM select ( VARIANT ) REM setActiveSheet ( OBJECT ) REM setFirstVisibleColumn ( LONG ) REM setFirstVisibleRow ( LONG ) oDoc.getCurrentController().setActiveSheet(oSheet) REM The sheet can return the range based on the name REM oSheet.getCellRangeByName(rngname) REM The sheet can also return a range by position, if you know it. REM This selects the ENTIRE range Dim oRange oRange = oSheet.getCellRangeByName(rngname) getNamedRange = oRange End Function
I should add that this is on the 2.0.2 stable build running on Windows XP
Reset assigne to the default "issues@openoffice.apache.org".