<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - gotoEndOfUsedArea doesn't give the correct position number when the cell background color is chaged from the initial color."
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=135203">135203</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>gotoEndOfUsedArea doesn't give the correct position number when the cell background color is chaged from the initial color.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.2.8.2 release
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>BASIC
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nukool@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>