LibreOffice Module sc (master)
1
sc
inc
formularesult.hxx
Go to the documentation of this file.
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
* This file incorporates work covered by the following license notice:
10
*
11
* Licensed to the Apache Software Foundation (ASF) under one or more
12
* contributor license agreements. See the NOTICE file distributed
13
* with this work for additional information regarding copyright
14
* ownership. The ASF licenses this file to you under the Apache
15
* License, Version 2.0 (the "License"); you may not use this file
16
* except in compliance with the License. You may obtain a copy of
17
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
*/
19
20
#pragma once
21
22
#include "
global.hxx
"
23
#include "
calcmacros.hxx
"
24
#include <
svl/sharedstring.hxx
>
25
#include <
formula/token.hxx
>
26
#include <
formula/types.hxx
>
27
28
class
ScMatrixFormulaCellToken
;
29
30
namespace
sc
{
31
32
struct
FormulaResultValue
33
{
34
enum
Type
:
sal_uInt8
{
Invalid
,
Value
,
String
,
Error
};
35
36
double
mfValue
;
37
svl::SharedString
maString
;
38
bool
mbMultiLine
=
false
;
39
Type
meType
;
40
FormulaError
mnError
;
41
42
FormulaResultValue
();
43
FormulaResultValue
(
double
fValue );
44
FormulaResultValue
(
svl::SharedString
aStr,
bool
bMultiLine );
45
FormulaResultValue
(
FormulaError
nErr );
46
};
47
48
}
49
52
class
ScFormulaResult
53
{
54
typedef
unsigned
char
Multiline
;
55
static
const
Multiline
MULTILINE_UNKNOWN
= 0;
56
static
const
Multiline
MULTILINE_FALSE
= 1;
57
static
const
Multiline
MULTILINE_TRUE
= 2;
58
59
union
60
{
61
double
mfValue
;
// double result direct for performance and memory consumption
62
const
formula::FormulaToken
*
mpToken
;
// if not, result token obtained from interpreter
63
};
64
bool
mbToken
:1;
// whether content of union is a token
65
bool
mbEmpty
:1;
// empty cell result
66
bool
mbEmptyDisplayedAsString
:1;
// only if mbEmpty
67
// If set it implies that the result is a simple double (in mfValue) and no error
68
bool
mbValueCached
:1;
69
Multiline
meMultiline
:2;
// result is multiline
70
FormulaError
mnError
;
// error code
71
74
void
ResetToDefaults
();
75
87
void
ResolveToken
(
const
formula::FormulaToken
* p );
88
89
public
:
91
ScFormulaResult
();
92
93
ScFormulaResult
(
const
ScFormulaResult
& r );
94
96
explicit
ScFormulaResult
(
const
formula::FormulaToken
* p );
97
98
~ScFormulaResult
();
99
101
ScFormulaResult
&
operator=
(
const
ScFormulaResult
& r );
102
104
void
Assign
(
const
ScFormulaResult
& r );
105
114
void
SetToken
(
const
formula::FormulaToken
* p );
115
117
formula::FormulaConstTokenRef
GetToken
()
const
;
118
121
formula::FormulaConstTokenRef
GetCellResultToken
()
const
;
122
125
formula::StackVar
GetType
()
const
;
126
129
formula::StackVar
GetCellResultType
()
const
;
130
133
bool
IsEmptyDisplayedAsString
()
const
;
134
141
bool
IsValue
()
const
;
142
143
bool
IsValueNoError
()
const
;
144
147
bool
IsMultiline
()
const
;
148
149
bool
GetErrorOrDouble
(
FormulaError
& rErr,
double
& rVal )
const
;
150
sc::FormulaResultValue
GetResult
()
const
;
151
154
FormulaError
GetResultError
()
const
;
155
157
void
SetResultError
(
FormulaError
nErr );
158
166
void
SetDouble
(
double
f );
167
170
double
GetDouble
()
const
;
171
174
const
svl::SharedString
&
GetString
()
const
;
175
177
ScConstMatrixRef
GetMatrix
()
const
;
178
180
OUString
GetHybridFormula
()
const
;
181
185
void
SetHybridDouble
(
double
f );
186
190
void
SetHybridString
(
const
svl::SharedString
& rStr );
191
195
void
SetHybridEmptyDisplayedAsString
();
196
200
void
SetHybridFormula
(
const
OUString & rFormula );
201
202
void
SetMatrix
(
SCCOL
nCols,
SCROW
nRows,
const
ScConstMatrixRef
& pMat,
const
formula::FormulaToken
* pUL );
203
206
const
ScMatrixFormulaCellToken
*
GetMatrixFormulaCellToken
()
const
;
207
210
ScMatrixFormulaCellToken
*
GetMatrixFormulaCellTokenNonConst
();
211
};
212
213
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
calcmacros.hxx
ScFormulaResult
Store a variable formula cell result, balancing between runtime performance and memory consumption.
Definition:
formularesult.hxx:53
ScFormulaResult::MULTILINE_TRUE
static const Multiline MULTILINE_TRUE
Definition:
formularesult.hxx:57
ScFormulaResult::SetDouble
void SetDouble(double f)
Set direct double.
Definition:
formularesult.cxx:225
ScFormulaResult::GetMatrixFormulaCellToken
const ScMatrixFormulaCellToken * GetMatrixFormulaCellToken() const
Get the const ScMatrixFormulaCellToken* if token is of that type, else NULL.
Definition:
formularesult.cxx:630
ScFormulaResult::ResetToDefaults
void ResetToDefaults()
Reset mnError, mbEmpty and mbEmptyDisplayedAsString to their defaults prior to assigning other types.
Definition:
formularesult.cxx:80
ScFormulaResult::mfValue
double mfValue
Definition:
formularesult.hxx:61
ScFormulaResult::SetHybridDouble
void SetHybridDouble(double f)
Should only be used by import filters, best in the order SetHybridDouble(), SetHybridString(),...
Definition:
formularesult.cxx:552
ScFormulaResult::SetResultError
void SetResultError(FormulaError nErr)
Set error code, don't touch token or double.
Definition:
formularesult.cxx:454
ScFormulaResult::GetMatrixFormulaCellTokenNonConst
ScMatrixFormulaCellToken * GetMatrixFormulaCellTokenNonConst()
Get the ScMatrixFormulaCellToken* if token is of that type, else NULL.
Definition:
formularesult.cxx:636
ScFormulaResult::meMultiline
Multiline meMultiline
Definition:
formularesult.hxx:69
ScFormulaResult::operator=
ScFormulaResult & operator=(const ScFormulaResult &r)
Well, guess what ...
Definition:
formularesult.cxx:134
ScFormulaResult::mbEmptyDisplayedAsString
bool mbEmptyDisplayedAsString
Definition:
formularesult.hxx:66
ScFormulaResult::GetToken
formula::FormulaConstTokenRef GetToken() const
May be NULL if SetToken() did so, also if type formula::svDouble or formula::svError!
Definition:
formularesult.cxx:461
ScFormulaResult::MULTILINE_FALSE
static const Multiline MULTILINE_FALSE
Definition:
formularesult.hxx:56
ScFormulaResult::SetToken
void SetToken(const formula::FormulaToken *p)
Sets a direct double if token type is formula::svDouble, or mbEmpty if formula::svEmptyCell,...
Definition:
formularesult.cxx:177
ScFormulaResult::MULTILINE_UNKNOWN
static const Multiline MULTILINE_UNKNOWN
Definition:
formularesult.hxx:55
ScFormulaResult::mpToken
const formula::FormulaToken * mpToken
Definition:
formularesult.hxx:62
ScFormulaResult::ScFormulaResult
ScFormulaResult()
Effectively type svUnknown.
Definition:
formularesult.cxx:26
ScFormulaResult::Multiline
unsigned char Multiline
Definition:
formularesult.hxx:54
ScFormulaResult::mbValueCached
bool mbValueCached
Definition:
formularesult.hxx:68
ScFormulaResult::GetMatrix
ScConstMatrixRef GetMatrix() const
Return matrix if type formula::svMatrixCell and ScMatrix present, else NULL.
Definition:
formularesult.cxx:535
ScFormulaResult::GetCellResultToken
formula::FormulaConstTokenRef GetCellResultToken() const
Return upper left token if formula::svMatrixCell, else return GetToken().
Definition:
formularesult.cxx:468
ScFormulaResult::GetDouble
double GetDouble() const
Return value if type formula::svDouble or formula::svHybridCell or formula::svMatrixCell and upper le...
Definition:
formularesult.cxx:476
ScFormulaResult::IsEmptyDisplayedAsString
bool IsEmptyDisplayedAsString() const
If type is formula::svEmptyCell (including matrix upper left) and should be displayed as empty string...
Definition:
formularesult.cxx:267
ScFormulaResult::SetHybridEmptyDisplayedAsString
void SetHybridEmptyDisplayedAsString()
Should only be used by import filters, best in the order SetHybridDouble(), SetHybridFormula(),...
Definition:
formularesult.cxx:590
ScFormulaResult::GetErrorOrDouble
bool GetErrorOrDouble(FormulaError &rErr, double &rVal) const
Definition:
formularesult.cxx:357
ScFormulaResult::SetHybridString
void SetHybridString(const svl::SharedString &rStr)
Should only be used by import filters, best in the order SetHybridDouble(), SetHybridString()/SetHybr...
Definition:
formularesult.cxx:577
ScFormulaResult::ResolveToken
void ResolveToken(const formula::FormulaToken *p)
If token is of formula::svError set error code and decrement RefCount.
Definition:
formularesult.cxx:89
ScFormulaResult::GetString
const svl::SharedString & GetString() const
Return string if type formula::svString or formula::svHybridCell or formula::svMatrixCell and upper l...
Definition:
formularesult.cxx:511
ScFormulaResult::IsValueNoError
bool IsValueNoError() const
Definition:
formularesult.cxx:332
ScFormulaResult::GetType
formula::StackVar GetType() const
Return type of result, including formula::svError, formula::svEmptyCell, formula::svDouble and formul...
Definition:
formularesult.cxx:244
ScFormulaResult::mbToken
bool mbToken
Definition:
formularesult.hxx:64
ScFormulaResult::SetHybridFormula
void SetHybridFormula(const OUString &rFormula)
Should only be used by import filters, best in the order SetHybridDouble(), SetHybridString()/SetHybr...
Definition:
formularesult.cxx:607
ScFormulaResult::IsMultiline
bool IsMultiline() const
Determines whether or not the result is a string containing more than one paragraph.
Definition:
formularesult.cxx:344
ScFormulaResult::~ScFormulaResult
~ScFormulaResult()
Definition:
formularesult.cxx:74
ScFormulaResult::SetMatrix
void SetMatrix(SCCOL nCols, SCROW nRows, const ScConstMatrixRef &pMat, const formula::FormulaToken *pUL)
Definition:
formularesult.cxx:620
ScFormulaResult::IsValue
bool IsValue() const
Test for cell result type formula::svDouble, including upper left if formula::svMatrixCell.
Definition:
formularesult.cxx:324
ScFormulaResult::GetHybridFormula
OUString GetHybridFormula() const
Return formula string if type formula::svHybridCell, else empty string.
Definition:
formularesult.cxx:542
ScFormulaResult::Assign
void Assign(const ScFormulaResult &r)
Assignment as in operator=() but without return.
Definition:
formularesult.cxx:140
ScFormulaResult::GetCellResultType
formula::StackVar GetCellResultType() const
If type is formula::svMatrixCell return the type of upper left element, else GetType()
Definition:
formularesult.cxx:258
ScFormulaResult::mnError
FormulaError mnError
Definition:
formularesult.hxx:70
ScFormulaResult::mbEmpty
bool mbEmpty
Definition:
formularesult.hxx:65
ScFormulaResult::GetResult
sc::FormulaResultValue GetResult() const
Definition:
formularesult.cxx:396
ScFormulaResult::GetResultError
FormulaError GetResultError() const
Get error code if set or GetCellResultType() is formula::svError or svUnknown, else 0.
Definition:
formularesult.cxx:437
ScMatrixFormulaCellToken
Stores the matrix result at the formula cell, additionally the range the matrix formula occupies.
Definition:
token.hxx:325
formula::FormulaToken
svl::SharedString
FormulaError
FormulaError
global.hxx
formula::FormulaConstTokenRef
::boost::intrusive_ptr< const FormulaToken > FormulaConstTokenRef
formula::StackVar
StackVar
sc
CAUTION! The following defines must be in the same namespace as the respective type.
Definition:
broadcast.cxx:15
sharedstring.hxx
sc::FormulaResultValue
Definition:
formularesult.hxx:33
sc::FormulaResultValue::FormulaResultValue
FormulaResultValue()
Definition:
formularesult.cxx:19
sc::FormulaResultValue::mfValue
double mfValue
Definition:
formularesult.hxx:36
sc::FormulaResultValue::mnError
FormulaError mnError
Definition:
formularesult.hxx:40
sc::FormulaResultValue::mbMultiLine
bool mbMultiLine
Definition:
formularesult.hxx:38
sc::FormulaResultValue::maString
svl::SharedString maString
Definition:
formularesult.hxx:37
sc::FormulaResultValue::meType
Type meType
Definition:
formularesult.hxx:39
sc::FormulaResultValue::Type
Type
Definition:
formularesult.hxx:34
sc::FormulaResultValue::String
@ String
Definition:
formularesult.hxx:34
sc::FormulaResultValue::Error
@ Error
Definition:
formularesult.hxx:34
sc::FormulaResultValue::Value
@ Value
Definition:
formularesult.hxx:34
sc::FormulaResultValue::Invalid
@ Invalid
Definition:
formularesult.hxx:34
token.hxx
sal_uInt8
unsigned char sal_uInt8
types.hxx
ScConstMatrixRef
::boost::intrusive_ptr< const ScMatrix > ScConstMatrixRef
Definition:
types.hxx:26
SCCOL
sal_Int16 SCCOL
Definition:
types.hxx:21
SCROW
sal_Int32 SCROW
Definition:
types.hxx:17
Generated on Sun Jul 30 2023 04:27:45 for LibreOffice Module sc (master) by
1.9.3