Bug 96464 - FILEOPEN FILESAVE: Add UpdateReferenceOnSort as a property of a sort range
Summary: FILEOPEN FILESAVE: Add UpdateReferenceOnSort as a property of a sort range
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
(earliest affected)
Hardware: All All
: medium enhancement
Assignee: Not Assigned
Depends on:
Blocks: Sorting
  Show dependency treegraph
Reported: 2015-12-13 21:03 UTC by Robert Lacroix
Modified: 2020-08-21 18:14 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:
Regression By:


Note You need to log in before you can comment on or make changes to this bug.
Description Robert Lacroix 2015-12-13 21:03:04 UTC
This feature request is a quick fix to mitigate the risk of silently damaging formulas in many documents by inadvertently having the wrong setting for the UpdateReferenceOnSort global option.

OL-Calc has 2 UpdateReferenceOnSort behaviours available through a global option, which has mooted the argument about which behaviour is broken. Both behaviours have valid use cases, and the preponderance of legacy spreadsheets has settled the default value of this option for compatibility.

From a document safety consideration however, each document needs it's own persistent property for UpdateReferenceOnSort, with initial value determined by the current state of the global UpdateReferenceOnSort option. Presently, Murphy's law guarantees that the wrong global setting will be used while sorting ranges in existing documents, silently mangling cell references.

In principle one document could have multiple sort ranges needing different behaviours and sort options, but OL-Calc does not support multiple persistent sort ranges in a document at this time - this could be the subject of a future feature request.
Comment 1 m.a.riosv 2015-12-15 01:08:43 UTC
Hi @Rober,

It's possible to have different ranges with their sort properties.

You only nee to create a Menu/Data/Define range, Menu/Data/Select range, and define their sort properties.

So for me if there is a place for the option it's the Sort properties.
Comment 2 Robert Lacroix 2015-12-15 08:17:03 UTC
(In reply to m.a.riosv from comment #1)
Thanks for the tip! Defined ranges do a great job of handling multiple sort ranges having distinct sort properties (range, keys, sort options).

I've changed the summary according to your suggestion, with each sort range having its own behaviour of UpdateReferenceOnSort by adding a range property. And forget the original comment about adding that global option as a new document property.

So the work to do is:

#1) Move the UpdateReferenceOnSort global option checkbox under Menu/Tools/Options from the LO Calc General group to the LO Calc Defaults group. It should appear under a new title "Sort Options" to distinguish it from default options for New Spreadsheet. As configured during installation, the default value for the global option will be FALSE, for compatibility with other spreadsheet software.

This cosmetic UI change tells the user that the checkbox sets the default value of some other setting, rather than directly controlling some behaviour as it does now.

#2) Add an UpdateReferencesOnSort range property to sort ranges (a sort range is a range with option "Operations: Sort" appearing under Menu/Data/Define Range/Options). The default value for this property is taken from the current value of the UpdateReferencesOnSort global option.

The last-sorted range without a definition is preserved in the saved document. This range will have the property too.

#3) Add a checkbox to the Sort Options tab of the Sort dialog to show and set the UpdateReferenceOnSort range property.

#4) A legacy document doesn't have this property in its sort ranges. When loading a legacy document, add the property to every sort range using the default option value as in #2.

This saves the user from manually running every sort in a document to add this property to all ranges.

#5) The behaviour when sorting a range is determined by the range's UpdateReferenceOnSort range property.

#6) Saving a document containing one or more ranges preserves the UpdateReferenceOnSort range property for each sort range.

#7) Loading a document containing one or more ranges

#8) When exporting LO to a document format that does not support the new UpdateReferenceOnSort range property, the presence of a sorted range in the document will cause the "potential data loss" warning to be displayed.

== Limitations ==

A sort range property can't be changed by the user without performing the sort. A user can only click OK to accept changes (and sort), or click Cancel and the property lose changes. Is that acceptable behaviour?
Comment 3 Buovjaga 2016-09-30 08:35:51 UTC
Pinged devs on IRC and it seems this is OK to set to NEW.
Comment 4 Robert Lacroix 2016-10-05 19:09:12 UTC
This case merits consideration as a higher priority defect. The change that introduced the two sort behaviours as a global user setting has minimial impact on users who are consumers of their own spreadsheets, but it introduces ambiguity to any enterprise environment where spreadsheet documents are often shared between users.