LibreOffice Module sc (master) 1
queryentry.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <queryentry.hxx>
21
23
24/*
25 * dialog returns the special field values "empty"/"not empty"
26 * as constants SC_EMPTYFIELDS and SC_NONEMPTYFIELDS respectively in nVal in
27 * conjunctions with the flag bQueryByString = FALSE.
28 */
29
30#define SC_EMPTYFIELDS (double(0x0042))
31#define SC_NONEMPTYFIELDS (double(0x0043))
32#define SC_TEXTCOLOR (double(0x0044))
33#define SC_BACKGROUNDCOLOR (double(0x0045))
34
36{
37 return meType == r.meType && mfVal == r.mfVal && maString == r.maString && mbMatchEmpty == r.mbMatchEmpty
39}
40
42 bDoQuery(false),
43 nField(0),
47{
48}
49
51 bDoQuery(r.bDoQuery),
52 nField(r.nField),
53 eOp(r.eOp),
54 eConnect(r.eConnect),
55 maQueryItems(r.maQueryItems)
56{
57}
58
60{
61}
62
64{
66 eOp = r.eOp;
68 nField = r.nField;
70
71 pSearchParam.reset();
72 pSearchText.reset();
73
74 return *this;
75}
76
78{
79 eOp = SC_EQUAL;
80 maQueryItems.resize(1);
81 Item& rItem = maQueryItems[0];
82 rItem.meType = ByEmpty;
84 rItem.mfVal = SC_EMPTYFIELDS;
85}
86
88{
89 if (maQueryItems.size() != 1)
90 return false;
91
92 const Item& rItem = maQueryItems[0];
93 return eOp == SC_EQUAL &&
94 rItem.meType == ByEmpty &&
95 rItem.maString.isEmpty() &&
96 rItem.mfVal == SC_EMPTYFIELDS;
97}
98
100{
101 eOp = SC_EQUAL;
102 maQueryItems.resize(1);
103 Item& rItem = maQueryItems[0];
104 rItem.meType = ByEmpty;
105 rItem.maString = svl::SharedString();
106 rItem.mfVal = SC_NONEMPTYFIELDS;
107}
108
110{
111 if (maQueryItems.size() != 1)
112 return false;
113
114 const Item& rItem = maQueryItems[0];
115 return eOp == SC_EQUAL &&
116 rItem.meType == ByEmpty &&
117 rItem.maString.isEmpty() &&
118 rItem.mfVal == SC_NONEMPTYFIELDS;
119}
120
122{
123 eOp = SC_EQUAL;
124 maQueryItems.resize(1);
125 Item& rItem = maQueryItems[0];
126 rItem.meType = ByTextColor;
127 rItem.maString = svl::SharedString();
128 rItem.mfVal = SC_TEXTCOLOR;
129 rItem.maColor = color;
130}
131
133{
134 if (maQueryItems.size() != 1)
135 return false;
136
137 const Item& rItem = maQueryItems[0];
138 return eOp == SC_EQUAL &&
139 rItem.meType == ByTextColor;
140}
141
143{
144 eOp = SC_EQUAL;
145 maQueryItems.resize(1);
146 Item& rItem = maQueryItems[0];
148 rItem.maString = svl::SharedString();
150 rItem.maColor = color;
151}
152
154{
155 if (maQueryItems.size() != 1)
156 return false;
157
158 const Item& rItem = maQueryItems[0];
159 return eOp == SC_EQUAL &&
160 rItem.meType == ByBackgroundColor;
161}
162
164{
165 if (maQueryItems.size() != 1)
166 // Reset to a single query mode.
167 maQueryItems.resize(1);
168 return maQueryItems[0];
169}
170
172{
173 bDoQuery = false;
174 eOp = SC_EQUAL;
176 nField = 0;
177 maQueryItems.clear();
178 maQueryItems.emplace_back();
179
180 pSearchParam.reset();
181 pSearchText.reset();
182}
183
185{
186 return bDoQuery == r.bDoQuery
187 && eOp == r.eOp
188 && eConnect == r.eConnect
189 && nField == r.nField
191 // do not compare pSearchParam and pSearchText!
192}
193
195 bool bWildMatchSel ) const
196{
197 if ( !pSearchParam )
198 {
199 OUString aStr = maQueryItems[0].maString.getString();
201 aStr, eSearchType, bCaseSens, '~', bWildMatchSel));
203 }
204 return pSearchText.get();
205}
206
207/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1064
bool isEmpty() const
@ SC_AND
Definition: global.hxx:855
@ SC_EQUAL
Definition: global.hxx:835
aStr
#define SC_TEXTCOLOR
Definition: queryentry.cxx:32
#define SC_NONEMPTYFIELDS
Definition: queryentry.cxx:31
#define SC_EMPTYFIELDS
Definition: queryentry.cxx:30
#define SC_BACKGROUNDCOLOR
Definition: queryentry.cxx:33
svl::SharedString maString
Definition: queryentry.hxx:49
bool operator==(const Item &r) const
Definition: queryentry.cxx:35
Each instance of this struct represents a single filtering criteria.
Definition: queryentry.hxx:34
void SetQueryByBackgroundColor(Color color)
Definition: queryentry.cxx:142
SCCOLROW nField
Definition: queryentry.hxx:61
bool IsQueryByNonEmpty() const
Definition: queryentry.cxx:109
void SetQueryByNonEmpty()
Definition: queryentry.cxx:99
ScQueryConnect eConnect
Definition: queryentry.hxx:63
bool IsQueryByTextColor() const
Definition: queryentry.cxx:132
void SetQueryByTextColor(Color color)
Definition: queryentry.cxx:121
std::unique_ptr< utl::TextSearch > pSearchText
if Wildcard or RegExp, not saved
Definition: queryentry.hxx:65
bool IsQueryByEmpty() const
Definition: queryentry.cxx:87
utl::TextSearch * GetSearchTextPtr(utl::SearchParam::SearchType eSearchType, bool bCaseSens, bool bWildMatchSel) const
creates pSearchParam and pSearchText if necessary
Definition: queryentry.cxx:194
bool operator==(const ScQueryEntry &r) const
Definition: queryentry.cxx:184
ScQueryOp eOp
Definition: queryentry.hxx:62
Item & GetQueryItemImpl() const
Definition: queryentry.cxx:163
void SetQueryByEmpty()
Definition: queryentry.cxx:77
ScQueryEntry & operator=(const ScQueryEntry &r)
Definition: queryentry.cxx:63
QueryItemsType maQueryItems
Stores all query items.
Definition: queryentry.hxx:99
std::unique_ptr< utl::SearchParam > pSearchParam
if Wildcard or RegExp, not saved
Definition: queryentry.hxx:64
bool IsQueryByBackgroundColor() const
Definition: queryentry.cxx:153