1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #ifndef INCLUDED_FORMULA_VECTORTOKEN_HXX
11 #define INCLUDED_FORMULA_VECTORTOKEN_HXX
13 #include <formula/token.hxx>
18 * Single unit of vector reference consists of two physical arrays.
20 * <p>If the whole data array consists of only numeric values, mpStringArray
21 * will be NULL, and NaN values in the numeric array represent empty
24 * <p>If the whole data array consists of only string values, mpNumericArray
25 * will be NULL, and NULL values in the string array represent empty
28 * <p>If the data array consists of numeric and string values, then both
29 * mpNumericArray and mpStringArray will be non-NULL, and a string cell will
30 * be represented by a non-NULL pointer value in the string array. If the
31 * string value is NULL, check the corresponding value in the numeric array.
32 * If the value in the numeric array is NaN, it's an empty cell, otherwise
33 * it's a numeric cell.</p>
35 struct FORMULA_DLLPUBLIC VectorRefArray
37 enum InitInvalid
{ Invalid
};
39 const double* mpNumericArray
;
40 rtl_uString
** mpStringArray
;
45 VectorRefArray( InitInvalid
);
46 VectorRefArray( const double* pArray
);
47 VectorRefArray( rtl_uString
** pArray
);
48 VectorRefArray( const double* pNumArray
, rtl_uString
** pStrArray
);
54 * This token represents a single cell reference in a vectorized formula
55 * calculation context.
57 class FORMULA_DLLPUBLIC SingleVectorRefToken
: public FormulaToken
59 VectorRefArray maArray
;
60 size_t mnRequestedLength
;
64 SingleVectorRefToken( const VectorRefArray
& rArray
, size_t nReqLength
, size_t nArrayLength
);
66 virtual FormulaToken
* Clone() const SAL_OVERRIDE
;
68 inline const VectorRefArray
& GetArray() const { return maArray
; }
69 inline size_t GetArrayLength() const { return mnArrayLength
; }
73 * This token represents a range reference in a vectorized formula
74 * calculation context.
76 class FORMULA_DLLPUBLIC DoubleVectorRefToken
: public FormulaToken
78 std::vector
<VectorRefArray
> maArrays
;
80 size_t mnRequestedLength
; /// requested length of all arrays which include trailing empty region.
81 size_t mnArrayLength
; /// length of all arrays which does not include trailing empty region.
82 size_t mnRefRowSize
; /// original reference row size. The row size may
83 /// change as it goes down the array if either the
84 /// stard or end position is fixed.
86 bool mbStartFixed
:1; /// whether or not the start row position is absolute.
87 bool mbEndFixed
:1; /// whether or not the end row position is absolute.
91 const std::vector
<VectorRefArray
>& rArrays
, size_t nReqLength
, size_t nArrayLength
,
92 size_t nRefRowSize
, bool bStartFixed
, bool bEndFixed
);
94 virtual FormulaToken
* Clone() const SAL_OVERRIDE
;
96 inline const std::vector
<VectorRefArray
>& GetArrays() const { return maArrays
; }
97 inline size_t GetArrayLength() const { return mnArrayLength
; }
98 inline size_t GetRefRowSize() const { return mnRefRowSize
; }
99 inline bool IsStartFixed() const { return mbStartFixed
; }
100 inline bool IsEndFixed() const { return mbEndFixed
; }
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */