Exemplo n.º 1
0
    def requests(self, data):
        args = comun.to_dict(data.Args)
        info = comun.to_dict(data.Data)
        if data.Method == 'get':
            params = comun.to_dict(data.Params)
            r = requests.get(data.Url, params, **args)
        elif data.Method == 'post':
            json = comun.to_dict(data.Json)
            r = requests.post(data.Url, info, json, **args)
        elif data.Method == 'options':
            r = requests.options(data.Url, **args)
        elif data.Method == 'head':
            r = requests.head(data.Url, **args)
        elif data.Method == 'put':
            r = requests.put(data.Url, info, **args)
        elif data.Method == 'patch':
            r = requests.patch(data.Url, info, **args)
        elif data.Method == 'delete':
            r = requests.delete(data.Url, **args)

        res = Response()
        res.StatusCode = r.status_code
        res.Url = r.url
        res.Encoding = str(r.encoding)
        res.Headers = str(r.headers)
        res.Cookies = str(r.cookies)
        res.Text = r.text
        try:
            res.Json = str(r.json())
        except ValueError:
            res.Json = ''
        res.Content = r.content
        return res
Exemplo n.º 2
0
    def requests(self, data):
        args = comun.to_dict(data.Args)
        info = comun.to_dict(data.Data)
        if data.Method == 'get':
            params = comun.to_dict(data.Params)
            r = requests.get(data.Url, params, **args)
        elif data.Method == 'post':
            json = comun.to_dict(data.Json)
            r = requests.post(data.Url, info, json, **args)
        elif data.Method == 'options':
            r = requests.options(data.Url, **args)
        elif data.Method == 'head':
            r = requests.head(data.Url, **args)
        elif data.Method == 'put':
            r = requests.put(data.Url, info, **args)
        elif data.Method == 'patch':
            r = requests.patch(data.Url, info, **args)
        elif data.Method == 'delete':
            r = requests.delete(data.Url, **args)

        res = Response()
        res.StatusCode = r.status_code
        res.Url = r.url
        res.Encoding = str(r.encoding)
        res.Headers = str(r.headers)
        res.Cookies = str(r.cookies)
        res.Text = r.text
        try:
            res.Json = str(r.json())
        except ValueError:
            res.Json = ''
        res.Content = r.content
        return res
Exemplo n.º 3
0
    def _create_serie(self, dp, data):
        serie = self._create_instance('com.sun.star.chart2.DataSeries', False)
        properties = comun.to_dict(data.Properties)
        range_y = data.Y
        if not isinstance(range_y, str):
            range_y = range_y.AbsoluteName
        range_x = data.X
        if not isinstance(range_x, str):
            range_x = range_x.AbsoluteName
        range_title = data.Title
        if not isinstance(range_title, str):
            range_title = range_title.AbsoluteName

        data_y = self._create_instance(
            'com.sun.star.chart2.data.LabeledDataSequence')
        values_y = self._create_data(dp, range_y, 'values-y')
        data_y.setValues(values_y)
        if data.Title:
            label = self._create_data(dp, range_title, '')
            data_y.setLabel(label)

        data_x = self._create_instance(
            'com.sun.star.chart2.data.LabeledDataSequence')
        values_x = self._create_data(dp, range_x, 'values-x')
        data_x.setValues(values_x)

        serie.setData((data_y, data_x))
        for k, v in properties.items():
            if hasattr(serie, k):
                setattr(serie, k, v)
        return serie
Exemplo n.º 4
0
    def imageAdd(self, data):
        doc = data.Doc
        sheet = comun.get_sheet(doc, data.Sheet)
        properties = comun.to_dict(data.Properties)
        position, size = comun.get_pos_size(data.PosSize)
        draw_page = sheet.getDrawPage()

        if data.Type:
            type_shape = SHAPES.get(data.Type, SRV_DCS)
            image = doc.createInstance(type_shape)
            if type_shape == SRV_DCS:
                pv = comun.set_properties((('Type', data.Type), ))
                comun.set_property(image, ('CustomShapeGeometry', pv))
        else:
            path = comun.path_to_url(data.Path)
            image = doc.createInstance(SRV_GOS)
            if data.Link:
                log.info(data.Link)
                image.GraphicURL = path
                log.info(path)
            else:
                gp = self._create_instance(SRV_GP)
                pv = comun.set_properties((('URL', path), ))
                image.Graphic = gp.queryGraphic(pv)
        draw_page.add(image)

        if data.Name:
            image.Name = data.Name

        image.setPosition(position)
        image.setSize(size)
        for k, v in properties.items():
            if hasattr(image, k):
                setattr(image, k, v)
        return image
Exemplo n.º 5
0
    def imageAdd(self, data):
        doc = data.Doc
        sheet = comun.get_sheet(doc, data.Sheet)
        properties = comun.to_dict(data.Properties)
        position, size = comun.get_pos_size(data.PosSize)
        draw_page = sheet.getDrawPage()

        if data.Type:
            type_shape = SHAPES.get(data.Type, SRV_DCS)
            image = doc.createInstance(type_shape)
            if type_shape == SRV_DCS:
                pv = comun.set_properties((('Type', data.Type),))
                comun.set_property(image, ('CustomShapeGeometry', pv))
        else:
            path = comun.path_to_url(data.Path)
            image = doc.createInstance(SRV_GOS)
            if data.Link:
                log.info(data.Link)
                image.GraphicURL = path
                log.info(path)
            else:
                gp = self._create_instance(SRV_GP)
                pv = comun.set_properties((('URL', path),))
                image.Graphic = gp.queryGraphic(pv)
        draw_page.add(image)

        if data.Name:
            image.Name = data.Name

        image.setPosition(position)
        image.setSize(size)
        for k, v in properties.items():
            if hasattr(image, k):
                setattr(image, k, v)
        return image
Exemplo n.º 6
0
    def _create_serie(self, dp, data):
        serie = self._create_instance('com.sun.star.chart2.DataSeries', False)
        properties = comun.to_dict(data.Properties)
        range_y = data.Y
        if not isinstance(range_y, str):
            range_y = range_y.AbsoluteName
        range_x = data.X
        if not isinstance(range_x, str):
            range_x = range_x.AbsoluteName
        range_title = data.Title
        if not isinstance(range_title, str):
            range_title = range_title.AbsoluteName

        data_y = self._create_instance('com.sun.star.chart2.data.LabeledDataSequence')
        values_y = self._create_data(dp, range_y, 'values-y')
        data_y.setValues(values_y)
        if data.Title:
            label = self._create_data(dp, range_title, '')
            data_y.setLabel(label)

        data_x = self._create_instance('com.sun.star.chart2.data.LabeledDataSequence')
        values_x = self._create_data(dp, range_x, 'values-x')
        data_x.setValues(values_x)

        serie.setData((data_y, data_x))
        for k, v in properties.items():
            if hasattr(serie, k):
                setattr(serie, k, v)
        return serie
Exemplo n.º 7
0
 def _add_columns_grid(self, columns):
     #~ https://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/grid/XGridColumn.html
     column_model = self._create_instance(
         'com.sun.star.awt.grid.DefaultGridColumnModel')
     for col in columns:
         values = comun.to_dict(col)
         grid_column = self._create_instance('com.sun.star.awt.grid.GridColumn')
         for k, v in values.items():
             setattr(grid_column, k, v)
         column_model.addColumn(grid_column)
     return column_model
Exemplo n.º 8
0
 def _add_columns_grid(self, columns):
     #~ https://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/grid/XGridColumn.html
     column_model = self._create_instance(
         'com.sun.star.awt.grid.DefaultGridColumnModel')
     for col in columns:
         values = comun.to_dict(col)
         grid_column = self._create_instance(
             'com.sun.star.awt.grid.GridColumn')
         for k, v in values.items():
             setattr(grid_column, k, v)
         column_model.addColumn(grid_column)
     return column_model
Exemplo n.º 9
0
 def format(self, template, data):
     """
         https://pyformat.info/
     """
     if isinstance(data, tuple):
         if isinstance(data[0], tuple):
             data = comun.to_dict(data, True)
             result = template.format(**data)
         else:
             data = [comun.to_date(v) for v in data]
             result = template.format(*data)
     else:
         result = template.format(comun.to_date(data))
     return result
Exemplo n.º 10
0
 def format(self, template, data):
     """
         https://pyformat.info/
     """
     if isinstance(data, tuple):
         if isinstance(data[0], tuple):
             data = comun.to_dict(data, True)
             result = template.format(**data)
         else:
             data = [comun.to_date(v) for v in data]
             result = template.format(*data)
     else:
         result = template.format(comun.to_date(data))
     return result
Exemplo n.º 11
0
 def imageFormat(self, image, data):
     properties = comun.to_dict(data)
     title = None
     if image.supportsService('com.sun.star.chart2.Title'):
         title = image.getText()[0]
     elif image.supportsService('com.sun.star.chart.ChartAxis'):
         title = image.getAxisTitle()
     for k, v in properties.items():
         if hasattr(image, k):
             if self._special_property(image, k, v):
                 continue
             setattr(image, k, v)
         if title and hasattr(title, k):
             setattr(title, k, v)
     return
Exemplo n.º 12
0
 def imageFormat(self, image, data):
     properties = comun.to_dict(data)
     title = None
     if image.supportsService('com.sun.star.chart2.Title'):
         title = image.getText()[0]
     elif image.supportsService('com.sun.star.chart.ChartAxis'):
         title = image.getAxisTitle()
     for k, v in properties.items():
         if hasattr(image, k):
             if self._special_property(image, k, v):
                 continue
             setattr(image, k, v)
         if title and hasattr(title, k):
             setattr(title, k, v)
     return
Exemplo n.º 13
0
    def chartAdd(self, data):
        charts = data.Sheet.getCharts()
        charts.addNewByName(data.Name, data.PosSize, (), True, True)
        chart = charts.getByName(data.Name).getEmbeddedObject()
        chart.setDiagram(chart.createInstance('com.sun.star.chart.{}'.format(data.Type)))
        self._add_series(chart, data.Doc, data.Series)

        properties = comun.to_dict(data.Properties)
        for k, v in properties.items():
            if k == 'Title':
                chart.getTitle().String = v
                continue
            if hasattr(chart, k):
                setattr(chart, k, v)

        return chart
Exemplo n.º 14
0
    def chartAdd(self, data):
        charts = data.Sheet.getCharts()
        charts.addNewByName(data.Name, data.PosSize, (), True, True)
        chart = charts.getByName(data.Name).getEmbeddedObject()
        chart.setDiagram(
            chart.createInstance('com.sun.star.chart.{}'.format(data.Type)))
        self._add_series(chart, data.Doc, data.Series)

        properties = comun.to_dict(data.Properties)
        for k, v in properties.items():
            if k == 'Title':
                chart.getTitle().String = v
                continue
            if hasattr(chart, k):
                setattr(chart, k, v)

        return chart
Exemplo n.º 15
0
 def importCSV(self, path, options):
     """
         See https://docs.python.org/3.3/library/csv.html#csv.reader
     """
     path = comun.path_to_os(path)
     if options:
         config = comun.to_dict(options)
     try:
         with open(path) as f:
             if options:
                 data = tuple(csv.reader(f, **config))
             else:
                 data = tuple(csv.reader(f))
         array = tuple(tuple(r) for r in data)
         return array
     except:
         log.debug('CSV', exc_info=True)
         return ()
Exemplo n.º 16
0
 def importCSV(self, path, options):
     """
         See https://docs.python.org/3.3/library/csv.html#csv.reader
     """
     path = comun.path_to_os(path)
     if options:
         config = comun.to_dict(options)
     try:
         with open(path) as f:
             if options:
                 data = tuple(csv.reader(f, **config))
             else:
                 data = tuple(csv.reader(f))
         array = tuple(tuple(r) for r in data)
         return array
     except:
         log.debug('CSV', exc_info=True)
         return ()
Exemplo n.º 17
0
 def exportCSV(self, path, data, options):
     """
         See https://docs.python.org/3.3/library/csv.html#csv.writer
     """
     path = comun.path_to_os(path)
     if options:
         config = comun.to_dict(options)
     try:
         with open(path, 'w') as f:
             if options:
                 if not 'lineterminator' in config:
                     config['lineterminator'] = '\n'
                 writer = csv.writer(f, **config)
             else:
                 writer = csv.writer(f, lineterminator='\n')
             writer.writerows(data)
         return True
     except:
         log.debug('CSV', exc_info=True)
         return False
Exemplo n.º 18
0
 def exportCSV(self, path, data, options):
     """
         See https://docs.python.org/3.3/library/csv.html#csv.writer
     """
     path = comun.path_to_os(path)
     if options:
         config = comun.to_dict(options)
     try:
         with open(path, 'w') as f:
             if options:
                 if not 'lineterminator' in config:
                     config['lineterminator'] = '\n'
                 writer = csv.writer(f, **config)
             else:
                 writer = csv.writer(f, lineterminator='\n')
             writer.writerows(data)
         return True
     except:
         log.debug('CSV', exc_info=True)
         return False
Exemplo n.º 19
0
    def createControl(self, dialog, type_control, options):
        properties = comun.to_dict(options)
        base_properties = {
            'Width': 100,
            'Height': 12,
            'PositionX': 0,
            'PositionY': 0,
            'Step': 0,
            'TabIndex': 1,
        }
        controls = {
            'Button': 'com.sun.star.awt.UnoControlButtonModel',
            'CheckBox': 'com.sun.star.awt.UnoControlCheckBoxModel',
            'ComboBox': 'com.sun.star.awt.UnoControlComboBoxModel',
            'CurrencyField': 'com.sun.star.awt.UnoControlCurrencyFieldModel',
            'DateField': 'com.sun.star.awt.UnoControlDateFieldModel',
            'Edit': 'com.sun.star.awt.UnoControlEditModel',
            'FileControl': 'com.sun.star.awt.UnoControlFileControlModel',
            'FixedHyperlink': 'com.sun.star.awt.UnoControlFixedHyperlinkModel',
            'FixedLine': 'com.sun.star.awt.UnoControlFixedLineModel',
            'FixedText': 'com.sun.star.awt.UnoControlFixedTextModel',
            'FormattedField': 'com.sun.star.awt.UnoControlFormattedFieldModel',
            'GroupBox': 'com.sun.star.awt.UnoControlGroupBoxModel',
            'ImageControl': 'com.sun.star.awt.UnoControlImageControlModel',
            'ListBox': 'com.sun.star.awt.UnoControlListBoxModel',
            'NumericField': 'com.sun.star.awt.UnoControlNumericFieldModel',
            'PatternField': 'com.sun.star.awt.UnoControlPatternFieldModel',
            'ProgressBar': 'com.sun.star.awt.UnoControlProgressBarModel',
            'RadioButton': 'com.sun.star.awt.UnoControlRadioButtonModel',
            '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',
            'Roadmap': 'com.sun.star.awt.UnoControlRoadmapModel',
            'Grid': 'com.sun.star.awt.grid.UnoControlGridModel',
        }
        controls_properties = {
            'FixedHyperlink': base_properties.copy(),
            'Roadmap': base_properties.copy(),
            'Grid': base_properties.copy(),
            'Edit': base_properties.copy(),
            'Button': base_properties.copy(),
            'DateField': base_properties.copy(),
        }
        controls_properties['Roadmap'].update({
            'Height': 100,
            'Text': 'Menu'}
        )
        controls_properties['Grid'].update({
            'Height': 100,
            'BackgroundColor': COLORS['WHITE'],
            'Sizeable': False,
            'ShowColumnHeader': True,
            'ShowRowHeader': True,
            'SelectionModel': 2,
            'UseGridLines': True}
        )
        controls_properties['Button'].update({
            'Label': 'CommandButton',
            'DefaultButton': False}
        )
        controls_properties['DateField'].update({
            'Dropdown': True}
        )

        #~ controls_properties['CheckBox'] = base_properties.update({
            #~ 'Label': 'CheckBox'})
        #~ controls_properties['ComboBox'] = base_properties.update({
            #~ 'Dropdown': True})
        #~ controls_properties['CurrencyField'] = base_properties.update({
            #~ 'Spin': True})
        #~ controls_properties['FileControl'] = base_properties.update({
            #~ 'Width':60,
            #~ 'Height':13})
        #~ controls_properties['FixedLine'] = base_properties.update({
            #~ 'Width':60,
            #~ 'Height':5})
        #~ controls_properties['FixedText'] = base_properties.update({
            #~ 'Label':'Label'})
        #~ controls_properties['FormattedField'] = base_properties.update({
            #~ 'Width':60,
            #~ 'Height':13})
        #~ controls_properties['GroupBox'] = base_properties.update({
            #~ 'Width':100,
            #~ 'Height':30})
        #~ controls_properties['ImageControl'] = base_properties.update({
            #~ 'Width':30,
            #~ 'Height':30})
        #~ controls_properties['ListBox'] = base_properties.update({
            #~ 'Width':60,
            #~ 'Height':30})
        #~ controls_properties['NumericField'] = base_properties.update({
            #~ 'Width':60,
            #~ 'Height':13})
        #~ controls_properties['PatternField'] = base_properties.update({
            #~ 'Width':60,
            #~ 'Height':13})
        #~ controls_properties['ProgressBar'] = base_properties.update({
            #~ 'Width':100,
            #~ 'Height':13})
        #~ controls_properties['RadioButton'] = base_properties.update({
            #~ 'Width':60,
            #~ 'Height':13})
        #~ controls_properties['ScrollBar'] = base_properties.update({
            #~ 'Width':60,
            #~ 'Height':13})
        #~ controls_properties['SimpleAnimation'] = base_properties.update({
            #~ 'Width':60,
            #~ 'Height':30})
        #~ controls_properties['SpinButton'] = base_properties.update({
            #~ 'Width':60,
            #~ 'Height':13})
        #~ controls_properties['Throbber'] = base_properties.update({
            #~ 'Width':60,
            #~ 'Height':30})
        #~ controls_properties['TimeField'] = base_properties.update({
            #~ 'Width':60,
            #~ 'Height':13})

        """Create controls"""
        if not 'Name' in properties:
            return None
        dialog_model = dialog.getModel()
        # Only add if not exist
        if dialog_model.hasByName(properties['Name']):
            return None

        if type_control in controls:
            control = dialog_model.createInstance(controls[type_control])
            # Add default properties
            for k, v in controls_properties[type_control].items():
                if not k in properties:
                    properties[k] = controls_properties[type_control][k]
                if type_control == 'Grid':
                    properties['GridDataModel'] = self._create_instance(
                        'com.sun.star.awt.grid.DefaultGridDataModel')
                    properties['ColumnModel'] = self._add_columns_grid(properties['Columns'])
            # Only properties in control
            for k, v in properties.items():
                if control.getPropertySetInfo().hasPropertyByName(k):
                    # Properties special
                    #~ if propertie == 'StringItemList':
                        #~ uno.invoke(control, "setPropertyValue" , (
                            #~ "StringItemList", uno.Any(
                                #~ "[]string", properties[propertie])))
                    #~ else:
                    control.setPropertyValue(k, v)
        dialog_model.insertByName(properties['Name'], control)
        obj = self._listeners(dialog, type_control, control, properties)
        return obj
Exemplo n.º 20
0
    def createControl(self, dialog, type_control, options):
        properties = comun.to_dict(options)
        base_properties = {
            'Width': 100,
            'Height': 12,
            'PositionX': 0,
            'PositionY': 0,
            'Step': 0,
            'TabIndex': 1,
        }
        controls = {
            'Button': 'com.sun.star.awt.UnoControlButtonModel',
            'CheckBox': 'com.sun.star.awt.UnoControlCheckBoxModel',
            'ComboBox': 'com.sun.star.awt.UnoControlComboBoxModel',
            'CurrencyField': 'com.sun.star.awt.UnoControlCurrencyFieldModel',
            'DateField': 'com.sun.star.awt.UnoControlDateFieldModel',
            'Edit': 'com.sun.star.awt.UnoControlEditModel',
            'FileControl': 'com.sun.star.awt.UnoControlFileControlModel',
            'FixedHyperlink': 'com.sun.star.awt.UnoControlFixedHyperlinkModel',
            'FixedLine': 'com.sun.star.awt.UnoControlFixedLineModel',
            'FixedText': 'com.sun.star.awt.UnoControlFixedTextModel',
            'FormattedField': 'com.sun.star.awt.UnoControlFormattedFieldModel',
            'GroupBox': 'com.sun.star.awt.UnoControlGroupBoxModel',
            'ImageControl': 'com.sun.star.awt.UnoControlImageControlModel',
            'ListBox': 'com.sun.star.awt.UnoControlListBoxModel',
            'NumericField': 'com.sun.star.awt.UnoControlNumericFieldModel',
            'PatternField': 'com.sun.star.awt.UnoControlPatternFieldModel',
            'ProgressBar': 'com.sun.star.awt.UnoControlProgressBarModel',
            'RadioButton': 'com.sun.star.awt.UnoControlRadioButtonModel',
            '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',
            'Roadmap': 'com.sun.star.awt.UnoControlRoadmapModel',
            'Grid': 'com.sun.star.awt.grid.UnoControlGridModel',
        }
        controls_properties = {
            'FixedHyperlink': base_properties.copy(),
            'Roadmap': base_properties.copy(),
            'Grid': base_properties.copy(),
            'Edit': base_properties.copy(),
            'Button': base_properties.copy(),
            'DateField': base_properties.copy(),
        }
        controls_properties['Roadmap'].update({'Height': 100, 'Text': 'Menu'})
        controls_properties['Grid'].update({
            'Height': 100,
            'BackgroundColor': COLORS['WHITE'],
            'Sizeable': False,
            'ShowColumnHeader': True,
            'ShowRowHeader': True,
            'SelectionModel': 2,
            'UseGridLines': True
        })
        controls_properties['Button'].update({
            'Label': 'CommandButton',
            'DefaultButton': False
        })
        controls_properties['DateField'].update({'Dropdown': True})

        #~ controls_properties['CheckBox'] = base_properties.update({
        #~ 'Label': 'CheckBox'})
        #~ controls_properties['ComboBox'] = base_properties.update({
        #~ 'Dropdown': True})
        #~ controls_properties['CurrencyField'] = base_properties.update({
        #~ 'Spin': True})
        #~ controls_properties['FileControl'] = base_properties.update({
        #~ 'Width':60,
        #~ 'Height':13})
        #~ controls_properties['FixedLine'] = base_properties.update({
        #~ 'Width':60,
        #~ 'Height':5})
        #~ controls_properties['FixedText'] = base_properties.update({
        #~ 'Label':'Label'})
        #~ controls_properties['FormattedField'] = base_properties.update({
        #~ 'Width':60,
        #~ 'Height':13})
        #~ controls_properties['GroupBox'] = base_properties.update({
        #~ 'Width':100,
        #~ 'Height':30})
        #~ controls_properties['ImageControl'] = base_properties.update({
        #~ 'Width':30,
        #~ 'Height':30})
        #~ controls_properties['ListBox'] = base_properties.update({
        #~ 'Width':60,
        #~ 'Height':30})
        #~ controls_properties['NumericField'] = base_properties.update({
        #~ 'Width':60,
        #~ 'Height':13})
        #~ controls_properties['PatternField'] = base_properties.update({
        #~ 'Width':60,
        #~ 'Height':13})
        #~ controls_properties['ProgressBar'] = base_properties.update({
        #~ 'Width':100,
        #~ 'Height':13})
        #~ controls_properties['RadioButton'] = base_properties.update({
        #~ 'Width':60,
        #~ 'Height':13})
        #~ controls_properties['ScrollBar'] = base_properties.update({
        #~ 'Width':60,
        #~ 'Height':13})
        #~ controls_properties['SimpleAnimation'] = base_properties.update({
        #~ 'Width':60,
        #~ 'Height':30})
        #~ controls_properties['SpinButton'] = base_properties.update({
        #~ 'Width':60,
        #~ 'Height':13})
        #~ controls_properties['Throbber'] = base_properties.update({
        #~ 'Width':60,
        #~ 'Height':30})
        #~ controls_properties['TimeField'] = base_properties.update({
        #~ 'Width':60,
        #~ 'Height':13})
        """Create controls"""
        if not 'Name' in properties:
            return None
        dialog_model = dialog.getModel()
        # Only add if not exist
        if dialog_model.hasByName(properties['Name']):
            return None

        if type_control in controls:
            control = dialog_model.createInstance(controls[type_control])
            # Add default properties
            for k, v in controls_properties[type_control].items():
                if not k in properties:
                    properties[k] = controls_properties[type_control][k]
                if type_control == 'Grid':
                    properties['GridDataModel'] = self._create_instance(
                        'com.sun.star.awt.grid.DefaultGridDataModel')
                    properties['ColumnModel'] = self._add_columns_grid(
                        properties['Columns'])
            # Only properties in control
            for k, v in properties.items():
                if control.getPropertySetInfo().hasPropertyByName(k):
                    # Properties special
                    #~ if propertie == 'StringItemList':
                    #~ uno.invoke(control, "setPropertyValue" , (
                    #~ "StringItemList", uno.Any(
                    #~ "[]string", properties[propertie])))
                    #~ else:
                    control.setPropertyValue(k, v)
        dialog_model.insertByName(properties['Name'], control)
        obj = self._listeners(dialog, type_control, control, properties)
        return obj
Exemplo n.º 21
0
 def render(self, template, data):
     data = comun.to_dict(data)
     s = Template(template)
     return s.safe_substitute(**data)
Exemplo n.º 22
0
 def render(self, template, data):
     data = comun.to_dict(data)
     s = Template(template)
     return s.safe_substitute(**data)