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 .
24 #include <unordered_map>
26 #include "queryentry.hxx"
31 class CollatorWrapper
;
32 struct ScRefCellValue
;
33 struct ScInterpreterContext
;
37 class TableColumnBlockPositionSet
;
41 class SharedStringPool
;
45 class TransliterationWrapper
;
48 class ScQueryEvaluator
51 svl::SharedStringPool
& mrStrPool
;
53 const ScQueryParam
& mrParam
;
54 bool* mpTestEqualCondition
;
55 utl::TransliterationWrapper
* mpTransliteration
;
56 CollatorWrapper
* mpCollator
;
57 const bool mbMatchWholeCell
;
58 const bool mbCaseSensitive
;
59 const ScInterpreterContext
* mpContext
;
61 const SCSIZE mnEntryCount
;
64 static constexpr SCSIZE nFixedBools
= 32;
65 bool maBool
[nFixedBools
];
66 bool maTest
[nFixedBools
];
67 std::unique_ptr
<bool[]> mpBoolDynamic
;
68 std::unique_ptr
<bool[]> mpTestDynamic
;
70 std::unordered_map
<FormulaError
, svl::SharedString
> mCachedSharedErrorStrings
;
71 // The "outside" index in these two is the index of ScQueryEntry in ScQueryParam.
72 std::vector
<std::vector
<double>> mCachedSortedItemValues
;
73 std::vector
<std::vector
<const rtl_uString
*>> mCachedSortedItemStrings
;
75 static bool isPartialTextMatchOp(const ScQueryEntry
& rEntry
);
76 static bool isTextMatchOp(const ScQueryEntry
& rEntry
);
77 void setupTransliteratorIfNeeded();
78 void setupCollatorIfNeeded();
80 bool isRealWildOrRegExp(const ScQueryEntry
& rEntry
) const;
81 bool isTestWildOrRegExp(const ScQueryEntry
& rEntry
) const;
82 static bool isQueryByValue(const ScQueryEntry
& rEntry
, const ScQueryEntry::Item
& rItem
,
83 const ScRefCellValue
& rCell
);
84 static bool isQueryByValueForCell(const ScRefCellValue
& rCell
);
85 static bool isQueryByString(const ScQueryEntry
& rEntry
, const ScQueryEntry::Item
& rItem
,
86 const ScRefCellValue
& rCell
);
88 sal_uInt32
getNumFmt(SCCOL nCol
, SCROW nRow
);
90 std::pair
<bool, bool> compareByValue(const ScRefCellValue
& rCell
, SCCOL nCol
, SCROW nRow
,
91 const ScQueryEntry
& rEntry
,
92 const ScQueryEntry::Item
& rItem
);
94 OUString
getCellString(const ScRefCellValue
& rCell
, SCROW nRow
, const ScQueryEntry
& rEntry
,
95 const svl::SharedString
** sharedString
);
97 bool isFastCompareByString(const ScQueryEntry
& rEntry
) const;
98 template <bool bFast
= false>
100 compareByString(const ScQueryEntry
& rEntry
, const ScQueryEntry::Item
& rItem
,
101 const svl::SharedString
* pValueSource1
, const OUString
* pValueSource2
);
102 std::pair
<bool, bool> compareByTextColor(SCCOL nCol
, SCROW nRow
,
103 const ScQueryEntry::Item
& rItem
);
104 std::pair
<bool, bool> compareByBackgroundColor(SCCOL nCol
, SCROW nRow
,
105 const ScQueryEntry::Item
& rItem
);
107 static std::pair
<bool, bool> compareByRangeLookup(const ScRefCellValue
& rCell
,
108 const ScQueryEntry
& rEntry
,
109 const ScQueryEntry::Item
& rItem
);
111 std::pair
<bool, bool> processEntry(SCROW nRow
, SCCOL nCol
, ScRefCellValue
& aCell
,
112 const ScQueryEntry
& rEntry
, size_t nEntryIndex
);
115 ScQueryEvaluator(ScDocument
& rDoc
, const ScTable
& rTab
, const ScQueryParam
& rParam
,
116 const ScInterpreterContext
* pContext
= nullptr,
117 bool* pTestEqualCondition
= nullptr);
119 bool ValidQuery(SCROW nRow
, const ScRefCellValue
* pCell
= nullptr,
120 sc::TableColumnBlockPositionSet
* pBlockPos
= nullptr);
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */