(hopefully final) update, for now: using LinguServiceManager I've
implemented a fallback mode which no longer uses hardcoded
hunspell/myspell but instead looks for any other spell checker plugin
in the list of service implementations:
# http://www.openoffice.org/api/docs/common/ref/com/sun/star/linguistic2/XSpellChecker.html
# XSpellChecker
def spell(self, aWord, aLocale, aProperties ):
try:
#print ("Speller: spell aWord: %s, aLocale:
%s, aProperties: %s" % (repr(aWord), repr(aLocale),
repr(aProperties)))
if not self.fallback_sc:
# look for another spellchecker in the
list of spell check service implementations
# that we could ask for proposals
ls =
self.service_manager.createInstance("com.sun.star.linguistic2.LinguServiceManager")
print ("Speller: lingu service manager
= %s" % repr(ls))
available = ls.getAvailableServices
('com.sun.star.linguistic2.SpellChecker', aLocale)
print ("Speller: spell services: %s" %
repr(available))
for speller in available:
if speller == self.ImplementationName:
continue
self.fallback_sc =
self.service_manager.createInstance (speller)
if self.fallback_sc:
print ("Speller: found
other spell checker: %s" % speller)
break
#self.fallback_sc =
self.service_manager.createInstance
("org.openoffice.lingu.MySpellSpellChecker")
if self.fallback_sc:
return self.fallback_sc.spell (aWord,
aLocale, aProperties)
except:
print ("Speller: spell EXCEPTION CAUGHT %s" %
repr(sys.exc_info()) )
return None
would still be interested if there is a cleaner way to achieve this.
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.