1 | /* Copyright (C) 2011 Jan Källman
|
---|
2 | *
|
---|
3 | * This library is free software; you can redistribute it and/or
|
---|
4 | * modify it under the terms of the GNU Lesser General Public
|
---|
5 | * License as published by the Free Software Foundation; either
|
---|
6 | * version 2.1 of the License, or (at your option) any later version.
|
---|
7 |
|
---|
8 | * This library is distributed in the hope that it will be useful,
|
---|
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
11 | * See the GNU Lesser General Public License for more details.
|
---|
12 | *
|
---|
13 | * The GNU Lesser General Public License can be viewed at http://www.opensource.org/licenses/lgpl-license.php
|
---|
14 | * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
|
---|
15 | *
|
---|
16 | * All code and executables are provided "as is" with no warranty either express or implied.
|
---|
17 | * The author accepts no liability for any damage or loss of business that this product may cause.
|
---|
18 | *
|
---|
19 | * Code change notes:
|
---|
20 | *
|
---|
21 | * Author Change Date
|
---|
22 | *******************************************************************************
|
---|
23 | * Mats Alm Added 2013-12-03
|
---|
24 | *******************************************************************************/
|
---|
25 | using System;
|
---|
26 | using System.Collections.Generic;
|
---|
27 | using System.Linq;
|
---|
28 | using System.Text;
|
---|
29 |
|
---|
30 | namespace OfficeOpenXml.FormulaParsing.Excel.Functions
|
---|
31 | {
|
---|
32 | public class FunctionArgument
|
---|
33 | {
|
---|
34 | public FunctionArgument(object val)
|
---|
35 | {
|
---|
36 | Value = val;
|
---|
37 | }
|
---|
38 |
|
---|
39 | private ExcelCellState _excelCellState;
|
---|
40 |
|
---|
41 | public void SetExcelStateFlag(ExcelCellState state)
|
---|
42 | {
|
---|
43 | _excelCellState |= state;
|
---|
44 | }
|
---|
45 |
|
---|
46 | public bool ExcelStateFlagIsSet(ExcelCellState state)
|
---|
47 | {
|
---|
48 | return (_excelCellState & state) != 0;
|
---|
49 | }
|
---|
50 |
|
---|
51 | public object Value { get; private set; }
|
---|
52 |
|
---|
53 | public Type Type
|
---|
54 | {
|
---|
55 | get { return Value != null ? Value.GetType() : null; }
|
---|
56 | }
|
---|
57 |
|
---|
58 | public bool IsExcelRange
|
---|
59 | {
|
---|
60 | get { return Value != null && Value is EpplusExcelDataProvider.IRangeInfo; }
|
---|
61 | }
|
---|
62 |
|
---|
63 | public bool ValueIsExcelError
|
---|
64 | {
|
---|
65 | get { return ExcelErrorValue.Values.IsErrorValue(Value); }
|
---|
66 | }
|
---|
67 |
|
---|
68 | public ExcelErrorValue ValueAsExcelErrorValue
|
---|
69 | {
|
---|
70 | get { return ExcelErrorValue.Parse(Value.ToString()); }
|
---|
71 | }
|
---|
72 |
|
---|
73 | public EpplusExcelDataProvider.IRangeInfo ValueAsRangeInfo
|
---|
74 | {
|
---|
75 | get { return Value as EpplusExcelDataProvider.IRangeInfo; }
|
---|
76 | }
|
---|
77 | public object ValueFirst
|
---|
78 | {
|
---|
79 | get
|
---|
80 | {
|
---|
81 | if (Value is ExcelDataProvider.INameInfo)
|
---|
82 | {
|
---|
83 | Value = ((ExcelDataProvider.INameInfo)Value).Value;
|
---|
84 | }
|
---|
85 | var v = Value as ExcelDataProvider.IRangeInfo;
|
---|
86 | if (v==null)
|
---|
87 | {
|
---|
88 | return Value;
|
---|
89 | }
|
---|
90 | else
|
---|
91 | {
|
---|
92 | return v.GetValue(v.Address._fromRow, v.Address._fromCol);
|
---|
93 | }
|
---|
94 | }
|
---|
95 | }
|
---|
96 |
|
---|
97 | }
|
---|
98 | }
|
---|