started replacing deputes dialog by a combobox in toolbar
This commit is contained in:
parent
2b1671dd27
commit
27c50e4843
|
@ -9,7 +9,7 @@
|
|||
<node oor:name="Tabellio.Orateurs" oor:op="replace">
|
||||
<node oor:name="m4" oor:op="replace">
|
||||
<prop oor:name="URL" oor:type="xs:string">
|
||||
<value>service:org.entrouvert.openoffice.OrateurDialog?deputes</value>
|
||||
<value>TabellioInserts:depute</value>
|
||||
</prop>
|
||||
<prop oor:name="ImageIdentifier" oor:type="xs:string">
|
||||
<value/>
|
||||
|
@ -24,6 +24,12 @@
|
|||
<prop oor:name="Context" oor:type="xs:string">
|
||||
<value>com.sun.star.text.TextDocument</value>
|
||||
</prop>
|
||||
<prop oor:name="ControlType" oor:type="xs:string">
|
||||
<value>Combobox</value>
|
||||
</prop>
|
||||
<prop oor:name="Width" oor:type="xs:long">
|
||||
<value>200</value>
|
||||
</prop>
|
||||
</node>
|
||||
|
||||
<node oor:name="m5" oor:op="replace">
|
||||
|
|
|
@ -11,5 +11,10 @@
|
|||
<value>TabellioListes:*</value>
|
||||
</prop>
|
||||
</node>
|
||||
<node oor:name="org.entrouvert.openoffice.Inserts" oor:op="replace">
|
||||
<prop oor:name="Protocols" oor:type="oor:string-list">
|
||||
<value>TabellioInserts:*</value>
|
||||
</prop>
|
||||
</node>
|
||||
</node>
|
||||
</oor:component-data>
|
||||
|
|
|
@ -93,6 +93,31 @@ def getText(nodeT):
|
|||
return rc
|
||||
|
||||
|
||||
def getListOfNames(list_filename, node_name):
|
||||
def getName(x):
|
||||
if not x.getElementsByTagName('firstname'):
|
||||
return ''
|
||||
return u'%s %s' % (getText(x.getElementsByTagName('name')[0]),
|
||||
getText(x.getElementsByTagName('firstname')[0]))
|
||||
|
||||
def getComName(x, ellipse = False):
|
||||
if not x.getElementsByTagName('nom'):
|
||||
return ''
|
||||
x = getText(x.getElementsByTagName('nom')[0])
|
||||
if ellipse:
|
||||
if len(x) > 40:
|
||||
x = x[:40] + ' ...'
|
||||
return x
|
||||
|
||||
dom = xml.dom.minidom.parseString(open(list_filename).read())
|
||||
speakers = dom.childNodes[0].getElementsByTagName(node_name)
|
||||
list_content = [getName(x) for x in speakers]
|
||||
list_values = list_content[:]
|
||||
|
||||
return list_content, list_values
|
||||
|
||||
|
||||
|
||||
class CloseListener(unohelper.Base, XActionListener):
|
||||
def __init__(self, dialog):
|
||||
self.dialog = dialog
|
||||
|
@ -524,12 +549,6 @@ class OrateurDialog(unohelper.Base, XJobExecutor):
|
|||
combobox = addWidget(dialogModel, 'insertWidget', 'ComboBox', 50, 7, 100, 14)
|
||||
combobox.Dropdown = True
|
||||
|
||||
def getName(x):
|
||||
if not x.getElementsByTagName('firstname'):
|
||||
return ''
|
||||
return u'%s %s' % (getText(x.getElementsByTagName('name')[0]),
|
||||
getText(x.getElementsByTagName('firstname')[0]))
|
||||
|
||||
def getComName(x, ellipse = False):
|
||||
if not x.getElementsByTagName('nom'):
|
||||
return ''
|
||||
|
@ -540,15 +559,9 @@ class OrateurDialog(unohelper.Base, XJobExecutor):
|
|||
return x
|
||||
|
||||
if args == 'deputes':
|
||||
dom = xml.dom.minidom.parseString(open(list_filename).read())
|
||||
speakers = dom.childNodes[0].getElementsByTagName('SParlSpeaker')
|
||||
list_content = [getName(x) for x in speakers]
|
||||
list_values = list_content[:]
|
||||
list_content, list_values = getListOfNames(list_filename, 'SParlSpeaker')
|
||||
elif args == 'ministres':
|
||||
dom = xml.dom.minidom.parseString(open(list_filename).read())
|
||||
speakers = dom.childNodes[0].getElementsByTagName('SMinistreSpeaker')
|
||||
list_content = [getName(x) for x in speakers]
|
||||
list_values = list_content[:]
|
||||
list_content, list_values = getListOfNames(list_filename, 'SMinistreSpeaker')
|
||||
elif args == 'commissions':
|
||||
dom = xml.dom.minidom.parseString(open(list_filename).read())
|
||||
coms = dom.childNodes[0].getElementsByTagName('MCOMSInfo')
|
||||
|
@ -993,8 +1006,8 @@ class Preview(unohelper.Base, XJobExecutor):
|
|||
|
||||
# XXX: clean up files
|
||||
|
||||
|
||||
class ListeDispatch(unohelper.Base, XDispatch, XControlNotificationListener):
|
||||
class Dispatcher(unohelper.Base, XDispatch, XControlNotificationListener, XJobExecutor,
|
||||
XActionListener):
|
||||
def __init__(self, ctx):
|
||||
self.listeners = []
|
||||
self.ctx = ctx
|
||||
|
@ -1004,14 +1017,6 @@ class ListeDispatch(unohelper.Base, XDispatch, XControlNotificationListener):
|
|||
# keep track of listeners, for proper removal afterwards
|
||||
self.listeners.append(control)
|
||||
|
||||
try:
|
||||
if url.Path == 'numbered':
|
||||
values = makeNamedList(('abricot', 'peche'))
|
||||
self.sendCommand(control, url, 'SetList', values)
|
||||
else:
|
||||
print 'Unknown Path:', url.Path
|
||||
except:
|
||||
printException()
|
||||
|
||||
def removeStatusListener(self, control, url):
|
||||
if control in self.listeners:
|
||||
|
@ -1043,6 +1048,84 @@ class ListeDispatch(unohelper.Base, XDispatch, XControlNotificationListener):
|
|||
printException()
|
||||
|
||||
|
||||
class InsertDispatcher(Dispatcher):
|
||||
|
||||
def addStatusListener(self, control, url):
|
||||
print 'insert dispatcher', url.Path
|
||||
Dispatcher.addStatusListener(self, control, url)
|
||||
try:
|
||||
if url.Path == 'depute':
|
||||
list_filename = download('http://perso.entrouvert.org/~fred/tabellio/Parls.xml')
|
||||
list_content, list_values = getListOfNames(list_filename, 'SParlSpeaker')
|
||||
values = makeNamedList(tuple(list_content))
|
||||
self.sendCommand(control, url, 'SetList', values)
|
||||
else:
|
||||
print 'Unknown Path:', url.Path
|
||||
except:
|
||||
printException()
|
||||
|
||||
def dispatch(self, url, args):
|
||||
print 'received dispatch instruction on', url.Path
|
||||
print ' args:', args
|
||||
pass
|
||||
|
||||
def actionPerformed(self, actionEvent):
|
||||
print 'actionPerformed', actionEvent
|
||||
|
||||
def controlEvent(self, event):
|
||||
try:
|
||||
print 'controlEvent', event.aURL.Path
|
||||
print ' ', event.Event
|
||||
|
||||
if event.aURL.Path == 'depute':
|
||||
pass
|
||||
except:
|
||||
printException()
|
||||
|
||||
|
||||
def trigger(self, args):
|
||||
print 'triggered Insert Plop'
|
||||
|
||||
|
||||
|
||||
|
||||
class Inserts(unohelper.Base, XJobExecutor, XDispatchProvider, XActionListener):
|
||||
def __init__(self, ctx):
|
||||
self.ctx = ctx
|
||||
|
||||
def queryDispatch(self, url, target, flags):
|
||||
return InsertDispatcher(self.ctx)
|
||||
|
||||
def trigger(self, args):
|
||||
print 'triggered Insert'
|
||||
|
||||
def actionPerformed(self, actionEvent):
|
||||
print 'action eprformed her'
|
||||
|
||||
class ListeDispatch(Dispatcher):
|
||||
|
||||
def addStatusListener(self, control, url):
|
||||
Dispatcher.addStatusListener(self, control, url)
|
||||
try:
|
||||
print 'plop', repr(url.Path)
|
||||
if url.Path == 'numbered':
|
||||
values = makeNamedList(('abricot', 'peche'))
|
||||
self.sendCommand(control, url, 'SetList', values)
|
||||
else:
|
||||
print 'Unknown Path:', url.Path
|
||||
except:
|
||||
print 'zaeaze'
|
||||
printException()
|
||||
|
||||
def dispatch(self, url, args):
|
||||
print 'received dispatch instruction on', url.Path
|
||||
print ' args:', args
|
||||
pass
|
||||
|
||||
def controlEvent(self, event):
|
||||
pass
|
||||
|
||||
|
||||
class ListesDropdowns(unohelper.Base, XJobExecutor, XDispatchProvider):
|
||||
def __init__(self, ctx):
|
||||
self.ctx = ctx
|
||||
|
@ -1104,3 +1187,8 @@ g_ImplementationHelper.addImplementation(
|
|||
'org.entrouvert.openoffice.ListesDropdowns',
|
||||
('com.sun.star.frame.DispatchProvider', 'com.sun.star.task.Job',))
|
||||
|
||||
g_ImplementationHelper.addImplementation(
|
||||
Inserts,
|
||||
'org.entrouvert.openoffice.Inserts',
|
||||
('com.sun.star.frame.DispatchProvider', 'com.sun.star.task.Job',))
|
||||
|
||||
|
|
Reference in New Issue