From c484829272cd13a738e35412498e12f2c9a194ac Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:48:59 +0200 Subject: Adding upstream version 0.19.2. Signed-off-by: Daniel Baumann --- src/spreadsheet/formula_global.cpp | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/spreadsheet/formula_global.cpp (limited to 'src/spreadsheet/formula_global.cpp') 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 +#include + +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(res.value).to_abs(pos); + range.last = range.first; + break; + case ixion::formula_name_t::range_reference: + // Range reference. + range = std::get(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: */ -- cgit v1.2.3