Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/inc/queryentry.hxx
Line
Count
Source
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 <boost/container/small_vector.hpp>
28
#include <memory>
29
#include <vector>
30
31
/**
32
 * Each instance of this struct represents a single filtering criteria.
33
 */
34
struct SC_DLLPUBLIC ScQueryEntry final
35
{
36
    enum QueryType
37
    {
38
        ByValue,
39
        ByString,
40
        ByDate,
41
        ByEmpty,
42
        ByTextColor,
43
        ByBackgroundColor,
44
    };
45
46
    struct SAL_DLLPRIVATE Item
47
    {
48
        QueryType         meType;
49
        double            mfVal;
50
        svl::SharedString maString;
51
        Color             maColor;
52
        bool              mbMatchEmpty;
53
        bool              mbRoundForFilter;
54
55
176k
        Item() : meType(ByValue), mfVal(0.0), mbMatchEmpty(false), mbRoundForFilter(false) {}
56
57
        bool operator== (const Item& r) const;
58
    };
59
    typedef boost::container::small_vector<Item, 1> QueryItemsType;
60
61
    bool            bDoQuery;
62
    SCCOLROW        nField;
63
    ScQueryOp       eOp;
64
    ScQueryConnect  eConnect;
65
    mutable std::unique_ptr<utl::SearchParam> pSearchParam;       ///< if Wildcard or RegExp, not saved
66
    mutable std::unique_ptr<utl::TextSearch>  pSearchText;        ///< if Wildcard or RegExp, not saved
67
68
    ScQueryEntry();
69
    ScQueryEntry(const ScQueryEntry& r);
70
    ScQueryEntry(ScQueryEntry&& r) noexcept;
71
    ~ScQueryEntry();
72
73
    /// creates pSearchParam and pSearchText if necessary
74
    utl::TextSearch* GetSearchTextPtr( utl::SearchParam::SearchType eSearchType, bool bCaseSens,
75
            bool bWildMatchSel ) const;
76
77
408
    QueryItemsType& GetQueryItems() { return maQueryItems;}
78
159k
    const QueryItemsType& GetQueryItems() const { return maQueryItems;}
79
    void SetQueryByEmpty();
80
    bool IsQueryByEmpty() const;
81
    void SetQueryByNonEmpty();
82
    bool IsQueryByNonEmpty() const;
83
    void SetQueryByTextColor(Color color);
84
    bool IsQueryByTextColor() const;
85
    void SetQueryByBackgroundColor(Color color);
86
    bool IsQueryByBackgroundColor() const;
87
32.5k
    const Item& GetQueryItem() const { return GetQueryItemImpl(); }
88
15.5k
    Item& GetQueryItem() { return GetQueryItemImpl(); }
89
    void            Clear();
90
    ScQueryEntry&   operator=( const ScQueryEntry& r );
91
    bool            operator==( const ScQueryEntry& r ) const;
92
93
private:
94
    Item& GetQueryItemImpl() const;
95
96
    /**
97
     * Stores all query items.  It must contain at least one item at all times
98
     * (for single equality match queries or comparative queries).  It may
99
     * contain multiple items for multi-equality match queries.
100
     */
101
    mutable QueryItemsType maQueryItems;
102
};
103
104
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */