source: salt-server/trunk/fuentes/py/doooListenersProcAdapters.py @ 473

Last change on this file since 473 was 473, checked in by daduve, 3 years ago

Adding files

  • Property svn:executable set to *
File size: 6.1 KB
Line 
1#**********************************************************************
2#
3#   Danny.OOo.Listeners.ListenerProcAdapters.py
4#
5#   A module to easily work with OpenOffice.org.
6#
7#**********************************************************************
8#   Copyright (c) 2003-2004 Danny Brewer
9#   d29583@groovegarden.com
10#
11#   This library is free software; you can redistribute it and/or
12#   modify it under the terms of the GNU Lesser General Public
13#   License as published by the Free Software Foundation; either
14#   version 2.1 of the License, or (at your option) any later version.
15#
16#   This library is distributed in the hope that it will be useful,
17#   but WITHOUT ANY WARRANTY; without even the implied warranty of
18#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19#   Lesser General Public License for more details.
20#
21#   You should have received a copy of the GNU Lesser General Public
22#   License along with this library; if not, write to the Free Software
23#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24#
25#   See:  http://www.gnu.org/licenses/lgpl.html
26#
27#**********************************************************************
28#   If you make changes, please append to the change log below.
29#
30#   Change Log
31#   Danny Brewer         Revised 2004-06-05-01
32#
33#**********************************************************************
34
35
36
37# OOo's libraries
38import uno 
39import unohelper 
40
41
42
43
44#--------------------------------------------------
45# An ActionListener adapter.
46# This object implements com.sun.star.awt.XActionListener.
47# When actionPerformed is called, this will call an arbitrary
48#  python procedure, passing it...
49#   1. the oActionEvent
50#   2. any other parameters you specified to this object's constructor (as a tuple).
51from com.sun.star.awt import XActionListener
52class ActionListenerProcAdapter( unohelper.Base, XActionListener ): 
53    def callable(f): return hasattr(f, '__call__')
54   
55    def __init__( self, oProcToCall, tParams=() ): 
56        self.oProcToCall = oProcToCall # a python procedure
57        self.tParams = tParams # a tuple
58    # oActionEvent is a com.sun.star.awt.ActionEvent struct.
59    def actionPerformed( self, oActionEvent ): 
60        if callable( self.oProcToCall ): 
61            #apply( self.oProcToCall, (oActionEvent,) + self.tParams )
62            self.oProcToCall(*(oActionEvent,)+self.tParams )
63
64
65
66#--------------------------------------------------
67# An ItemListener adapter.
68# This object implements com.sun.star.awt.XItemListener.
69# When itemStateChanged is called, this will call an arbitrary
70#  python procedure, passing it...
71#   1. the oItemEvent
72#   2. any other parameters you specified to this object's constructor (as a tuple).
73from com.sun.star.awt import XItemListener
74class ItemListenerProcAdapter( unohelper.Base, XItemListener ): 
75    def callable(f): return hasattr(f, '__call__')
76   
77    def __init__( self, oProcToCall, tParams=() ): 
78        self.oProcToCall = oProcToCall # a python procedure
79        self.tParams = tParams # a tuple
80
81    # oItemEvent is a com.sun.star.awt.ItemEvent struct.
82    def itemStateChanged( self, oItemEvent ): 
83        if callable( self.oProcToCall ): 
84            #apply( self.oProcToCall, (oItemEvent,) + self.tParams )
85            self.oProcToCall(*(oItemEvent,)+self.tParams )
86
87
88#--------------------------------------------------
89# An TextListener adapter.
90# This object implements com.sun.star.awt.XTextistener.
91# When textChanged is called, this will call an arbitrary
92#  python procedure, passing it...
93#   1. the oTextEvent
94#   2. any other parameters you specified to this object's constructor (as a tuple).
95from com.sun.star.awt import XTextListener
96class TextListenerProcAdapter( unohelper.Base, XTextListener ): 
97    def callable(f): return hasattr(f, '__call__')
98   
99    def __init__( self, oProcToCall, tParams=() ): 
100        self.oProcToCall = oProcToCall # a python procedure
101        self.tParams = tParams # a tuple
102
103    # oTextEvent is a com.sun.star.awt.TextEvent struct.
104    def textChanged( self, oTextEvent ): 
105        if callable( self.oProcToCall ): 
106            #apply( self.oProcToCall, (oTextEvent,) + self.tParams )
107            self.oProcToCall(*(oTextEvent,)+self.tParams )
108
109#--------------------------------------------------
110# An Adjustament event adapter.
111# This object implements com.sun.star.awt.AdjustmentEvent.
112# When textChanged is called, this will call an arbitrary
113#  python procedure, passing it...
114#   1. the oTextEvent
115#   2. any other parameters you specified to this object's constructor (as a tuple).
116from com.sun.star.awt import XAdjustmentListener
117class AdjustmentListenerProcAdapter( unohelper.Base, XAdjustmentListener ): 
118    def callable(f): return hasattr(f, '__call__')
119   
120    def __init__( self, oProcToCall, tParams=() ): 
121        self.oProcToCall = oProcToCall # a python procedure
122        self.tParams = tParams # a tuple
123
124    # oTextEvent is a com.sun.star.awt.TextEvent struct.
125    def adjustmentValueChanged( self, oAdjustmentEvent ): 
126        if callable( self.oProcToCall ): 
127            #apply( self.oProcToCall, (oAdjustmentEvent,) + self.tParams )
128            self.oProcToCall(*(oAdjustmentEvent,)+self.tParams )
129
130#--------------------------------------------------
131# An Key Listener event adapter.
132# This object implements com.sun.star.awt.XKeyListener.
133# When textChanged is called, this will call an arbitrary
134#  python procedure, passing it...
135#   1. the oTextEvent
136#   2. any other parameters you specified to this object's constructor (as a tuple).
137from com.sun.star.awt import XKeyListener
138class KeyListenerProcAdapter( unohelper.Base, XKeyListener ): 
139    def callable(f): return hasattr(f, '__call__')
140    def __init__( self, oProcToCall, tParams=() ): 
141        self.oProcToCall = oProcToCall # a python procedure
142        self.tParams = tParams # a tuple
143
144    # oKeyEvent is a com.sun.star.awt.KeyEvent struct.
145    def keyPressed( self, oKeyEvent ): 
146        if callable( self.oProcToCall ): 
147            #apply( self.oProcToCall, (oKeyEvent,) + self.tParams )
148            self.oProcToCall(*(oKeyEvent,)+self.tParams )
Note: See TracBrowser for help on using the repository browser.