Add tree control
This commit is contained in:
parent
ccdb875bbb
commit
98e09e9e1d
|
@ -470,46 +470,6 @@ class LOBase(object):
|
|||
return cursor
|
||||
|
||||
|
||||
class LODrawImpress(LODocument):
|
||||
|
||||
def __init__(self, obj):
|
||||
super().__init__(obj)
|
||||
|
||||
@property
|
||||
def draw_page(self):
|
||||
return self._cc.getCurrentPage()
|
||||
|
||||
def insert_image(self, path, **kwargs):
|
||||
w = kwargs.get('width', 3000)
|
||||
h = kwargs.get('Height', 3000)
|
||||
x = kwargs.get('X', 1000)
|
||||
y = kwargs.get('Y', 1000)
|
||||
|
||||
image = self.create_instance('com.sun.star.drawing.GraphicObjectShape')
|
||||
image.GraphicURL = _path_url(path)
|
||||
image.Size = Size(w, h)
|
||||
image.Position = Point(x, y)
|
||||
self.draw_page.add(image)
|
||||
return
|
||||
|
||||
|
||||
class LOImpress(LODrawImpress):
|
||||
|
||||
def __init__(self, obj):
|
||||
super().__init__(obj)
|
||||
|
||||
|
||||
class LODraw(LODrawImpress):
|
||||
|
||||
def __init__(self, obj):
|
||||
super().__init__(obj)
|
||||
|
||||
@property
|
||||
def selection(self):
|
||||
sel = self.obj.getCurrentSelection()
|
||||
return sel
|
||||
|
||||
|
||||
class LOCellRange(object):
|
||||
|
||||
def __contains__(self, item):
|
||||
|
@ -1145,60 +1105,6 @@ class UnoGrid(UnoBaseObject):
|
|||
return
|
||||
|
||||
|
||||
class UnoTree(UnoBaseObject):
|
||||
|
||||
def __init__(self, obj, ):
|
||||
super().__init__(obj)
|
||||
self._tdm = None
|
||||
self._data = []
|
||||
|
||||
@property
|
||||
def selection(self):
|
||||
return self.obj.Selection
|
||||
|
||||
@property
|
||||
def root(self):
|
||||
if self._tdm is None:
|
||||
return ''
|
||||
return self._tdm.Root.DisplayValue
|
||||
|
||||
@root.setter
|
||||
def root(self, value):
|
||||
self._add_data_model(value)
|
||||
|
||||
def _add_data_model(self, name):
|
||||
tdm = create_instance('com.sun.star.awt.tree.MutableTreeDataModel')
|
||||
root = tdm.createNode(name, True)
|
||||
root.DataValue = 0
|
||||
tdm.setRoot(root)
|
||||
self.model.DataModel = tdm
|
||||
self._tdm = self.model.DataModel
|
||||
self._add_data()
|
||||
return
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
return self._data
|
||||
@data.setter
|
||||
def data(self, values):
|
||||
self._data = list(values)
|
||||
self._add_data()
|
||||
|
||||
def _add_data(self):
|
||||
if not self.data:
|
||||
return
|
||||
|
||||
parents = {}
|
||||
for node in self.data:
|
||||
parent = parents.get(node[1], self._tdm.Root)
|
||||
child = self._tdm.createNode(node[2], False)
|
||||
child.DataValue = node[0]
|
||||
parent.appendChild(child)
|
||||
parents[node[0]] = child
|
||||
self.obj.expandNode(self._tdm.Root)
|
||||
return
|
||||
|
||||
|
||||
class UnoTab(UnoBaseObject):
|
||||
|
||||
def __init__(self, obj):
|
||||
|
|
|
@ -5717,23 +5717,3 @@ class LIBOServer(object):
|
|||
else:
|
||||
instance = self._sm.createInstance(name)
|
||||
return instance
|
||||
|
||||
|
||||
# ~ controls = {
|
||||
# ~ 'CheckBox': 'com.sun.star.awt.UnoControlCheckBoxModel',
|
||||
# ~ 'ComboBox': 'com.sun.star.awt.UnoControlComboBoxModel',
|
||||
# ~ 'CurrencyField': 'com.sun.star.awt.UnoControlCurrencyFieldModel',
|
||||
# ~ 'DateField': 'com.sun.star.awt.UnoControlDateFieldModel',
|
||||
# ~ 'FileControl': 'com.sun.star.awt.UnoControlFileControlModel',
|
||||
# ~ 'FormattedField': 'com.sun.star.awt.UnoControlFormattedFieldModel',
|
||||
# ~ 'GroupBox': 'com.sun.star.awt.UnoControlGroupBoxModel',
|
||||
# ~ 'ImageControl': 'com.sun.star.awt.UnoControlImageControlModel',
|
||||
# ~ 'NumericField': 'com.sun.star.awt.UnoControlNumericFieldModel',
|
||||
# ~ 'PatternField': 'com.sun.star.awt.UnoControlPatternFieldModel',
|
||||
# ~ 'ProgressBar': 'com.sun.star.awt.UnoControlProgressBarModel',
|
||||
# ~ 'ScrollBar': 'com.sun.star.awt.UnoControlScrollBarModel',
|
||||
# ~ 'SimpleAnimation': 'com.sun.star.awt.UnoControlSimpleAnimationModel',
|
||||
# ~ 'SpinButton': 'com.sun.star.awt.UnoControlSpinButtonModel',
|
||||
# ~ 'Throbber': 'com.sun.star.awt.UnoControlThrobberModel',
|
||||
# ~ 'TimeField': 'com.sun.star.awt.UnoControlTimeFieldModel',
|
||||
# ~ }
|
||||
|
|
|
@ -3659,6 +3659,65 @@ class UnoRoadmap(UnoBaseObject):
|
|||
return
|
||||
|
||||
|
||||
class UnoTree(UnoBaseObject):
|
||||
|
||||
def __init__(self, obj, ):
|
||||
super().__init__(obj)
|
||||
self._tdm = None
|
||||
self._data = []
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name in ('_tdm', '_data'):
|
||||
self.__dict__[name] = value
|
||||
else:
|
||||
super().__setattr__(name, value)
|
||||
|
||||
@property
|
||||
def selection(self):
|
||||
return self.obj.Selection
|
||||
|
||||
@property
|
||||
def root(self):
|
||||
if self._tdm is None:
|
||||
return ''
|
||||
return self._tdm.Root.DisplayValue
|
||||
@root.setter
|
||||
def root(self, value):
|
||||
self._add_data_model(value)
|
||||
|
||||
def _add_data_model(self, name):
|
||||
tdm = create_instance('com.sun.star.awt.tree.MutableTreeDataModel')
|
||||
root = tdm.createNode(name, True)
|
||||
root.DataValue = 0
|
||||
tdm.setRoot(root)
|
||||
self.model.DataModel = tdm
|
||||
self._tdm = self.model.DataModel
|
||||
self._add_data()
|
||||
return
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
return self._data
|
||||
@data.setter
|
||||
def data(self, values):
|
||||
self._data = list(values)
|
||||
self._add_data()
|
||||
|
||||
def _add_data(self):
|
||||
if not self.data:
|
||||
return
|
||||
|
||||
parents = {}
|
||||
for node in self.data:
|
||||
parent = parents.get(node[1], self._tdm.Root)
|
||||
child = self._tdm.createNode(node[2], False)
|
||||
child.DataValue = node[0]
|
||||
parent.appendChild(child)
|
||||
parents[node[0]] = child
|
||||
self.obj.expandNode(self._tdm.Root)
|
||||
return
|
||||
|
||||
|
||||
UNO_CLASSES = {
|
||||
'label': UnoLabel,
|
||||
'link': UnoLabelLink,
|
||||
|
@ -3669,9 +3728,24 @@ UNO_CLASSES = {
|
|||
'image': UnoImage,
|
||||
'listbox': UnoListBox,
|
||||
'roadmap': UnoRoadmap,
|
||||
'tree': UnoTree,
|
||||
}
|
||||
|
||||
|
||||
# ~ 'ComboBox': 'com.sun.star.awt.UnoControlComboBoxModel',
|
||||
# ~ 'CurrencyField': 'com.sun.star.awt.UnoControlCurrencyFieldModel',
|
||||
# ~ 'DateField': 'com.sun.star.awt.UnoControlDateFieldModel',
|
||||
# ~ 'FileControl': 'com.sun.star.awt.UnoControlFileControlModel',
|
||||
# ~ 'FormattedField': 'com.sun.star.awt.UnoControlFormattedFieldModel',
|
||||
# ~ 'NumericField': 'com.sun.star.awt.UnoControlNumericFieldModel',
|
||||
# ~ 'PatternField': 'com.sun.star.awt.UnoControlPatternFieldModel',
|
||||
# ~ 'ProgressBar': 'com.sun.star.awt.UnoControlProgressBarModel',
|
||||
# ~ 'ScrollBar': 'com.sun.star.awt.UnoControlScrollBarModel',
|
||||
# ~ 'SimpleAnimation': 'com.sun.star.awt.UnoControlSimpleAnimationModel',
|
||||
# ~ 'SpinButton': 'com.sun.star.awt.UnoControlSpinButtonModel',
|
||||
# ~ 'Throbber': 'com.sun.star.awt.UnoControlThrobberModel',
|
||||
# ~ 'TimeField': 'com.sun.star.awt.UnoControlTimeFieldModel',
|
||||
|
||||
class LODialog(object):
|
||||
SEPARATION = 5
|
||||
MODELS = {
|
||||
|
@ -3684,9 +3758,9 @@ class LODialog(object):
|
|||
'image': 'com.sun.star.awt.UnoControlImageControlModel',
|
||||
'listbox': 'com.sun.star.awt.UnoControlListBoxModel',
|
||||
'roadmap': 'com.sun.star.awt.UnoControlRoadmapModel',
|
||||
'tree': 'com.sun.star.awt.tree.TreeControlModel',
|
||||
# ~ 'grid': 'com.sun.star.awt.grid.UnoControlGridModel',
|
||||
# ~ 'groupbox': 'com.sun.star.awt.UnoControlGroupBoxModel',
|
||||
# ~ 'tree': 'com.sun.star.awt.tree.TreeControlModel',
|
||||
# ~ 'pages': 'com.sun.star.awt.UnoMultiPageModel',
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue