Add support for control link
This commit is contained in:
parent
9768bf2498
commit
a88d9a1fca
|
@ -498,6 +498,15 @@ class ObjectBase(object):
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
return self.obj[index]
|
return self.obj[index]
|
||||||
|
|
||||||
|
def __getattr__(self, name):
|
||||||
|
a = None
|
||||||
|
if name == 'obj':
|
||||||
|
a = super().__getattr__(name)
|
||||||
|
else:
|
||||||
|
if hasattr(self.obj, name):
|
||||||
|
a = getattr(self.obj, name)
|
||||||
|
return a
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def obj(self):
|
def obj(self):
|
||||||
return self._obj
|
return self._obj
|
||||||
|
@ -682,6 +691,57 @@ class LODocument(object):
|
||||||
return path_pdf
|
return path_pdf
|
||||||
|
|
||||||
|
|
||||||
|
class LOForm(ObjectBase):
|
||||||
|
|
||||||
|
def __init__(self, obj):
|
||||||
|
super().__init__(obj)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._obj.getName()
|
||||||
|
@name.setter
|
||||||
|
def name(self, value):
|
||||||
|
self._obj.setName(value)
|
||||||
|
|
||||||
|
|
||||||
|
class LOForms(ObjectBase):
|
||||||
|
|
||||||
|
def __init__(self, obj, doc):
|
||||||
|
self._doc = doc
|
||||||
|
super().__init__(obj)
|
||||||
|
|
||||||
|
def __getitem__(self, index):
|
||||||
|
form = super().__getitem__(index)
|
||||||
|
return LOForm(form)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def doc(self):
|
||||||
|
return self._doc
|
||||||
|
|
||||||
|
@property
|
||||||
|
def count(self):
|
||||||
|
return self.obj.getCount()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def names(self):
|
||||||
|
return self.obj.getElementNames()
|
||||||
|
|
||||||
|
def exists(self, name):
|
||||||
|
return name in self.names
|
||||||
|
|
||||||
|
def insert(self, name):
|
||||||
|
form = self.doc.create_instance('com.sun.star.form.component.Form')
|
||||||
|
self.obj.insertByName(name, form)
|
||||||
|
return self[name]
|
||||||
|
|
||||||
|
def remove(self, index):
|
||||||
|
if isinstance(index, int):
|
||||||
|
self.obj.removeByIndex(index)
|
||||||
|
else:
|
||||||
|
self.obj.removeByName(index)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class LOCellStyle(LOObjectBase):
|
class LOCellStyle(LOObjectBase):
|
||||||
|
|
||||||
def __init__(self, obj):
|
def __init__(self, obj):
|
||||||
|
@ -978,6 +1038,8 @@ class LOCalcSheet(object):
|
||||||
|
|
||||||
def _init_values(self):
|
def _init_values(self):
|
||||||
self._events = None
|
self._events = None
|
||||||
|
self._dp = self.obj.getDrawPage()
|
||||||
|
return
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def obj(self):
|
def obj(self):
|
||||||
|
@ -1048,6 +1110,10 @@ class LOCalcSheet(object):
|
||||||
def exists_chart(self, name):
|
def exists_chart(self, name):
|
||||||
return name in self.obj.Charts.ElementNames
|
return name in self.obj.Charts.ElementNames
|
||||||
|
|
||||||
|
@property
|
||||||
|
def forms(self):
|
||||||
|
return LOForms(self._dp.getForms(), self.doc)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def events(self):
|
def events(self):
|
||||||
return self._events
|
return self._events
|
||||||
|
@ -1696,6 +1762,19 @@ class EventsMouse(EventsListenerBase, XMouseListener, XMouseMotionListener):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class EventsMouseLink(EventsMouse):
|
||||||
|
|
||||||
|
def mouseEntered(self, event):
|
||||||
|
obj = event.Source.Model
|
||||||
|
obj.TextColor = get_color('blue')
|
||||||
|
return
|
||||||
|
|
||||||
|
def mouseExited(self, event):
|
||||||
|
obj = event.Source.Model
|
||||||
|
obj.TextColor = 0
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class EventsMouseGrid(EventsMouse):
|
class EventsMouseGrid(EventsMouse):
|
||||||
selected = False
|
selected = False
|
||||||
|
|
||||||
|
@ -1997,6 +2076,16 @@ class UnoLabel(UnoBaseObject):
|
||||||
self.model.Label = value
|
self.model.Label = value
|
||||||
|
|
||||||
|
|
||||||
|
class UnoLabelLink(UnoLabel):
|
||||||
|
|
||||||
|
def __init__(self, obj):
|
||||||
|
super().__init__(obj)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type(self):
|
||||||
|
return 'link'
|
||||||
|
|
||||||
|
|
||||||
class UnoButton(UnoBaseObject):
|
class UnoButton(UnoBaseObject):
|
||||||
|
|
||||||
def __init__(self, obj):
|
def __init__(self, obj):
|
||||||
|
@ -2178,7 +2267,7 @@ def get_custom_class(tipo, obj):
|
||||||
'text': UnoText,
|
'text': UnoText,
|
||||||
'listbox': UnoListBox,
|
'listbox': UnoListBox,
|
||||||
'grid': UnoGrid,
|
'grid': UnoGrid,
|
||||||
# ~ 'link': UnoLink,
|
'link': UnoLabelLink,
|
||||||
# ~ 'tab': UnoTab,
|
# ~ 'tab': UnoTab,
|
||||||
# ~ 'roadmap': UnoRoadmap,
|
# ~ 'roadmap': UnoRoadmap,
|
||||||
# ~ 'image': UnoImage,
|
# ~ 'image': UnoImage,
|
||||||
|
@ -2197,12 +2286,16 @@ def add_listeners(events, control, name=''):
|
||||||
if hasattr(control, 'obj'):
|
if hasattr(control, 'obj'):
|
||||||
control = contro.obj
|
control = contro.obj
|
||||||
is_grid = control.ImplementationName == 'stardiv.Toolkit.GridControl'
|
is_grid = control.ImplementationName == 'stardiv.Toolkit.GridControl'
|
||||||
|
is_link = control.ImplementationName == 'stardiv.Toolkit.UnoFixedHyperlinkControl'
|
||||||
|
|
||||||
for key, value in listeners.items():
|
for key, value in listeners.items():
|
||||||
if hasattr(control, key):
|
if hasattr(control, key):
|
||||||
if is_grid and key == 'addMouseListener':
|
if is_grid and key == 'addMouseListener':
|
||||||
control.addMouseListener(EventsMouseGrid(events))
|
control.addMouseListener(EventsMouseGrid(events))
|
||||||
continue
|
continue
|
||||||
|
if is_link and key == 'addMouseListener':
|
||||||
|
control.addMouseListener(EventsMouseLink(events, name))
|
||||||
|
continue
|
||||||
getattr(control, key)(listeners[key](events, name))
|
getattr(control, key)(listeners[key](events, name))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -2654,7 +2747,6 @@ class LODialog(object):
|
||||||
self._model = self._obj.Model
|
self._model = self._obj.Model
|
||||||
self._init_controls()
|
self._init_controls()
|
||||||
self._events = None
|
self._events = None
|
||||||
# ~ self._response = None
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _create(self, properties):
|
def _create(self, properties):
|
||||||
|
|
|
@ -50,6 +50,7 @@ class LiboXML(object):
|
||||||
'rdb': 'application/vnd.sun.star.uno-typelibrary;type=RDB',
|
'rdb': 'application/vnd.sun.star.uno-typelibrary;type=RDB',
|
||||||
'xcs': 'application/vnd.sun.star.configuration-schema',
|
'xcs': 'application/vnd.sun.star.configuration-schema',
|
||||||
'help': 'application/vnd.sun.star.help',
|
'help': 'application/vnd.sun.star.help',
|
||||||
|
'component': 'application/vnd.sun.star.uno-components',
|
||||||
}
|
}
|
||||||
NAME_SPACES = {
|
NAME_SPACES = {
|
||||||
'manifest_version': '1.2',
|
'manifest_version': '1.2',
|
||||||
|
|
Loading…
Reference in New Issue