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: fr, trunk
2020-04-24
19:01
[lo] conjugueur: bouton pour copier les données dans le presse-papiers check-in: bc8bf7c81b user: olr tags: lo, trunk
17:14
[fr] màj: notice sur la langue check-in: b0d6ad20b1 user: olr tags: fr, trunk
Changes

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

     8      8   
     9      9   import grammalecte.fr.conj as conj_fr
    10     10   import helpers
    11     11   
    12     12   from com.sun.star.task import XJobExecutor
    13     13   from com.sun.star.awt import XActionListener
    14     14   from com.sun.star.awt import XTopWindowListener
           15  +from com.sun.star.datatransfer import XTransferable
           16  +
           17  +
           18  +class ClipBoardObject (unohelper.Base, XTransferable):
           19  +
           20  +    def __init__ (self):
           21  +        self.sText = ""
           22  +
           23  +    # XTransferable
           24  +    def getTransferData (self, xFlavor):
           25  +        if xFlavor.MimeType == "text/plain;charset=utf-16":
           26  +            return self.sText
           27  +        return
           28  +
           29  +    def getTransferDataFlavors (self):
           30  +        xFlavor = uno.createUnoStruct("com.sun.star.datatransfer.DataFlavor")
           31  +        xFlavor.MimeType = "text/plain;charset=utf-16"
           32  +        xFlavor.HumanPresentableName = "Unicode-Text"
           33  +        return (xFlavor,)
           34  +
           35  +    def isDataFlavorSupported (self, xFlavor):
           36  +        return xFlavor.MimeType == "text/plain;charset=utf-16"
    15     37   
    16     38   
    17     39   class Conjugueur (unohelper.Base, XActionListener, XTopWindowListener, XJobExecutor):
    18     40       def __init__ (self, ctx):
    19     41           self.ctx = ctx
    20     42           self.xSvMgr = self.ctx.ServiceManager
    21     43           self.xContainer = None
    22     44           self.xDialog = None
           45  +        self.xClipboard = None
           46  +        self.xClipboardObject = None
    23     47           self.lDropDown = ["être", "avoir", "aller", "vouloir", "pouvoir", "devoir", "acquérir", "connaître", "dire", "faire", \
    24     48                             "mettre", "partir", "prendre", "répondre", "savoir", "sentir", "tenir", "vaincre", "venir", "voir", \
    25     49                             "appeler", "envoyer", "commencer", "manger", "trouver", "accomplir", "agir", "finir", "haïr", "réussir"]
    26     50           self.sWarning = "Verbe non vérifié.\nOptions “pronominal” et “temps composés” désactivées."
    27     51   
    28     52       def _addWidget (self, name, wtype, x, y, w, h, **kwargs):
    29     53           xWidget = self.xDialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype)
................................................................................
   201    225           self.condb1 = self._addWidget('condb1', 'FixedText', nX2, nY7b+21, nWidth, nHeightCj, Label = "")
   202    226           self.condb2 = self._addWidget('condb2', 'FixedText', nX2, nY7b+28, nWidth, nHeightCj, Label = "")
   203    227           self.condb3 = self._addWidget('condb3', 'FixedText', nX2, nY7b+35, nWidth, nHeightCj, Label = "")
   204    228           self.condb4 = self._addWidget('condb4', 'FixedText', nX2, nY7b+42, nWidth, nHeightCj, Label = "")
   205    229           self.condb5 = self._addWidget('condb5', 'FixedText', nX2, nY7b+49, nWidth, nHeightCj, Label = "")
   206    230           self.condb6 = self._addWidget('condb6', 'FixedText', nX2, nY7b+56, nWidth, nHeightCj, Label = "")
   207    231   
          232  +        self.copybutton = self._addWidget('copybutton', 'Button', nX1, nY7+68, 10, 10, Label = ">", TextColor = 0x000088, HelpText="Presse-papiers")
          233  +
   208    234           # dialog height
   209    235           self.xDialog.Height = 350
   210    236           xWindowSize = helpers.getWindowSize()
   211    237           self.xDialog.PositionX = int((xWindowSize.Width / 2) - (self.xDialog.Width / 2))
   212    238           self.xDialog.PositionY = int((xWindowSize.Height / 2) - (self.xDialog.Height / 2))
   213    239   
   214    240           ## container
................................................................................
   226    252           self.xContainer.getControl('opro').setActionCommand('Change')
   227    253           self.xContainer.getControl('oint').addActionListener(self)
   228    254           self.xContainer.getControl('oint').setActionCommand('Change')
   229    255           self.xContainer.getControl('otco').addActionListener(self)
   230    256           self.xContainer.getControl('otco').setActionCommand('Change')
   231    257           self.xContainer.getControl('ofem').addActionListener(self)
   232    258           self.xContainer.getControl('ofem').setActionCommand('Change')
          259  +        self.xContainer.getControl('copybutton').addActionListener(self)
          260  +        self.xContainer.getControl('copybutton').setActionCommand('CopyData')
   233    261           self.xContainer.addTopWindowListener(self) # listener with XTopWindowListener methods
   234    262           #self.xContainer.execute()  # Modal dialog
   235    263   
   236    264           ## set verb
   237    265           self.input.Text = sArgs  if sArgs  else "être"
   238    266           self._newVerb()
   239    267   
................................................................................
   248    276                   self.xContainer.dispose()           # Non modal dialog
   249    277                   #self.xContainer.endExecute()       # Modal dialog
   250    278               elif xActionEvent.ActionCommand == 'New':
   251    279                   self._newVerb()
   252    280               elif xActionEvent.ActionCommand == 'Change':
   253    281                   if self.oVerb:
   254    282                       self._displayResults()
          283  +            elif xActionEvent.ActionCommand == 'CopyData':
          284  +                self.stringToClipboard(self.sTextForClipboard)
   255    285               else:
   256    286                   print(str(xActionEvent))
   257    287           except:
   258    288               traceback.print_exc()
   259    289   
   260    290       # XTopWindowListener (useful for non modal dialog only)
   261    291       def windowOpened (self, xEvent):
................................................................................
   275    305   
   276    306       def windowActivated (self, xEvent):
   277    307           return
   278    308   
   279    309       def windowDeactivated (self, xEvent):
   280    310           return
   281    311   
          312  +    # Clipboard
          313  +    # see: https://forum.openoffice.org/en/forum/viewtopic.php?f=21&t=93562
          314  +    def stringToClipboard (self, sText):
          315  +        if not self.xClipboard:
          316  +            self.xClipboard = self.xSvMgr.createInstance("com.sun.star.datatransfer.clipboard.SystemClipboard")
          317  +            self.xClipboardObject = ClipBoardObject()
          318  +        self.xClipboardObject.sText = sText
          319  +        self.xClipboard.setContents(self.xClipboardObject, None)
          320  +
   282    321       # XJobExecutor
   283    322       def trigger (self, args):
   284    323           try:
   285    324               xDialog = Conjugueur(self.ctx)
   286    325               xDialog.run(args)
   287    326           except:
   288    327               traceback.print_exc()
          328  +
   289    329   
   290    330       def _newVerb (self):
   291    331           self.oneg.State = False
   292    332           self.opro.State = False
   293    333           self.oint.State = False
   294    334           self.otco.State = False
   295    335           self.ofem.State = False
................................................................................
   415    455               self.simp2.Label = dConjTable["simp2"]
   416    456               self.simp3.Label = dConjTable["simp3"]
   417    457               self.simp4.Label = dConjTable["simp4"]
   418    458               self.simp5.Label = dConjTable["simp5"]
   419    459               self.simp6.Label = dConjTable["simp6"]
   420    460               # refresh
   421    461               self.xContainer.setVisible(True)
          462  +            self.sTextForClipboard = "\n".join( [ s for s in dConjTable.values() ] )
   422    463           except:
   423    464               traceback.print_exc()
   424    465   
   425    466   # g_ImplementationHelper = unohelper.ImplementationHelper()
   426    467   # g_ImplementationHelper.addImplementation(Conjugueur, 'dicollecte.Conjugueur', ('com.sun.star.task.Job',))