0000: 23 20 47 72 61 6d 6d 61 6c 65 63 74 65 20 2d 20 # Grammalecte -
0010: 4c 65 78 69 63 6f 67 72 61 70 68 65 0a 23 20 62 Lexicographe.# b
0020: 79 20 4f 6c 69 76 69 65 72 20 52 2e 20 4c 69 63 y Olivier R. Lic
0030: 65 6e 73 65 3a 20 4d 50 4c 20 32 0a 0a 69 6d 70 ense: MPL 2..imp
0040: 6f 72 74 20 75 6e 6f 0a 69 6d 70 6f 72 74 20 75 ort uno.import u
0050: 6e 6f 68 65 6c 70 65 72 0a 69 6d 70 6f 72 74 20 nohelper.import
0060: 74 72 61 63 65 62 61 63 6b 0a 0a 66 72 6f 6d 20 traceback..from
0070: 63 6f 6d 2e 73 75 6e 2e 73 74 61 72 2e 74 61 73 com.sun.star.tas
0080: 6b 20 69 6d 70 6f 72 74 20 58 4a 6f 62 0a 66 72 k import XJob.fr
0090: 6f 6d 20 63 6f 6d 2e 73 75 6e 2e 73 74 61 72 2e om com.sun.star.
00a0: 75 69 20 69 6d 70 6f 72 74 20 58 43 6f 6e 74 65 ui import XConte
00b0: 78 74 4d 65 6e 75 49 6e 74 65 72 63 65 70 74 6f xtMenuIntercepto
00c0: 72 0a 23 66 72 6f 6d 20 63 6f 6d 2e 73 75 6e 2e r.#from com.sun.
00d0: 73 74 61 72 2e 75 69 2e 43 6f 6e 74 65 78 74 4d star.ui.ContextM
00e0: 65 6e 75 49 6e 74 65 72 63 65 70 74 6f 72 41 63 enuInterceptorAc
00f0: 74 69 6f 6e 20 69 6d 70 6f 72 74 20 49 47 4e 4f tion import IGNO
0100: 52 45 44 0a 23 66 72 6f 6d 20 63 6f 6d 2e 73 75 RED.#from com.su
0110: 6e 2e 73 74 61 72 2e 75 69 2e 43 6f 6e 74 65 78 n.star.ui.Contex
0120: 74 4d 65 6e 75 49 6e 74 65 72 63 65 70 74 6f 72 tMenuInterceptor
0130: 41 63 74 69 6f 6e 20 69 6d 70 6f 72 74 20 45 58 Action import EX
0140: 45 43 55 54 45 5f 4d 4f 44 49 46 49 45 44 0a 0a ECUTE_MODIFIED..
0150: 69 6d 70 6f 72 74 20 67 72 61 6d 6d 61 6c 65 63 import grammalec
0160: 74 65 2e 66 72 2e 6c 65 78 69 63 6f 67 72 61 70 te.fr.lexicograp
0170: 68 65 20 61 73 20 6c 78 67 0a 66 72 6f 6d 20 67 he as lxg.from g
0180: 72 61 6d 6d 61 6c 65 63 74 65 2e 67 72 61 70 68 rammalecte.graph
0190: 73 70 65 6c 6c 2e 73 70 65 6c 6c 63 68 65 63 6b spell.spellcheck
01a0: 65 72 20 69 6d 70 6f 72 74 20 53 70 65 6c 6c 43 er import SpellC
01b0: 68 65 63 6b 65 72 0a 66 72 6f 6d 20 67 72 61 6d hecker.from gram
01c0: 6d 61 6c 65 63 74 65 2e 67 72 61 70 68 73 70 65 malecte.graphspe
01d0: 6c 6c 2e 65 63 68 6f 20 69 6d 70 6f 72 74 20 65 ll.echo import e
01e0: 63 68 6f 0a 69 6d 70 6f 72 74 20 68 65 6c 70 65 cho.import helpe
01f0: 72 73 0a 0a 0a 78 44 65 73 6b 74 6f 70 20 3d 20 rs...xDesktop =
0200: 4e 6f 6e 65 0a 6f 53 70 65 6c 6c 43 68 65 63 6b None.oSpellCheck
0210: 65 72 20 3d 20 4e 6f 6e 65 0a 6f 4c 65 78 69 63 er = None.oLexic
0220: 6f 67 72 61 70 68 65 20 3d 20 4e 6f 6e 65 0a 0a ographe = None..
0230: 0a 63 6c 61 73 73 20 4d 79 43 6f 6e 74 65 78 74 .class MyContext
0240: 4d 65 6e 75 49 6e 74 65 72 63 65 70 74 6f 72 20 MenuInterceptor
0250: 28 58 43 6f 6e 74 65 78 74 4d 65 6e 75 49 6e 74 (XContextMenuInt
0260: 65 72 63 65 70 74 6f 72 2c 20 75 6e 6f 68 65 6c erceptor, unohel
0270: 70 65 72 2e 42 61 73 65 29 3a 0a 20 20 20 20 64 per.Base):. d
0280: 65 66 20 5f 5f 69 6e 69 74 5f 5f 20 28 73 65 6c ef __init__ (sel
0290: 66 2c 20 63 74 78 29 3a 0a 20 20 20 20 20 20 20 f, ctx):.
02a0: 20 73 65 6c 66 2e 63 74 78 20 3d 20 63 74 78 0a self.ctx = ctx.
02b0: 0a 20 20 20 20 64 65 66 20 6e 6f 74 69 66 79 43 . def notifyC
02c0: 6f 6e 74 65 78 74 4d 65 6e 75 45 78 65 63 75 74 ontextMenuExecut
02d0: 65 20 28 73 65 6c 66 2c 20 78 45 76 65 6e 74 29 e (self, xEvent)
02e0: 3a 0a 20 20 20 20 20 20 20 20 73 57 6f 72 64 20 :. sWord
02f0: 3d 20 73 65 6c 66 2e 5f 67 65 74 57 6f 72 64 28 = self._getWord(
0300: 29 0a 20 20 20 20 20 20 20 20 74 72 79 3a 0a 20 ). try:.
0310: 20 20 20 20 20 20 20 20 20 20 20 61 49 74 65 6d aItem
0320: 2c 20 61 56 65 72 62 20 3d 20 6f 4c 65 78 69 63 , aVerb = oLexic
0330: 6f 67 72 61 70 68 65 2e 61 6e 61 6c 79 7a 65 57 ographe.analyzeW
0340: 6f 72 64 28 73 57 6f 72 64 29 0a 20 20 20 20 20 ord(sWord).
0350: 20 20 20 20 20 20 20 69 66 20 6e 6f 74 20 61 49 if not aI
0360: 74 65 6d 3a 0a 20 20 20 20 20 20 20 20 20 20 20 tem:.
0370: 20 20 20 20 20 72 65 74 75 72 6e 20 75 6e 6f 2e return uno.
0380: 45 6e 75 6d 28 22 63 6f 6d 2e 73 75 6e 2e 73 74 Enum("com.sun.st
0390: 61 72 2e 75 69 2e 43 6f 6e 74 65 78 74 4d 65 6e ar.ui.ContextMen
03a0: 75 49 6e 74 65 72 63 65 70 74 6f 72 41 63 74 69 uInterceptorActi
03b0: 6f 6e 22 2c 20 22 49 47 4e 4f 52 45 44 22 29 20 on", "IGNORED")
03c0: 23 20 64 6f 6e e2 80 99 74 20 77 6f 72 6b 20 6f # don...t work o
03d0: 6e 20 41 4f 4f 2c 20 68 61 76 65 20 74 6f 20 69 n AOO, have to i
03e0: 6d 70 6f 72 74 20 74 68 65 20 76 61 6c 75 65 0a mport the value.
03f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0400: 23 72 65 74 75 72 6e 20 49 47 4e 4f 52 45 44 0a #return IGNORED.
0410: 20 20 20 20 20 20 20 20 20 20 20 20 78 43 6f 6e xCon
0420: 74 65 78 74 4d 65 6e 75 20 3d 20 78 45 76 65 6e textMenu = xEven
0430: 74 2e 41 63 74 69 6f 6e 54 72 69 67 67 65 72 43 t.ActionTriggerC
0440: 6f 6e 74 61 69 6e 65 72 0a 20 20 20 20 20 20 20 ontainer.
0450: 20 20 20 20 20 69 66 20 78 43 6f 6e 74 65 78 74 if xContext
0460: 4d 65 6e 75 3a 0a 20 20 20 20 20 20 20 20 20 20 Menu:.
0470: 20 20 20 20 20 20 23 20 65 6e 74 72 69 65 73 20 # entries
0480: 69 6e 64 65 78 0a 20 20 20 20 20 20 20 20 20 20 index.
0490: 20 20 20 20 20 20 69 20 3d 20 78 43 6f 6e 74 65 i = xConte
04a0: 78 74 4d 65 6e 75 2e 43 6f 75 6e 74 0a 20 20 20 xtMenu.Count.
04b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 6e 55 6e nUn
04c0: 6f 43 6f 6e 73 74 61 6e 74 4c 69 6e 65 20 3d 20 oConstantLine =
04d0: 75 6e 6f 2e 67 65 74 43 6f 6e 73 74 61 6e 74 42 uno.getConstantB
04e0: 79 4e 61 6d 65 28 22 63 6f 6d 2e 73 75 6e 2e 73 yName("com.sun.s
04f0: 74 61 72 2e 75 69 2e 41 63 74 69 6f 6e 54 72 69 tar.ui.ActionTri
0500: 67 67 65 72 53 65 70 61 72 61 74 6f 72 54 79 70 ggerSeparatorTyp
0510: 65 2e 4c 49 4e 45 22 29 0a 0a 20 20 20 20 20 20 e.LINE")..
0520: 20 20 20 20 20 20 20 20 20 20 23 20 77 6f 72 64 # word
0530: 20 61 6e 61 6c 79 73 69 73 0a 20 20 20 20 20 20 analysis.
0540: 20 20 20 20 20 20 20 20 20 20 69 20 3d 20 73 65 i = se
0550: 6c 66 2e 5f 61 64 64 49 74 65 6d 54 6f 43 6f 6e lf._addItemToCon
0560: 74 65 78 74 4d 65 6e 75 28 78 43 6f 6e 74 65 78 textMenu(xContex
0570: 74 4d 65 6e 75 2c 20 69 2c 20 22 41 63 74 69 6f tMenu, i, "Actio
0580: 6e 54 72 69 67 67 65 72 53 65 70 61 72 61 74 6f nTriggerSeparato
0590: 72 22 2c 20 53 65 70 61 72 61 74 6f 72 54 79 70 r", SeparatorTyp
05a0: 65 3d 6e 55 6e 6f 43 6f 6e 73 74 61 6e 74 4c 69 e=nUnoConstantLi
05b0: 6e 65 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 ne).
05c0: 20 20 20 20 66 6f 72 20 69 74 65 6d 20 69 6e 20 for item in
05d0: 61 49 74 65 6d 3a 0a 20 20 20 20 20 20 20 20 20 aItem:.
05e0: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 69 73 if is
05f0: 69 6e 73 74 61 6e 63 65 28 69 74 65 6d 2c 20 73 instance(item, s
0600: 74 72 29 3a 0a 20 20 20 20 20 20 20 20 20 20 20 tr):.
0610: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 20 3d i =
0620: 20 73 65 6c 66 2e 5f 61 64 64 49 74 65 6d 54 6f self._addItemTo
0630: 43 6f 6e 74 65 78 74 4d 65 6e 75 28 78 43 6f 6e ContextMenu(xCon
0640: 74 65 78 74 4d 65 6e 75 2c 20 69 2c 20 22 41 63 textMenu, i, "Ac
0650: 74 69 6f 6e 54 72 69 67 67 65 72 22 2c 20 54 65 tionTrigger", Te
0660: 78 74 3d 69 74 65 6d 2c 20 43 6f 6d 6d 61 6e 64 xt=item, Command
0670: 55 52 4c 3d 22 73 65 72 76 69 63 65 3a 6e 65 74 URL="service:net
0680: 2e 67 72 61 6d 6d 61 6c 65 63 74 65 2e 41 70 70 .grammalecte.App
0690: 4c 61 75 6e 63 68 65 72 3f 4e 6f 6e 65 22 29 0a Launcher?None").
06a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
06b0: 20 20 20 20 65 6c 69 66 20 69 73 69 6e 73 74 61 elif isinsta
06c0: 6e 63 65 28 69 74 65 6d 2c 20 74 75 70 6c 65 29 nce(item, tuple)
06d0: 3a 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 :.
06e0: 20 20 20 20 20 20 20 20 20 20 73 52 6f 6f 74 2c sRoot,
06f0: 20 6c 4d 6f 72 70 68 20 3d 20 69 74 65 6d 0a 20 lMorph = item.
0700: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0710: 20 20 20 20 20 20 20 23 20 73 75 62 6d 65 6e 75 # submenu
0720: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
0730: 20 20 20 20 20 20 20 20 20 78 53 75 62 4d 65 6e xSubMen
0740: 75 43 6f 6e 74 61 69 6e 65 72 20 3d 20 78 43 6f uContainer = xCo
0750: 6e 74 65 78 74 4d 65 6e 75 2e 63 72 65 61 74 65 ntextMenu.create
0760: 49 6e 73 74 61 6e 63 65 28 22 63 6f 6d 2e 73 75 Instance("com.su
0770: 6e 2e 73 74 61 72 2e 75 69 2e 41 63 74 69 6f 6e n.star.ui.Action
0780: 54 72 69 67 67 65 72 43 6f 6e 74 61 69 6e 65 72 TriggerContainer
0790: 22 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ").
07a0: 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 6a for j
07b0: 2c 20 73 20 69 6e 20 65 6e 75 6d 65 72 61 74 65 , s in enumerate
07c0: 28 6c 4d 6f 72 70 68 29 3a 0a 20 20 20 20 20 20 (lMorph):.
07d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
07e0: 20 20 20 20 20 20 73 65 6c 66 2e 5f 61 64 64 49 self._addI
07f0: 74 65 6d 54 6f 43 6f 6e 74 65 78 74 4d 65 6e 75 temToContextMenu
0800: 28 78 53 75 62 4d 65 6e 75 43 6f 6e 74 61 69 6e (xSubMenuContain
0810: 65 72 2c 20 6a 2c 20 22 41 63 74 69 6f 6e 54 72 er, j, "ActionTr
0820: 69 67 67 65 72 22 2c 20 54 65 78 74 3d 73 2c 20 igger", Text=s,
0830: 43 6f 6d 6d 61 6e 64 55 52 4c 3d 22 73 65 72 76 CommandURL="serv
0840: 69 63 65 3a 6e 65 74 2e 67 72 61 6d 6d 61 6c 65 ice:net.grammale
0850: 63 74 65 2e 41 70 70 4c 61 75 6e 63 68 65 72 3f cte.AppLauncher?
0860: 4e 6f 6e 65 22 29 0a 20 20 20 20 20 20 20 20 20 None").
0870: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 #
0880: 20 63 72 65 61 74 65 20 72 6f 6f 74 20 6d 65 6e create root men
0890: 75 20 65 6e 74 72 79 0a 20 20 20 20 20 20 20 20 u entry.
08a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
08b0: 69 20 3d 20 73 65 6c 66 2e 5f 61 64 64 49 74 65 i = self._addIte
08c0: 6d 54 6f 43 6f 6e 74 65 78 74 4d 65 6e 75 28 78 mToContextMenu(x
08d0: 43 6f 6e 74 65 78 74 4d 65 6e 75 2c 20 69 2c 20 ContextMenu, i,
08e0: 22 41 63 74 69 6f 6e 54 72 69 67 67 65 72 22 2c "ActionTrigger",
08f0: 20 54 65 78 74 3d 73 52 6f 6f 74 2c 20 53 75 62 Text=sRoot, Sub
0900: 43 6f 6e 74 61 69 6e 65 72 3d 78 53 75 62 4d 65 Container=xSubMe
0910: 6e 75 43 6f 6e 74 61 69 6e 65 72 29 0a 20 20 20 nuContainer).
0920: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0930: 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 20 20 20 else:.
0940: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 i
0950: 20 3d 20 73 65 6c 66 2e 5f 61 64 64 49 74 65 6d = self._addItem
0960: 54 6f 43 6f 6e 74 65 78 74 4d 65 6e 75 28 78 43 ToContextMenu(xC
0970: 6f 6e 74 65 78 74 4d 65 6e 75 2c 20 69 2c 20 22 ontextMenu, i, "
0980: 41 63 74 69 6f 6e 54 72 69 67 67 65 72 22 2c 20 ActionTrigger",
0990: 54 65 78 74 3d 22 23 20 65 72 72 65 75 72 20 3a Text="# erreur :
09a0: 20 7b 7d 22 2e 66 6f 72 6d 61 74 28 69 74 65 6d {}".format(item
09b0: 29 29 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 ))..
09c0: 20 20 20 20 23 20 4c 69 6e 6b 73 20 74 6f 20 43 # Links to C
09d0: 6f 6e 6a 75 67 75 65 75 72 0a 20 20 20 20 20 20 onjugueur.
09e0: 20 20 20 20 20 20 20 20 20 20 69 66 20 61 56 65 if aVe
09f0: 72 62 3a 0a 20 20 20 20 20 20 20 20 20 20 20 20 rb:.
0a00: 20 20 20 20 20 20 20 20 69 20 3d 20 73 65 6c 66 i = self
0a10: 2e 5f 61 64 64 49 74 65 6d 54 6f 43 6f 6e 74 65 ._addItemToConte
0a20: 78 74 4d 65 6e 75 28 78 43 6f 6e 74 65 78 74 4d xtMenu(xContextM
0a30: 65 6e 75 2c 20 69 2c 20 22 41 63 74 69 6f 6e 54 enu, i, "ActionT
0a40: 72 69 67 67 65 72 53 65 70 61 72 61 74 6f 72 22 riggerSeparator"
0a50: 2c 20 53 65 70 61 72 61 74 6f 72 54 79 70 65 3d , SeparatorType=
0a60: 6e 55 6e 6f 43 6f 6e 73 74 61 6e 74 4c 69 6e 65 nUnoConstantLine
0a70: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ).
0a80: 20 20 20 20 20 20 66 6f 72 20 73 56 65 72 62 20 for sVerb
0a90: 69 6e 20 61 56 65 72 62 3a 0a 20 20 20 20 20 20 in aVerb:.
0aa0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0ab0: 20 20 69 20 3d 20 73 65 6c 66 2e 5f 61 64 64 49 i = self._addI
0ac0: 74 65 6d 54 6f 43 6f 6e 74 65 78 74 4d 65 6e 75 temToContextMenu
0ad0: 28 78 43 6f 6e 74 65 78 74 4d 65 6e 75 2c 20 69 (xContextMenu, i
0ae0: 2c 20 22 41 63 74 69 6f 6e 54 72 69 67 67 65 72 , "ActionTrigger
0af0: 22 2c 20 54 65 78 74 3d 22 43 6f 6e 6a 75 67 75 ", Text="Conjugu
0b00: 65 72 20 e2 80 9c 7b 7d e2 80 9d e2 80 a6 22 2e er ...{}......".
0b10: 66 6f 72 6d 61 74 28 73 56 65 72 62 29 2c 0a 20 format(sVerb),.
0b20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0b30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0b40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0b50: 20 20 20 20 20 20 43 6f 6d 6d 61 6e 64 55 52 4c CommandURL
0b60: 3d 22 73 65 72 76 69 63 65 3a 6e 65 74 2e 67 72 ="service:net.gr
0b70: 61 6d 6d 61 6c 65 63 74 65 2e 41 70 70 4c 61 75 ammalecte.AppLau
0b80: 6e 63 68 65 72 3f 43 4a 2f 22 2b 73 56 65 72 62 ncher?CJ/"+sVerb
0b90: 29 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
0ba0: 20 20 20 23 20 53 65 61 72 63 68 0a 20 20 20 20 # Search.
0bb0: 20 20 20 20 20 20 20 20 20 20 20 20 78 44 6f 63 xDoc
0bc0: 20 3d 20 78 44 65 73 6b 74 6f 70 2e 67 65 74 43 = xDesktop.getC
0bd0: 75 72 72 65 6e 74 43 6f 6d 70 6f 6e 65 6e 74 28 urrentComponent(
0be0: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ).
0bf0: 20 20 78 56 69 65 77 43 75 72 73 6f 72 20 3d 20 xViewCursor =
0c00: 78 44 6f 63 2e 43 75 72 72 65 6e 74 43 6f 6e 74 xDoc.CurrentCont
0c10: 72 6f 6c 6c 65 72 2e 56 69 65 77 43 75 72 73 6f roller.ViewCurso
0c20: 72 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 r.
0c30: 20 20 69 66 20 6e 6f 74 20 78 56 69 65 77 43 75 if not xViewCu
0c40: 72 73 6f 72 2e 69 73 43 6f 6c 6c 61 70 73 65 64 rsor.isCollapsed
0c50: 28 29 3a 0a 20 20 20 20 20 20 20 20 20 20 20 20 ():.
0c60: 20 20 20 20 20 20 20 20 73 53 65 6c 65 63 20 3d sSelec =
0c70: 20 78 56 69 65 77 43 75 72 73 6f 72 2e 67 65 74 xViewCursor.get
0c80: 53 74 72 69 6e 67 28 29 0a 20 20 20 20 20 20 20 String().
0c90: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 if
0ca0: 73 53 65 6c 65 63 2e 63 6f 75 6e 74 28 22 20 22 sSelec.count(" "
0cb0: 29 20 3c 3d 20 32 3a 0a 20 20 20 20 20 20 20 20 ) <= 2:.
0cc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0cd0: 69 20 3d 20 73 65 6c 66 2e 5f 61 64 64 49 74 65 i = self._addIte
0ce0: 6d 54 6f 43 6f 6e 74 65 78 74 4d 65 6e 75 28 78 mToContextMenu(x
0cf0: 43 6f 6e 74 65 78 74 4d 65 6e 75 2c 20 69 2c 20 ContextMenu, i,
0d00: 22 41 63 74 69 6f 6e 54 72 69 67 67 65 72 53 65 "ActionTriggerSe
0d10: 70 61 72 61 74 6f 72 22 2c 20 53 65 70 61 72 61 parator", Separa
0d20: 74 6f 72 54 79 70 65 3d 6e 55 6e 6f 43 6f 6e 73 torType=nUnoCons
0d30: 74 61 6e 74 4c 69 6e 65 29 0a 20 20 20 20 20 20 tantLine).
0d40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0d50: 20 20 23 20 73 75 62 6d 65 6e 75 0a 20 20 20 20 # submenu.
0d60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0d70: 20 20 20 20 78 53 75 62 4d 65 6e 75 43 6f 6e 74 xSubMenuCont
0d80: 61 69 6e 65 72 20 3d 20 78 43 6f 6e 74 65 78 74 ainer = xContext
0d90: 4d 65 6e 75 2e 63 72 65 61 74 65 49 6e 73 74 61 Menu.createInsta
0da0: 6e 63 65 28 22 63 6f 6d 2e 73 75 6e 2e 73 74 61 nce("com.sun.sta
0db0: 72 2e 75 69 2e 41 63 74 69 6f 6e 54 72 69 67 67 r.ui.ActionTrigg
0dc0: 65 72 43 6f 6e 74 61 69 6e 65 72 22 29 0a 20 20 erContainer").
0dd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0de0: 20 20 20 20 20 20 73 65 6c 66 2e 5f 61 64 64 49 self._addI
0df0: 74 65 6d 54 6f 43 6f 6e 74 65 78 74 4d 65 6e 75 temToContextMenu
0e00: 28 78 53 75 62 4d 65 6e 75 43 6f 6e 74 61 69 6e (xSubMenuContain
0e10: 65 72 2c 20 30 2c 20 22 41 63 74 69 6f 6e 54 72 er, 0, "ActionTr
0e20: 69 67 67 65 72 22 2c 20 54 65 78 74 3d 22 69 6e igger", Text="in
0e30: 73 65 6e 73 69 62 6c 65 20 c3 a0 20 6c 61 20 63 sensible .. la c
0e40: 61 73 73 65 22 2c 0a 20 20 20 20 20 20 20 20 20 asse",.
0e50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0e60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0e70: 20 20 20 20 20 20 20 20 20 20 43 6f 6d 6d 61 6e Comman
0e80: 64 55 52 4c 3d 22 73 65 72 76 69 63 65 3a 6e 65 dURL="service:ne
0e90: 74 2e 67 72 61 6d 6d 61 6c 65 63 74 65 2e 41 70 t.grammalecte.Ap
0ea0: 70 4c 61 75 6e 63 68 65 72 3f 46 41 2f 6e 6e 2f pLauncher?FA/nn/
0eb0: 22 2b 73 53 65 6c 65 63 29 0a 20 20 20 20 20 20 "+sSelec).
0ec0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0ed0: 20 20 73 65 6c 66 2e 5f 61 64 64 49 74 65 6d 54 self._addItemT
0ee0: 6f 43 6f 6e 74 65 78 74 4d 65 6e 75 28 78 53 75 oContextMenu(xSu
0ef0: 62 4d 65 6e 75 43 6f 6e 74 61 69 6e 65 72 2c 20 bMenuContainer,
0f00: 31 2c 20 22 41 63 74 69 6f 6e 54 72 69 67 67 65 1, "ActionTrigge
0f10: 72 22 2c 20 54 65 78 74 3d 22 63 61 73 73 65 20 r", Text="casse
0f20: 70 72 c3 a9 73 65 72 76 c3 a9 65 22 2c 0a 20 20 pr..serv..e",.
0f30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0f40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0f50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0f60: 20 43 6f 6d 6d 61 6e 64 55 52 4c 3d 22 73 65 72 CommandURL="ser
0f70: 76 69 63 65 3a 6e 65 74 2e 67 72 61 6d 6d 61 6c vice:net.grammal
0f80: 65 63 74 65 2e 41 70 70 4c 61 75 6e 63 68 65 72 ecte.AppLauncher
0f90: 3f 46 41 2f 79 6e 2f 22 2b 73 53 65 6c 65 63 29 ?FA/yn/"+sSelec)
0fa0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
0fb0: 20 20 20 20 20 20 20 20 20 73 65 6c 66 2e 5f 61 self._a
0fc0: 64 64 49 74 65 6d 54 6f 43 6f 6e 74 65 78 74 4d ddItemToContextM
0fd0: 65 6e 75 28 78 53 75 62 4d 65 6e 75 43 6f 6e 74 enu(xSubMenuCont
0fe0: 61 69 6e 65 72 2c 20 32 2c 20 22 41 63 74 69 6f ainer, 2, "Actio
0ff0: 6e 54 72 69 67 67 65 72 22 2c 20 54 65 78 74 3d nTrigger", Text=
1000: 22 6d 6f 74 28 73 29 20 65 6e 74 69 65 72 28 73 "mot(s) entier(s
1010: 29 22 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 )",.
1020: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1030: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1040: 20 20 20 20 20 20 20 43 6f 6d 6d 61 6e 64 55 52 CommandUR
1050: 4c 3d 22 73 65 72 76 69 63 65 3a 6e 65 74 2e 67 L="service:net.g
1060: 72 61 6d 6d 61 6c 65 63 74 65 2e 41 70 70 4c 61 rammalecte.AppLa
1070: 75 6e 63 68 65 72 3f 46 41 2f 6e 79 2f 22 2b 73 uncher?FA/ny/"+s
1080: 53 65 6c 65 63 29 0a 20 20 20 20 20 20 20 20 20 Selec).
1090: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 s
10a0: 65 6c 66 2e 5f 61 64 64 49 74 65 6d 54 6f 43 6f elf._addItemToCo
10b0: 6e 74 65 78 74 4d 65 6e 75 28 78 53 75 62 4d 65 ntextMenu(xSubMe
10c0: 6e 75 43 6f 6e 74 61 69 6e 65 72 2c 20 33 2c 20 nuContainer, 3,
10d0: 22 41 63 74 69 6f 6e 54 72 69 67 67 65 72 22 2c "ActionTrigger",
10e0: 20 54 65 78 74 3d 22 63 61 73 73 65 20 70 72 c3 Text="casse pr.
10f0: a9 73 65 72 76 c3 a9 65 20 2b 20 6d 6f 74 28 73 .serv..e + mot(s
1100: 29 20 65 6e 74 69 65 72 28 73 29 22 2c 0a 20 20 ) entier(s)",.
1110: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1120: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1130: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1140: 20 43 6f 6d 6d 61 6e 64 55 52 4c 3d 22 73 65 72 CommandURL="ser
1150: 76 69 63 65 3a 6e 65 74 2e 67 72 61 6d 6d 61 6c vice:net.grammal
1160: 65 63 74 65 2e 41 70 70 4c 61 75 6e 63 68 65 72 ecte.AppLauncher
1170: 3f 46 41 2f 79 79 2f 22 2b 73 53 65 6c 65 63 29 ?FA/yy/"+sSelec)
1180: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
1190: 20 20 20 20 20 20 20 20 20 23 20 63 72 65 61 74 # creat
11a0: 65 20 72 6f 6f 74 20 6d 65 6e 75 20 65 6e 74 72 e root menu entr
11b0: 79 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 y.
11c0: 20 20 20 20 20 20 20 20 20 20 69 20 3d 20 73 65 i = se
11d0: 6c 66 2e 5f 61 64 64 49 74 65 6d 54 6f 43 6f 6e lf._addItemToCon
11e0: 74 65 78 74 4d 65 6e 75 28 78 43 6f 6e 74 65 78 textMenu(xContex
11f0: 74 4d 65 6e 75 2c 20 69 2c 20 22 41 63 74 69 6f tMenu, i, "Actio
1200: 6e 54 72 69 67 67 65 72 22 2c 20 54 65 78 74 3d nTrigger", Text=
1210: 22 52 65 63 68 65 72 63 68 65 72 20 e2 80 9c 7b "Rechercher ...{
1220: 7d e2 80 9d 22 2e 66 6f 72 6d 61 74 28 73 53 65 }...".format(sSe
1230: 6c 65 63 29 2c 0a 20 20 20 20 20 20 20 20 20 20 lec),.
1240: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1250: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1260: 20 20 20 20 20 20 20 20 20 20 20 20 20 53 75 62 Sub
1270: 43 6f 6e 74 61 69 6e 65 72 3d 78 53 75 62 4d 65 Container=xSubMe
1280: 6e 75 43 6f 6e 74 61 69 6e 65 72 29 0a 20 20 20 nuContainer).
1290: 20 20 20 20 20 20 20 20 20 20 20 20 20 23 20 54 # T
12a0: 68 65 20 63 6f 6e 74 72 6f 6c 6c 65 72 20 73 68 he controller sh
12b0: 6f 75 6c 64 20 65 78 65 63 75 74 65 20 74 68 65 ould execute the
12c0: 20 6d 6f 64 69 66 69 65 64 20 63 6f 6e 74 65 78 modified contex
12d0: 74 20 6d 65 6e 75 20 61 6e 64 20 73 74 6f 70 20 t menu and stop
12e0: 6e 6f 74 69 66 79 69 6e 67 20 6f 74 68 65 72 20 notifying other
12f0: 69 6e 74 65 72 63 65 70 74 6f 72 73 2e 0a 20 20 interceptors..
1300: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 re
1310: 74 75 72 6e 20 75 6e 6f 2e 45 6e 75 6d 28 22 63 turn uno.Enum("c
1320: 6f 6d 2e 73 75 6e 2e 73 74 61 72 2e 75 69 2e 43 om.sun.star.ui.C
1330: 6f 6e 74 65 78 74 4d 65 6e 75 49 6e 74 65 72 63 ontextMenuInterc
1340: 65 70 74 6f 72 41 63 74 69 6f 6e 22 2c 20 22 45 eptorAction", "E
1350: 58 45 43 55 54 45 5f 4d 4f 44 49 46 49 45 44 22 XECUTE_MODIFIED"
1360: 29 20 23 20 64 6f 6e e2 80 99 74 20 77 6f 72 6b ) # don...t work
1370: 20 6f 6e 20 41 4f 4f 2c 20 68 61 76 65 20 74 6f on AOO, have to
1380: 20 69 6d 70 6f 72 74 20 74 68 65 20 76 61 6c 75 import the valu
1390: 65 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 e.
13a0: 20 20 23 72 65 74 75 72 6e 20 45 58 45 43 55 54 #return EXECUT
13b0: 45 5f 4d 4f 44 49 46 49 45 44 20 23 20 44 6f 65 E_MODIFIED # Doe
13c0: 73 6e e2 80 99 74 20 77 6f 72 6b 20 73 69 6e 63 sn...t work sinc
13d0: 65 20 4c 4f 20 35 2e 33 0a 20 20 20 20 20 20 20 e LO 5.3.
13e0: 20 65 78 63 65 70 74 3a 0a 20 20 20 20 20 20 20 except:.
13f0: 20 20 20 20 20 74 72 61 63 65 62 61 63 6b 2e 70 traceback.p
1400: 72 69 6e 74 5f 65 78 63 28 29 0a 20 20 20 20 20 rint_exc().
1410: 20 20 20 72 65 74 75 72 6e 20 75 6e 6f 2e 45 6e return uno.En
1420: 75 6d 28 22 63 6f 6d 2e 73 75 6e 2e 73 74 61 72 um("com.sun.star
1430: 2e 75 69 2e 43 6f 6e 74 65 78 74 4d 65 6e 75 49 .ui.ContextMenuI
1440: 6e 74 65 72 63 65 70 74 6f 72 41 63 74 69 6f 6e nterceptorAction
1450: 22 2c 20 22 49 47 4e 4f 52 45 44 22 29 20 23 20 ", "IGNORED") #
1460: 64 6f 6e e2 80 99 74 20 77 6f 72 6b 20 6f 6e 20 don...t work on
1470: 41 4f 4f 2c 20 68 61 76 65 20 74 6f 20 69 6d 70 AOO, have to imp
1480: 6f 72 74 20 74 68 65 20 76 61 6c 75 65 0a 20 20 ort the value.
1490: 20 20 20 20 20 20 23 72 65 74 75 72 6e 20 49 47 #return IG
14a0: 4e 4f 52 45 44 20 23 20 44 6f 65 73 6e e2 80 99 NORED # Doesn...
14b0: 74 20 77 6f 72 6b 20 73 69 6e 63 65 20 4c 4f 20 t work since LO
14c0: 35 2e 33 0a 0a 20 20 20 20 64 65 66 20 5f 61 64 5.3.. def _ad
14d0: 64 49 74 65 6d 54 6f 43 6f 6e 74 65 78 74 4d 65 dItemToContextMe
14e0: 6e 75 20 28 73 65 6c 66 2c 20 78 43 6f 6e 74 65 nu (self, xConte
14f0: 78 74 4d 65 6e 75 2c 20 69 2c 20 73 54 79 70 65 xtMenu, i, sType
1500: 2c 20 2a 2a 61 72 67 73 29 3a 0a 20 20 20 20 20 , **args):.
1510: 20 20 20 78 4d 65 6e 75 49 74 65 6d 20 3d 20 78 xMenuItem = x
1520: 43 6f 6e 74 65 78 74 4d 65 6e 75 2e 63 72 65 61 ContextMenu.crea
1530: 74 65 49 6e 73 74 61 6e 63 65 28 22 63 6f 6d 2e teInstance("com.
1540: 73 75 6e 2e 73 74 61 72 2e 75 69 2e 22 2b 73 54 sun.star.ui."+sT
1550: 79 70 65 29 0a 20 20 20 20 20 20 20 20 23 65 63 ype). #ec
1560: 68 6f 28 22 63 6f 6d 2e 73 75 6e 2e 73 74 61 72 ho("com.sun.star
1570: 2e 75 69 2e 22 2b 73 54 79 70 65 29 0a 20 20 20 .ui."+sType).
1580: 20 20 20 20 20 66 6f 72 20 6b 2c 20 76 20 69 6e for k, v in
1590: 20 61 72 67 73 2e 69 74 65 6d 73 28 29 3a 0a 20 args.items():.
15a0: 20 20 20 20 20 20 20 20 20 20 20 78 4d 65 6e 75 xMenu
15b0: 49 74 65 6d 2e 73 65 74 50 72 6f 70 65 72 74 79 Item.setProperty
15c0: 56 61 6c 75 65 28 6b 2c 20 76 29 0a 20 20 20 20 Value(k, v).
15d0: 20 20 20 20 20 20 20 20 23 70 72 69 6e 74 28 22 #print("
15e0: 3e 20 22 2c 20 6b 2c 20 76 2c 20 78 4d 65 6e 75 > ", k, v, xMenu
15f0: 49 74 65 6d 29 0a 20 20 20 20 20 20 20 20 78 43 Item). xC
1600: 6f 6e 74 65 78 74 4d 65 6e 75 2e 69 6e 73 65 72 ontextMenu.inser
1610: 74 42 79 49 6e 64 65 78 28 69 2c 20 78 4d 65 6e tByIndex(i, xMen
1620: 75 49 74 65 6d 29 0a 20 20 20 20 20 20 20 20 72 uItem). r
1630: 65 74 75 72 6e 20 69 20 2b 20 31 0a 0a 20 20 20 eturn i + 1..
1640: 20 64 65 66 20 5f 67 65 74 57 6f 72 64 20 28 73 def _getWord (s
1650: 65 6c 66 29 3a 0a 20 20 20 20 20 20 20 20 74 72 elf):. tr
1660: 79 3a 0a 20 20 20 20 20 20 20 20 20 20 20 20 78 y:. x
1670: 44 6f 63 20 3d 20 78 44 65 73 6b 74 6f 70 2e 67 Doc = xDesktop.g
1680: 65 74 43 75 72 72 65 6e 74 43 6f 6d 70 6f 6e 65 etCurrentCompone
1690: 6e 74 28 29 0a 20 20 20 20 20 20 20 20 20 20 20 nt().
16a0: 20 78 56 69 65 77 43 75 72 73 6f 72 20 3d 20 78 xViewCursor = x
16b0: 44 6f 63 2e 43 75 72 72 65 6e 74 43 6f 6e 74 72 Doc.CurrentContr
16c0: 6f 6c 6c 65 72 2e 56 69 65 77 43 75 72 73 6f 72 oller.ViewCursor
16d0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 . if
16e0: 78 56 69 65 77 43 75 72 73 6f 72 2e 43 68 61 72 xViewCursor.Char
16f0: 4c 6f 63 61 6c 65 2e 4c 61 6e 67 75 61 67 65 20 Locale.Language
1700: 21 3d 20 22 66 72 22 3a 0a 20 20 20 20 20 20 20 != "fr":.
1710: 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 return
1720: 22 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 78 "". x
1730: 54 65 78 74 20 3d 20 78 56 69 65 77 43 75 72 73 Text = xViewCurs
1740: 6f 72 2e 54 65 78 74 0a 20 20 20 20 20 20 20 20 or.Text.
1750: 20 20 20 20 78 43 75 72 73 6f 72 20 3d 20 78 54 xCursor = xT
1760: 65 78 74 2e 63 72 65 61 74 65 54 65 78 74 43 75 ext.createTextCu
1770: 72 73 6f 72 42 79 52 61 6e 67 65 28 78 56 69 65 rsorByRange(xVie
1780: 77 43 75 72 73 6f 72 29 0a 20 20 20 20 20 20 20 wCursor).
1790: 20 20 20 20 20 78 43 75 72 73 6f 72 2e 67 6f 74 xCursor.got
17a0: 6f 53 74 61 72 74 4f 66 57 6f 72 64 28 46 61 6c oStartOfWord(Fal
17b0: 73 65 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 se).
17c0: 78 43 75 72 73 6f 72 2e 67 6f 74 6f 45 6e 64 4f xCursor.gotoEndO
17d0: 66 57 6f 72 64 28 54 72 75 65 29 0a 20 20 20 20 fWord(True).
17e0: 20 20 20 20 65 78 63 65 70 74 3a 0a 20 20 20 20 except:.
17f0: 20 20 20 20 20 20 20 20 74 72 61 63 65 62 61 63 tracebac
1800: 6b 2e 70 72 69 6e 74 5f 65 78 63 28 29 0a 20 20 k.print_exc().
1810: 20 20 20 20 20 20 72 65 74 75 72 6e 20 78 43 75 return xCu
1820: 72 73 6f 72 2e 53 74 72 69 6e 67 2e 73 74 72 69 rsor.String.stri
1830: 70 28 27 2e 27 29 0a 0a 0a 63 6c 61 73 73 20 4a p('.')...class J
1840: 6f 62 45 78 65 63 75 74 6f 72 20 28 58 4a 6f 62 obExecutor (XJob
1850: 2c 20 75 6e 6f 68 65 6c 70 65 72 2e 42 61 73 65 , unohelper.Base
1860: 29 3a 0a 20 20 20 20 64 65 66 20 5f 5f 69 6e 69 ):. def __ini
1870: 74 5f 5f 20 28 73 65 6c 66 2c 20 63 74 78 29 3a t__ (self, ctx):
1880: 0a 20 20 20 20 20 20 20 20 73 65 6c 66 2e 63 74 . self.ct
1890: 78 20 3d 20 63 74 78 0a 20 20 20 20 20 20 20 20 x = ctx.
18a0: 67 6c 6f 62 61 6c 20 78 44 65 73 6b 74 6f 70 0a global xDesktop.
18b0: 20 20 20 20 20 20 20 20 67 6c 6f 62 61 6c 20 6f global o
18c0: 53 70 65 6c 6c 43 68 65 63 6b 65 72 0a 20 20 20 SpellChecker.
18d0: 20 20 20 20 20 67 6c 6f 62 61 6c 20 6f 4c 65 78 global oLex
18e0: 69 63 6f 67 72 61 70 68 65 0a 20 20 20 20 20 20 icographe.
18f0: 20 20 74 72 79 3a 0a 20 20 20 20 20 20 20 20 20 try:.
1900: 20 20 20 69 66 20 6e 6f 74 20 78 44 65 73 6b 74 if not xDeskt
1910: 6f 70 3a 0a 20 20 20 20 20 20 20 20 20 20 20 20 op:.
1920: 20 20 20 20 78 44 65 73 6b 74 6f 70 20 3d 20 73 xDesktop = s
1930: 65 6c 66 2e 63 74 78 2e 67 65 74 53 65 72 76 69 elf.ctx.getServi
1940: 63 65 4d 61 6e 61 67 65 72 28 29 2e 63 72 65 61 ceManager().crea
1950: 74 65 49 6e 73 74 61 6e 63 65 57 69 74 68 43 6f teInstanceWithCo
1960: 6e 74 65 78 74 28 27 63 6f 6d 2e 73 75 6e 2e 73 ntext('com.sun.s
1970: 74 61 72 2e 66 72 61 6d 65 2e 44 65 73 6b 74 6f tar.frame.Deskto
1980: 70 27 2c 20 73 65 6c 66 2e 63 74 78 29 0a 20 20 p', self.ctx).
1990: 20 20 20 20 20 20 20 20 20 20 69 66 20 6e 6f 74 if not
19a0: 20 6f 53 70 65 6c 6c 43 68 65 63 6b 65 72 3a 0a oSpellChecker:.
19b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
19c0: 78 43 75 72 43 74 78 20 3d 20 75 6e 6f 2e 67 65 xCurCtx = uno.ge
19d0: 74 43 6f 6d 70 6f 6e 65 6e 74 43 6f 6e 74 65 78 tComponentContex
19e0: 74 28 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 t().
19f0: 20 20 20 20 6f 47 43 20 3d 20 73 65 6c 66 2e 63 oGC = self.c
1a00: 74 78 2e 53 65 72 76 69 63 65 4d 61 6e 61 67 65 tx.ServiceManage
1a10: 72 2e 63 72 65 61 74 65 49 6e 73 74 61 6e 63 65 r.createInstance
1a20: 57 69 74 68 43 6f 6e 74 65 78 74 28 22 6f 72 67 WithContext("org
1a30: 2e 6f 70 65 6e 6f 66 66 69 63 65 2e 63 6f 6d 70 .openoffice.comp
1a40: 2e 70 79 75 6e 6f 2e 4c 69 67 68 74 70 72 6f 6f .pyuno.Lightproo
1a50: 66 2e 67 72 61 6d 6d 61 6c 65 63 74 65 22 2c 20 f.grammalecte",
1a60: 73 65 6c 66 2e 63 74 78 29 0a 20 20 20 20 20 20 self.ctx).
1a70: 20 20 20 20 20 20 20 20 20 20 69 66 20 68 61 73 if has
1a80: 61 74 74 72 28 6f 47 43 2c 20 22 67 65 74 53 70 attr(oGC, "getSp
1a90: 65 6c 6c 43 68 65 63 6b 65 72 22 29 3a 0a 20 20 ellChecker"):.
1aa0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1ab0: 20 20 23 20 68 74 74 70 73 3a 2f 2f 62 75 67 73 # https://bugs
1ac0: 2e 64 6f 63 75 6d 65 6e 74 66 6f 75 6e 64 61 74 .documentfoundat
1ad0: 69 6f 6e 2e 6f 72 67 2f 73 68 6f 77 5f 62 75 67 ion.org/show_bug
1ae0: 2e 63 67 69 3f 69 64 3d 39 37 37 39 30 0a 20 20 .cgi?id=97790.
1af0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1b00: 20 20 6f 53 70 65 6c 6c 43 68 65 63 6b 65 72 20 oSpellChecker
1b10: 3d 20 6f 47 43 2e 67 65 74 53 70 65 6c 6c 43 68 = oGC.getSpellCh
1b20: 65 63 6b 65 72 28 29 0a 20 20 20 20 20 20 20 20 ecker().
1b30: 20 20 20 20 20 20 20 20 65 6c 73 65 3a 0a 20 20 else:.
1b40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1b50: 20 20 6f 53 70 65 6c 6c 43 68 65 63 6b 65 72 20 oSpellChecker
1b60: 3d 20 53 70 65 6c 6c 43 68 65 63 6b 65 72 28 22 = SpellChecker("
1b70: 24 7b 6c 61 6e 67 7d 22 2c 20 22 66 72 2d 61 6c ${lang}", "fr-al
1b80: 6c 76 61 72 73 2e 62 64 69 63 22 29 0a 20 20 20 lvars.bdic").
1b90: 20 20 20 20 20 20 20 20 20 69 66 20 6e 6f 74 20 if not
1ba0: 6f 4c 65 78 69 63 6f 67 72 61 70 68 65 3a 0a 20 oLexicographe:.
1bb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f o
1bc0: 4c 65 78 69 63 6f 67 72 61 70 68 65 20 3d 20 6c Lexicographe = l
1bd0: 78 67 2e 4c 65 78 69 63 6f 67 72 61 70 68 65 28 xg.Lexicographe(
1be0: 6f 53 70 65 6c 6c 43 68 65 63 6b 65 72 29 0a 20 oSpellChecker).
1bf0: 20 20 20 20 20 20 20 65 78 63 65 70 74 3a 0a 20 except:.
1c00: 20 20 20 20 20 20 20 20 20 20 20 74 72 61 63 65 trace
1c10: 62 61 63 6b 2e 70 72 69 6e 74 5f 65 78 63 28 29 back.print_exc()
1c20: 0a 0a 20 20 20 20 64 65 66 20 65 78 65 63 75 74 .. def execut
1c30: 65 20 28 73 65 6c 66 2c 20 61 72 67 73 29 3a 0a e (self, args):.
1c40: 20 20 20 20 20 20 20 20 69 66 20 6e 6f 74 20 61 if not a
1c50: 72 67 73 3a 0a 20 20 20 20 20 20 20 20 20 20 20 rgs:.
1c60: 20 72 65 74 75 72 6e 0a 20 20 20 20 20 20 20 20 return.
1c70: 74 72 79 3a 0a 20 20 20 20 20 20 20 20 20 20 20 try:.
1c80: 20 73 50 72 6f 64 4e 61 6d 65 2c 20 73 56 65 72 sProdName, sVer
1c90: 73 69 6f 6e 20 3d 20 68 65 6c 70 65 72 73 2e 67 sion = helpers.g
1ca0: 65 74 50 72 6f 64 75 63 74 4e 61 6d 65 41 6e 64 etProductNameAnd
1cb0: 56 65 72 73 69 6f 6e 28 29 0a 20 20 20 20 20 20 Version().
1cc0: 20 20 20 20 20 20 69 66 20 28 73 50 72 6f 64 4e if (sProdN
1cd0: 61 6d 65 20 3d 3d 20 22 4c 69 62 72 65 4f 66 66 ame == "LibreOff
1ce0: 69 63 65 22 20 61 6e 64 20 73 56 65 72 73 69 6f ice" and sVersio
1cf0: 6e 20 3c 20 22 34 22 29 20 6f 72 20 73 50 72 6f n < "4") or sPro
1d00: 64 4e 61 6d 65 20 3d 3d 20 22 4f 70 65 6e 4f 66 dName == "OpenOf
1d10: 66 69 63 65 2e 6f 72 67 22 3a 0a 20 20 20 20 20 fice.org":.
1d20: 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 retur
1d30: 6e 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 n.. #
1d40: 20 77 68 61 74 20 65 76 65 6e 74 3f 0a 20 20 20 what event?.
1d50: 20 20 20 20 20 20 20 20 20 62 43 6f 72 72 65 63 bCorrec
1d60: 74 45 76 65 6e 74 20 3d 20 46 61 6c 73 65 0a 20 tEvent = False.
1d70: 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 61 for a
1d80: 72 67 20 69 6e 20 61 72 67 73 3a 0a 20 20 20 20 rg in args:.
1d90: 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 61 if a
1da0: 72 67 2e 4e 61 6d 65 20 3d 3d 20 22 45 6e 76 69 rg.Name == "Envi
1db0: 72 6f 6e 6d 65 6e 74 22 3a 0a 20 20 20 20 20 20 ronment":.
1dc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f fo
1dd0: 72 20 76 20 69 6e 20 61 72 67 2e 56 61 6c 75 65 r v in arg.Value
1de0: 3a 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 :.
1df0: 20 20 20 20 20 20 20 20 20 20 69 66 20 76 2e 4e if v.N
1e00: 61 6d 65 20 3d 3d 20 22 45 6e 76 54 79 70 65 22 ame == "EnvType"
1e10: 20 61 6e 64 20 76 2e 56 61 6c 75 65 20 3d 3d 20 and v.Value ==
1e20: 22 44 4f 43 55 4d 45 4e 54 45 56 45 4e 54 22 3a "DOCUMENTEVENT":
1e30: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
1e40: 20 20 20 20 20 20 20 20 20 20 20 20 20 62 43 6f bCo
1e50: 72 72 65 63 74 45 76 65 6e 74 20 3d 20 54 72 75 rrectEvent = Tru
1e60: 65 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 e.
1e70: 20 20 20 20 20 20 20 20 20 20 65 6c 69 66 20 76 elif v
1e80: 2e 4e 61 6d 65 20 3d 3d 20 22 45 76 65 6e 74 4e .Name == "EventN
1e90: 61 6d 65 22 3a 0a 20 20 20 20 20 20 20 20 20 20 ame":.
1ea0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1eb0: 20 20 70 61 73 73 0a 20 20 20 20 20 20 20 20 20 pass.
1ec0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1ed0: 20 20 20 23 20 63 68 65 63 6b 20 69 73 20 63 6f # check is co
1ee0: 72 72 65 63 74 20 65 76 65 6e 74 0a 20 20 20 20 rrect event.
1ef0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1f00: 20 20 20 20 20 20 20 20 23 70 72 69 6e 74 20 22 #print "
1f10: 45 76 65 6e 74 3a 20 25 73 22 20 25 20 76 2e 56 Event: %s" % v.V
1f20: 61 6c 75 65 0a 20 20 20 20 20 20 20 20 20 20 20 alue.
1f30: 20 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 69 eli
1f40: 66 20 76 2e 4e 61 6d 65 20 3d 3d 20 22 4d 6f 64 f v.Name == "Mod
1f50: 65 6c 22 3a 0a 20 20 20 20 20 20 20 20 20 20 20 el":.
1f60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1f70: 20 6d 6f 64 65 6c 20 3d 20 76 2e 56 61 6c 75 65 model = v.Value
1f80: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 . if
1f90: 62 43 6f 72 72 65 63 74 45 76 65 6e 74 3a 0a 20 bCorrectEvent:.
1fa0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 i
1fb0: 66 20 6d 6f 64 65 6c 2e 73 75 70 70 6f 72 74 73 f model.supports
1fc0: 53 65 72 76 69 63 65 28 22 63 6f 6d 2e 73 75 6e Service("com.sun
1fd0: 2e 73 74 61 72 2e 74 65 78 74 2e 54 65 78 74 44 .star.text.TextD
1fe0: 6f 63 75 6d 65 6e 74 22 29 3a 0a 20 20 20 20 20 ocument"):.
1ff0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 78 x
2000: 43 6f 6e 74 72 6f 6c 6c 65 72 20 3d 20 6d 6f 64 Controller = mod
2010: 65 6c 2e 67 65 74 43 75 72 72 65 6e 74 43 6f 6e el.getCurrentCon
2020: 74 72 6f 6c 6c 65 72 28 29 0a 20 20 20 20 20 20 troller().
2030: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 if
2040: 20 78 43 6f 6e 74 72 6f 6c 6c 65 72 3a 0a 20 20 xController:.
2050: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2060: 20 20 20 20 20 20 78 43 6f 6e 74 72 6f 6c 6c 65 xControlle
2070: 72 2e 72 65 67 69 73 74 65 72 43 6f 6e 74 65 78 r.registerContex
2080: 74 4d 65 6e 75 49 6e 74 65 72 63 65 70 74 6f 72 tMenuInterceptor
2090: 28 4d 79 43 6f 6e 74 65 78 74 4d 65 6e 75 49 6e (MyContextMenuIn
20a0: 74 65 72 63 65 70 74 6f 72 28 73 65 6c 66 2e 63 terceptor(self.c
20b0: 74 78 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 tx)).
20c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 23 70 72 #pr
20d0: 69 6e 74 28 22 4f 46 46 22 29 0a 20 20 20 20 20 int("OFF").
20e0: 20 20 20 65 78 63 65 70 74 3a 0a 20 20 20 20 20 except:.
20f0: 20 20 20 20 20 20 20 74 72 61 63 65 62 61 63 6b traceback
2100: 2e 70 72 69 6e 74 5f 65 78 63 28 29 0a 0a 0a 67 .print_exc()...g
2110: 5f 49 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 48 _ImplementationH
2120: 65 6c 70 65 72 20 3d 20 75 6e 6f 68 65 6c 70 65 elper = unohelpe
2130: 72 2e 49 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e r.Implementation
2140: 48 65 6c 70 65 72 28 29 0a 67 5f 49 6d 70 6c 65 Helper().g_Imple
2150: 6d 65 6e 74 61 74 69 6f 6e 48 65 6c 70 65 72 2e mentationHelper.
2160: 61 64 64 49 6d 70 6c 65 6d 65 6e 74 61 74 69 6f addImplementatio
2170: 6e 28 4a 6f 62 45 78 65 63 75 74 6f 72 2c 20 22 n(JobExecutor, "
2180: 67 72 61 6d 6d 61 6c 65 63 74 65 2e 43 6f 6e 74 grammalecte.Cont
2190: 65 78 74 4d 65 6e 75 48 61 6e 64 6c 65 72 22 2c extMenuHandler",
21a0: 20 28 22 67 72 61 6d 6d 61 6c 65 63 74 65 2e 43 ("grammalecte.C
21b0: 6f 6e 74 65 78 74 4d 65 6e 75 48 61 6e 64 6c 65 ontextMenuHandle
21c0: 72 22 2c 29 2c 29 0a r",),).