LibreOffice Module sc (master) 1
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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 .
18 */
20#pragma once
22#include <memory>
23#include <vector>
24#include <unordered_map>
26#include "queryentry.hxx"
28class ScDocument;
29class ScTable;
30struct ScQueryParam;
31class CollatorWrapper;
32struct ScRefCellValue;
35namespace sc
37class TableColumnBlockPositionSet;
39namespace svl
41class SharedStringPool;
43namespace utl
45class TransliterationWrapper;
52 const ScTable& mrTab;
57 const bool mbMatchWholeCell;
58 const bool mbCaseSensitive;
62 bool* mpPasst;
63 bool* mpTest;
64 static constexpr SCSIZE nFixedBools = 32;
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(ScQueryOp eOp);
76 static bool isTextMatchOp(ScQueryOp eOp);
77 static bool isMatchWholeCellHelper(bool docMatchWholeCell, ScQueryOp eOp);
78 bool isMatchWholeCell(ScQueryOp eOp) const;
82 bool isRealWildOrRegExp(const ScQueryEntry& rEntry) const;
83 bool isTestWildOrRegExp(const ScQueryEntry& rEntry) const;
84 static bool isQueryByValueForCell(const ScRefCellValue& rCell);
86 sal_uInt32 getNumFmt(SCCOL nCol, SCROW nRow);
88 std::pair<bool, bool> compareByValue(const ScRefCellValue& rCell, SCCOL nCol, SCROW nRow,
89 const ScQueryEntry& rEntry,
90 const ScQueryEntry::Item& rItem);
92 bool isFastCompareByString(const ScQueryEntry& rEntry) const;
93 template <bool bFast = false>
94 std::pair<bool, bool>
95 compareByString(const ScQueryEntry& rEntry, const ScQueryEntry::Item& rItem,
96 const svl::SharedString* pValueSource1, const OUString* pValueSource2);
97 std::pair<bool, bool> compareByTextColor(SCCOL nCol, SCROW nRow,
98 const ScQueryEntry::Item& rItem);
99 std::pair<bool, bool> compareByBackgroundColor(SCCOL nCol, SCROW nRow,
100 const ScQueryEntry::Item& rItem);
102 static std::pair<bool, bool> compareByRangeLookup(const ScRefCellValue& rCell,
103 const ScQueryEntry& rEntry,
104 const ScQueryEntry::Item& rItem);
106 std::pair<bool, bool> processEntry(SCROW nRow, SCCOL nCol, ScRefCellValue& aCell,
107 const ScQueryEntry& rEntry, size_t nEntryIndex);
110 ScQueryEvaluator(ScDocument& rDoc, const ScTable& rTab, const ScQueryParam& rParam,
111 const ScInterpreterContext* pContext = nullptr,
112 bool* pTestEqualCondition = nullptr);
114 bool ValidQuery(SCROW nRow, const ScRefCellValue* pCell = nullptr,
115 sc::TableColumnBlockPositionSet* pBlockPos = nullptr);
117 static bool isQueryByValue(ScQueryOp eOp, ScQueryEntry::QueryType eType,
118 const ScRefCellValue& rCell);
120 const ScRefCellValue& rCell);
121 OUString getCellString(const ScRefCellValue& rCell, SCROW nRow, SCCOL nCol,
122 const svl::SharedString** sharedString);
123 static bool isMatchWholeCell(const ScDocument& rDoc, ScQueryOp eOp);
126/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
ScQueryEvaluator(ScDocument &rDoc, const ScTable &rTab, const ScQueryParam &rParam, const ScInterpreterContext *pContext=nullptr, bool *pTestEqualCondition=nullptr)
std::unique_ptr< bool[]> mpTestDynamic
bool maBool[nFixedBools]
const ScQueryParam & mrParam
OUString getCellString(const ScRefCellValue &rCell, SCROW nRow, SCCOL nCol, const svl::SharedString **sharedString)
bool isMatchWholeCell(ScQueryOp eOp) const
bool isTestWildOrRegExp(const ScQueryEntry &rEntry) const
std::pair< bool, bool > compareByString(const ScQueryEntry &rEntry, const ScQueryEntry::Item &rItem, const svl::SharedString *pValueSource1, const OUString *pValueSource2)
std::unique_ptr< bool[]> mpBoolDynamic
std::vector< std::vector< double > > mCachedSortedItemValues
void setupTransliteratorIfNeeded()
std::pair< bool, bool > compareByTextColor(SCCOL nCol, SCROW nRow, const ScQueryEntry::Item &rItem)
static bool isTextMatchOp(ScQueryOp eOp)
std::unordered_map< FormulaError, svl::SharedString > mCachedSharedErrorStrings
sal_uInt32 getNumFmt(SCCOL nCol, SCROW nRow)
static bool isPartialTextMatchOp(ScQueryOp eOp)
const ScInterpreterContext * mpContext
std::pair< bool, bool > processEntry(SCROW nRow, SCCOL nCol, ScRefCellValue &aCell, const ScQueryEntry &rEntry, size_t nEntryIndex)
const bool mbCaseSensitive
static bool isQueryByValueForCell(const ScRefCellValue &rCell)
svl::SharedStringPool & mrStrPool
const bool mbMatchWholeCell
ScDocument & mrDoc
utl::TransliterationWrapper * mpTransliteration
void setupCollatorIfNeeded()
static bool isQueryByValue(ScQueryOp eOp, ScQueryEntry::QueryType eType, const ScRefCellValue &rCell)
bool maTest[nFixedBools]
static std::pair< bool, bool > compareByRangeLookup(const ScRefCellValue &rCell, const ScQueryEntry &rEntry, const ScQueryEntry::Item &rItem)
CollatorWrapper * mpCollator
const SCSIZE mnEntryCount
bool ValidQuery(SCROW nRow, const ScRefCellValue *pCell=nullptr, sc::TableColumnBlockPositionSet *pBlockPos=nullptr)
bool isRealWildOrRegExp(const ScQueryEntry &rEntry) const
static bool isQueryByString(ScQueryOp eOp, ScQueryEntry::QueryType eType, const ScRefCellValue &rCell)
const ScTable & mrTab
static constexpr SCSIZE nFixedBools
std::vector< std::vector< const rtl_uString * > > mCachedSortedItemStrings
bool isFastCompareByString(const ScQueryEntry &rEntry) const
static bool isMatchWholeCellHelper(bool docMatchWholeCell, ScQueryOp eOp)
std::pair< bool, bool > compareByValue(const ScRefCellValue &rCell, SCCOL nCol, SCROW nRow, const ScQueryEntry &rEntry, const ScQueryEntry::Item &rItem)
std::pair< bool, bool > compareByBackgroundColor(SCCOL nCol, SCROW nRow, const ScQueryEntry::Item &rItem)
Set of column block positions only for one table.
Definition: global.hxx:833
CAUTION! The following defines must be in the same namespace as the respective type.
These need to be in global namespace just like their respective types are.
Each instance of this struct represents a single filtering criteria.
Definition: queryentry.hxx:34
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:108
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17