Bug 135203 - gotoEndOfUsedArea doesn't give the correct position number of the Calc cell at the end when its background color is changed from the initial color.
Summary: gotoEndOfUsedArea doesn't give the correct position number of the Calc cell a...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.2.8.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-27 17:46 UTC by Nukool Chompuparn
Modified: 2024-03-14 02:02 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Example (14.87 KB, application/vnd.oasis.opendocument.spreadsheet)
2020-07-27 17:49 UTC, Nukool Chompuparn
Details
This is the incorrect result. The correct result must be the position ( 20, 99) (296.19 KB, image/png)
2020-07-27 17:52 UTC, Nukool Chompuparn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nukool Chompuparn 2020-07-27 17:46:58 UTC
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.
Comment 1 Nukool Chompuparn 2020-07-27 17:49:00 UTC
Created attachment 163645 [details]
Example
Comment 2 Nukool Chompuparn 2020-07-27 17:52:52 UTC
Created attachment 163646 [details]
This is the incorrect result. The correct result must be the position ( 20, 99)
Comment 3 Buovjaga 2021-03-11 08:34:38 UTC
Repro. No idea if this is somehow related to the macro or the data, but setting to NEW anyway.

Arch Linux 64-bit
Version: 7.2.0.0.alpha0+ / LibreOffice Community
Build ID: 5800a15e0f2d668b844f73072dc146fd0e4237bb
CPU threads: 8; OS: Linux 5.11; UI render: default; VCL: kf5
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 11 March 2021
Comment 4 QA Administrators 2023-03-12 03:22:02 UTC Comment hidden (obsolete)
Comment 5 RichardWilliam 2024-03-14 02:02:56 UTC Comment hidden (spam)