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 #pragma once 21 22 #include "global.hxx" 23 #include <svl/sharedstring.hxx> 24 #include <unotools/textsearch.hxx> 25 #include <tools/color.hxx> 26 27 #include <memory> 28 #include <vector> 29 30 /** 31 * Each instance of this struct represents a single filtering criteria. 32 */ 33 struct SC_DLLPUBLIC ScQueryEntry 34 { 35 enum QueryType 36 { 37 ByValue, 38 ByString, 39 ByDate, 40 ByEmpty, 41 ByTextColor, 42 ByBackgroundColor, 43 }; 44 45 struct SAL_DLLPRIVATE Item 46 { 47 QueryType meType; 48 double mfVal; 49 svl::SharedString maString; 50 Color maColor; 51 bool mbMatchEmpty; 52 bool mbRoundForFilter; 53 ItemScQueryEntry::Item54 Item() : meType(ByValue), mfVal(0.0), mbMatchEmpty(false), mbRoundForFilter(false) {} 55 56 bool operator== (const Item& r) const; 57 }; 58 typedef std::vector<Item> QueryItemsType; 59 60 bool bDoQuery; 61 SCCOLROW nField; 62 ScQueryOp eOp; 63 ScQueryConnect eConnect; 64 mutable std::unique_ptr<utl::SearchParam> pSearchParam; ///< if Wildcard or RegExp, not saved 65 mutable std::unique_ptr<utl::TextSearch> pSearchText; ///< if Wildcard or RegExp, not saved 66 67 ScQueryEntry(); 68 ScQueryEntry(const ScQueryEntry& r); 69 ~ScQueryEntry(); 70 71 /// creates pSearchParam and pSearchText if necessary 72 utl::TextSearch* GetSearchTextPtr( utl::SearchParam::SearchType eSearchType, bool bCaseSens, 73 bool bWildMatchSel ) const; 74 GetQueryItemsScQueryEntry75 QueryItemsType& GetQueryItems() { return maQueryItems;} GetQueryItemsScQueryEntry76 const QueryItemsType& GetQueryItems() const { return maQueryItems;} 77 void SetQueryByEmpty(); 78 bool IsQueryByEmpty() const; 79 void SetQueryByNonEmpty(); 80 bool IsQueryByNonEmpty() const; 81 void SetQueryByTextColor(Color color); 82 bool IsQueryByTextColor() const; 83 void SetQueryByBackgroundColor(Color color); 84 bool IsQueryByBackgroundColor() const; GetQueryItemScQueryEntry85 const Item& GetQueryItem() const { return GetQueryItemImpl(); } GetQueryItemScQueryEntry86 Item& GetQueryItem() { return GetQueryItemImpl(); } 87 void Clear(); 88 ScQueryEntry& operator=( const ScQueryEntry& r ); 89 bool operator==( const ScQueryEntry& r ) const; 90 91 private: 92 Item& GetQueryItemImpl() const; 93 94 /** 95 * Stores all query items. It must contain at least one item at all times 96 * (for single equality match queries or comparative queries). It may 97 * contain multiple items for multi-equality match queries. 98 */ 99 mutable QueryItemsType maQueryItems; 100 }; 101 102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 103