8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
from com.sun.star.task import XJob
from com.sun.star.ui import XContextMenuInterceptor
#from com.sun.star.ui.ContextMenuInterceptorAction import IGNORED
#from com.sun.star.ui.ContextMenuInterceptorAction import EXECUTE_MODIFIED
import grammalecte.fr.lexicographe as lxg
from grammalecte.ibdawg import IBDAWG
from grammalecte.echo import echo
import helpers
xDesktop = None
oDict = None
oLexicographe = None
class MyContextMenuInterceptor (XContextMenuInterceptor, unohelper.Base):
def __init__ (self, ctx):
self.ctx = ctx
|
|
|
|
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
from com.sun.star.task import XJob
from com.sun.star.ui import XContextMenuInterceptor
#from com.sun.star.ui.ContextMenuInterceptorAction import IGNORED
#from com.sun.star.ui.ContextMenuInterceptorAction import EXECUTE_MODIFIED
import grammalecte.fr.lexicographe as lxg
from grammalecte.graphspell.spellchecker import SpellChecker
from grammalecte.graphspell.echo import echo
import helpers
xDesktop = None
oSpellChecker = None
oLexicographe = None
class MyContextMenuInterceptor (XContextMenuInterceptor, unohelper.Base):
def __init__ (self, ctx):
self.ctx = ctx
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
return xCursor.String.strip('.')
class JobExecutor (XJob, unohelper.Base):
def __init__ (self, ctx):
self.ctx = ctx
global xDesktop
global oDict
global oLexicographe
try:
if not xDesktop:
xDesktop = self.ctx.getServiceManager().createInstanceWithContext('com.sun.star.frame.Desktop', self.ctx)
if not oDict:
xCurCtx = uno.getComponentContext()
oGC = self.ctx.ServiceManager.createInstanceWithContext("org.openoffice.comp.pyuno.Lightproof.grammalecte", self.ctx)
if hasattr(oGC, "getDictionary"):
# https://bugs.documentfoundation.org/show_bug.cgi?id=97790
oDict = oGC.getDictionary()
else:
oDict = IBDAWG("French.bdic")
if not oLexicographe:
oLexicographe = lxg.Lexicographe(oDict)
except:
traceback.print_exc()
def execute (self, args):
if not args:
return
try:
|
|
|
|
|
|
|
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
return xCursor.String.strip('.')
class JobExecutor (XJob, unohelper.Base):
def __init__ (self, ctx):
self.ctx = ctx
global xDesktop
global oSpellChecker
global oLexicographe
try:
if not xDesktop:
xDesktop = self.ctx.getServiceManager().createInstanceWithContext('com.sun.star.frame.Desktop', self.ctx)
if not oSpellChecker:
xCurCtx = uno.getComponentContext()
oGC = self.ctx.ServiceManager.createInstanceWithContext("org.openoffice.comp.pyuno.Lightproof.grammalecte", self.ctx)
if hasattr(oGC, "getSpellChecker"):
# https://bugs.documentfoundation.org/show_bug.cgi?id=97790
oSpellChecker = oGC.getSpellChecker()
else:
oSpellChecker = SpellChecker("${lang}", "${dic_filename}.bdic")
if not oLexicographe:
oLexicographe = lxg.Lexicographe(oSpellChecker)
except:
traceback.print_exc()
def execute (self, args):
if not args:
return
try:
|