Hi there,

in the process of creating a little nutshell to demonstrate how to use
the XSortable.sort(props) methods it is possible to sort the rows of a
cell range by columns successfully (including variants to copy the
sorted result to a different cell in the spreadsheet).

Trying to do the same for the transposed cell range (having copied the
cell range and pasted it with "transpose"), ie. now sorting the colums
of a cell range by rows, has not yielded a working solution for me,
although I have been trying for a couple of hours now to analyze
possible causes.

The layout of the table with the cell range in question is roughly:

       A           B                C               D 

    24 CustNr      1                19              99
    25 Name        Zeppelin, Inc.   AlphaOmega  BigCompany
    26 Country     Germany          Netherlands     Austria
    27 LastOrder   2017-01-02       2029-12-17      2059-05-20
      

For sorting the columns in range "A24:D27" by row "2" (Country)
ascendingly the following definitions are undertaken:

    * one "com.sun.star.table.TableSortField" object is created and set
      as follows: Field=[2] IsAscending=[true] IsCaseSensitive=[false]
    * the following properties are created and supplied as a sequence to
      XSortable.sort():
          o [BindFormatsToContent]=[true]
            [ContainsHeader]=[true]
            [IsSortColumns]=[false]
            [SortFields]= a TableSortField sequence with one member
            being set to the values given above

Executing the sort does not sort the range as expected, there is no
pattern so far that I could detect in what happens.

Fetching the SortDescriptor from the XSortable with
createSortDescriptor(), immediately after the sort() was invoked
(assuming, which may be false, that the values shown should match the
explicit settings in the submitted property sequence) shows:

    * [IsSortColumns]=[false]
      [ContainsHeader]=[true]
      [MaxFieldCount]=[3]
      [SortFields]=[[Lcom.sun.star.table.TableSortField;@ccc588]
        -> Field=[1] IsAscending=[1] IsCaseSensitive=[0]
      [BindFormatsToContent]=[true]
      [CopyOutputData]=[false]
      [outputposition]=[com.sun.star.table.celladdr...@140c281]
        -> Sheet=[0] Column=[0] Row=[23]
      [IsUserListEnabled]=[false]
      [UserListIndex]=[false]

As "IsSortColumns" was set to false (and even the descriptor sets it to
false), I am wondering why this does not work.

Maybe I miss something important (even something obvious), hence the
request for hints, ideas.

TIA,

---rony

P.S.: Doing the same sort interactively via the GUI works.
P.P.S.: Used the information found in
<http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Sorting>
and quite a few related hits via Google, which discuss sorting, but I
found nothing related to "IsSortColumns=false".




Reply via email to