Bug 100297 - API, Calc sheets, Inconsistency concerning changes of cell properties by a user function.
Summary: API, Calc sheets, Inconsistency concerning changes of cell properties by a us...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.1.2.2 release
Hardware: All All
: low normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro
  Show dependency treegraph
 
Reported: 2016-06-09 17:40 UTC by Wolfgang Jäger
Modified: 2025-04-28 12:32 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Demonstration of the problems; Code included (21.28 KB, application/vnd.oasis.opendocument.spreadsheet)
2016-06-09 17:40 UTC, Wolfgang Jäger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Jäger 2016-06-09 17:40:27 UTC
Created attachment 125577 [details]
Demonstration of the problems; Code included

Predecessors of LibO Calc did not allow any changes of the content of a cell by a function called from a formula contained in a cell of the same sheet. AOO 4.1.2 still is regarding this restriction (as I tested). 

LibO relieved this restriction substantially. From my recent tests I found that changes of all the relevant properties as there are 
- Value
- String
- Formula
for cells in the same sheet as the call of the function whose body is performing the changes are allowed. 
This with one exception: Setting the Formula property to "" (empty string) which should make the cell BLANK (answer TRUE if asked ISBLANK) does not cause an error, but is not performed. It only works for cells in different sheets. 

If the content of a cell in a different sheet is changed by the body of a function called from a cell not in the active sheet, the recalculation of a cell in the active sheet referencing the changed cell, is not correctly triggered. 

Generally the behaviour of cells is inconsistent with respect to changes of contents by the bodies of user functions via the API. 

The alternatives I see are to either suppress changes of cells by function bodies completely, or to thoroughly remove any inconsistencies. 

See attached example.
Comment 1 Buovjaga 2016-10-12 11:19:01 UTC
Tentatively setting to NEW and CC'ing Eike.
Comment 2 Wolfgang Jäger 2017-09-30 19:15:07 UTC
It is still unclear which properties of cells allow chagnes by SIDE-EFFECTs of user functions called during the evaluation of a formula IN THE SAME SHEET. 

The classical restriction was (and still is in AOO) that no changes at all are allowed. 

LibreOffice since V5.1 (at least) loosened this restriction: 
.String
.Value
.Formula e.g.
accept assignments, .Formula with the exception of new content "".

Other properties, in specific those containing hard attributes and the 
.CellStyle 
property refuse to accept an assignment. 

Above statements are made after testing with V5.4.1 and V5.4.2 today.

Is there any specification concerning this?
Comment 3 QA Administrators 2018-10-01 02:52:27 UTC Comment hidden (obsolete)
Comment 4 QA Administrators 2021-04-22 03:54:36 UTC Comment hidden (obsolete)
Comment 5 QA Administrators 2023-04-23 03:26:11 UTC Comment hidden (obsolete)
Comment 6 Eike Rathke 2023-04-24 17:29:23 UTC
(In reply to Wolfgang Jäger from comment #2)
> It is still unclear which properties of cells allow chagnes by SIDE-EFFECTs
> of user functions called during the evaluation of a formula IN THE SAME
> SHEET. 
> 
> The classical restriction was (and still is in AOO) that no changes at all
> are allowed. 
Best would be to go back to that behaviour.. least surprises.


> LibreOffice since V5.1 (at least) loosened this restriction: 
> .String
> .Value
> .Formula e.g.
> accept assignments, .Formula with the exception of new content "".
Which IMHO is *wrong*. Any modification to content while a calculation is running cries for undefined behaviour.

> Other properties, in specific those containing hard attributes and the 
> .CellStyle 
> property refuse to accept an assignment. 
Even those, with conditional formatting and the dreaded STYLE() function and CELL() obtaining formatting, can clash with calculations.

> Above statements are made after testing with V5.4.1 and V5.4.2 today.
> 
> Is there any specification concerning this?
No. It depends on implementation and actual spreadsheet content / formulas what could work and what not. The safe side is to not allow any modifications.

Even modifications on other sheets than the user defined function being called from aren't safe, they are just less likely to interfere with less inter-sheets references, and it is possible to build well behaving documents when knowing the implications.
Comment 7 QA Administrators 2025-04-24 03:12:59 UTC Comment hidden (obsolete)
Comment 8 Wolfgang Jäger 2025-04-25 17:40:51 UTC
(In reply to Eike Rathke from comment #6)
> (In reply to Wolfgang Jäger from comment #2)
> > It is still unclear which properties of cells allow chagnes by SIDE-EFFECTs
> > of user functions called during the evaluation of a formula IN THE SAME
> > SHEET. 
> > 
> > The classical restriction was (and still is in AOO) that no changes at all
> > are allowed. 
> Best would be to go back to that behaviour.. least surprises.
> 
> > LibreOffice since V5.1 (at least) loosened this restriction: 
> > .String
> > .Value
> > .Formula e.g.
> > accept assignments, .Formula with the exception of new content "".
> Which IMHO is *wrong*. Any modification to content while a calculation is
> running cries for undefined behaviour.

I also see risks, but why can changes to cells in other sheets by side-effects of calculations (also by UDFs) be accepted though the "current" sheet may contain cells depending on them?
For the time the restriction was relieved: Were there actually reports about related malfunctions?
...
> > Other properties, in specific those containing hard attributes and the 
> > .CellStyle 
> > property refuse to accept an assignment. 
> Even those, with conditional formatting and the dreaded STYLE() function and
> CELL() obtaining formatting, can clash with calculations.
> 
> > Above statements are made after testing with V5.4.1 and V5.4.2 today.
> > 
> > Is there any specification concerning this?
> No. It depends on implementation and actual spreadsheet content / formulas
> what could work and what not. The safe side is to not allow any
> modifications.
> 
> Even modifications on other sheets than the user defined function being
> called from aren't safe, they are just less likely to interfere with less
> inter-sheets references, and it is possible to build well behaving documents
> when knowing the implications.
Yes. See above. Nevertheless such side-effects are accepted, and I can't remember (e.g.) lots of questions in the ask site related to the issue.

Also:
I didn't want to ask about ODF specifications, but about rules developers have to regard. There must be such rules, and "my bug" is about the rules that are defined for the implementation called LibreOffice.
Comment 9 Wolfgang Jäger 2025-04-25 17:45:12 UTC
(In reply to QA Administrators from comment #7)
> Dear Wolfgang Jäger,
> ...
See my above reply to Eike Rathke.
The behavior is "inmplementation dependent" but the inconsistencies aren't cleared as long as there isn't an explicit and published specification for THIS implementation which is binding for developers.
Comment 10 Eike Rathke 2025-04-28 12:32:04 UTC
(In reply to Wolfgang Jäger from comment #8)
> (In reply to Eike Rathke from comment #6)
> > (In reply to Wolfgang Jäger from comment #2)
> > > LibreOffice since V5.1 (at least) loosened this restriction: 
> > > .String
> > > .Value
> > > .Formula e.g.
> > > accept assignments, .Formula with the exception of new content "".
> > Which IMHO is *wrong*. Any modification to content while a calculation is
> > running cries for undefined behaviour.
> 
> I also see risks, but why can changes to cells in other sheets by
> side-effects of calculations (also by UDFs) be accepted though the "current"
> sheet may contain cells depending on them?
Because it was a bad decision to follow user-requests that asked for it despite being warned that it is a bad thing.

> For the time the restriction was relieved: Were there actually reports about
> related malfunctions?
Who knows. Anything can happen when attempting to access data that isn't present anymore, from miscalculation (if it was to be accessed twice and changed in between) to crashes (if in-memory representation changed while data was held).