Hi *,
Do you know a way to go to the next spelling/grammar error from the cursor via the API?
Or is there a method to list all spelling/grammar errors found in a document?
Get next spelling/grammar errors via the API
Get next spelling/grammar errors via the API
LibreOffice 6.4 • Windows 10
Re: Get next spelling/grammar errors via the API
Macros would not be necessary, since by pressing the F7 key we have everything.
Here is a possible example that maybe you could improve and adapt to your needs.
It's a macro for Writer:
Here is a possible example that maybe you could improve and adapt to your needs.
It's a macro for Writer:
Code: Select all
Sub SpellingError
Dim aEmpty(0) As New com.sun.star.beans.PropertyValue
Dim locale As New com.sun.star.lang.Locale
locale.Language = "en"
locale.Country = "US"
SpellC = createUnoService("com.sun.star.linguistic2.SpellChecker")
oText = ThisComponent.Text
oCursor = oText.CreateTextCursor()
oSentenceCursor = oText.CreateTextCursor()
Do While oCursor.gotoNextWord(True)
oSentenceCursor.gotoRange(oCursor.getStart(), False)
Do While oSentenceCursor.gotoNextWord(True) AND oText.compareRegionEnds(oSentenceCursor, oCursor) >= 0
dato = Trim(oSentenceCursor.String)
'-----------------------------------------------------------------------------------------------------
dato = replace(dato, Chr(13) + Chr(10), "")
dato = replace(dato, ":","")
dato = replace(dato, ".","")
dato = replace(dato, ";","")
dato = replace(dato, ",","")
dato = replace(dato, "-","")
dato = replace(dato, "_","")
'ETC
'----------------------------------------------------------------------------------------------------
oReturn = SpellC.isValid(dato, locale, aEmpty())
If oReturn = False Then
acum = acum & chr(13) & dato
end if
Loop
oCursor.goRight(0, False)
Loop
msgbox acum, , "MisSpellings"
End Sub
lo 5.1.6.2 | aoo 4.1.3 | win 7/10
All I know is that I know nothing
All I know is that I know nothing
Re: Get next spelling/grammar errors via the API
Thanks for the answer.
But I don’t want to parse anew a text that had already been parsed. What I’d like is to go to the next error already found. And BTW I’m much more interested by grammar errors than spelling mistakes.
I also need to list all errors. In LO, a grammar error is defined by a structure (https://www.openoffice.org/api/docs/com ... Error.html) that would allow to sort them.
But I don’t want to parse anew a text that had already been parsed. What I’d like is to go to the next error already found. And BTW I’m much more interested by grammar errors than spelling mistakes.
I also need to list all errors. In LO, a grammar error is defined by a structure (https://www.openoffice.org/api/docs/com ... Error.html) that would allow to sort them.
LibreOffice 6.4 • Windows 10
Re: Get next spelling/grammar errors via the API
This module
http://www.openoffice.org/api/docs/comm ... le-ix.html
offers access to the proofreading Iterator.
http://www.openoffice.org/api/docs/comm ... le-ix.html
offers access to the proofreading Iterator.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS