LibreOffice Module sc (master)  1
queryparam.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 http://mozilla.org/MPL/2.0/.
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 http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_SC_INC_QUERYPARAM_HXX
21 #define INCLUDED_SC_INC_QUERYPARAM_HXX
22 
23 #include <unotools/textsearch.hxx>
24 #include "address.hxx"
25 #include "types.hxx"
26 
27 #include <memory>
28 #include <vector>
29 #include <ostream>
30 
31 class SvNumberFormatter;
32 
34 struct ScQueryEntry;
35 
36 namespace svl {
37 
38 class SharedStringPool;
39 
40 }
41 
42 struct SAL_DLLPUBLIC_RTTI ScQueryParamBase
43 {
45  bool bHasHeader;
46  bool bByRow;
47  bool bInplace;
48  bool bCaseSens;
49  bool bDuplicate;
51 
52  virtual ~ScQueryParamBase();
53 
54  virtual bool IsValidFieldIndex() const;
55 
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 );
67 
68 protected:
69  typedef std::vector<std::unique_ptr<ScQueryEntry>> EntriesType;
70 
71 public:
72  typedef EntriesType::const_iterator const_iterator;
73 
74  const_iterator begin() const;
75  const_iterator end() const;
76 
77 protected:
80  ScQueryParamBase& operator=(const ScQueryParamBase& r);
81 
82  EntriesType m_Entries;
83 };
84 
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)
88 {
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  "}";
98 
99  return stream;
100 }
101 
102 struct SAL_DLLPUBLIC_RTTI ScQueryParamTable
103 {
109 
111  virtual ~ScQueryParamTable();
112 
113  ScQueryParamTable(ScQueryParamTable const &) = default;
114  ScQueryParamTable(ScQueryParamTable &&) = default;
115  ScQueryParamTable & operator =(ScQueryParamTable const &) = default;
116  ScQueryParamTable & operator =(ScQueryParamTable &&) = default;
117 };
118 
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)
122 {
123  stream << "{" <<
124  "col1=" << rParam.nCol1 <<
125  ",row1=" << rParam.nRow1 <<
126  ",col2=" << rParam.nCol2 <<
127  ",row2=" << rParam.nRow2 <<
128  ",tab=" << rParam.nTab <<
129  "}";
130 
131  return stream;
132 }
133 
135 {
136  bool bDestPers; // not saved
140 
141  ScQueryParam();
142  ScQueryParam( const ScQueryParam& );
144  virtual ~ScQueryParam() override;
145 
147  bool operator== ( const ScQueryParam& rOther ) const;
148  void Clear();
149  void ClearDestParams();
150  void MoveToDest();
151 };
152 
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)
156 {
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  "}";
165 
166  return stream;
167 }
168 
170 {
172 
175 
176  DataType GetType() const { return meType;}
177 
178  ScDBQueryParamBase() = delete;
179  virtual ~ScDBQueryParamBase() override;
180 
181 protected:
183 
184 private:
186 };
187 
189 {
191  virtual ~ScDBQueryParamInternal() override;
192 
193  virtual bool IsValidFieldIndex() const override;
194 };
195 
197 {
199 
201  virtual ~ScDBQueryParamMatrix() override;
202 
203  virtual bool IsValidFieldIndex() const override;
204 };
205 
206 #endif
207 
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)
Definition: xlstyle.cxx:517
DataType GetType() const
Definition: queryparam.hxx:176
virtual ~ScDBQueryParamInternal() override
Definition: queryparam.cxx:441
virtual ~ScDBQueryParamMatrix() override
Definition: queryparam.cxx:462
std::vector< std::unique_ptr< ScQueryEntry > > EntriesType
Definition: queryparam.hxx:69
enumrange< T >::Iterator begin(enumrange< T >)
DataType
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:45
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:24
ScMatrixRef mpMatrix
Definition: queryparam.hxx:198
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:26
EntriesType::const_iterator const_iterator
Definition: queryparam.hxx:72
EntriesType m_Entries
Definition: queryparam.hxx:82
virtual bool IsValidFieldIndex() const override
Definition: queryparam.cxx:455
sal_Int16 SCCOL
Definition: types.hxx:22
bool mbRangeLookup
for spreadsheet functions like MATCH, LOOKUP, HLOOKUP, VLOOKUP
Definition: queryparam.hxx:50
virtual ~ScDBQueryParamBase() override
Definition: queryparam.cxx:431
enumrange< T >::Iterator end(enumrange< T >)
Reference< XOutputStream > stream
ScQueryParamBase & operator=(const ScQueryParamBase &r)
Definition: queryparam.cxx:89
ScDBQueryParamBase()=delete
sal_Int32 SCROW
Definition: types.hxx:18
These need to be in global namespace just like their respective types are.
bool mbSkipString
the field in which the values are processed during iteration.
Definition: queryparam.hxx:174
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
Each instance of this struct represents a single filtering criteria.
Definition: queryentry.hxx:33
utl::SearchParam::SearchType eSearchType
Definition: queryparam.hxx:44
sal_Int16 SCTAB
Definition: types.hxx:23
virtual bool IsValidFieldIndex() const override
Definition: queryparam.cxx:445