Add control layout manager
This commit is contained in:
parent
3313dddae2
commit
3aaec4df56
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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={}):
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"""
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue