diff --git a/CHANGELOG.md b/CHANGELOG.md index 3eb9389..cfbf32e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +v 0.4.0 [20-Sep-2023] +--------------------- + - Add control layout manager + v 0.3.0 [23-Apr-2023] --------------------- - Add method post diff --git a/VERSION b/VERSION index d15723f..1d0ba9e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.2 +0.4.0 diff --git a/source/easymacro/easydoc.py b/source/easymacro/easydoc.py index 5e5c1dc..69e1004 100644 --- a/source/easymacro/easydoc.py +++ b/source/easymacro/easydoc.py @@ -8,11 +8,51 @@ from .easymain import (log, from .easyuno import IOStream +class LOLayoutManager(BaseObject): + PR = 'private:resource/' + + def __init__(self, obj): + super().__init__(obj) + + def __getitem__(self, index): + """ """ + name = index + if not name.startswith(self.PR): + name = self.PR + name + return self.obj.getElement(name) + + @property + def visible(self): + """ """ + return self.obj.isVisible() + @visible.setter + def visible(self, value): + self.obj.Visible = value + + @property + def elements(self): + """ """ + return [e.ResourceURL[17:] for e in self.obj.Elements] + + def show(self, name): + if not name.startswith(self.PR): + name = self.PR + name + self.obj.showElement(name) + return + + def hide(self, name): + if not name.startswith(self.PR): + name = self.PR + name + self.obj.hideElement(name) + return + + class LODocument(BaseObject): def __init__(self, obj): super().__init__(obj) self._cc = obj.getCurrentController() + self._layout_manager = LOLayoutManager(self._cc.Frame.LayoutManager) self._undo = True def __enter__(self): @@ -109,6 +149,11 @@ class LODocument(BaseObject): """Get frame document""" return self._cc.getFrame() + @property + def layout_manager(self): + """ """ + return self._layout_manager + def _create_instance(self, name): obj = self.obj.createInstance(name) return obj diff --git a/source/easymacro/easydocs.py b/source/easymacro/easydocs.py index e11f010..7073b3a 100644 --- a/source/easymacro/easydocs.py +++ b/source/easymacro/easydocs.py @@ -12,7 +12,6 @@ from .easyide import LOBasicIDE DESKTOP = create_instance('com.sun.star.frame.Desktop', True) -ACTIVE = DESKTOP.getCurrentComponent() class LODocuments(): @@ -87,7 +86,7 @@ class LODocuments(): mm = create_instance('com.sun.star.frame.ModuleManager') # ~ ?? - print(mm.supportsService('com.sun.star.frame.ModuleManager')) + # ~ print(mm.supportsService('com.sun.star.frame.ModuleManager')) type_module = mm.identify(doc) return self._classes[type_module](doc) @@ -95,7 +94,8 @@ class LODocuments(): @property def active(self): """Get active doc""" - obj = self._get_class_doc(ACTIVE) + active = self._desktop.getCurrentComponent() + obj = self._get_class_doc(active) return obj def new(self, type_doc: str='calc', args: dict={}): diff --git a/source/easymacro/easydrawpage.py b/source/easymacro/easydrawpage.py index 1fa0a9a..fcb1718 100644 --- a/source/easymacro/easydrawpage.py +++ b/source/easymacro/easydrawpage.py @@ -231,6 +231,7 @@ class LODrawPage(BaseObject): if isinstance(path, str): image.GraphicURL = Path(path).as_uri() else: + # ~ URL = path gp = create_instance('com.sun.star.graphic.GraphicProvider') stream = IOStream.input(path) properties = dict_to_property({'InputStream': stream}) diff --git a/source/easymacro/easyevents.py b/source/easymacro/easyevents.py index 71713d2..d2211be 100644 --- a/source/easymacro/easyevents.py +++ b/source/easymacro/easyevents.py @@ -141,7 +141,10 @@ class EventsMouse(EventsListenerBase, XMouseListener, XMouseMotionListener): # ~ XMouseMotionListener def mouseMoved(self, event): - pass + event_name = f'{self._name}_mouse_moved' + if hasattr(self._controller, event_name): + getattr(self._controller, event_name)(event) + return def mouseDragged(self, event): pass diff --git a/source/easymacro/easymain.py b/source/easymacro/easymain.py index 8118454..ac401b0 100644 --- a/source/easymacro/easymain.py +++ b/source/easymacro/easymain.py @@ -840,6 +840,10 @@ class Paths(object): """ return Path(path).is_file() + @classmethod + def is_symlink(cls, path: str): + return Path(path).is_symlink() + @classmethod def temp_file(self): """Make temporary file""" diff --git a/source/easymacro/easyshape.py b/source/easymacro/easyshape.py index afcab38..f346a1a 100644 --- a/source/easymacro/easyshape.py +++ b/source/easymacro/easyshape.py @@ -227,7 +227,6 @@ class LOShape(BaseObject): url = Paths.to_system(self.obj.GraphicURL.OriginURL) return url - # ~ not work @property def visible(self): return self.obj.Visible diff --git a/source/easymacro/easytools.py b/source/easymacro/easytools.py index 9e4c5cd..05b85eb 100644 --- a/source/easymacro/easytools.py +++ b/source/easymacro/easytools.py @@ -338,7 +338,7 @@ class LOInspect(): 'STRUCT': '-Struct-', } - def __init__(self, obj: Any, to_doc: bool=False): + def __init__(self, obj: Any, to_doc: bool=True): """Introspection objects pyUno :param obj: Object to inspect @@ -381,7 +381,8 @@ class LOInspect(): sheet['A1'].data = self.interfaces sheet = doc.insert('Services') - sheet['A1'].data = self.services + if self.services: + sheet['A1'].data = self.services sheet = doc.insert('Listeners') sheet['A1'].data = self.listeners diff --git a/source/easymacro/easyuno.py b/source/easymacro/easyuno.py index ff6d128..c054f58 100644 --- a/source/easymacro/easyuno.py +++ b/source/easymacro/easyuno.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import uno import unohelper from com.sun.star.io import IOException, XOutputStream from .easymain import create_instance