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 .
22 #include <unotools/textsearch.hxx>
23 #include "address.hxx"
30 class SvNumberFormatter
;
32 struct ScDBQueryParamInternal
;
37 class SharedStringPool
;
41 struct SAL_DLLPUBLIC_RTTI ScQueryParamBase
43 utl::SearchParam::SearchType eSearchType
;
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
);
68 typedef std::vector
<std::unique_ptr
<ScQueryEntry
>> EntriesType
;
71 typedef EntriesType::const_iterator const_iterator
;
73 const_iterator
begin() const;
74 const_iterator
end() const;
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
)
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") <<
101 struct SAL_DLLPUBLIC_RTTI 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
)
123 "col1=" << rParam
.nCol1
<<
124 ",row1=" << rParam
.nRow1
<<
125 ",col2=" << rParam
.nCol2
<<
126 ",row2=" << rParam
.nRow2
<<
127 ",tab=" << rParam
.nTab
<<
133 struct SC_DLLPUBLIC ScQueryParam final
: public ScQueryParamBase
, public ScQueryParamTable
135 bool bDestPers
; // not saved
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;
148 void ClearDestParams();
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
)
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
<<
168 struct ScDBQueryParamBase
: public ScQueryParamBase
170 enum DataType
{ INTERNAL
, MATRIX
};
172 SCCOL mnField
; /// the field in which the values are processed during iteration.
175 DataType
GetType() const { return meType
;}
177 ScDBQueryParamBase() = delete;
178 virtual ~ScDBQueryParamBase() override
;
181 ScDBQueryParamBase(DataType eType
);
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: */