I need urgent help in sorting TextTables in Writer while writing C++ code. I'm using the XSortable interface and the what I'm not able to figure out is how to use the TextSortDesciptor2 and the TableSortDescriptor2 to aid in sorting. I have a text table of 2 columns and 5 rows and have to sort column 1 numerically.
Any help in this?
The following is the code I'm trying unsuccessfully:
- Code: Select all Expand viewCollapse view
Reference <XSortable> xSort (xTT, UNO_QUERY);
Sequence <PropertyValue> sortPropsDefault = xSort->createSortDescriptor();
Sequence <PropertyValue> sortProps(3);
Sequence <TableSortField> tableSortField(1);
tableSortField[0].Field = 0;
tableSortField[0].FieldType = TableSortFieldType::TableSortFieldType_NUMERIC;
tableSortField[0].IsAscending = false;
sortProps[0].Name = OUString::createFromAscii("SortFields");
sortProps[0].Value <<= (Sequence <TableSortField>)tableSortField;
sortProps[1].Name = OUString::createFromAscii("IsSortColumns");
sortProps[1].Value <<= (sal_Bool)false;
sortProps[2].Name = OUString::createFromAscii("IsSortInTable");
sortProps[2].Value <<= (sal_Bool)true;
xSort->sort(sortProps);