android: Update app-specific/MIME type icons
[LibreOffice.git] / sc / inc / sortparam.hxx
blob94817b862b3ea799173c90aa25d40df5d44c4d6b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #define DEFSORT 3
24 #include <vector>
26 #include "address.hxx"
27 #include <editeng/colritem.hxx>
28 #include <com/sun/star/lang/Locale.hpp>
29 #include "scdllapi.h"
31 struct ScSubTotalParam;
32 struct ScQueryParam;
34 enum class ScColorSortMode {
35 None,
36 TextColor,
37 BackgroundColor
40 struct ScSortKeyState
42 SCCOLROW nField;
43 bool bDoSort;
44 bool bAscending;
45 ScColorSortMode aColorSortMode;
46 Color aColorSortColor;
49 /** Struct to hold non-data extended area, used with
50 ScDocument::ShrinkToUsedDataArea().
52 struct ScDataAreaExtras
54 /// If TRUE, consider the presence of cell notes besides data.
55 bool mbCellNotes = false;
56 /// If TRUE, consider the presence of draw objects anchored to the cell.
57 bool mbCellDrawObjects = false;
58 /// If TRUE, consider the presence of cell formats.
59 bool mbCellFormats = false;
60 SCCOL mnStartCol = SCCOL_MAX;
61 SCROW mnStartRow = SCROW_MAX;
62 SCCOL mnEndCol = -1;
63 SCROW mnEndRow = -1;
65 bool anyExtrasWanted() const { return mbCellNotes || mbCellDrawObjects || mbCellFormats; }
66 void resetArea() { mnStartCol = SCCOL_MAX; mnStartRow = SCROW_MAX; mnEndCol = -1; mnEndRow = -1; }
68 bool operator==( const ScDataAreaExtras& rOther ) const
70 // Ignore area range, this is used in ScSortParam::operator==().
71 return mbCellNotes == rOther.mbCellNotes
72 && mbCellDrawObjects == rOther.mbCellDrawObjects
73 && mbCellFormats == rOther.mbCellFormats;
76 enum class Clip
78 None,
79 Col,
80 Row
83 /// Obtain the overall range if area extras are larger.
84 void GetOverallRange( SCCOL& nCol1, SCROW& nRow1, SCCOL& nCol2, SCROW& nRow2, Clip eClip = Clip::None ) const
86 if (eClip != Clip::Col)
88 if (nCol1 > mnStartCol)
89 nCol1 = mnStartCol;
90 if (nCol2 < mnEndCol)
91 nCol2 = mnEndCol;
93 if (eClip != Clip::Row)
95 if (nRow1 > mnStartRow)
96 nRow1 = mnStartRow;
97 if (nRow2 < mnEndRow)
98 nRow2 = mnEndRow;
102 /// Set the overall range.
103 void SetOverallRange( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
105 mnStartCol = nCol1;
106 mnStartRow = nRow1;
107 mnEndCol = nCol2;
108 mnEndRow = nRow2;
112 struct SC_DLLPUBLIC ScSortParam
114 SCCOL nCol1;
115 SCROW nRow1;
116 SCCOL nCol2;
117 SCROW nRow2;
118 ScDataAreaExtras aDataAreaExtras;
119 sal_uInt16 nUserIndex;
120 bool bHasHeader;
121 bool bByRow;
122 bool bCaseSens;
123 bool bNaturalSort;
124 bool bUserDef;
125 bool bInplace;
126 SCTAB nDestTab;
127 SCCOL nDestCol;
128 SCROW nDestRow;
129 ::std::vector<ScSortKeyState>
130 maKeyState;
131 css::lang::Locale aCollatorLocale;
132 OUString aCollatorAlgorithm;
133 sal_uInt16 nCompatHeader;
135 ScSortParam();
136 ScSortParam( const ScSortParam& r );
137 /// SubTotals sort
138 ScSortParam( const ScSubTotalParam& rSub, const ScSortParam& rOld );
139 /// TopTen sort
140 ScSortParam( const ScQueryParam&, SCCOL nCol );
141 ~ScSortParam();
143 ScSortParam& operator= ( const ScSortParam& r );
144 bool operator== ( const ScSortParam& rOther ) const;
145 void Clear ();
146 void MoveToDest();
148 sal_uInt16 GetSortKeyCount() const { return maKeyState.size(); }
151 namespace sc {
153 struct ReorderParam
156 * This sort range already takes into account the presence or absence of
157 * header row / column i.e. if a header row / column is present, it
158 * excludes that row / column.
160 ScRange maSortRange;
161 ScDataAreaExtras maDataAreaExtras;
164 * List of original column / row positions after reordering.
166 std::vector<SCCOLROW> maOrderIndices;
167 bool mbByRow;
168 bool mbHiddenFiltered;
169 bool mbUpdateRefs;
170 bool mbHasHeaders;
173 * Reorder the position indices such that it can be used to undo the
174 * original reordering.
176 void reverse();
178 ReorderParam()
179 : mbByRow(false)
180 , mbHiddenFiltered(false)
181 , mbUpdateRefs(false)
182 , mbHasHeaders(false)
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */