[Libreoffice-bugs] [Bug 135203] New: gotoEndOfUsedArea doesn't give the correct position number when the cell background color is chaged from the initial color.

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Mon Jul 27 17:46:58 UTC 2020


https://bugs.documentfoundation.org/show_bug.cgi?id=135203

            Bug ID: 135203
           Summary: gotoEndOfUsedArea doesn't give the correct position
                    number when the cell background color is chaged from
                    the initial color.
           Product: LibreOffice
           Version: 6.2.8.2 release
          Hardware: x86-64 (AMD64)
                OS: Linux (All)
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: libreoffice-bugs at lists.freedesktop.org
          Reporter: nukool at gmail.com

Description:
The result of position number is sometimes wrong. 

Steps to Reproduce:
1. Open a brand new .ods
2. Only Sheet1 will be used to demonstrate
3. Place the code and run
Option Explicit

Function GetLastUsedColumnOfSheet(pSheetName$) As Long
        Dim oSheet, oCursor     As Object
                oSheet                                          =
thiscomponent.Sheets.getByName(pSheetName)
                oCursor                                         =
oSheet.createCursor
                oCursor.gotoEndOfUsedArea(False)
                GetLastUsedColumnOfSheet        =
oCursor.RangeAddress.EndColumn
End Function

Function GetLastUsedRowOfSheet(pSheetName$) As Long
        Dim oSheet, oCursor  As Object
                oSheet                                  =
thiscomponent.Sheets.getByName(pSheetName)
                oCursor                                 = oSheet.createCursor
                oCursor.gotoEndOfUsedArea(False)
                GetLastUsedRowOfSheet   = oCursor.RangeAddress.EndRow
End Function

Sub ChangeCellRangeBackgroundColorAndCheckLastUsedCellOfSheet1
        Dim row%, r&, g%, b%, t$, lc&, lr&
        thiscomponent.CurrentController.ActiveSheet =
thiscomponent.Sheets.getByName("Sheet1")
        thiscomponent.Sheets.getByName("Sheet1").getCellRangeByPosition(0, 0,
20, 99).CellBackColor = RGB(r, g, b)
        For row = 1 To 100
                r = Int((255 * Rnd) + 0)    ' Generate random value between 0
and 255.
                g = Int((255 * Rnd) + 0)    ' Generate random value between 0
and 255.
                b = Int((255 * Rnd) + 0)    ' Generate random value between 0
and 255.
               
thiscomponent.Sheets.getByName("Sheet1").getCellRangeByPosition(0, 0, 20, row -
1).CellBackColor = RGB(r, g, b)
                lc = GetLastUsedColumnOfSheet("Sheet1") : lr =
GetLastUsedRowOfSheet("Sheet1")
                If lc <> 20 Or lr <> 99 Then
                        t = t & "Randomizing : " & row & " / RGB("& r & ", " &
g & ", " & b & ") / Last used cell = (" & lc & ", " & lr & ")" & Chr(13)
                End If
        Next
        MsgBox t, , "Sheet1" 
End Sub

Actual Results:
Some positions of the last cell from gotoEndOfUsedArea are wrong. 

Expected Results:
All positions of the last cell from gotoEndOfUsedArea must be correct. 


Reproducible: Always


User Profile Reset: No



Additional Info:
Please see attached file.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20200727/0113d501/attachment.htm>


More information about the Libreoffice-bugs mailing list