diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /sc/source/core/tool/listenerquery.cxx | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/source/core/tool/listenerquery.cxx')
-rw-r--r-- | sc/source/core/tool/listenerquery.cxx | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/sc/source/core/tool/listenerquery.cxx b/sc/source/core/tool/listenerquery.cxx new file mode 100644 index 000000000..10cebdd42 --- /dev/null +++ b/sc/source/core/tool/listenerquery.cxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <listenerquery.hxx> +#include <listenerqueryids.hxx> +#include <address.hxx> + +namespace sc { + +RefQueryFormulaGroup::RefQueryFormulaGroup() : + SvtListener::QueryBase(SC_LISTENER_QUERY_FORMULA_GROUP_POS), + maSkipRange(ScAddress::INITIALIZE_INVALID) {} + +RefQueryFormulaGroup::~RefQueryFormulaGroup() {} + +void RefQueryFormulaGroup::setSkipRange( const ScRange& rRange ) +{ + maSkipRange = rRange; +} + +void RefQueryFormulaGroup::add( const ScAddress& rPos ) +{ + if (!rPos.IsValid()) + return; + + if (maSkipRange.IsValid() && maSkipRange.Contains(rPos)) + // This is within the skip range. Skip it. + return; + + TabsType::iterator itTab = maTabs.find(rPos.Tab()); + if (itTab == maTabs.end()) + { + std::pair<TabsType::iterator,bool> r = + maTabs.emplace(rPos.Tab(), ColsType()); + if (!r.second) + // Insertion failed. + return; + + itTab = r.first; + } + + ColsType& rCols = itTab->second; + ColsType::iterator itCol = rCols.find(rPos.Col()); + if (itCol == rCols.end()) + { + std::pair<ColsType::iterator,bool> r = + rCols.emplace(rPos.Col(), ColType()); + if (!r.second) + // Insertion failed. + return; + + itCol = r.first; + } + + ColType& rCol = itCol->second; + rCol.push_back(rPos.Row()); +} + +const RefQueryFormulaGroup::TabsType& RefQueryFormulaGroup::getAllPositions() const +{ + return maTabs; +} + +QueryRange::QueryRange() : + SvtListener::QueryBase(SC_LISTENER_QUERY_FORMULA_GROUP_RANGE) +{} + +QueryRange::~QueryRange() +{ +} + +void QueryRange::add( const ScRange& rRange ) +{ + maRanges.Join(rRange); +} + +void QueryRange::swapRanges( ScRangeList& rRanges ) +{ + maRanges.swap(rRanges); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |