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 : enum InitInvalid { Invalid };
38 :
39 : const double* mpNumericArray;
40 : rtl_uString** mpStringArray;
41 :
42 : bool mbValid;
43 :
44 : VectorRefArray();
45 : VectorRefArray( InitInvalid );
46 : VectorRefArray( const double* pArray );
47 : VectorRefArray( rtl_uString** pArray );
48 : VectorRefArray( const double* pNumArray, rtl_uString** pStrArray );
49 :
50 : bool isValid() const;
51 : };
52 :
53 : /**
54 : * This token represents a single cell reference in a vectorized formula
55 : * calculation context.
56 : */
57 6 : class FORMULA_DLLPUBLIC SingleVectorRefToken : public FormulaToken
58 : {
59 : VectorRefArray maArray;
60 : size_t mnRequestedLength;
61 : size_t mnArrayLength;
62 :
63 : public:
64 : SingleVectorRefToken( const VectorRefArray& rArray, size_t nReqLength, size_t nArrayLength );
65 :
66 : virtual FormulaToken* Clone() const SAL_OVERRIDE;
67 :
68 : const VectorRefArray& GetArray() const;
69 : size_t GetArrayLength() const;
70 : };
71 :
72 : /**
73 : * This token represents a range reference in a vectorized formula
74 : * calculation context.
75 : */
76 0 : class FORMULA_DLLPUBLIC DoubleVectorRefToken : public FormulaToken
77 : {
78 : std::vector<VectorRefArray> maArrays;
79 :
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.
85 :
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.
88 :
89 : public:
90 : DoubleVectorRefToken(
91 : const std::vector<VectorRefArray>& rArrays, size_t nReqLength, size_t nArrayLength,
92 : size_t nRefRowSize, bool bStartFixed, bool bEndFixed );
93 :
94 : virtual FormulaToken* Clone() const SAL_OVERRIDE;
95 :
96 : const std::vector<VectorRefArray>& GetArrays() const;
97 : size_t GetArrayLength() const;
98 : size_t GetRefRowSize() const;
99 : bool IsStartFixed() const;
100 : bool IsEndFixed() const;
101 : };
102 :
103 : }
104 :
105 : #endif
106 :
107 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|