Bug 131990 - Macros: thisComponent.getCurrentController.getViewCursor.goUp() never returns false
Summary: Macros: thisComponent.getCurrentController.getViewCursor.goUp() never returns...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.0.0.0.alpha0+
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Canberk TURAN
URL:
Whiteboard: target:7.1.0 target:7.0.0.1 target:7.2.0
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2020-04-08 22:49 UTC by Eltomito
Modified: 2022-08-17 22:12 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
document with a macro that shows the bug (8.99 KB, application/vnd.oasis.opendocument.text)
2020-04-08 22:50 UTC, Eltomito
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eltomito 2020-04-08 22:49:35 UTC
Description:
When writing macros in LO Basic, the method thisComponent.getCurrentController.getViewCursor.goUp() used to return false when it reached the top of the document.
Now it always returns true, which makes it impossible to use its return value to detect when you get to the start of the document.

In effect, it breaks macros that used to work in LO 6.4.


Steps to Reproduce:
1. open the attached file with macros enabled
2. go to the macro editor and run the main macro
3. watch what happens

Actual Results:
the loop never ends

Expected Results:
the loop should end once the cursor gets to the top of the document


Reproducible: Always


User Profile Reset: Yes



Additional Info:
The macro in the attachment looks like this:

Sub Main
	Dim canMove
	Dim oCurs
	Dim oDoc
	oDoc = ThisComponent
	oCur = oDoc.getCurrentController.getViewCursor()
	canMove = oCur.goUp(1,false)
	While canMove
		canMove = oCur.goUp(1,false)
	Wend

End Sub
Comment 1 Eltomito 2020-04-08 22:50:31 UTC
Created attachment 159438 [details]
document with a macro that shows the bug
Comment 2 Oliver Brinzing 2020-04-10 16:40:23 UTC
reproducible with:

Version: 7.0.0.0.alpha0+ (x64)
Build ID: 5fb793d9d3d6f7bbeb16eb2857ee396405d94b6d
CPU threads: 4; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL: win; 
Locale: de-DE (de_DE); UI-Language: en-US
Calc: threaded

but *not* reproducible with:

Version: 6.4.3.2 (x64)
Build-ID: 747b5d0ebf89f41c860ec2a39efd7cb15b54f2d8
CPU-Threads: 4; BS: Windows 10.0 Build 18363; UI-Render: Standard; VCL: win; 
Gebietsschema: de-DE (de_DE); UI-Sprache: de-DE
Calc:
Comment 3 raal 2020-04-24 17:30:26 UTC
This seems to have begun at the below commit.
Adding Cc: to Canberk TURAN ; Could you possibly take a look at this one?
Thanks
 0d58aebadfc69bc1037865a6a61968edf8a90da4 is the first bad commit
commit 0d58aebadfc69bc1037865a6a61968edf8a90da4
Author: Jenkins Build User <tdf@pollux.tdf>
Date:   Thu Feb 27 08:25:31 2020 +0100

    source 0aa0fda64057647219954480ac1bab86b0f0e433

author	Canberk TURAN <canberkkturann@gmail.com>	2020-02-25 23:55:50 +0300
committer	Gülşah Köse <gulsah.kose@collabora.com>	2020-02-27 08:06:16 +0100
commit 0aa0fda64057647219954480ac1bab86b0f0e433 (patch)
tree eaadcfc57045b5021d9ca18e1c6a4aaad7590b08
parent b11293297e581b87fba7e995d350ba59ecb820f2 (diff)
tdf#81226: Cursor jumping fixed
Comment 4 Eltomito 2020-06-01 15:39:23 UTC
I'd hate this bug to stay in the official 7.0. Could someone raise its importance to major or critical, please?
I mean, it's probably going to break all macros that move the cursor between lines, which I think is pretty serious.
Comment 5 Canberk TURAN 2020-06-07 13:24:45 UTC
Ok, I'm gonna take a look. It looks like my bad. bRet variable must be set false before return when the cursor reachs to start or end of the document. Thanks for your warning. I'll send a patch today.
Comment 6 Commit Notification 2020-06-08 06:09:24 UTC
Canberk TURAN committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1e5cf1b3ebf39aee01ed2a3bfd5be7ee6f44d18e

tdf#131990 MACROS: fixes return value of UpDown Method

It will be available in 7.1.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Xisco Faulí 2020-06-08 10:02:12 UTC
Verified in

Version: 7.1.0.0.alpha0+
Build ID: 8bbd8324282e7890de29ede5912d24c6e1c7ce7f
CPU threads: 4; OS: Linux 4.19; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: 

@0Canberk TURAN, thanks for fixing this issue!. Should this issue be closed as RESOLVED FIXED ?
Comment 8 Canberk TURAN 2020-06-08 11:04:38 UTC
Yes, I tested that macro after patch. Everything looks like expected.
Comment 9 Commit Notification 2020-06-08 17:08:33 UTC
Canberk TURAN committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

https://git.libreoffice.org/core/commit/402f36efb215338ad545caa65d39fb8a39685ea1

tdf#131990 MACROS: fixes return value of UpDown Method

It will be available in 7.0.0.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Eltomito 2020-06-11 13:04:59 UTC
I tested it in 1.0 beta 1 and it works. Thank you!
Comment 11 Eltomito 2020-06-11 13:05:46 UTC
(In reply to Eltomito from comment #10)
> I tested it in 1.0 beta 1 and it works. Thank you!

Obviously, I meant 7.0 beta 1 :)
Comment 12 Commit Notification 2020-12-10 22:43:52 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/61d07657caab5e0fb8ec4446f67a7044e14dae4b

tdf#131990: sw_uiwriter: Add unittest

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.