Clean class Dialog
This commit is contained in:
parent
89fed4931d
commit
e0ead063ed
102
source/diff.py
102
source/diff.py
|
@ -1784,49 +1784,6 @@ def _set_column_model(columns):
|
|||
|
||||
class LODialog(object):
|
||||
|
||||
def __init__(self, **properties):
|
||||
self._obj = self._create(properties)
|
||||
self._init_values()
|
||||
|
||||
def _init_values(self):
|
||||
self._model = self._obj.Model
|
||||
self._init_controls()
|
||||
self._events = None
|
||||
self._color_on_focus = -1
|
||||
self._id_extension = ''
|
||||
self._images = 'images'
|
||||
return
|
||||
|
||||
def _create(self, properties):
|
||||
path = properties.pop('Path', '')
|
||||
if path:
|
||||
dp = create_instance('com.sun.star.awt.DialogProvider', True)
|
||||
return dp.createDialog(_path_url(path))
|
||||
|
||||
if 'Location' in properties:
|
||||
location = properties.get('Location', 'application')
|
||||
library = properties.get('Library', 'Standard')
|
||||
if location == 'user':
|
||||
location = 'application'
|
||||
dp = create_instance('com.sun.star.awt.DialogProvider', True)
|
||||
path = 'vnd.sun.star.script:{}.{}?location={}'.format(
|
||||
library, properties['Name'], location)
|
||||
if location == 'document':
|
||||
uid = get_document().uid
|
||||
path = 'vnd.sun.star.tdoc:/{}/Dialogs/{}/{}.xml'.format(
|
||||
uid, library, properties['Name'])
|
||||
return dp.createDialog(path)
|
||||
|
||||
dlg = create_instance('com.sun.star.awt.UnoControlDialog', True)
|
||||
model = create_instance('com.sun.star.awt.UnoControlDialogModel', True)
|
||||
toolkit = create_instance('com.sun.star.awt.Toolkit', True)
|
||||
set_properties(model, properties)
|
||||
dlg.setModel(model)
|
||||
dlg.setVisible(False)
|
||||
dlg.createPeer(toolkit, None)
|
||||
|
||||
return dlg
|
||||
|
||||
def _get_type_control(self, name):
|
||||
types = {
|
||||
'stardiv.Toolkit.UnoFixedTextControl': 'label',
|
||||
|
@ -1847,23 +1804,6 @@ class LODialog(object):
|
|||
setattr(self, name, control)
|
||||
return
|
||||
|
||||
@property
|
||||
def obj(self):
|
||||
return self._obj
|
||||
|
||||
@property
|
||||
def model(self):
|
||||
return self._model
|
||||
|
||||
@property
|
||||
def id_extension(self):
|
||||
return self._id_extension
|
||||
@id_extension.setter
|
||||
def id_extension(self, value):
|
||||
global ID_EXTENSION
|
||||
ID_EXTENSION = value
|
||||
self._id_extension = value
|
||||
|
||||
@property
|
||||
def images(self):
|
||||
return self._images
|
||||
|
@ -1871,48 +1811,6 @@ class LODialog(object):
|
|||
def images(self, value):
|
||||
self._images = value
|
||||
|
||||
@property
|
||||
def height(self):
|
||||
return self.model.Height
|
||||
@height.setter
|
||||
def height(self, value):
|
||||
self.model.Height = value
|
||||
|
||||
@property
|
||||
def width(self):
|
||||
return self.model.Width
|
||||
@width.setter
|
||||
def width(self, value):
|
||||
self.model.Width = value
|
||||
|
||||
@property
|
||||
def color_on_focus(self):
|
||||
return self._color_on_focus
|
||||
@color_on_focus.setter
|
||||
def color_on_focus(self, value):
|
||||
global COLOR_ON_FOCUS
|
||||
COLOR_ON_FOCUS = get_color(value)
|
||||
self._color_on_focus = COLOR_ON_FOCUS
|
||||
|
||||
@property
|
||||
def events(self):
|
||||
return self._events
|
||||
@events.setter
|
||||
def events(self, controllers):
|
||||
self._events = controllers
|
||||
self._connect_listeners()
|
||||
|
||||
def _connect_listeners(self):
|
||||
for control in self.obj.getControls():
|
||||
add_listeners(self._events, control, control.Model.Name)
|
||||
return
|
||||
|
||||
def open(self):
|
||||
return self.obj.execute()
|
||||
|
||||
def close(self, value=0):
|
||||
return self.obj.endDialog(value)
|
||||
|
||||
def _get_control_model(self, control):
|
||||
services = {
|
||||
'label': 'com.sun.star.awt.UnoControlFixedTextModel',
|
||||
|
|
Loading…
Reference in New Issue