LibreOffice Module sc (master)  1
listenerquery.cxx
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 
10 #include <listenerquery.hxx>
11 #include <listenerqueryids.hxx>
12 #include <address.hxx>
13 
14 namespace sc {
15 
18  maSkipRange(ScAddress::INITIALIZE_INVALID) {}
19 
21 
23 {
24  maSkipRange = rRange;
25 }
26 
28 {
29  if (!rPos.IsValid())
30  return;
31 
32  if (maSkipRange.IsValid() && maSkipRange.In(rPos))
33  // This is within the skip range. Skip it.
34  return;
35 
36  TabsType::iterator itTab = maTabs.find(rPos.Tab());
37  if (itTab == maTabs.end())
38  {
39  std::pair<TabsType::iterator,bool> r =
40  maTabs.emplace(rPos.Tab(), ColsType());
41  if (!r.second)
42  // Insertion failed.
43  return;
44 
45  itTab = r.first;
46  }
47 
48  ColsType& rCols = itTab->second;
49  ColsType::iterator itCol = rCols.find(rPos.Col());
50  if (itCol == rCols.end())
51  {
52  std::pair<ColsType::iterator,bool> r =
53  rCols.emplace(rPos.Col(), ColType());
54  if (!r.second)
55  // Insertion failed.
56  return;
57 
58  itCol = r.first;
59  }
60 
61  ColType& rCol = itCol->second;
62  rCol.push_back(rPos.Row());
63 }
64 
66 {
67  return maTabs;
68 }
69 
72 {}
73 
75 {
76 }
77 
78 void QueryRange::add( const ScRange& rRange )
79 {
80  maRanges.Join(rRange);
81 }
82 
84 {
85  maRanges.swap(rRanges);
86 }
87 
88 }
89 
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unordered_map< SCTAB, ColsType > TabsType
SCROW Row() const
Definition: address.hxx:262
#define SC_LISTENER_QUERY_FORMULA_GROUP_POS
std::vector< SCROW > ColType
void add(const ScRange &rRange)
#define SC_LISTENER_QUERY_FORMULA_GROUP_RANGE
const TabsType & getAllPositions() const
Row positions in each column may contain duplicates.
void swap(ScRangeList &r)
Definition: rangelst.cxx:1151
SCTAB Tab() const
Definition: address.hxx:271
bool IsValid() const
Definition: address.hxx:293
void setSkipRange(const ScRange &rRange)
void swapRanges(ScRangeList &rRanges)
virtual ~QueryRange() override
bool In(const ScAddress &) const
is Address& in Range?
Definition: address.hxx:733
bool IsValid() const
Definition: address.hxx:547
SCCOL Col() const
Definition: address.hxx:267
std::unordered_map< SCCOL, ColType > ColsType
void Join(const ScRange &, bool bIsInList=false)
Definition: rangelst.cxx:166
ScRangeList maRanges
virtual ~RefQueryFormulaGroup() override
void add(const ScAddress &rPos)