https://bugs.documentfoundation.org/show_bug.cgi?id=105136
Bug ID: 105136
Summary: TextCursor gotoNextWord method fails when paragraph
does not end in period
Product: LibreOffice
Version: 5.1.6.2 release
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: BASIC
Assignee: libreoffice-bugs@lists.freedesktop.org
Reporter: vic.orgos+bugslibreoff...@gmail.com
Description:
While running 5.0.5.2, I wrote a macro to move the visible cursor to the next
misspelled word. When I upgraded to 5.2.4.2 the macro was getting stuck. Upon
further investigation it appears that the bug is there from as early as 5.1.6.2
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.
3.
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
gotoSpellingError(true)
End Sub
Sub gotoPreviousSpellingError
gotoSpellingError(false)
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()
oTextCursor.gotoRange(OVC,false)
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
oTextCursor.gotoNextWord(false)
Else
oTextCursor.gotoPreviousWord(false)
End if
Dim oTCWordStart,oTCString,oTCProp,bValidWord
Do
' If NOT oTextCursor.isStartOfWord() Then
oTextCursor.gotoStartOfWord(false)
' End If
oTCWordStart = oTextCursor.getStart()
oTextCursor.gotoEndOfWord(True)
oTCString = oTextCursor.getString()
'DEBUG
'oVC.collapseToEnd()
'oVC.gotorange(oTextCursor,true)
oTCProp = oTextCursor.getPropertyValue("CharLocale") '.Language
If IsEmpty(oTCProp) Or IsNull(oTCProp) Then
bValidWord = true
else
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
oVC.gotoRange(oTCWordStart,false)
Exit Sub 'Found invalid word
End If
If fwd then
notDone = oTextCursor.gotoNextWord(false)
Else
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
--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
Libreoffice-bugs@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs