https://bugs.documentfoundation.org/show_bug.cgi?id=103358
Bug ID: 103358
Summary: isValid method of SpellChecker UNO service ignores
custom dic
Product: LibreOffice
Version: 5.0.5.2 release
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: Writer
Assignee: [email protected]
Reporter: [email protected]
Description:
I have a macro that moves my cursor to the next mispelled word. I works quite
well except that the isValid method does not skip words that have been added to
the custom dictionary. This is regardless of language.
The Spell Checker dialog box on the other hand does skip custom dictionary
words.
Tested on Windows 7 x64 running 5.0.5.2 and ArchLinux x86 with 5.1.5.2 with the
same behaviour.
Here is the code...
'
' Find next misspelled word and move cursor to it
'
Sub goToNextSpellingError
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")
If isNull(vSpeller) Then
Print "No Speller object"
Exit Sub
End if
'xray vSpeller
'Repeated runs should walk through errors...
oTextCursor.gotoNextWord(false)
Dim oTCWordStart,oTCString,oTCProp,bValidWord
do
If oTextCursor.isStartOfWord() Then
oTCWordStart = oTextCursor.getStart()
oTextCursor.gotoEndOfWord(True)
oTCString = oTextCursor.getString()
oTCProp = oTextCursor.getPropertyValue("CharLocale")
'.Language
If IsEmpty(oTCProp) Or IsNull(oTCProp) Then
'Print "'" & oTCString & "' has no lang
property"
bValidWord = true
else
Select Case oTCProp.Language
Case "el", "en"
bValidWord =
vSpeller.isValid(oTCString, oTCProp, aProp())
Case Else
bValidWord = true
End Select
End If
If not bValidWord Then
oVC.gotoRange(oTCWordStart,false)
'Print "found invalid word"
Exit Sub 'Found invalid word
End If
End if
Loop while oTextCursor.gotoNextWord(False)
Print "Done. No more mispelled words found."
End Sub
Steps to Reproduce:
1. Add word to custom dictionary
2. Run macro
3.
Actual Results:
method returns custom dictionary entry as invalid
Expected Results:
custom dictionary entry to be ignored, ie isValid method to return true
Reproducible: Always
User Profile Reset: No, happens with fresh install
Additional Info:
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101
Firefox/49.0
--
You are receiving this mail because:
You are the assignee for the bug._______________________________________________
Libreoffice-bugs mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs