Clearly setting UserDefninedAttribues is not reliable. As soon as a macro or other code runs to set the sheet UserDefninedAttribues all Cell UserDefninedAttribues are lost.
I want to add a feature to OOO Development Tools (OooDev) that allows for setting of custom properties. I have been able to do this for Writer Docs, Draw Pages, Impress Sheets, Calc Sheet. Not yet figured out Calc Sheet Cells. That is what I am trying to solve in this post. If I can figure out a way for Calc Sheet Cells then I can investigated if there is a way to extend that to Calc Sheet Ranges and elsewhere.
I am not certain that I need this feature for the up coming PY extension (expected to be named LibrePythonista) that I am working on ( if i can get past all the challenges ), see YouTube for the example idea. Although the extension would most likely benefit from this feature. The Extension will automatically install OooDev
and will run on top of it. Also I think Pandas
, Numpy
, MatLab
and Seaborn
will automatically be installed.
An example use case.
The LibrePythonista python code for a sheet will be one single module that is built and rebuilt dynamically as the sheet get new python cells.
Cells are calculated across and then down.
Lets say when the sheet is first loaded I want to find all the cells in order ( across and then down) that are to be considered python code cells, ( I am not sure at this point that those cells will be formula cells, yet to be seen). If I can add the feature to OooDev
then it should be easy to get all the cells that have a custom property set that contains a property with the the the name LibrePythonistaCell=True
for example. I expect there would be a limited number of cells on a sheet that would have custom properties assigned. Custom properties are easily stored in a hidden control similar to my CalcSheetId class. Because only the cells with custom properties would be stored in the sheet it should be simple to parse through them and find the relevant cells. I may also want to store other data in the properties such as the python code that goes with the cell, or at least the storage location for the python code. From a developer stand point I can see there are many way that custom properties on a cell can be useful.
Yes it is within a bigger frame; However, not limited to the bigger frame (LibrePythonistaCell). The connection to UserDefinedAttributes
is very simple. I want to store custom properties for a cell. I mostly know How to do this, I can not use UserDefinedAttributes
, My plan is to add one hidden control per cell that has custom properties ( unless I can find a better way). A hidden control has the benefit of being saved with the document and can contain unlimited number of Key value properties.
The issued I have not solved is how to name the hidden control so that it is connected to the cell. So when I load a cell in python code I can more or less just props = cell.get_custom_props()
and the get_custom_props()
method should be able to get the some unique name of the cell and find the hidden control with the matching name that contains custom properties. I just don’t know how to have a reliable name that I can use for a cell. So, if custom properties are added to a cell then a hidden control name of cell_0_0
(for cell “A1”) would be fine if the cell it belong to would never be moved, but that would be naive to think that way. I am looking for a way to find the hidden control for a cell (if it exist), even after the cell has been moved, for reason such as inserting rows or columns. My thinking is If I could just find a way to give a cell a unique id such as jour46jj
(random) then I could also name the hidden control jour46jj
and then if the cell is moved it would not matter. The unique id would always be the same.
I don’t expect needing to hold references to all cells with custom properties. It should be that when a cell is accessed in code that the propertied can be dynamically loaded as suggest by props = cell.get_custom_props()
.
In my mind what I am proposing to accomplish (ability to assign custom properties to cells) is not difficult in theory. I hope I am communicating this clearly enough.