Bump version to 6.4-15
[LibreOffice.git] / sc / inc / queryparam.hxx
blobd7b52374e14de9588e2d33d9c4c56472d839e13d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifndef INCLUDED_SC_INC_QUERYPARAM_HXX
21 #define INCLUDED_SC_INC_QUERYPARAM_HXX
23 #include <unotools/textsearch.hxx>
24 #include "address.hxx"
25 #include "types.hxx"
27 #include <memory>
28 #include <vector>
29 #include <ostream>
31 class SvNumberFormatter;
33 struct ScDBQueryParamInternal;
34 struct ScQueryEntry;
36 namespace svl {
38 class SharedStringPool;
42 struct SAL_DLLPUBLIC_RTTI ScQueryParamBase
44 utl::SearchParam::SearchType eSearchType;
45 bool bHasHeader;
46 bool bByRow;
47 bool bInplace;
48 bool bCaseSens;
49 bool bDuplicate;
50 bool mbRangeLookup; ///< for spreadsheet functions like MATCH, LOOKUP, HLOOKUP, VLOOKUP
52 virtual ~ScQueryParamBase();
54 virtual bool IsValidFieldIndex() const;
56 SC_DLLPUBLIC SCSIZE GetEntryCount() const;
57 SC_DLLPUBLIC const ScQueryEntry& GetEntry(SCSIZE n) const;
58 SC_DLLPUBLIC ScQueryEntry& GetEntry(SCSIZE n);
59 SC_DLLPUBLIC ScQueryEntry& AppendEntry();
60 ScQueryEntry* FindEntryByField(SCCOLROW nField, bool bNew);
61 std::vector<ScQueryEntry*> FindAllEntriesByField(SCCOLROW nField);
62 SC_DLLPUBLIC bool RemoveEntryByField(SCCOLROW nField);
63 SC_DLLPUBLIC void RemoveAllEntriesByField(SCCOLROW nField);
64 void Resize(size_t nNew);
65 void FillInExcelSyntax( svl::SharedStringPool& rPool, const OUString& aCellStr, SCSIZE nIndex,
66 SvNumberFormatter* pFormatter );
68 protected:
69 typedef std::vector<std::unique_ptr<ScQueryEntry>> EntriesType;
71 public:
72 typedef EntriesType::const_iterator const_iterator;
74 const_iterator begin() const;
75 const_iterator end() const;
77 protected:
78 ScQueryParamBase();
79 ScQueryParamBase(const ScQueryParamBase& r);
80 ScQueryParamBase& operator=(const ScQueryParamBase& r);
82 EntriesType m_Entries;
85 // For use in SAL_DEBUG etc. Output format not guaranteed to be stable.
86 template<typename charT, typename traits>
87 inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScQueryParamBase& rParam)
89 stream << "{" <<
90 "searchType=" << rParam.eSearchType <<
91 ",hasHeader=" << (rParam.bHasHeader?"YES":"NO") <<
92 ",byRow=" << (rParam.bByRow?"YES":"NO") <<
93 ",inplace=" << (rParam.bInplace?"YES":"NO") <<
94 ",caseSens=" << (rParam.bCaseSens?"YES":"NO") <<
95 ",duplicate=" << (rParam.bDuplicate?"YES":"NO") <<
96 ",rangeLookup=" << (rParam.mbRangeLookup?"YES":"NO") <<
97 "}";
99 return stream;
102 struct SAL_DLLPUBLIC_RTTI ScQueryParamTable
104 SCCOL nCol1;
105 SCROW nRow1;
106 SCCOL nCol2;
107 SCROW nRow2;
108 SCTAB nTab;
110 ScQueryParamTable();
111 virtual ~ScQueryParamTable();
113 ScQueryParamTable(ScQueryParamTable const &) = default;
114 ScQueryParamTable(ScQueryParamTable &&) = default;
115 ScQueryParamTable & operator =(ScQueryParamTable const &) = default;
116 ScQueryParamTable & operator =(ScQueryParamTable &&) = default;
119 // For use in SAL_DEBUG etc. Output format not guaranteed to be stable.
120 template<typename charT, typename traits>
121 inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScQueryParamTable& rParam)
123 stream << "{" <<
124 "col1=" << rParam.nCol1 <<
125 ",row1=" << rParam.nRow1 <<
126 ",col2=" << rParam.nCol2 <<
127 ",row2=" << rParam.nRow2 <<
128 ",tab=" << rParam.nTab <<
129 "}";
131 return stream;
134 struct SC_DLLPUBLIC ScQueryParam final : public ScQueryParamBase, public ScQueryParamTable
136 bool bDestPers; // not saved
137 SCTAB nDestTab;
138 SCCOL nDestCol;
139 SCROW nDestRow;
141 ScQueryParam();
142 ScQueryParam( const ScQueryParam& );
143 ScQueryParam( const ScDBQueryParamInternal& r );
144 virtual ~ScQueryParam() override;
146 ScQueryParam& operator= ( const ScQueryParam& );
147 bool operator== ( const ScQueryParam& rOther ) const;
148 void Clear();
149 void ClearDestParams();
150 void MoveToDest();
153 // For use in SAL_DEBUG etc. Output format not guaranteed to be stable.
154 template<typename charT, typename traits>
155 inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScQueryParam& rParam)
157 stream << "{" <<
158 "base=" << *static_cast<const ScQueryParamBase*>(&rParam) <<
159 ",table=" << *static_cast<const ScQueryParamTable*>(&rParam) <<
160 ",destPers=" << (rParam.bDestPers?"YES":"NO") <<
161 ",destTab=" << rParam.nDestTab <<
162 ",destCol=" << rParam.nDestCol <<
163 ",destRow=" << rParam.nDestRow <<
164 "}";
166 return stream;
169 struct ScDBQueryParamBase : public ScQueryParamBase
171 enum DataType { INTERNAL, MATRIX };
173 SCCOL mnField; /// the field in which the values are processed during iteration.
174 bool mbSkipString;
176 DataType GetType() const { return meType;}
178 ScDBQueryParamBase() = delete;
179 virtual ~ScDBQueryParamBase() override;
181 protected:
182 ScDBQueryParamBase(DataType eType);
184 private:
185 DataType const meType;
188 struct ScDBQueryParamInternal : public ScDBQueryParamBase, public ScQueryParamTable
190 ScDBQueryParamInternal();
191 virtual ~ScDBQueryParamInternal() override;
193 virtual bool IsValidFieldIndex() const override;
196 struct ScDBQueryParamMatrix final : public ScDBQueryParamBase
198 ScMatrixRef mpMatrix;
200 ScDBQueryParamMatrix();
201 virtual ~ScDBQueryParamMatrix() override;
203 virtual bool IsValidFieldIndex() const override;
206 #endif
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */