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 #pragma once
21 
22 #include <unotools/textsearch.hxx>
23 #include "address.hxx"
24 #include "types.hxx"
25 
26 #include <memory>
27 #include <vector>
28 #include <ostream>
29 
30 class SvNumberFormatter;
31 
33 struct ScQueryEntry;
34 
35 namespace svl {
36 
37 class SharedStringPool;
38 
39 }
40 
41 struct SAL_DLLPUBLIC_RTTI ScQueryParamBase
42 {
44  bool bHasHeader;
45  bool bByRow;
46  bool bInplace;
47  bool bCaseSens;
48  bool bDuplicate;
50 
51  virtual ~ScQueryParamBase();
52 
53  virtual bool IsValidFieldIndex() const;
54 
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 );
66 
67 protected:
68  typedef std::vector<std::unique_ptr<ScQueryEntry>> EntriesType;
69 
70 public:
71  typedef EntriesType::const_iterator const_iterator;
72 
73  const_iterator begin() const;
74  const_iterator end() const;
75 
76 protected:
79  ScQueryParamBase& operator=(const ScQueryParamBase& r);
80 
81  EntriesType m_Entries;
82 };
83 
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)
87 {
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  "}";
97 
98  return stream;
99 }
100 
101 struct SAL_DLLPUBLIC_RTTI ScQueryParamTable
102 {
108 
110  virtual ~ScQueryParamTable();
111 
112  ScQueryParamTable(ScQueryParamTable const &) = default;
113  ScQueryParamTable(ScQueryParamTable &&) = default;
114  ScQueryParamTable & operator =(ScQueryParamTable const &) = default;
115  ScQueryParamTable & operator =(ScQueryParamTable &&) = default;
116 };
117 
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)
121 {
122  stream << "{" <<
123  "col1=" << rParam.nCol1 <<
124  ",row1=" << rParam.nRow1 <<
125  ",col2=" << rParam.nCol2 <<
126  ",row2=" << rParam.nRow2 <<
127  ",tab=" << rParam.nTab <<
128  "}";
129 
130  return stream;
131 }
132 
134 {
135  bool bDestPers; // not saved
139 
140  ScQueryParam();
141  ScQueryParam( const ScQueryParam& );
143  virtual ~ScQueryParam() override;
144 
146  bool operator== ( const ScQueryParam& rOther ) const;
147  void Clear();
148  void ClearDestParams();
149  void MoveToDest();
150 };
151 
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)
155 {
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  "}";
164 
165  return stream;
166 }
167 
169 {
171 
174 
175  DataType GetType() const { return meType;}
176 
177  ScDBQueryParamBase() = delete;
178  virtual ~ScDBQueryParamBase() override;
179 
180 protected:
182 
183 private:
185 };
186 
188 {
190  virtual ~ScDBQueryParamInternal() override;
191 
192  virtual bool IsValidFieldIndex() const override;
193 };
194 
196 {
198 
200  virtual ~ScDBQueryParamMatrix() override;
201 
202  virtual bool IsValidFieldIndex() const override;
203 };
204 
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)
Definition: xlstyle.cxx:518
DataType GetType() const
Definition: queryparam.hxx:175
virtual ~ScDBQueryParamInternal() override
Definition: queryparam.cxx:441
virtual ~ScDBQueryParamMatrix() override
Definition: queryparam.cxx:462
std::vector< std::unique_ptr< ScQueryEntry > > EntriesType
Definition: queryparam.hxx:68
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:44
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
ScMatrixRef mpMatrix
Definition: queryparam.hxx:197
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:25
EntriesType::const_iterator const_iterator
Definition: queryparam.hxx:71
EntriesType m_Entries
Definition: queryparam.hxx:81
virtual bool IsValidFieldIndex() const override
Definition: queryparam.cxx:455
sal_Int16 SCCOL
Definition: types.hxx:21
bool mbRangeLookup
for spreadsheet functions like MATCH, LOOKUP, HLOOKUP, VLOOKUP
Definition: queryparam.hxx:49
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:17
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:173
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
Each instance of this struct represents a single filtering criteria.
Definition: queryentry.hxx:32
utl::SearchParam::SearchType eSearchType
Definition: queryparam.hxx:43
sal_Int16 SCTAB
Definition: types.hxx:22
virtual bool IsValidFieldIndex() const override
Definition: queryparam.cxx:445