1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include "queryentry.hxx"
22 #include <unotools/textsearch.hxx>
25 * dialog returns the special field values "empty"/"not empty"
26 * as constants SC_EMPTYFIELDS and SC_NONEMPTYFIELDS respectively in nVal in
27 * conjuctions with the flag bQueryByString = FALSE.
30 #define SC_EMPTYFIELDS ((double)0x0042)
31 #define SC_NONEMPTYFIELDS ((double)0x0043)
33 bool ScQueryEntry::Item::operator== (const Item
& r
) const
35 return meType
== r
.meType
&& mfVal
== r
.mfVal
&& maString
== r
.maString
;
38 ScQueryEntry::ScQueryEntry() :
49 ScQueryEntry::ScQueryEntry(const ScQueryEntry
& r
) :
56 maQueryItems(r
.maQueryItems
)
60 ScQueryEntry::~ScQueryEntry()
66 ScQueryEntry
& ScQueryEntry::operator=( const ScQueryEntry
& r
)
68 bDoQuery
= r
.bDoQuery
;
70 eConnect
= r
.eConnect
;
72 maQueryItems
= r
.maQueryItems
;
82 ScQueryEntry::QueryItemsType
& ScQueryEntry::GetQueryItems()
87 const ScQueryEntry::QueryItemsType
& ScQueryEntry::GetQueryItems() const
92 void ScQueryEntry::SetQueryByEmpty()
95 maQueryItems
.resize(1);
96 Item
& rItem
= maQueryItems
[0];
97 rItem
.meType
= ByEmpty
;
98 rItem
.maString
= svl::SharedString();
99 rItem
.mfVal
= SC_EMPTYFIELDS
;
102 bool ScQueryEntry::IsQueryByEmpty() const
104 if (maQueryItems
.size() != 1)
107 const Item
& rItem
= maQueryItems
[0];
108 return eOp
== SC_EQUAL
&&
109 rItem
.meType
== ByEmpty
&&
110 rItem
.maString
.isEmpty() &&
111 rItem
.mfVal
== SC_EMPTYFIELDS
;
114 void ScQueryEntry::SetQueryByNonEmpty()
117 maQueryItems
.resize(1);
118 Item
& rItem
= maQueryItems
[0];
119 rItem
.meType
= ByEmpty
;
120 rItem
.maString
= svl::SharedString();
121 rItem
.mfVal
= SC_NONEMPTYFIELDS
;
124 bool ScQueryEntry::IsQueryByNonEmpty() const
126 if (maQueryItems
.size() != 1)
129 const Item
& rItem
= maQueryItems
[0];
130 return eOp
== SC_EQUAL
&&
131 rItem
.meType
== ByEmpty
&&
132 rItem
.maString
.isEmpty() &&
133 rItem
.mfVal
== SC_NONEMPTYFIELDS
;
136 const ScQueryEntry::Item
& ScQueryEntry::GetQueryItem() const
138 if (maQueryItems
.size() > 1)
139 // Reset to a single query mode.
140 maQueryItems
.resize(1);
141 return maQueryItems
[0];
144 ScQueryEntry::Item
& ScQueryEntry::GetQueryItem()
146 if (maQueryItems
.size() > 1)
147 // Reset to a single query mode.
148 maQueryItems
.resize(1);
149 return maQueryItems
[0];
152 void ScQueryEntry::Clear()
158 maQueryItems
.clear();
159 maQueryItems
.push_back(Item());
167 bool ScQueryEntry::operator==( const ScQueryEntry
& r
) const
169 return bDoQuery
== r
.bDoQuery
171 && eConnect
== r
.eConnect
172 && nField
== r
.nField
173 && maQueryItems
== r
.maQueryItems
;
174 //! pSearchParam und pSearchText nicht vergleichen
177 utl::TextSearch
* ScQueryEntry::GetSearchTextPtr( bool bCaseSens
) const
181 OUString aStr
= maQueryItems
[0].maString
.getString();
182 pSearchParam
= new utl::SearchParam(
183 aStr
, utl::SearchParam::SRCH_REGEXP
, bCaseSens
, false, false);
184 pSearchText
= new utl::TextSearch( *pSearchParam
, *ScGlobal::pCharClass
);
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */