Add cell styles
This commit is contained in:
parent
2ac1415975
commit
ceb97135b6
|
@ -161,55 +161,6 @@ class LOForms(ObjectBase):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class LOCellStyle(LOObjectBase):
|
|
||||||
|
|
||||||
def __init__(self, obj):
|
|
||||||
super().__init__(obj)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
return self.obj.Name
|
|
||||||
|
|
||||||
def apply(self, properties):
|
|
||||||
set_properties(self.obj, properties)
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
class LOCellStyles(object):
|
|
||||||
|
|
||||||
def __init__(self, obj):
|
|
||||||
self._obj = obj
|
|
||||||
|
|
||||||
def __len__(self):
|
|
||||||
return len(self.obj)
|
|
||||||
|
|
||||||
def __getitem__(self, index):
|
|
||||||
return LOCellStyle(self.obj[index])
|
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
|
||||||
self.obj[key] = value
|
|
||||||
|
|
||||||
def __delitem__(self, key):
|
|
||||||
if not isinstance(key, str):
|
|
||||||
key = key.Name
|
|
||||||
del self.obj[key]
|
|
||||||
|
|
||||||
def __contains__(self, item):
|
|
||||||
return item in self.obj
|
|
||||||
|
|
||||||
@property
|
|
||||||
def obj(self):
|
|
||||||
return self._obj
|
|
||||||
|
|
||||||
@property
|
|
||||||
def names(self):
|
|
||||||
return self.obj.ElementNames
|
|
||||||
|
|
||||||
def apply(self, style, properties):
|
|
||||||
set_properties(style, properties)
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
class LOImage(object):
|
class LOImage(object):
|
||||||
TYPES = {
|
TYPES = {
|
||||||
'image/png': 'png',
|
'image/png': 'png',
|
||||||
|
@ -245,20 +196,6 @@ class LOImage(object):
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
class LOCalc(LODocument):
|
|
||||||
|
|
||||||
@property
|
|
||||||
def cell_style(self):
|
|
||||||
obj = self.obj.getStyleFamilies()['CellStyles']
|
|
||||||
return LOCellStyles(obj)
|
|
||||||
|
|
||||||
def create_cell_style(self, name=''):
|
|
||||||
obj = self.create_instance('com.sun.star.style.CellStyle')
|
|
||||||
if name:
|
|
||||||
self.cell_style[name] = obj
|
|
||||||
return LOCellStyle(obj)
|
|
||||||
|
|
||||||
|
|
||||||
class LOCalcSheet(object):
|
class LOCalcSheet(object):
|
||||||
|
|
||||||
def __init__(self, obj, doc):
|
def __init__(self, obj, doc):
|
||||||
|
@ -268,12 +205,6 @@ class LOCalcSheet(object):
|
||||||
def _init_values(self):
|
def _init_values(self):
|
||||||
self._events = None
|
self._events = None
|
||||||
|
|
||||||
def get_cursor(self, cell):
|
|
||||||
return self.obj.createCursorByRange(cell)
|
|
||||||
|
|
||||||
def exists_chart(self, name):
|
|
||||||
return name in self.obj.Charts.ElementNames
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def forms(self):
|
def forms(self):
|
||||||
return LOForms(self._dp.getForms(), self.doc)
|
return LOForms(self._dp.getForms(), self.doc)
|
||||||
|
|
|
@ -1153,6 +1153,64 @@ class LODocument(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class LOCellStyle(LOBaseObject):
|
||||||
|
|
||||||
|
def __init__(self, obj):
|
||||||
|
super().__init__(obj)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self.obj.Name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def properties(self):
|
||||||
|
properties = self.obj.PropertySetInfo.Properties
|
||||||
|
data = {p.Name: getattr(self.obj, p.Name) for p in properties}
|
||||||
|
return data
|
||||||
|
@properties.setter
|
||||||
|
def properties(self, values):
|
||||||
|
_set_properties(self.obj, values)
|
||||||
|
|
||||||
|
|
||||||
|
class LOCellStyles(object):
|
||||||
|
|
||||||
|
def __init__(self, obj, doc):
|
||||||
|
self._obj = obj
|
||||||
|
self._doc = doc
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self.obj)
|
||||||
|
|
||||||
|
def __getitem__(self, index):
|
||||||
|
return LOCellStyle(self.obj[index])
|
||||||
|
|
||||||
|
def __setitem__(self, key, value):
|
||||||
|
self.obj[key] = value
|
||||||
|
|
||||||
|
def __delitem__(self, key):
|
||||||
|
if not isinstance(key, str):
|
||||||
|
key = key.Name
|
||||||
|
del self.obj[key]
|
||||||
|
|
||||||
|
def __contains__(self, item):
|
||||||
|
return item in self.obj
|
||||||
|
|
||||||
|
@property
|
||||||
|
def obj(self):
|
||||||
|
return self._obj
|
||||||
|
|
||||||
|
@property
|
||||||
|
def names(self):
|
||||||
|
return self.obj.ElementNames
|
||||||
|
|
||||||
|
def new(self, name: str=''):
|
||||||
|
obj = self._doc.create_instance('com.sun.star.style.CellStyle')
|
||||||
|
if name:
|
||||||
|
self.obj[name] = obj
|
||||||
|
obj = LOCellStyle(obj)
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
class LOCalc(LODocument):
|
class LOCalc(LODocument):
|
||||||
|
|
||||||
def __init__(self, obj):
|
def __init__(self, obj):
|
||||||
|
@ -1208,6 +1266,14 @@ class LOCalc(LODocument):
|
||||||
def tabs(self, value):
|
def tabs(self, value):
|
||||||
self._cc.SheetTabs = value
|
self._cc.SheetTabs = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cs(self):
|
||||||
|
return self.cell_styles
|
||||||
|
@property
|
||||||
|
def cell_styles(self):
|
||||||
|
obj = self.obj.StyleFamilies['CellStyles']
|
||||||
|
return LOCellStyles(obj, self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def db_ranges(self):
|
def db_ranges(self):
|
||||||
# ~ return LOCalcDataBaseRanges(self.obj.DataBaseRanges)
|
# ~ return LOCalcDataBaseRanges(self.obj.DataBaseRanges)
|
||||||
|
|
Loading…
Reference in New Issue