Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / inc / sortparam.hxx
blob63d83e2c059547a72bace98a010c4991acd38026
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 <com/sun/star/lang/Locale.hpp>
28 #include "scdllapi.h"
30 struct ScSubTotalParam;
31 struct ScQueryParam;
33 struct ScSortKeyState
35 SCCOLROW nField;
36 bool bDoSort;
37 bool bAscending;
40 /** Struct to hold non-data extended area, used with
41 ScDocument::ShrinkToUsedDataArea().
43 struct ScDataAreaExtras
45 /// If TRUE, consider the presence of cell notes besides data.
46 bool mbCellNotes = false;
47 /// If TRUE, consider the presence of draw objects anchored to the cell.
48 bool mbCellDrawObjects = false;
49 /// If TRUE, consider the presence of cell formats.
50 bool mbCellFormats = false;
51 SCCOL mnStartCol = SCCOL_MAX;
52 SCROW mnStartRow = SCROW_MAX;
53 SCCOL mnEndCol = -1;
54 SCROW mnEndRow = -1;
56 bool anyExtrasWanted() const { return mbCellNotes || mbCellDrawObjects || mbCellFormats; }
57 void resetArea() { mnStartCol = SCCOL_MAX; mnStartRow = SCROW_MAX; mnEndCol = -1; mnEndRow = -1; }
59 bool operator==( const ScDataAreaExtras& rOther ) const
61 // Ignore area range, this is used in ScSortParam::operator==().
62 return mbCellNotes == rOther.mbCellNotes
63 && mbCellDrawObjects == rOther.mbCellDrawObjects
64 && mbCellFormats == rOther.mbCellFormats;
67 enum class Clip
69 None,
70 Col,
71 Row
74 /// Obtain the overall range if area extras are larger.
75 void GetOverallRange( SCCOL& nCol1, SCROW& nRow1, SCCOL& nCol2, SCROW& nRow2, Clip eClip = Clip::None ) const
77 if (eClip != Clip::Col)
79 if (nCol1 > mnStartCol)
80 nCol1 = mnStartCol;
81 if (nCol2 < mnEndCol)
82 nCol2 = mnEndCol;
84 if (eClip != Clip::Row)
86 if (nRow1 > mnStartRow)
87 nRow1 = mnStartRow;
88 if (nRow2 < mnEndRow)
89 nRow2 = mnEndRow;
93 /// Set the overall range.
94 void SetOverallRange( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
96 mnStartCol = nCol1;
97 mnStartRow = nRow1;
98 mnEndCol = nCol2;
99 mnEndRow = nRow2;
103 struct SC_DLLPUBLIC ScSortParam
105 SCCOL nCol1;
106 SCROW nRow1;
107 SCCOL nCol2;
108 SCROW nRow2;
109 ScDataAreaExtras aDataAreaExtras;
110 sal_uInt16 nUserIndex;
111 bool bHasHeader;
112 bool bByRow;
113 bool bCaseSens;
114 bool bNaturalSort;
115 bool bUserDef;
116 bool bInplace;
117 SCTAB nDestTab;
118 SCCOL nDestCol;
119 SCROW nDestRow;
120 ::std::vector<ScSortKeyState>
121 maKeyState;
122 css::lang::Locale aCollatorLocale;
123 OUString aCollatorAlgorithm;
124 sal_uInt16 nCompatHeader;
126 ScSortParam();
127 ScSortParam( const ScSortParam& r );
128 /// SubTotals sort
129 ScSortParam( const ScSubTotalParam& rSub, const ScSortParam& rOld );
130 /// TopTen sort
131 ScSortParam( const ScQueryParam&, SCCOL nCol );
132 ~ScSortParam();
134 ScSortParam& operator= ( const ScSortParam& r );
135 bool operator== ( const ScSortParam& rOther ) const;
136 void Clear ();
137 void MoveToDest();
139 sal_uInt16 GetSortKeyCount() const { return maKeyState.size(); }
142 namespace sc {
144 struct ReorderParam
147 * This sort range already takes into account the presence or absence of
148 * header row / column i.e. if a header row / column is present, it
149 * excludes that row / column.
151 ScRange maSortRange;
152 ScDataAreaExtras maDataAreaExtras;
155 * List of original column / row positions after reordering.
157 std::vector<SCCOLROW> maOrderIndices;
158 bool mbByRow;
159 bool mbHiddenFiltered;
160 bool mbUpdateRefs;
161 bool mbHasHeaders;
164 * Reorder the position indices such that it can be used to undo the
165 * original reordering.
167 void reverse();
169 ReorderParam()
170 : mbByRow(false)
171 , mbHiddenFiltered(false)
172 , mbUpdateRefs(false)
173 , mbHasHeaders(false)
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */