Issue 121167 - XSortableGridData sort is too restrictive on column data type
Summary: XSortableGridData sort is too restrictive on column data type
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Normal
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
Depends on:
Reported: 2012-10-05 17:08 UTC by bmarcelly
Modified: 2013-02-24 21:09 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---

Three examples of UnoControlGrid trap (16.43 KB, application/vnd.oasis.opendocument.text)
2012-10-05 17:08 UTC, bmarcelly
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description bmarcelly 2012-10-05 17:08:01 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.
Comment 1 Oliver Brinzing 2012-10-07 09:43:50 UTC
Comment 2 bmarcelly 2012-10-10 10:24:06 UTC
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).