1
2
3
4
5
6
7
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
|
import uno
import traceback
from common.PropertyNames import PropertyNames
from com.sun.star.awt import Rectangle
from common.Helper import Helper
from PeerConfig import PeerConfig
from common.Listener import *
from com.sun.star.awt import Rectangle
from com.sun.star.awt.PosSize import POS
class UnoDialog(object):
def __init__(self, xMSF, PropertyNames, PropertyValues):
try:
self.xMSF = xMSF
self.ControlList = {}
self.xDialogModel = xMSF.createInstance("com.sun.star.awt.UnoControlDialogModel")
self.xDialogModel.setPropertyValues(PropertyNames, PropertyValues)
self.xUnoDialog = xMSF.createInstance("com.sun.star.awt.UnoControlDialog")
self.xUnoDialog.setModel(self.xDialogModel)
self.BisHighContrastModeActivated = None
self.m_oPeerConfig = None
self.xWindowPeer = None
except UnoException, e:
traceback.print_exc()
def getControlKey(self, EventObject, ControlList):
xControlModel = EventObject.getModel()
try:
sName = xControlModel.getPropertyValue(PropertyNames.PROPERTY_NAME)
iKey = ControlList.get(sName).intValue()
except com.sun.star.uno.Exception, exception:
traceback.print_exc()
iKey = 2000
return iKey
def createPeerConfiguration(self):
self.m_oPeerConfig = PeerConfig(self)
def getPeerConfiguration(self):
if self.m_oPeerConfig == None:
self.createPeerConfiguration()
return self.m_oPeerConfig
def setControlProperty(self, ControlName, PropertyName, PropertyValue):
try:
if PropertyValue is not None:
if self.xDialogModel.hasByName(ControlName) == False:
return
xPSet = self.xDialogModel.getByName(ControlName)
if isinstance(PropertyValue,bool):
xPSet.setPropertyValue(PropertyName, PropertyValue)
else:
if isinstance(PropertyValue,list):
methodname = "[]short"
PropertyValue = tuple(PropertyValue)
elif isinstance(PropertyValue,tuple):
methodname = "[]string"
else:
PropertyValue = (PropertyValue,)
methodname = "[]string"
uno.invoke(xPSet, "setPropertyValue", (PropertyName, uno.Any( \
methodname, PropertyValue)))
except Exception, exception:
traceback.print_exc()
def transform( self, struct , propName, value ):
myinv = self.inv.createInstanceWithArguments( (struct,) )
access = self.insp.inspect( myinv )
method = access.getMethod( "setValue" , -1 )
uno.invoke( method, "invoke", ( myinv, ( propName , value ) ))
method = access.getMethod( "getMaterial" , -1 )
ret,dummy = method.invoke(myinv,() )
return ret
def getResource(self):
return self.m_oResource
def setControlProperties(self, ControlName, PropertyNames, PropertyValues):
self.setControlProperty(ControlName, PropertyNames, PropertyValues)
def getControlProperty(self, ControlName, PropertyName):
try:
xPSet = self.xDialogModel().getByName(ControlName)
oPropValuezxPSet.getPropertyValue(PropertyName)
except com.sun.star.uno.Exception, exception:
traceback.print_exc()
return None
def printControlProperties(self, ControlName):
try:
xControlModel = self.xDialogModel().getByName(ControlName)
allProps = xControlModel.getPropertySetInfo().getProperties()
i = 0
while i < allProps.length:
sName = allProps[i].Name
i += 1
except com.sun.star.uno.Exception, exception:
traceback.print_exc()
def getMAPConversionFactor(self, ControlName):
xControl2 = self.xUnoDialog.getControl(ControlName)
aSize = xControl2.getSize()
dblMAPWidth = ((Helper.getUnoPropertyValue(xControl2.getModel(), PropertyNames.PROPERTY_WIDTH)).intValue())
dblFactor = (((aSize.Width)) / dblMAPWidth)
return dblFactor
def getpreferredLabelSize(self, LabelName, sLabel):
xControl2 = self.xUnoDialog.getControl(LabelName)
OldText = xControl2.getText()
xControl2.setText(sLabel)
aSize = xControl2.getPreferredSize()
xControl2.setText(OldText)
return aSize
def removeSelectedItems(self, xListBox):
SelList = xListBox.getSelectedItemsPos()
Sellen = SelList.length
i = Sellen - 1
while i >= 0:
xListBox.removeItems(SelList[i], 1)
i -= 1
def getListBoxItemCount(self, _xListBox):
# This function may look ugly, but this is the only way to check the count
# of values in the model,which is always right.
# the control is only a view and could be right or not.
fieldnames = Helper.getUnoPropertyValue(getModel(_xListBox), "StringItemList")
return fieldnames.length
def getSelectedItemPos(self, _xListBox):
ipos = Helper.getUnoPropertyValue(getModel(_xListBox), "SelectedItems")
return ipos[0]
def isListBoxSelected(self, _xListBox):
ipos = Helper.getUnoPropertyValue(getModel(_xListBox), "SelectedItems")
return ipos.length > 0
def addSingleItemtoListbox(self, xListBox, ListItem, iSelIndex):
xListBox.addItem(ListItem, xListBox.getItemCount())
if iSelIndex != -1:
xListBox.selectItemPos(iSelIndex, True)
def insertLabel(self, sName, sPropNames, oPropValues):
try:
oFixedText = self.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", sName, sPropNames, oPropValues)
oFixedText.setPropertyValue(PropertyNames.PROPERTY_NAME, sName)
oLabel = self.xUnoDialog.getControl(sName)
return oLabel
except Exception, ex:
traceback.print_exc()
return None
def insertButton(self, sName, iControlKey, xActionListener, sProperties, sValues):
oButtonModel = self.insertControlModel("com.sun.star.awt.UnoControlButtonModel", sName, sProperties, sValues)
xPSet.setPropertyValue(PropertyNames.PROPERTY_NAME, sName)
xButton = self.xUnoDialog.getControl(sName)
if xActionListener != None:
xButton.addActionListener(ActionListenerProcAdapter(xActionListener))
ControlKey = iControlKey
if self.ControlList != None:
self.ControlList.put(sName, ControlKey)
return xButton
def insertCheckBox(self, sName, iControlKey, xItemListener, sProperties, sValues):
oButtonModel = self.insertControlModel("com.sun.star.awt.UnoControlCheckBoxModel", sName, sProperties, sValues)
oButtonModel.setPropertyValue(PropertyNames.PROPERTY_NAME, sName)
xCheckBox = self.xUnoDialog.getControl(sName)
if xItemListener != None:
xCheckBox.addItemListener(ItemListenerProcAdapter(xItemListener))
ControlKey = iControlKey
if self.ControlList != None:
self.ControlList.put(sName, ControlKey)
def insertNumericField(self, sName, iControlKey, xTextListener, sProperties, sValues):
oNumericFieldModel = self.insertControlModel("com.sun.star.awt.UnoControlNumericFieldModel", sName, sProperties, sValues)
oNumericFieldModel.setPropertyValue(PropertyNames.PROPERTY_NAME, sName)
xNumericField = self.xUnoDialog.getControl(sName)
if xTextListener != None:
xNumericField.addTextListener(TextListenerProcAdapter(xTextListener))
ControlKey = iControlKey
if self.ControlList != None:
self.ControlList.put(sName, ControlKey)
def insertScrollBar(self, sName, iControlKey, xAdjustmentListener, sProperties, sValues):
try:
oScrollModel = self.insertControlModel("com.sun.star.awt.UnoControlScrollBarModel", sName, sProperties, sValues)
oScrollModel.setPropertyValue(PropertyNames.PROPERTY_NAME, sName)
xScrollBar = self.xUnoDialog.getControl(sName)
if xAdjustmentListener != None:
xScrollBar.addAdjustmentListener(xAdjustmentListener)
ControlKey = iControlKey
if self.ControlList != None:
self.ControlList.put(sName, ControlKey)
return xScrollBar
except com.sun.star.uno.Exception, exception:
traceback.print_exc()
return None
def insertTextField(self, sName, iControlKey, xTextListener, sProperties, sValues):
xTextBox = insertEditField("com.sun.star.awt.UnoControlEditModel", sName, iControlKey, xTextListener, sProperties, sValues)
return xTextBox
def insertFormattedField(self, sName, iControlKey, xTextListener, sProperties, sValues):
xTextBox = insertEditField("com.sun.star.awt.UnoControlFormattedFieldModel", sName, iControlKey, xTextListener, sProperties, sValues)
return xTextBox
def insertEditField(self, ServiceName, sName, iControlKey, xTextListener, sProperties, sValues):
try:
xTextModel = self.insertControlModel(ServiceName, sName, sProperties, sValues)
xTextModel.setPropertyValue(PropertyNames.PROPERTY_NAME, sName)
xTextBox = self.xUnoDialog.getControl(sName)
if xTextListener != None:
xTextBox.addTextListener(TextListenerProcAdapter(xTextListener))
ControlKey = iControlKey
self.ControlList.put(sName, ControlKey)
return xTextBox
except com.sun.star.uno.Exception, exception:
traceback.print_exc()
return None
def insertListBox(self, sName, iControlKey, xActionListener, xItemListener, sProperties, sValues):
xListBoxModel = self.insertControlModel("com.sun.star.awt.UnoControlListBoxModel", sName, sProperties, sValues)
xListBoxModel.setPropertyValue(PropertyNames.PROPERTY_NAME, sName)
xListBox = self.xUnoDialog.getControl(sName)
if xItemListener != None:
xListBox.addItemListener(ItemListenerProcAdapter(xItemListener))
if xActionListener != None:
xListBox.addActionListener(ActionListenerProcAdapter(xActionListener))
ControlKey = iControlKey
self.ControlList.put(sName, ControlKey)
return xListBox
def insertComboBox(self, sName, iControlKey, xActionListener, xTextListener, xItemListener, sProperties, sValues):
xComboBoxModel = self.insertControlModel("com.sun.star.awt.UnoControlComboBoxModel", sName, sProperties, sValues)
xComboBoxModel.setPropertyValue(PropertyNames.PROPERTY_NAME, sName)
xComboBox = self.xUnoDialog.getControl(sName)
if xItemListener != None:
xComboBox.addItemListener(ItemListenerProcAdapter(xItemListener))
if xTextListener != None:
xComboBox.addTextListener(TextListenerProcAdapter(xTextListener))
if xActionListener != None:
xComboBox.addActionListener(ActionListenerProcAdapter(xActionListener))
ControlKey = iControlKey
self.ControlList.put(sName, ControlKey)
return xComboBox
def insertRadioButton(self, sName, iControlKey, xItemListener, sProperties, sValues):
try:
xRadioButton = insertRadioButton(sName, iControlKey, sProperties, sValues)
if xItemListener != None:
xRadioButton.addItemListener(ItemListenerProcAdapter(xItemListener))
return xRadioButton
except com.sun.star.uno.Exception, exception:
traceback.print_exc()
return None
def insertRadioButton(self, sName, iControlKey, xActionListener, sProperties, sValues):
try:
xButton = insertRadioButton(sName, iControlKey, sProperties, sValues)
if xActionListener != None:
xButton.addActionListener(ActionListenerProcAdapter(xActionListener))
return xButton
except com.sun.star.uno.Exception, exception:
traceback.print_exc()
return None
def insertRadioButton(self, sName, iControlKey, sProperties, sValues):
xRadioButton = insertRadioButton(sName, sProperties, sValues)
ControlKey = iControlKey
self.ControlList.put(sName, ControlKey)
return xRadioButton
def insertRadioButton(self, sName, sProperties, sValues):
try:
oRadioButtonModel = self.insertControlModel("com.sun.star.awt.UnoControlRadioButtonModel", sName, sProperties, sValues)
oRadioButtonModel.setPropertyValue(PropertyNames.PROPERTY_NAME, sName)
xRadioButton = self.xUnoDialog.getControl(sName)
return xRadioButton
except com.sun.star.uno.Exception, exception:
traceback.print_exc()
return None
'''
The problem with setting the visibility of controls is that changing the current step
of a dialog will automatically make all controls visible. The PropertyNames.PROPERTY_STEP property always wins against
the property "visible". Therfor a control meant to be invisible is placed on a step far far away.
@param the name of the control
@param iStep change the step if you want to make the control invisible
'''
def setControlVisible(self, controlname, iStep):
try:
iCurStep = int(getControlProperty(controlname, PropertyNames.PROPERTY_STEP))
setControlProperty(controlname, PropertyNames.PROPERTY_STEP, iStep)
except com.sun.star.uno.Exception, exception:
traceback.print_exc()
'''
The problem with setting the visibility of controls is that changing the current step
of a dialog will automatically make all controls visible. The PropertyNames.PROPERTY_STEP property always wins against
the property "visible". Therfor a control meant to be invisible is placed on a step far far away.
Afterwards the step property of the dialog has to be set with "repaintDialogStep". As the performance
of that method is very bad it should be used only once for all controls
@param controlname the name of the control
@param bIsVisible sets the control visible or invisible
'''
def setControlVisible(self, controlname, bIsVisible):
try:
iCurControlStep = int(getControlProperty(controlname, PropertyNames.PROPERTY_STEP))
iCurDialogStep = int(Helper.getUnoPropertyValue(self.xDialogModel, PropertyNames.PROPERTY_STEP))
if bIsVisible:
setControlProperty(controlname, PropertyNames.PROPERTY_STEP, iCurDialogStep)
else:
setControlProperty(controlname, PropertyNames.PROPERTY_STEP, UIConsts.INVISIBLESTEP)
except com.sun.star.uno.Exception, exception:
traceback.print_exc()
# repaints the currentDialogStep
def repaintDialogStep(self):
try:
ncurstep = int(Helper.getUnoPropertyValue(self.xDialogModel, PropertyNames.PROPERTY_STEP))
Helper.setUnoPropertyValue(self.xDialogModel, PropertyNames.PROPERTY_STEP, 99)
Helper.setUnoPropertyValue(self.xDialogModel, PropertyNames.PROPERTY_STEP, ncurstep)
except com.sun.star.uno.Exception, exception:
traceback.print_exc()
def insertControlModel(self, ServiceName, sName, sProperties, sValues):
try:
xControlModel = self.xDialogModel.createInstance(ServiceName)
Helper.setUnoPropertyValues(xControlModel, sProperties, sValues)
self.xDialogModel.insertByName(sName, xControlModel)
return xControlModel
except Exception, exception:
traceback.print_exc()
return None
def setFocus(self, ControlName):
oFocusControl = self.xUnoDialog.getControl(ControlName)
oFocusControl.setFocus()
def combineListboxList(self, sFirstEntry, MainList):
try:
FirstList = [sFirstEntry]
ResultList = [MainList.length + 1]
System.arraycopy(FirstList, 0, ResultList, 0, 1)
System.arraycopy(MainList, 0, ResultList, 1, MainList.length)
return ResultList
except java.lang.Exception, jexception:
traceback.print_exc()
return None
def selectListBoxItem(self, xListBox, iFieldsSelIndex):
if iFieldsSelIndex > -1:
FieldCount = xListBox.getItemCount()
if FieldCount > 0:
if iFieldsSelIndex < FieldCount:
xListBox.selectItemPos(iFieldsSelIndex, True)
else:
xListBox.selectItemPos((short)(iFieldsSelIndex - 1), True)
# deselects a Listbox. MultipleMode is not supported
def deselectListBox(self, _xBasisListBox):
oListBoxModel = getModel(_xBasisListBox)
sList = Helper.getUnoPropertyValue(oListBoxModel, "StringItemList")
Helper.setUnoPropertyValue(oListBoxModel, "StringItemList", [[],[]])
Helper.setUnoPropertyValue(oListBoxModel, "StringItemList", sList)
def calculateDialogPosition(self, FramePosSize):
# Todo: check if it would be useful or possible to create a dialog peer, that can be used for the messageboxes to
# maintain modality when they pop up.
CurPosSize = self.xUnoDialog.getPosSize()
WindowHeight = FramePosSize.Height
WindowWidth = FramePosSize.Width
DialogWidth = CurPosSize.Width
DialogHeight = CurPosSize.Height
iXPos = ((WindowWidth / 2) - (DialogWidth / 2))
iYPos = ((WindowHeight / 2) - (DialogHeight / 2))
self.xUnoDialog.setPosSize(iXPos, iYPos, DialogWidth, DialogHeight, POS)
'''
@param FramePosSize
@return 0 for cancel, 1 for ok
@throws com.sun.star.uno.Exception
'''
def executeDialog(self, FramePosSize):
if self.xUnoDialog.getPeer() == None:
raise AttributeError("Please create a peer, using your own frame");
self.calculateDialogPosition(FramePosSize)
if self.xWindowPeer == None:
self.createWindowPeer()
self.BisHighContrastModeActivated = self.isHighContrastModeActivated()
return self.xUnoDialog.execute()
def setVisible(self, parent):
self.calculateDialogPosition(parent.xWindow.getPosSize())
if self.xWindowPeer == None:
self.createWindowPeer()
self.xUnoDialog.setVisible(True)
'''
@param parent
@return 0 for cancel, 1 for ok
@throws com.sun.star.uno.Exception
'''
def executeDialogFromParent(self, parent):
return self.executeDialog(parent.xWindow.getPosSize())
'''
@param XComponent
@return 0 for cancel, 1 for ok
@throws com.sun.star.uno.Exception
'''
def executeDialogFromComponent(self, xComponent):
if xComponent != None:
w = xComponent.getComponentWindow()
if w != None:
return self.executeDialog(w.getPosSize())
return self.executeDialog( Rectangle (0, 0, 640, 400))
def setAutoMnemonic(self, ControlName, bValue):
self.xUnoDialog = self.xUnoDialog.getControl(ControlName)
xVclWindowPedsfer = self.xUnoDialog.getPeer()
self.xContainerWindow.setProperty("AutoMnemonics", bValue)
def modifyFontWeight(self, ControlName, FontWeight):
oFontDesc = FontDescriptor.FontDescriptor()
oFontDesc.Weight = FontWeight
setControlProperty(ControlName, "FontDescriptor", oFontDesc)
'''
create a peer for this
dialog, using the given
peer as a parent.
@param parentPeer
@return
@throws java.lang.Exception
'''
def createWindowPeer(self, parentPeer=None):
self.xUnoDialog.setVisible(False)
xToolkit = self.xMSF.createInstance("com.sun.star.awt.Toolkit")
if parentPeer == None:
parentPeer = xToolkit.getDesktopWindow()
self.xUnoDialog.createPeer(xToolkit, parentPeer)
self.xWindowPeer = self.xUnoDialog.getPeer()
return self.xUnoDialog.getPeer()
# deletes the first entry when this is equal to "DelEntryName"
# returns true when a new item is selected
def deletefirstListboxEntry(self, ListBoxName, DelEntryName):
xListBox = self.xUnoDialog.getControl(ListBoxName)
FirstItem = xListBox.getItem(0)
if FirstItem.equals(DelEntryName):
SelPos = xListBox.getSelectedItemPos()
xListBox.removeItems(0, 1)
if SelPos > 0:
setControlProperty(ListBoxName, "SelectedItems", [SelPos])
xListBox.selectItemPos((short)(SelPos - 1), True)
def setPeerProperty(self, ControlName, PropertyName, PropertyValue):
xControl = self.xUnoDialog.getControl(ControlName)
xVclWindowPeer = self.xControl.getPeer()
self.xContainerWindow.setProperty(PropertyName, PropertyValue)
@classmethod
def getModel(self, control):
return control.getModel()
@classmethod
def setEnabled(self, control, enabled):
setEnabled(control, enabled)
@classmethod
def setEnabled(self, control, enabled):
Helper.setUnoPropertyValue(getModel(control), PropertyNames.PROPERTY_ENABLED, enabled)
'''
@author bc93774
@param oControlModel the model of a control
@return the LabelType according to UIConsts.CONTROLTYPE
'''
@classmethod
def getControlModelType(self, oControlModel):
if oControlModel.supportsService("com.sun.star.awt.UnoControlFixedTextModel"):
return UIConsts.CONTROLTYPE.FIXEDTEXT
elif oControlModel.supportsService("com.sun.star.awt.UnoControlButtonModel"):
return UIConsts.CONTROLTYPE.BUTTON
elif oControlModel.supportsService("com.sun.star.awt.UnoControlCurrencyFieldModel"):
return UIConsts.CONTROLTYPE.CURRENCYFIELD
elif oControlModel.supportsService("com.sun.star.awt.UnoControlDateFieldModel"):
return UIConsts.CONTROLTYPE.DATEFIELD
elif oControlModel.supportsService("com.sun.star.awt.UnoControlFixedLineModel"):
return UIConsts.CONTROLTYPE.FIXEDLINE
elif oControlModel.supportsService("com.sun.star.awt.UnoControlFormattedFieldModel"):
return UIConsts.CONTROLTYPE.FORMATTEDFIELD
elif oControlModel.supportsService("com.sun.star.awt.UnoControlRoadmapModel"):
return UIConsts.CONTROLTYPE.ROADMAP
elif oControlModel.supportsService("com.sun.star.awt.UnoControlNumericFieldModel"):
return UIConsts.CONTROLTYPE.NUMERICFIELD
elif oControlModel.supportsService("com.sun.star.awt.UnoControlPatternFieldModel"):
return UIConsts.CONTROLTYPE.PATTERNFIELD
elif oControlModel.supportsService("com.sun.star.awt.UnoControlHyperTextModel"):
return UIConsts.CONTROLTYPE.HYPERTEXT
elif oControlModel.supportsService("com.sun.star.awt.UnoControlProgressBarModel"):
return UIConsts.CONTROLTYPE.PROGRESSBAR
elif oControlModel.supportsService("com.sun.star.awt.UnoControlTimeFieldModel"):
return UIConsts.CONTROLTYPE.TIMEFIELD
elif oControlModel.supportsService("com.sun.star.awt.UnoControlImageControlModel"):
return UIConsts.CONTROLTYPE.IMAGECONTROL
elif oControlModel.supportsService("com.sun.star.awt.UnoControlRadioButtonModel"):
return UIConsts.CONTROLTYPE.RADIOBUTTON
elif oControlModel.supportsService("com.sun.star.awt.UnoControlCheckBoxModel"):
return UIConsts.CONTROLTYPE.CHECKBOX
elif oControlModel.supportsService("com.sun.star.awt.UnoControlEditModel"):
return UIConsts.CONTROLTYPE.EDITCONTROL
elif oControlModel.supportsService("com.sun.star.awt.UnoControlComboBoxModel"):
return UIConsts.CONTROLTYPE.COMBOBOX
else:
if (oControlModel.supportsService("com.sun.star.awt.UnoControlListBoxModel")):
return UIConsts.CONTROLTYPE.LISTBOX
else:
return UIConsts.CONTROLTYPE.UNKNOWN
'''
@author bc93774
@param oControlModel
@return the name of the property that contains the value of a controlmodel
'''
@classmethod
def getDisplayProperty(self, oControlModel):
itype = getControlModelType(oControlModel)
return getDisplayProperty(itype)
'''
@param itype The type of the control conforming to UIConst.ControlType
@return the name of the property that contains the value of a controlmodel
'''
'''
@classmethod
def getDisplayProperty(self, itype):
# String propertyname = "";
tmp_switch_var1 = itype
if 1:
pass
else:
return ""
'''
def addResourceHandler(self, _Unit, _Module):
self.m_oResource = Resource.Resource_unknown(self.xMSF, _Unit, _Module)
def setInitialTabindex(self, _istep):
return (short)(_istep * 100)
def isHighContrastModeActivated(self):
if self.xContainerWindow != None:
if self.BisHighContrastModeActivated == None:
try:
nUIColor = int(self.xContainerWindow.getProperty("DisplayBackgroundColor"))
except IllegalArgumentException, e:
traceback.print_exc()
return False
#TODO: The following methods could be wrapped in an own class implementation
nRed = self.getRedColorShare(nUIColor)
nGreen = self.getGreenColorShare(nUIColor)
nBlue = self.getBlueColorShare(nUIColor)
nLuminance = ((nBlue * 28 + nGreen * 151 + nRed * 77) / 256)
bisactivated = (nLuminance <= 25)
self.BisHighContrastModeActivated = bisactivated
return bisactivated
else:
return self.BisHighContrastModeActivated.booleanValue()
else:
return False
def getRedColorShare(self, _nColor):
nRed = _nColor / 65536
nRedModulo = _nColor % 65536
nGreen = (int)(nRedModulo / 256)
nGreenModulo = (nRedModulo % 256)
nBlue = nGreenModulo
return nRed
def getGreenColorShare(self, _nColor):
nRed = _nColor / 65536
nRedModulo = _nColor % 65536
nGreen = (int)(nRedModulo / 256)
return nGreen
def getBlueColorShare(self, _nColor):
nRed = _nColor / 65536
nRedModulo = _nColor % 65536
nGreen = (int)(nRedModulo / 256)
nGreenModulo = (nRedModulo % 256)
nBlue = nGreenModulo
return nBlue
def getWizardImageUrl(self, _nResId, _nHCResId):
if isHighContrastModeActivated():
return "private:resource/wzi/image/" + _nHCResId
else:
return "private:resource/wzi/image/" + _nResId
def getImageUrl(self, _surl, _shcurl):
if isHighContrastModeActivated():
return _shcurl
else:
return _surl
def getListBoxLineCount(self):
return 20
|