Apache OpenOffice (AOO) Bugzilla – Issue 121167
XSortableGridData sort is too restrictive on column data type
Last modified: 2013-02-24 21:09:02 UTC
Created attachment 79737 [details] Three examples of UnoControlGrid trap Testing the UnoControlGrid, I found cases where column sort do not work. Investigation shows that it depends on the _value_ of the first cell of the column, at least in Basic. The sort mechanism uses the smallest type that can contain the value of the first cell. Example 1 If the column contains integer values, if the first cell contains 30 and another cell contains 7500, sort is impossible. This happens even if the programmer uses Basic conversion routines, like CLng( ). Example 2 If the column contains Double values, but if the first cell happens to contains 300.0, sort is impossible because the sort routine supposes that the column contains short values. This happens even if the programmer uses CDbl() Basic conversion routine. An awkward solution in Basic is to fill the cell values of the first row with explicit UNO types, for example : CreateUnoValue("long", 3) All programmers using Basic/Python/COM Automation languages will be caught in this trap and spend a lot of time. And the problem may appear only with certain data. A more simple solution is needed : - either make the sort routine smarter, - or force the programmer to indicate the UNO type of each column, for example have a column property named DataType that must be filled with a string like "double" or "long". The attachment contains 3 examples of the above explanations.
.
The handling of column values should use the service c.s.s.script.Converter to widen from one type to another when it is possible (e.g. short > long or long > double).