Start documentation for cells and range
This commit is contained in:
parent
e41ac71b2f
commit
1a35cdfd8a
|
@ -14,5 +14,5 @@ Remember, always import library.
|
||||||
calc_doc.rst
|
calc_doc.rst
|
||||||
calc_sheets.rst
|
calc_sheets.rst
|
||||||
calc_ranges.rst
|
calc_ranges.rst
|
||||||
calc_ranges2.rst
|
calc_cells.rst
|
||||||
calc_data.rst
|
calc_data.rst
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
Cells and Range
|
||||||
|
---------------
|
||||||
|
|
||||||
|
By selection
|
||||||
|
^^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
doc = app.active
|
||||||
|
selection = doc.selection
|
||||||
|
app.debug(selection)
|
||||||
|
|
|
@ -61,6 +61,7 @@ from email import encoders
|
||||||
|
|
||||||
import uno
|
import uno
|
||||||
import unohelper
|
import unohelper
|
||||||
|
from com.sun.star.awt import Rectangle, Size, Point
|
||||||
from com.sun.star.awt import Key, KeyEvent, KeyModifier
|
from com.sun.star.awt import Key, KeyEvent, KeyModifier
|
||||||
from com.sun.star.awt import MessageBoxButtons as MSG_BUTTONS
|
from com.sun.star.awt import MessageBoxButtons as MSG_BUTTONS
|
||||||
from com.sun.star.awt.MessageBoxResults import YES
|
from com.sun.star.awt.MessageBoxResults import YES
|
||||||
|
@ -475,6 +476,17 @@ def render(template, data):
|
||||||
return s.safe_substitute(**data)
|
return s.safe_substitute(**data)
|
||||||
|
|
||||||
|
|
||||||
|
def _set_properties(model, properties):
|
||||||
|
# ~ if 'X' in properties:
|
||||||
|
# ~ properties['PositionX'] = properties.pop('X')
|
||||||
|
# ~ if 'Y' in properties:
|
||||||
|
# ~ properties['PositionY'] = properties.pop('Y')
|
||||||
|
keys = tuple(properties.keys())
|
||||||
|
values = tuple(properties.values())
|
||||||
|
model.setPropertyValues(keys, values)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
# Classes
|
# Classes
|
||||||
|
|
||||||
class LOInspect():
|
class LOInspect():
|
||||||
|
@ -2204,6 +2216,147 @@ class EventsRangeSelectionListener(EventsListenerBase, XRangeSelectionListener):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class LOShapes(object):
|
||||||
|
_type = 'ShapeCollection'
|
||||||
|
|
||||||
|
def __init__(self, obj):
|
||||||
|
self._obj = obj
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return self.obj.Count
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
self._index = 0
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __next__(self):
|
||||||
|
try:
|
||||||
|
s = self.obj[self._index]
|
||||||
|
shape = LOShape(s)
|
||||||
|
except IndexError:
|
||||||
|
raise StopIteration
|
||||||
|
|
||||||
|
self._index += 1
|
||||||
|
return shape
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return 'Shapes'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def obj(self):
|
||||||
|
return self._obj
|
||||||
|
|
||||||
|
|
||||||
|
class LOShape(object):
|
||||||
|
IMAGE = 'com.sun.star.drawing.GraphicObjectShape'
|
||||||
|
|
||||||
|
def __init__(self, obj):
|
||||||
|
self._obj = obj
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f'Shape: {self.name}'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def obj(self):
|
||||||
|
return self._obj
|
||||||
|
|
||||||
|
@property
|
||||||
|
def properties(self):
|
||||||
|
data = self.obj.PropertySetInfo.Properties
|
||||||
|
keys = [p.Name for p in data]
|
||||||
|
values = self.obj.getPropertyValues(keys)
|
||||||
|
data = dict(zip(keys, values))
|
||||||
|
return data
|
||||||
|
@properties.setter
|
||||||
|
def properties(self, values):
|
||||||
|
_set_properties(self.obj, values)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def shape_type(self):
|
||||||
|
return self.obj.ShapeType
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self.obj.Name
|
||||||
|
@name.setter
|
||||||
|
def name(self, value):
|
||||||
|
self.obj.Name = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_image(self):
|
||||||
|
return self.shape_type == self.IMAGE
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_shape(self):
|
||||||
|
return self.shape_type != self.IMAGE
|
||||||
|
|
||||||
|
@property
|
||||||
|
def size(self):
|
||||||
|
s = self.obj.Size
|
||||||
|
return s
|
||||||
|
@size.setter
|
||||||
|
def size(self, value):
|
||||||
|
self.obj.Size = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def width(self):
|
||||||
|
s = self.obj.Size
|
||||||
|
return s.Width
|
||||||
|
@width.setter
|
||||||
|
def width(self, value):
|
||||||
|
s = self.size
|
||||||
|
s.Width = value
|
||||||
|
self.size = s
|
||||||
|
|
||||||
|
@property
|
||||||
|
def height(self):
|
||||||
|
s = self.obj.Size
|
||||||
|
return s.Height
|
||||||
|
@height.setter
|
||||||
|
def height(self, value):
|
||||||
|
s = self.size
|
||||||
|
s.Height = value
|
||||||
|
self.size = s
|
||||||
|
|
||||||
|
@property
|
||||||
|
def position(self):
|
||||||
|
return self.obj.Position
|
||||||
|
@property
|
||||||
|
def x(self):
|
||||||
|
return self.position.X
|
||||||
|
@property
|
||||||
|
def y(self):
|
||||||
|
return self.position.Y
|
||||||
|
|
||||||
|
@property
|
||||||
|
def string(self):
|
||||||
|
return self.obj.String
|
||||||
|
@string.setter
|
||||||
|
def string(self, value):
|
||||||
|
self.obj.String = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def title(self):
|
||||||
|
return self.obj.Title
|
||||||
|
@title.setter
|
||||||
|
def title(self, value):
|
||||||
|
self.obj.Title = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def description(self):
|
||||||
|
return self.obj.Description
|
||||||
|
@description.setter
|
||||||
|
def description(self, value):
|
||||||
|
self.obj.Description = value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LOShortCuts(object):
|
class LOShortCuts(object):
|
||||||
"""Classe for manager shortcuts"""
|
"""Classe for manager shortcuts"""
|
||||||
KEYS = {getattr(Key, k): k for k in dir(Key)}
|
KEYS = {getattr(Key, k): k for k in dir(Key)}
|
||||||
|
@ -3233,7 +3386,10 @@ class LODocCalc(LODocument):
|
||||||
elif type_obj == self.RANGES:
|
elif type_obj == self.RANGES:
|
||||||
sel = LOCalcRanges(sel)
|
sel = LOCalcRanges(sel)
|
||||||
elif type_obj == self.SHAPE:
|
elif type_obj == self.SHAPE:
|
||||||
print(len(sel))
|
if len(sel) == 1:
|
||||||
|
sel = LOShape(sel[0])
|
||||||
|
else:
|
||||||
|
sel = LOShapes(sel)
|
||||||
else:
|
else:
|
||||||
debug(type_obj)
|
debug(type_obj)
|
||||||
return sel
|
return sel
|
||||||
|
|
Loading…
Reference in New Issue