Grammalecte  Check-in [bc8bf7c81b]

Overview
Comment:[lo] conjugueur: bouton pour copier les données dans le presse-papiers
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | lo
Files: files | file ages | folders
SHA3-256: bc8bf7c81b3811e1f04bd83862bb1eff24f7d620e976ed961356931b06b2c4b8
User & Date: olr on 2020-04-24 19:01:01
Other Links: manifest | tags
Context
2020-04-25
10:47
[fr] ajustements check-in: 4ee0d4b1fc user: olr tags: trunk, fr
2020-04-24
19:01
[lo] conjugueur: bouton pour copier les données dans le presse-papiers check-in: bc8bf7c81b user: olr tags: trunk, lo
17:14
[fr] màj: notice sur la langue check-in: b0d6ad20b1 user: olr tags: trunk, fr
Changes

Modified gc_lang/fr/oxt/Conjugueur/Conjugueur.py from [19edfcebcd] to [0184f1d23e].

8
9
10
11
12
13
14






















15
16
17
18
19
20
21
22


23
24
25
26
27
28
29

import grammalecte.fr.conj as conj_fr
import helpers

from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener
from com.sun.star.awt import XTopWindowListener
























class Conjugueur (unohelper.Base, XActionListener, XTopWindowListener, XJobExecutor):
    def __init__ (self, ctx):
        self.ctx = ctx
        self.xSvMgr = self.ctx.ServiceManager
        self.xContainer = None
        self.xDialog = None


        self.lDropDown = ["être", "avoir", "aller", "vouloir", "pouvoir", "devoir", "acquérir", "connaître", "dire", "faire", \
                          "mettre", "partir", "prendre", "répondre", "savoir", "sentir", "tenir", "vaincre", "venir", "voir", \
                          "appeler", "envoyer", "commencer", "manger", "trouver", "accomplir", "agir", "finir", "haïr", "réussir"]
        self.sWarning = "Verbe non vérifié.\nOptions “pronominal” et “temps composés” désactivées."

    def _addWidget (self, name, wtype, x, y, w, h, **kwargs):
        xWidget = self.xDialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

import grammalecte.fr.conj as conj_fr
import helpers

from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener
from com.sun.star.awt import XTopWindowListener
from com.sun.star.datatransfer import XTransferable


class ClipBoardObject (unohelper.Base, XTransferable):

    def __init__ (self):
        self.sText = ""

    # XTransferable
    def getTransferData (self, xFlavor):
        if xFlavor.MimeType == "text/plain;charset=utf-16":
            return self.sText
        return

    def getTransferDataFlavors (self):
        xFlavor = uno.createUnoStruct("com.sun.star.datatransfer.DataFlavor")
        xFlavor.MimeType = "text/plain;charset=utf-16"
        xFlavor.HumanPresentableName = "Unicode-Text"
        return (xFlavor,)

    def isDataFlavorSupported (self, xFlavor):
        return xFlavor.MimeType == "text/plain;charset=utf-16"


class Conjugueur (unohelper.Base, XActionListener, XTopWindowListener, XJobExecutor):
    def __init__ (self, ctx):
        self.ctx = ctx
        self.xSvMgr = self.ctx.ServiceManager
        self.xContainer = None
        self.xDialog = None
        self.xClipboard = None
        self.xClipboardObject = None
        self.lDropDown = ["être", "avoir", "aller", "vouloir", "pouvoir", "devoir", "acquérir", "connaître", "dire", "faire", \
                          "mettre", "partir", "prendre", "répondre", "savoir", "sentir", "tenir", "vaincre", "venir", "voir", \
                          "appeler", "envoyer", "commencer", "manger", "trouver", "accomplir", "agir", "finir", "haïr", "réussir"]
        self.sWarning = "Verbe non vérifié.\nOptions “pronominal” et “temps composés” désactivées."

    def _addWidget (self, name, wtype, x, y, w, h, **kwargs):
        xWidget = self.xDialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype)
201
202
203
204
205
206
207


208
209
210
211
212
213
214
        self.condb1 = self._addWidget('condb1', 'FixedText', nX2, nY7b+21, nWidth, nHeightCj, Label = "")
        self.condb2 = self._addWidget('condb2', 'FixedText', nX2, nY7b+28, nWidth, nHeightCj, Label = "")
        self.condb3 = self._addWidget('condb3', 'FixedText', nX2, nY7b+35, nWidth, nHeightCj, Label = "")
        self.condb4 = self._addWidget('condb4', 'FixedText', nX2, nY7b+42, nWidth, nHeightCj, Label = "")
        self.condb5 = self._addWidget('condb5', 'FixedText', nX2, nY7b+49, nWidth, nHeightCj, Label = "")
        self.condb6 = self._addWidget('condb6', 'FixedText', nX2, nY7b+56, nWidth, nHeightCj, Label = "")



        # dialog height
        self.xDialog.Height = 350
        xWindowSize = helpers.getWindowSize()
        self.xDialog.PositionX = int((xWindowSize.Width / 2) - (self.xDialog.Width / 2))
        self.xDialog.PositionY = int((xWindowSize.Height / 2) - (self.xDialog.Height / 2))

        ## container







>
>







225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
        self.condb1 = self._addWidget('condb1', 'FixedText', nX2, nY7b+21, nWidth, nHeightCj, Label = "")
        self.condb2 = self._addWidget('condb2', 'FixedText', nX2, nY7b+28, nWidth, nHeightCj, Label = "")
        self.condb3 = self._addWidget('condb3', 'FixedText', nX2, nY7b+35, nWidth, nHeightCj, Label = "")
        self.condb4 = self._addWidget('condb4', 'FixedText', nX2, nY7b+42, nWidth, nHeightCj, Label = "")
        self.condb5 = self._addWidget('condb5', 'FixedText', nX2, nY7b+49, nWidth, nHeightCj, Label = "")
        self.condb6 = self._addWidget('condb6', 'FixedText', nX2, nY7b+56, nWidth, nHeightCj, Label = "")

        self.copybutton = self._addWidget('copybutton', 'Button', nX1, nY7+68, 10, 10, Label = ">", TextColor = 0x000088, HelpText="Presse-papiers")

        # dialog height
        self.xDialog.Height = 350
        xWindowSize = helpers.getWindowSize()
        self.xDialog.PositionX = int((xWindowSize.Width / 2) - (self.xDialog.Width / 2))
        self.xDialog.PositionY = int((xWindowSize.Height / 2) - (self.xDialog.Height / 2))

        ## container
226
227
228
229
230
231
232


233
234
235
236
237
238
239
        self.xContainer.getControl('opro').setActionCommand('Change')
        self.xContainer.getControl('oint').addActionListener(self)
        self.xContainer.getControl('oint').setActionCommand('Change')
        self.xContainer.getControl('otco').addActionListener(self)
        self.xContainer.getControl('otco').setActionCommand('Change')
        self.xContainer.getControl('ofem').addActionListener(self)
        self.xContainer.getControl('ofem').setActionCommand('Change')


        self.xContainer.addTopWindowListener(self) # listener with XTopWindowListener methods
        #self.xContainer.execute()  # Modal dialog

        ## set verb
        self.input.Text = sArgs  if sArgs  else "être"
        self._newVerb()








>
>







252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
        self.xContainer.getControl('opro').setActionCommand('Change')
        self.xContainer.getControl('oint').addActionListener(self)
        self.xContainer.getControl('oint').setActionCommand('Change')
        self.xContainer.getControl('otco').addActionListener(self)
        self.xContainer.getControl('otco').setActionCommand('Change')
        self.xContainer.getControl('ofem').addActionListener(self)
        self.xContainer.getControl('ofem').setActionCommand('Change')
        self.xContainer.getControl('copybutton').addActionListener(self)
        self.xContainer.getControl('copybutton').setActionCommand('CopyData')
        self.xContainer.addTopWindowListener(self) # listener with XTopWindowListener methods
        #self.xContainer.execute()  # Modal dialog

        ## set verb
        self.input.Text = sArgs  if sArgs  else "être"
        self._newVerb()

248
249
250
251
252
253
254


255
256
257
258
259
260
261
                self.xContainer.dispose()           # Non modal dialog
                #self.xContainer.endExecute()       # Modal dialog
            elif xActionEvent.ActionCommand == 'New':
                self._newVerb()
            elif xActionEvent.ActionCommand == 'Change':
                if self.oVerb:
                    self._displayResults()


            else:
                print(str(xActionEvent))
        except:
            traceback.print_exc()

    # XTopWindowListener (useful for non modal dialog only)
    def windowOpened (self, xEvent):







>
>







276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
                self.xContainer.dispose()           # Non modal dialog
                #self.xContainer.endExecute()       # Modal dialog
            elif xActionEvent.ActionCommand == 'New':
                self._newVerb()
            elif xActionEvent.ActionCommand == 'Change':
                if self.oVerb:
                    self._displayResults()
            elif xActionEvent.ActionCommand == 'CopyData':
                self.stringToClipboard(self.sTextForClipboard)
            else:
                print(str(xActionEvent))
        except:
            traceback.print_exc()

    # XTopWindowListener (useful for non modal dialog only)
    def windowOpened (self, xEvent):
275
276
277
278
279
280
281









282
283
284
285
286
287
288

289
290
291
292
293
294
295

    def windowActivated (self, xEvent):
        return

    def windowDeactivated (self, xEvent):
        return










    # XJobExecutor
    def trigger (self, args):
        try:
            xDialog = Conjugueur(self.ctx)
            xDialog.run(args)
        except:
            traceback.print_exc()


    def _newVerb (self):
        self.oneg.State = False
        self.opro.State = False
        self.oint.State = False
        self.otco.State = False
        self.ofem.State = False







>
>
>
>
>
>
>
>
>







>







305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335

    def windowActivated (self, xEvent):
        return

    def windowDeactivated (self, xEvent):
        return

    # Clipboard
    # see: https://forum.openoffice.org/en/forum/viewtopic.php?f=21&t=93562
    def stringToClipboard (self, sText):
        if not self.xClipboard:
            self.xClipboard = self.xSvMgr.createInstance("com.sun.star.datatransfer.clipboard.SystemClipboard")
            self.xClipboardObject = ClipBoardObject()
        self.xClipboardObject.sText = sText
        self.xClipboard.setContents(self.xClipboardObject, None)

    # XJobExecutor
    def trigger (self, args):
        try:
            xDialog = Conjugueur(self.ctx)
            xDialog.run(args)
        except:
            traceback.print_exc()


    def _newVerb (self):
        self.oneg.State = False
        self.opro.State = False
        self.oint.State = False
        self.otco.State = False
        self.ofem.State = False
415
416
417
418
419
420
421

422
423
424
425
426
            self.simp2.Label = dConjTable["simp2"]
            self.simp3.Label = dConjTable["simp3"]
            self.simp4.Label = dConjTable["simp4"]
            self.simp5.Label = dConjTable["simp5"]
            self.simp6.Label = dConjTable["simp6"]
            # refresh
            self.xContainer.setVisible(True)

        except:
            traceback.print_exc()

# g_ImplementationHelper = unohelper.ImplementationHelper()
# g_ImplementationHelper.addImplementation(Conjugueur, 'dicollecte.Conjugueur', ('com.sun.star.task.Job',))







>





455
456
457
458
459
460
461
462
463
464
465
466
467
            self.simp2.Label = dConjTable["simp2"]
            self.simp3.Label = dConjTable["simp3"]
            self.simp4.Label = dConjTable["simp4"]
            self.simp5.Label = dConjTable["simp5"]
            self.simp6.Label = dConjTable["simp6"]
            # refresh
            self.xContainer.setVisible(True)
            self.sTextForClipboard = "\n".join( [ s for s in dConjTable.values() ] )
        except:
            traceback.print_exc()

# g_ImplementationHelper = unohelper.ImplementationHelper()
# g_ImplementationHelper.addImplementation(Conjugueur, 'dicollecte.Conjugueur', ('com.sun.star.task.Job',))