Difference between revisions of "API/Samples/StarBasic/Office/SpellChecker"

From Apache OpenOffice Wiki
< API‎ | Samples‎ | StarBasic
Jump to: navigation, search
 
m
 
(4 intermediate revisions by 3 users not shown)
Line 6: Line 6:
 
| Programming Language: || StarBasic
 
| Programming Language: || StarBasic
 
|+
 
|+
| Author:              || [[User:laurentgodard@openoffice.org| Laurent Godard]], 2007
+
| Author:              || Laurent Godard , 2007
 
|+
 
|+
 
| License:              || LGPL
 
| License:              || LGPL
 
|}
 
|}
  
<code>[starbasic]
+
<syntaxhighlight lang="oobas">
 
Sub Main
 
Sub Main
  
Line 42: Line 42:
  
 
End Sub
 
End Sub
 +
</syntaxhighlight>
  
</code>
+
[[Category:API]]
 +
[[Category:Samples]]
 +
[[Category:StarBasic]]
 +
[[Category:Office]]

Latest revision as of 17:07, 30 January 2021

Snippet: SpellChecking.BAS
Description: Illustrate the use of the spellchecker to know if a word is valid.
Programming Language: StarBasic
Author: Laurent Godard , 2007
License: LGPL
Sub Main
 
' Selects the language
dim locale as new com.sun.star.lang.Locale
locale.Language="fr" 'ISO 639
locale.Country="FR"  'ISO 3166
 
' Get the service
LinguService = createUnoService("com.sun.star.linguistic2.LinguServiceManager")
spellChecker = LinguService.getSpellchecker()
 
msgbox "is dictionary detected ? " +chr(10)+ spellChecker.hasLocale(locale)
 
word = inputbox("File to check (empty for end) ?")
 
while word<>""
 
	isWordValid = spellChecker.isValid(word, locale, array())
 
	if isWordValid then
		msgbox word + " is valid"
	else
		msgbox word + " is NOT valid"
	endif
 
	word = inputbox("File to check (empty for end) ?")
 
wend
 
End Sub
Personal tools