Line data Source code
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 :
16 66 : RefQueryFormulaGroup::RefQueryFormulaGroup() :
17 : SvtListener::QueryBase(SC_LISTENER_QUERY_FORMULA_GROUP_POS),
18 66 : maSkipRange(ScAddress::INITIALIZE_INVALID) {}
19 :
20 66 : RefQueryFormulaGroup::~RefQueryFormulaGroup() {}
21 :
22 66 : void RefQueryFormulaGroup::setSkipRange( const ScRange& rRange )
23 : {
24 66 : maSkipRange = rRange;
25 66 : }
26 :
27 52 : void RefQueryFormulaGroup::add( const ScAddress& rPos )
28 : {
29 52 : if (!rPos.IsValid())
30 0 : return;
31 :
32 52 : if (maSkipRange.IsValid() && maSkipRange.In(rPos))
33 : // This is within the skip range. Skip it.
34 0 : return;
35 :
36 52 : TabsType::iterator itTab = maTabs.find(rPos.Tab());
37 52 : if (itTab == maTabs.end())
38 : {
39 : std::pair<TabsType::iterator,bool> r =
40 10 : maTabs.insert(TabsType::value_type(rPos.Tab(), ColsType()));
41 10 : if (!r.second)
42 : // Insertion failed.
43 0 : return;
44 :
45 10 : itTab = r.first;
46 : }
47 :
48 52 : ColsType& rCols = itTab->second;
49 52 : ColsType::iterator itCol = rCols.find(rPos.Col());
50 52 : if (itCol == rCols.end())
51 : {
52 : std::pair<ColsType::iterator,bool> r =
53 10 : rCols.insert(ColsType::value_type(rPos.Col(), ColType()));
54 10 : if (!r.second)
55 : // Insertion failed.
56 0 : return;
57 :
58 10 : itCol = r.first;
59 : }
60 :
61 52 : ColType& rCol = itCol->second;
62 52 : rCol.push_back(rPos.Row());
63 : }
64 :
65 66 : const RefQueryFormulaGroup::TabsType& RefQueryFormulaGroup::getAllPositions() const
66 : {
67 66 : return maTabs;
68 : }
69 :
70 : }
71 :
72 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|