summaryrefslogtreecommitdiffstats
path: root/include/formula/vectortoken.hxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /include/formula/vectortoken.hxx
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.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 'include/formula/vectortoken.hxx')
-rw-r--r--include/formula/vectortoken.hxx110
1 files changed, 110 insertions, 0 deletions
diff --git a/include/formula/vectortoken.hxx b/include/formula/vectortoken.hxx
new file mode 100644
index 000000000..046d71faf
--- /dev/null
+++ b/include/formula/vectortoken.hxx
@@ -0,0 +1,110 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_FORMULA_VECTORTOKEN_HXX
+#define INCLUDED_FORMULA_VECTORTOKEN_HXX
+
+#include <cstddef>
+#include <vector>
+
+#include <formula/formuladllapi.h>
+#include <formula/token.hxx>
+#include <rtl/ustring.h>
+
+namespace formula {
+
+/**
+ * Single unit of vector reference consists of two physical arrays.
+ *
+ * <p>If the whole data array consists of only numeric values, mpStringArray
+ * will be NULL, and NaN values in the numeric array represent empty
+ * cells.</p>
+ *
+ * <p>If the whole data array consists of only string values, mpNumericArray
+ * will be NULL, and NULL values in the string array represent empty
+ * cells.</p>
+ *
+ * <p>If the data array consists of numeric and string values, then both
+ * mpNumericArray and mpStringArray will be non-NULL, and a string cell will
+ * be represented by a non-NULL pointer value in the string array. If the
+ * string value is NULL, check the corresponding value in the numeric array.
+ * If the value in the numeric array is NaN, it's an empty cell, otherwise
+ * it's a numeric cell.</p>
+ */
+struct FORMULA_DLLPUBLIC VectorRefArray
+{
+ enum InitInvalid { Invalid };
+
+ const double* mpNumericArray;
+ rtl_uString** mpStringArray;
+
+ bool mbValid;
+
+ VectorRefArray();
+ VectorRefArray( InitInvalid );
+ VectorRefArray( const double* pArray );
+ VectorRefArray( rtl_uString** pArray );
+ VectorRefArray( const double* pNumArray, rtl_uString** pStrArray );
+
+ bool isValid() const;
+};
+
+/**
+ * This token represents a single cell reference in a vectorized formula
+ * calculation context.
+ */
+class FORMULA_DLLPUBLIC SingleVectorRefToken final : public FormulaToken
+{
+ VectorRefArray maArray;
+ size_t mnArrayLength;
+
+public:
+ SingleVectorRefToken( const VectorRefArray& rArray, size_t nArrayLength );
+
+ virtual FormulaToken* Clone() const override;
+
+ const VectorRefArray& GetArray() const;
+ size_t GetArrayLength() const;
+};
+
+/**
+ * This token represents a range reference in a vectorized formula
+ * calculation context.
+ */
+class FORMULA_DLLPUBLIC DoubleVectorRefToken final : public FormulaToken
+{
+ std::vector<VectorRefArray> maArrays;
+
+ size_t mnArrayLength; /// length of all arrays which does not include trailing empty region.
+ size_t mnRefRowSize; /// original reference row size. The row size may
+ /// change as it goes down the array if either the
+ /// start or end position is fixed.
+
+ bool mbStartFixed:1; /// whether or not the start row position is absolute.
+ bool mbEndFixed:1; /// whether or not the end row position is absolute.
+
+public:
+ DoubleVectorRefToken(
+ std::vector<VectorRefArray>&& rArrays, size_t nArrayLength,
+ size_t nRefRowSize, bool bStartFixed, bool bEndFixed );
+
+ virtual FormulaToken* Clone() const override;
+
+ const std::vector<VectorRefArray>& GetArrays() const;
+ size_t GetArrayLength() const;
+ size_t GetRefRowSize() const;
+ bool IsStartFixed() const;
+ bool IsEndFixed() const;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */