1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SVTOOLS_TABLESORT_HXX
25 #define SVTOOLS_TABLESORT_HXX
26 
27 #include "svtools/table/tabletypes.hxx"
28 
29 //......................................................................................................................
30 namespace svt { namespace table
31 {
32 //......................................................................................................................
33 
34 	//==================================================================================================================
35 	//= ColumnSortDirection
36 	//==================================================================================================================
37     enum ColumnSortDirection
38     {
39         ColumnSortAscending,
40         ColumnSortDescending
41     };
42 
43 	//==================================================================================================================
44 	//= ColumnSort
45 	//==================================================================================================================
46     struct ColumnSort
47     {
48         ColPos              nColumnPos;
49         ColumnSortDirection eSortDirection;
50 
ColumnSortsvt::table::ColumnSort51         ColumnSort()
52             :nColumnPos( COL_INVALID )
53             ,eSortDirection( ColumnSortAscending )
54         {
55         }
56 
ColumnSortsvt::table::ColumnSort57         ColumnSort( ColPos const i_columnPos, ColumnSortDirection const i_sortDirection )
58             :nColumnPos( i_columnPos )
59             ,eSortDirection( i_sortDirection )
60         {
61         }
62     };
63 
64 	//==================================================================================================================
65 	//= ITableDataSort
66 	//==================================================================================================================
67     /** provides sorting functionality for the datta underlying an ITableModel
68     */
69 	class SAL_NO_VTABLE ITableDataSort
70 	{
71     public:
72         /** sorts the rows in the model by the given column's data, in the given direction.
73         */
74         virtual void        sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection ) = 0;
75 
76         /** retrieves the current sort order of the data
77 
78             If the <code>nColumnIndex</code> member of the returned srtructure is <code>COL_INVALID</code>, then
79             the data is currently not sorted.
80         */
81         virtual ColumnSort  getCurrentSortOrder() const = 0;
82 	};
83 
84 //......................................................................................................................
85 } } // namespace svt::table
86 //......................................................................................................................
87 
88 #endif // SVTOOLS_TABLESORT_HXX
89