Problem description: Previously, one could iterate through all of the single cells in a SheetCellRanges object by using the getCells() method and then creating an enumeration with createEnumeration(). This is particularly useful when using something like "queryContentCells" on a SheetCellRange to find cells filled with some content, or perhaps using the com.sun.star.util.XSearchable inteface and a SearchDescriptor to find cells matching some criteria, and then iterate through each cell. A workaround is instead to access each contained SheetCellRange within the SheetCellRanges (using getByIndex), and then iterate through each cell of each contained SheetCellRange (using getCellByPosition). Steps to reproduce: - Fill a com.sun.star.sheet.SheetCellRanges object with some cell ranges (manually or with some search function like queryContentCells or findAll) - call the getCells method (oSheetCellRanges.getCells()) and inspect the returned container Routines to reproduce the problem: Sub GetCellsBugExample() Dim oCalcDoc as Object Dim oSheet as Object Dim oSheetCellRanges as Object ' Create a spreadsheet document oCalcDoc = StarDesktop.loadComponentFromURL( "private:factory/scalc", "_default", 0, array() ) ' Generate some searchable data oSheet = oCalcDoc.Sheets(0) oSheet.getCellRangeByName("C10").setString("Something") oSheet.getCellRangeByName("C1:E2").setDataArray( Array( Array("A","B","C"), Array("X","Y","Something") ) ) oSheet.getCellRangeByName("A1:A4").setDataArray( Array( Array("Hello"), Array("World"), Array("How are"), Array("You?") ) ) REM USING queryContentCells oSheetCellRanges = oSheet.queryContentCells( com.sun.star.sheet.CellFlags.STRING ) ' Select the cells in the document oCalcDoc.CurrentController.select( oSheetCellRanges ) ' Test the SheetCellRanges object TestSheetCellRanges( oSheetCellRanges ) oSheetCellRanges = Nothing REM USING Search Descriptor Dim oSearch as Object oSearch = oSheet.createSearchDescriptor() With oSearch .SearchRegularExpression = FALSE .searchString = "Something" .SearchType = 1 .SearchBackwards = FALSE .SearchWords = TRUE .SearchCaseSensitive = TRUE End With oSheetCellRanges = oSheet.FindAll( oSearch ) ' Select the cells in the document oCalcDoc.CurrentController.select( oSheetCellRanges ) ' Test the SheetCellRanges object TestSheetCellRanges( oSheetCellRanges ) oSheetCellRanges = Nothing REM Manually using createInstance Dim oRangeAddress as New com.sun.star.table.CellRangeAddress oSheetCellRanges = oCalcDoc.createInstance("com.sun.star.sheet.SheetCellRanges") With oRangeAddress .Sheet = 0 .StartColumn = 0 .StartRow = 0 .EndColumn = 0 .EndRow = 3 End With oSheetCellRanges.addRangeAddress( oRangeAddress, FALSE ) With oRangeAddress .Sheet = 0 .StartColumn = 4 .StartRow = 0 .EndColumn = 4 .EndRow = 0 End With oSheetCellRanges.addRangeAddress( oRangeAddress, FALSE ) ' Select the cells in the document oCalcDoc.CurrentController.select( oSheetCellRanges ) ' Test the SheetCellRanges object TestSheetCellRanges( oSheetCellRanges ) oSheetCellRanges = Nothing ' Close the spreadsheet oCalcDoc.close(TRUE) End Sub Sub TestSheetCellRanges( ByRef oSheetCellRanges as Object ) On Error GoTo ErrorHandler Dim oRange as Object Dim oCells as Object Dim eCells as Object Dim oCell as Object Dim lRange as Long Dim lCol as Long Dim lRow as Long Dim lColMax as Long Dim lRowMax as Long Dim sMsg as String sMsg = "" ' Make sure the object supports the SheetCellRanges Service If NOT oSheetCellRanges.supportsService("com.sun.star.sheet.SheetCellRanges") Then Exit Sub End If ' Make sure the object exporst the XSheetCellRanges Interfaces If NOT hasUnoInterfaces(oSheetCellRanges,"com.sun.star.sheet.XSheetCellRanges") Then Exit Sub End If ' Check to see if the SheetCellRanges is empty sMsg = sMsg & Chr(10) & "oSheetCellRanges.getCount() = " & oSheetCellRanges.getCount() ' Double check by printing out it's Absolute Name sMsg = sMsg & Chr(10) & "oSheetCellRanges.AbsoluteName = " & oSheetCellRanges.AbsoluteName ' Call the "getCells" method to fetch what should be a container of all of the cells in the SheetCellRanges oCells = oSheetCellRanges.getCells() ' Check to see if the cells container is emtpy If oCells.hasElements() Then sMsg = sMsg & Chr(10) & "oCells.hasElements() = TRUE" ' Enumerate the cells and print each cell name eCells = oCells.createEnumeration() While eCells.hasMoreElements() oCell = eCells.nextElement() sMsg = sMsg & Chr(10) & oCell.AbsoluteName & " - " & oCell.getString() Wend Else sMsg = sMsg & Chr(10) & "oCells.hasElements() = FALSE" ' Iterate through each contained range For lRange = 0 To (oSheetCellRanges.getCount() - 1) oRange = oSheetCellRanges.getByIndex(lRange) lColMax = oRange.RangeAddress.EndColumn - oRange.RangeAddress.StartColumn lRowMax = oRange.RangeAddress.EndRow - oRange.RangeAddress.StartRow ' iterate through each column For lCol = 0 To lColMax ' iterate through each row For lRow = 0 To lRowMax oCell = oRange.getCellByPosition(lCol,lRow) sMsg = sMsg & Chr(10) & oCell.AbsoluteName & " - " & oCell.getString() Next lRow Next lCol Next lRange End If MsgBox sMsg Exit Sub ErrorHandler: MsgBox "Error " & err & ": " & error$ + chr(13) + "In line : " + Erl + chr(13) + Now End Sub Current behavior: The returned container from getCells() is either empty or contains only some of the cells within the SheetCellRanges Expected behavior: The returned container from getCells() should return every com.sun.star.sheet.SheetCell object that is contained by the com.sun.star.sheet.SheetCellRanges object. Operating System: Windows 7 Version: 4.2.0.4 release Last worked in: 4.1.4.2 release
Please attach a document with the macro in it. Marking as NEEDINFO - once you do please mark as UNCONFIRMED.
Dear Bug Submitter, This bug has been in NEEDINFO status with no change for at least 6 months. Please provide the requested information as soon as possible and mark the bug as UNCONFIRMED. Due to regular bug tracker maintenance, if the bug is still in NEEDINFO status with no change in 30 days the QA team will close the bug as INVALID due to lack of needed information. For more information about our NEEDINFO policy please read the wiki located here: https://wiki.documentfoundation.org/QA/FDO/NEEDINFO If you have already provided the requested information, please mark the bug as UNCONFIRMED so that the QA team knows that the bug is ready to be confirmed. Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team Message generated on: 10/01/2015
Dear Bug Submitter, Please read this message in its entirety before proceeding. Your bug report is being closed as INVALID due to inactivity and a lack of information which is needed in order to accurately reproduce and confirm the problem. We encourage you to retest your bug against the latest release. If the issue is still present in the latest stable release, we need the following information (please ignore any that you've already provided): a) Provide details of your system including your operating system and the latest version of LibreOffice that you have confirmed the bug to be present b) Provide easy to reproduce steps – the simpler the better c) Provide any test case(s) which will help us confirm the problem d) Provide screenshots of the problem if you think it might help e) Read all comments and provide any requested information Once all of this is done, please set the bug back to UNCONFIRMED and we will attempt to reproduce the issue. Please do not: a) respond via email b) update the version field in the bug or any of the other details on the top section of FDO Message generated on: 2015-02-11
Migrating Whiteboard tags to Keywords: (possibleRegression) [NinjaEdit]