Bug 105136 - TextCursor gotoNextWord method fails when paragraph does not end in period
Summary: TextCursor gotoNextWord method fails when paragraph does not end in period
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
(earliest affected) release
Hardware: All All
: medium minor
Assignee: Not Assigned
Keywords: bibisected, bisected, regression
Depends on:
Reported: 2017-01-06 03:46 UTC by vic.orgos+bugslibreoffice
Modified: 2020-04-11 14:59 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:

Test file containing macro. (10.99 KB, application/vnd.oasis.opendocument.text)
2017-01-21 02:47 UTC, vic.orgos+bugslibreoffice

Note You need to log in before you can comment on or make changes to this bug.
Description vic.orgos+bugslibreoffice 2017-01-06 03:46:56 UTC
While running, I wrote a macro to move the visible cursor to the next misspelled word. When I upgraded to the macro was getting stuck. Upon further investigation it appears that the bug is there from as early as release. I've checked and it there regardless of language used, I originally caught it with Greek question marks (;), or operating system used, I tried Linux, Windows 10, Windows 7.

Steps to Reproduce:
1. Type paragraph and end it with punctuation other than period
2. Run macro.

Actual Results:  
Macro appears stuck, will eventually give error possibly due to resources issue...?

Expected Results:
Expect the macro not to get stuck ?!?

Reproducible: Always

User Profile Reset: Yes

Additional Info:
Here is the macro I used...

Sub gotoNextSpellingError
End Sub

Sub gotoPreviousSpellingError
End Sub

' Find next misspelled word and move cursor to it
Sub gotoSpellingError(fwd As boolean)
	Dim oDocModel as Variant
	Dim oTextCursor as Variant
	Dim aProp(0) As New com.sun.star.beans.PropertyValue

	oDocModel = StarDesktop.CurrentFrame.Controller.getModel()
	If IsNull(oDocModel) Then
		MsgBox("No active document.")
		Exit Sub
	End If

	If Not HasUnoInterfaces (oDocModel, "com.sun.star.text.XTextDocument") Then
		MsgBox("This macro is for Text documents only.")
		Exit Sub
	End If

	'Start search from currect view cursor position...
	Dim oVC
    oVC = ThisComponent.currentController.getViewCursor()
	oTextCursor = oDocModel.Text.createTextCursor()
	Dim vSpeller As Variant
	'vSpeller = createUnoService("com.sun.star.linguistic2.SpellChecker")
	vSpeller = createUnoService("com.sun.star.linguistic2.LinguServiceManager")
	    oLinguSvcMgr = createUnoService("com.sun.star.linguistic2.LinguServiceManager")
    If IsNull(oLinguSvcMgr) Then
    	Print "Failed to create LinguServiceManager object"
    	Exit Sub
	End If   
	vSpeller = oLinguSvcMgr.getSpellChecker()
	If isNull(vSpeller) Then
		Print "No SpellChecker object"
		Exit Sub
	End if
	'xray vSpeller
	'Repeated runs should walk through errors...
	If fwd then
	End if
	Dim oTCWordStart,oTCString,oTCProp,bValidWord

'		If NOT oTextCursor.isStartOfWord() Then
'		End If
		oTCWordStart = oTextCursor.getStart()
		oTCString = oTextCursor.getString()
		oTCProp = oTextCursor.getPropertyValue("CharLocale") '.Language

		If IsEmpty(oTCProp) Or IsNull(oTCProp) Then
			bValidWord = true
			Select Case oTCProp.Language
			Case "el", "en"
				bValidWord = vSpeller.com_sun_star_linguistic2_XSpellChecker_isValid(oTCString, oTCProp, aProp())
			Case Else
				bValidWord = true
			End Select
		End If
		If not bValidWord Then
			Exit Sub 	'Found invalid word
		End If

		If fwd then
			notDone = oTextCursor.gotoNextWord(false)
			oTextCursor.collapseToStart()		'collapse selection...
			notDone = oTextCursor.gotoPreviousWord(false)
		End if
	Loop while notDone
	Print "Done. No mispelled words found."
End Sub

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
Comment 1 Xisco Faulí 2017-01-12 11:09:54 UTC

Thank you for reporting the bug. Please attach a sample document, as this makes it easier for us to verify the bug. 
I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested document is provided.
(Please note that the attachment will be public, remove any sensitive information before attaching it. 
See https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help on how to do so.)
Comment 2 vic.orgos+bugslibreoffice 2017-01-21 02:47:26 UTC
Created attachment 130591 [details]
Test file containing macro.
Comment 3 Buovjaga 2017-01-25 10:30:42 UTC
Ok, so you mean by running gotoNextSpellingError and clicking OK, it just continues finding 'line' all the time?

Win 7 Pro 64-bit Version:
Build ID: 1c27286b9d5331634c073cd3e327bd941e61bbb6
CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@39, Branch:master, Time: 2017-01-23_03:24:17
Locale: fi-FI (fi_FI); Calc: group
Comment 4 vic.orgos+bugslibreoffice 2017-02-11 00:24:50 UTC
Yes, it continues to show "line", the last word from the second paragraph and will not move beyond that.
Comment 5 raal 2017-04-08 22:02:13 UTC
This seems to have begun at the below commit.
Adding Cc: to Tomaž Vajngerl; Could you possibly take a look at this one? Thanks

8e048850e03974bcdf2cf6943324a88c53a1fed3 is the first bad commit
commit 8e048850e03974bcdf2cf6943324a88c53a1fed3
Author: Norbert Thiebaud <nthiebaud@gmail.com>
Date:   Tue Aug 4 23:59:48 2015 -0700

    source sha:8eca4da70506e1e6c2e4b600262cced93aba8c96

author	Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>	2015-07-31 07:54:48 (GMT)
committer	Tomaž Vajngerl <quikee@gmail.com>	2015-08-04 06:28:15 (GMT)
commit	8eca4da70506e1e6c2e4b600262cced93aba8c96 (patch)
tree	d8c4158af8263b94ee48b4fad5daf50c755e4938
parent	a933e01a54f08132c2d8699f7c6851a8b493d5dc (diff)
tdf#89154 stop at paragraph end when using CTRL+Right (or Left)
Comment 6 QA Administrators 2018-04-09 02:31:24 UTC Comment hidden (obsolete)
Comment 7 QA Administrators 2020-04-09 03:35:57 UTC
Dear vic.orgos+bugslibreoffice,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)

If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword

Feel free to come ask questions or to say hello in our QA chat: https://kiwiirc.com/nextclient/irc.freenode.net/#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team