diff --git a/source/easymacro.py b/source/easymacro.py index 218abbf..25e04b4 100644 --- a/source/easymacro.py +++ b/source/easymacro.py @@ -498,6 +498,15 @@ class ObjectBase(object): def __getitem__(self, 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 def obj(self): return self._obj @@ -682,6 +691,57 @@ class LODocument(object): 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): def __init__(self, obj): @@ -978,6 +1038,8 @@ class LOCalcSheet(object): def _init_values(self): self._events = None + self._dp = self.obj.getDrawPage() + return @property def obj(self): @@ -1048,6 +1110,10 @@ class LOCalcSheet(object): def exists_chart(self, name): return name in self.obj.Charts.ElementNames + @property + def forms(self): + return LOForms(self._dp.getForms(), self.doc) + @property def events(self): return self._events @@ -1696,6 +1762,19 @@ class EventsMouse(EventsListenerBase, XMouseListener, XMouseMotionListener): 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): selected = False @@ -1997,6 +2076,16 @@ class UnoLabel(UnoBaseObject): self.model.Label = value +class UnoLabelLink(UnoLabel): + + def __init__(self, obj): + super().__init__(obj) + + @property + def type(self): + return 'link' + + class UnoButton(UnoBaseObject): def __init__(self, obj): @@ -2178,7 +2267,7 @@ def get_custom_class(tipo, obj): 'text': UnoText, 'listbox': UnoListBox, 'grid': UnoGrid, - # ~ 'link': UnoLink, + 'link': UnoLabelLink, # ~ 'tab': UnoTab, # ~ 'roadmap': UnoRoadmap, # ~ 'image': UnoImage, @@ -2197,12 +2286,16 @@ def add_listeners(events, control, name=''): if hasattr(control, 'obj'): control = contro.obj is_grid = control.ImplementationName == 'stardiv.Toolkit.GridControl' + is_link = control.ImplementationName == 'stardiv.Toolkit.UnoFixedHyperlinkControl' for key, value in listeners.items(): if hasattr(control, key): if is_grid and key == 'addMouseListener': control.addMouseListener(EventsMouseGrid(events)) continue + if is_link and key == 'addMouseListener': + control.addMouseListener(EventsMouseLink(events, name)) + continue getattr(control, key)(listeners[key](events, name)) return @@ -2654,7 +2747,6 @@ class LODialog(object): self._model = self._obj.Model self._init_controls() self._events = None - # ~ self._response = None return def _create(self, properties): diff --git a/source/zaz.py b/source/zaz.py index 867ac42..2cac1bc 100644 --- a/source/zaz.py +++ b/source/zaz.py @@ -50,6 +50,7 @@ class LiboXML(object): 'rdb': 'application/vnd.sun.star.uno-typelibrary;type=RDB', 'xcs': 'application/vnd.sun.star.configuration-schema', 'help': 'application/vnd.sun.star.help', + 'component': 'application/vnd.sun.star.uno-components', } NAME_SPACES = { 'manifest_version': '1.2',