check IFrame "FrameURL" target
[LibreOffice.git] / sc / inc / queryparam.hxx
blobe27399107f3f3be6f6795116f468b955f70a4e7a
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 #pragma once
22 #include <unotools/textsearch.hxx>
23 #include "address.hxx"
24 #include "types.hxx"
26 #include <memory>
27 #include <vector>
28 #include <ostream>
30 class SvNumberFormatter;
32 struct ScDBQueryParamInternal;
33 struct ScQueryEntry;
35 namespace svl {
37 class SharedStringPool;
41 struct SAL_DLLPUBLIC_RTTI ScQueryParamBase
43 utl::SearchParam::SearchType eSearchType;
44 bool bHasHeader;
45 bool bByRow;
46 bool bInplace;
47 bool bCaseSens;
48 bool bDuplicate;
49 bool mbRangeLookup; ///< for spreadsheet functions like MATCH, LOOKUP, HLOOKUP, VLOOKUP
51 virtual ~ScQueryParamBase();
53 virtual bool IsValidFieldIndex() const;
55 SC_DLLPUBLIC SCSIZE GetEntryCount() const;
56 SC_DLLPUBLIC const ScQueryEntry& GetEntry(SCSIZE n) const;
57 SC_DLLPUBLIC ScQueryEntry& GetEntry(SCSIZE n);
58 SC_DLLPUBLIC ScQueryEntry& AppendEntry();
59 ScQueryEntry* FindEntryByField(SCCOLROW nField, bool bNew);
60 std::vector<ScQueryEntry*> FindAllEntriesByField(SCCOLROW nField);
61 SC_DLLPUBLIC bool RemoveEntryByField(SCCOLROW nField);
62 SC_DLLPUBLIC void RemoveAllEntriesByField(SCCOLROW nField);
63 void Resize(size_t nNew);
64 void FillInExcelSyntax( svl::SharedStringPool& rPool, const OUString& aCellStr, SCSIZE nIndex,
65 SvNumberFormatter* pFormatter );
67 protected:
68 typedef std::vector<std::unique_ptr<ScQueryEntry>> EntriesType;
70 public:
71 typedef EntriesType::const_iterator const_iterator;
73 const_iterator begin() const;
74 const_iterator end() const;
76 protected:
77 ScQueryParamBase();
78 ScQueryParamBase(const ScQueryParamBase& r);
79 ScQueryParamBase& operator=(const ScQueryParamBase& r);
81 EntriesType m_Entries;
84 // For use in SAL_DEBUG etc. Output format not guaranteed to be stable.
85 template<typename charT, typename traits>
86 inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScQueryParamBase& rParam)
88 stream << "{" <<
89 "searchType=" << rParam.eSearchType <<
90 ",hasHeader=" << (rParam.bHasHeader?"YES":"NO") <<
91 ",byRow=" << (rParam.bByRow?"YES":"NO") <<
92 ",inplace=" << (rParam.bInplace?"YES":"NO") <<
93 ",caseSens=" << (rParam.bCaseSens?"YES":"NO") <<
94 ",duplicate=" << (rParam.bDuplicate?"YES":"NO") <<
95 ",rangeLookup=" << (rParam.mbRangeLookup?"YES":"NO") <<
96 "}";
98 return stream;
101 struct SAL_DLLPUBLIC_RTTI ScQueryParamTable
103 SCCOL nCol1;
104 SCROW nRow1;
105 SCCOL nCol2;
106 SCROW nRow2;
107 SCTAB nTab;
109 ScQueryParamTable();
110 virtual ~ScQueryParamTable();
112 ScQueryParamTable(ScQueryParamTable const &) = default;
113 ScQueryParamTable(ScQueryParamTable &&) = default;
114 ScQueryParamTable & operator =(ScQueryParamTable const &) = default;
115 ScQueryParamTable & operator =(ScQueryParamTable &&) = default;
118 // For use in SAL_DEBUG etc. Output format not guaranteed to be stable.
119 template<typename charT, typename traits>
120 inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScQueryParamTable& rParam)
122 stream << "{" <<
123 "col1=" << rParam.nCol1 <<
124 ",row1=" << rParam.nRow1 <<
125 ",col2=" << rParam.nCol2 <<
126 ",row2=" << rParam.nRow2 <<
127 ",tab=" << rParam.nTab <<
128 "}";
130 return stream;
133 struct SC_DLLPUBLIC ScQueryParam final : public ScQueryParamBase, public ScQueryParamTable
135 bool bDestPers; // not saved
136 SCTAB nDestTab;
137 SCCOL nDestCol;
138 SCROW nDestRow;
140 ScQueryParam();
141 ScQueryParam( const ScQueryParam& );
142 ScQueryParam( const ScDBQueryParamInternal& r );
143 virtual ~ScQueryParam() override;
145 ScQueryParam& operator= ( const ScQueryParam& );
146 bool operator== ( const ScQueryParam& rOther ) const;
147 void Clear();
148 void ClearDestParams();
149 void MoveToDest();
152 // For use in SAL_DEBUG etc. Output format not guaranteed to be stable.
153 template<typename charT, typename traits>
154 inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScQueryParam& rParam)
156 stream << "{" <<
157 "base=" << *static_cast<const ScQueryParamBase*>(&rParam) <<
158 ",table=" << *static_cast<const ScQueryParamTable*>(&rParam) <<
159 ",destPers=" << (rParam.bDestPers?"YES":"NO") <<
160 ",destTab=" << rParam.nDestTab <<
161 ",destCol=" << rParam.nDestCol <<
162 ",destRow=" << rParam.nDestRow <<
163 "}";
165 return stream;
168 struct ScDBQueryParamBase : public ScQueryParamBase
170 enum DataType { INTERNAL, MATRIX };
172 SCCOL mnField; /// the field in which the values are processed during iteration.
173 bool mbSkipString;
175 DataType GetType() const { return meType;}
177 ScDBQueryParamBase() = delete;
178 virtual ~ScDBQueryParamBase() override;
180 protected:
181 ScDBQueryParamBase(DataType eType);
183 private:
184 DataType meType;
187 struct ScDBQueryParamInternal final : public ScDBQueryParamBase, public ScQueryParamTable
189 ScDBQueryParamInternal();
190 virtual ~ScDBQueryParamInternal() override;
192 virtual bool IsValidFieldIndex() const override;
195 struct ScDBQueryParamMatrix final : public ScDBQueryParamBase
197 ScMatrixRef mpMatrix;
199 ScDBQueryParamMatrix();
200 virtual ~ScDBQueryParamMatrix() override;
202 virtual bool IsValidFieldIndex() const override;
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */