Hi,
I hope I'm hitting the right mailing list...
I have a problem accessing the SpellChecker service in the API from Python.
My code looks like this:
--
import uno
import string
def main():
"""This is the main function."""
currentContext = XSCRIPTCONTEXT.getComponentContext()
currentDocument = XSCRIPTCONTEXT.getDocument()
words = collectWords(currentDocument, currentContext)
#newDocument = createDocument(words, currentContext)
def collectWords(document, context):
"""Collext words from the text document."""
cursor = document.Text.createTextCursor()
smgr = context.ServiceManager
spellchecker = smgr.createInstanceWithContext(
"com.sun.star.linguistic2.XSpellChecker", context)
locale = smgr.createInstanceWithContext(
"com.sun.star.lang.Locale", context)
#locale.Language = "da"
#locale.Country = "DK"
words = []
cursor.gotoStart(False)
while cursor.gotoNextWord(True):
cursor.gotoStartOfWord(False)
cursor.gotoEndOfWord(True)
word = cursor.getString()
if not word in words:
if not spellchecker.isValid(word, locale):
words.append(word)
words.sort()
return words
--
When I run the code, I get an error at this line:
if not spellchecker.isValid(word, locale):
The error message says: 'NoneType' object has no attribute 'isValid'.
Am I doing something wrong, or does the Python UNO bridge have a problem
with the SpellChecker service?
Best regards,
Finn Gruwier Larsen
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]