Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : */
9 :
10 : #ifndef INCLUDED_FORMULA_VECTORTOKEN_HXX
11 : #define INCLUDED_FORMULA_VECTORTOKEN_HXX
12 :
13 : #include <formula/token.hxx>
14 :
15 : namespace formula {
16 :
17 : /**
18 : * Single unit of vector reference consists of two physical arrays.
19 : *
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
22 : * cells.</p>
23 : *
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
26 : * cells.</p>
27 : *
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>
34 : */
35 : struct FORMULA_DLLPUBLIC VectorRefArray
36 : {
37 : const double* mpNumericArray;
38 : rtl_uString** mpStringArray;
39 :
40 : VectorRefArray();
41 : VectorRefArray( const double* pArray );
42 : VectorRefArray( rtl_uString** pArray );
43 : VectorRefArray( const double* pNumArray, rtl_uString** pStrArray );
44 :
45 : bool isValid() const;
46 : };
47 :
48 : /**
49 : * This token represents a single cell reference in a vectorized formula
50 : * calculation context.
51 : */
52 0 : class FORMULA_DLLPUBLIC SingleVectorRefToken : public FormulaToken
53 : {
54 : VectorRefArray maArray;
55 : size_t mnRequestedLength;
56 : size_t mnArrayLength;
57 :
58 : public:
59 : SingleVectorRefToken( const VectorRefArray& rArray, size_t nReqLength, size_t nArrayLength );
60 :
61 : virtual FormulaToken* Clone() const SAL_OVERRIDE;
62 :
63 0 : inline const VectorRefArray& GetArray() const { return maArray; }
64 0 : inline size_t GetArrayLength() const { return mnArrayLength; }
65 : };
66 :
67 : /**
68 : * This token represents a range reference in a vectorized formula
69 : * calculation context.
70 : */
71 0 : class FORMULA_DLLPUBLIC DoubleVectorRefToken : public FormulaToken
72 : {
73 : std::vector<VectorRefArray> maArrays;
74 :
75 : size_t mnRequestedLength; /// requested length of all arrays which include trailing empty region.
76 : size_t mnArrayLength; /// length of all arrays which does not include trailing empty region.
77 : size_t mnRefRowSize; /// original reference row size. The row size may
78 : /// change as it goes down the array if either the
79 : /// stard or end position is fixed.
80 :
81 : bool mbStartFixed:1; /// whether or not the start row position is absolute.
82 : bool mbEndFixed:1; /// whether or not the end row position is absolute.
83 :
84 : public:
85 : DoubleVectorRefToken(
86 : const std::vector<VectorRefArray>& rArrays, size_t nReqLength, size_t nArrayLength,
87 : size_t nRefRowSize, bool bStartFixed, bool bEndFixed );
88 :
89 : virtual FormulaToken* Clone() const SAL_OVERRIDE;
90 :
91 0 : inline const std::vector<VectorRefArray>& GetArrays() const { return maArrays; }
92 0 : inline size_t GetArrayLength() const { return mnArrayLength; }
93 0 : inline size_t GetRefRowSize() const { return mnRefRowSize; }
94 0 : inline bool IsStartFixed() const { return mbStartFixed; }
95 0 : inline bool IsEndFixed() const { return mbEndFixed; }
96 : };
97 :
98 : }
99 :
100 : #endif
101 :
102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|