summaryrefslogtreecommitdiffstats
path: root/src/spreadsheet/formula_global.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:48:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:48:59 +0000
commitc484829272cd13a738e35412498e12f2c9a194ac (patch)
treea1f5ec09629ee895bd3963fa8820b45f2f4c574b /src/spreadsheet/formula_global.cpp
parentInitial commit. (diff)
downloadliborcus-upstream/0.19.2.tar.xz
liborcus-upstream/0.19.2.zip
Adding upstream version 0.19.2.upstream/0.19.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spreadsheet/formula_global.cpp')
-rw-r--r--src/spreadsheet/formula_global.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/spreadsheet/formula_global.cpp b/src/spreadsheet/formula_global.cpp
new file mode 100644
index 0000000..a4d7c6d
--- /dev/null
+++ b/src/spreadsheet/formula_global.cpp
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 "formula_global.hpp"
+
+#include <ixion/address.hpp>
+#include <ixion/formula_name_resolver.hpp>
+
+namespace orcus { namespace spreadsheet {
+
+ixion::abs_range_t to_abs_range(
+ const ixion::formula_name_resolver& resolver, const char* p_ref, size_t n_ref)
+{
+ ixion::abs_range_t range(ixion::abs_range_t::invalid);
+ ixion::abs_address_t pos(0,0,0);
+
+ ixion::formula_name_t res = resolver.resolve({p_ref, n_ref}, pos);
+ switch (res.type)
+ {
+ case ixion::formula_name_t::cell_reference:
+ // Single cell reference.
+ range.first = std::get<ixion::address_t>(res.value).to_abs(pos);
+ range.last = range.first;
+ break;
+ case ixion::formula_name_t::range_reference:
+ // Range reference.
+ range = std::get<ixion::range_t>(res.value).to_abs(pos);
+ break;
+ default:
+ ; // Unsupported range. Leave it invalid.
+ }
+
+ return range;
+}
+
+ixion::abs_range_t to_abs_range(const range_t& range, sheet_t sheet_pos)
+{
+ ixion::abs_range_t ret;
+ ret.first.column = range.first.column;
+ ret.first.row = range.first.row;
+ ret.first.sheet = sheet_pos;
+
+ ret.last.column = range.last.column;
+ ret.last.row = range.last.row;
+ ret.last.sheet = sheet_pos;
+
+ return ret;
+}
+
+}}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */