LibreOffice Module sc (master) 1
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ScFormulaResult Class Reference

Store a variable formula cell result, balancing between runtime performance and memory consumption. More...

#include <formularesult.hxx>

Collaboration diagram for ScFormulaResult:
[legend]

Public Member Functions

 ScFormulaResult ()
 Effectively type svUnknown. More...
 
 ScFormulaResult (const ScFormulaResult &r)
 
 ScFormulaResult (const formula::FormulaToken *p)
 Same comments as for SetToken() apply! More...
 
 ~ScFormulaResult ()
 
ScFormulaResultoperator= (const ScFormulaResult &r)
 Well, guess what ... More...
 
void Assign (const ScFormulaResult &r)
 Assignment as in operator=() but without return. More...
 
void SetToken (const formula::FormulaToken *p)
 Sets a direct double if token type is formula::svDouble, or mbEmpty if formula::svEmptyCell, else token. More...
 
formula::FormulaConstTokenRef GetToken () const
 May be NULL if SetToken() did so, also if type formula::svDouble or formula::svError! More...
 
formula::FormulaConstTokenRef GetCellResultToken () const
 Return upper left token if formula::svMatrixCell, else return GetToken(). More...
 
formula::StackVar GetType () const
 Return type of result, including formula::svError, formula::svEmptyCell, formula::svDouble and formula::svMatrixCell. More...
 
formula::StackVar GetCellResultType () const
 If type is formula::svMatrixCell return the type of upper left element, else GetType() More...
 
bool IsEmptyDisplayedAsString () const
 If type is formula::svEmptyCell (including matrix upper left) and should be displayed as empty string. More...
 
bool IsValue () const
 Test for cell result type formula::svDouble, including upper left if formula::svMatrixCell. More...
 
bool IsValueNoError () const
 
bool IsMultiline () const
 Determines whether or not the result is a string containing more than one paragraph. More...
 
bool GetErrorOrDouble (FormulaError &rErr, double &rVal) const
 
sc::FormulaResultValue GetResult () const
 
FormulaError GetResultError () const
 Get error code if set or GetCellResultType() is formula::svError or svUnknown, else 0. More...
 
void SetResultError (FormulaError nErr)
 Set error code, don't touch token or double. More...
 
void SetDouble (double f)
 Set direct double. More...
 
double GetDouble () const
 Return value if type formula::svDouble or formula::svHybridCell or formula::svMatrixCell and upper left formula::svDouble, else 0.0. More...
 
const svl::SharedStringGetString () const
 Return string if type formula::svString or formula::svHybridCell or formula::svMatrixCell and upper left formula::svString, else empty string. More...
 
ScConstMatrixRef GetMatrix () const
 Return matrix if type formula::svMatrixCell and ScMatrix present, else NULL. More...
 
OUString GetHybridFormula () const
 Return formula string if type formula::svHybridCell, else empty string. More...
 
void SetHybridDouble (double f)
 Should only be used by import filters, best in the order SetHybridDouble(), SetHybridString(), or only SetHybridFormula() for formula string to be compiled later. More...
 
void SetHybridString (const svl::SharedString &rStr)
 Should only be used by import filters, best in the order SetHybridDouble(), SetHybridString()/SetHybridFormula(), or only SetHybridFormula() for formula string to be compiled later. More...
 
void SetHybridEmptyDisplayedAsString ()
 Should only be used by import filters, best in the order SetHybridDouble(), SetHybridFormula(), SetHybridEmptyDisplayedAsString() must be last. More...
 
void SetHybridFormula (const OUString &rFormula)
 Should only be used by import filters, best in the order SetHybridDouble(), SetHybridString()/SetHybridFormula(), or only SetHybridFormula() for formula string to be compiled later. More...
 
void SetMatrix (SCCOL nCols, SCROW nRows, const ScConstMatrixRef &pMat, const formula::FormulaToken *pUL)
 
const ScMatrixFormulaCellTokenGetMatrixFormulaCellToken () const
 Get the const ScMatrixFormulaCellToken* if token is of that type, else NULL. More...
 
ScMatrixFormulaCellTokenGetMatrixFormulaCellTokenNonConst ()
 Get the ScMatrixFormulaCellToken* if token is of that type, else NULL. More...
 

Private Types

typedef unsigned char Multiline
 

Private Member Functions

void ResetToDefaults ()
 Reset mnError, mbEmpty and mbEmptyDisplayedAsString to their defaults prior to assigning other types. More...
 
void ResolveToken (const formula::FormulaToken *p)
 If token is of formula::svError set error code and decrement RefCount. More...
 

Private Attributes

union {
   double   mfValue
 
   const formula::FormulaToken *   mpToken
 
}; 
 
bool mbToken:1
 
bool mbEmpty:1
 
bool mbEmptyDisplayedAsString:1
 
bool mbValueCached:1
 
Multiline meMultiline:2
 
FormulaError mnError
 

Static Private Attributes

static const Multiline MULTILINE_UNKNOWN = 0
 
static const Multiline MULTILINE_FALSE = 1
 
static const Multiline MULTILINE_TRUE = 2
 

Detailed Description

Store a variable formula cell result, balancing between runtime performance and memory consumption.

Definition at line 52 of file formularesult.hxx.

Member Typedef Documentation

◆ Multiline

typedef unsigned char ScFormulaResult::Multiline
private

Definition at line 54 of file formularesult.hxx.

Constructor & Destructor Documentation

◆ ScFormulaResult() [1/3]

ScFormulaResult::ScFormulaResult ( )

Effectively type svUnknown.

Definition at line 26 of file formularesult.cxx.

◆ ScFormulaResult() [2/3]

ScFormulaResult::ScFormulaResult ( const ScFormulaResult r)

◆ ScFormulaResult() [3/3]

ScFormulaResult::ScFormulaResult ( const formula::FormulaToken p)
explicit

Same comments as for SetToken() apply!

Definition at line 63 of file formularesult.cxx.

References p, and SetToken().

◆ ~ScFormulaResult()

ScFormulaResult::~ScFormulaResult ( )

Definition at line 74 of file formularesult.cxx.

References formula::FormulaToken::DecRef(), mbToken, and mpToken.

Member Function Documentation

◆ Assign()

void ScFormulaResult::Assign ( const ScFormulaResult r)

◆ GetCellResultToken()

formula::FormulaConstTokenRef ScFormulaResult::GetCellResultToken ( ) const

Return upper left token if formula::svMatrixCell, else return GetToken().

May be NULL if SetToken() did so, also if type formula::svDouble or formula::svError!

Definition at line 468 of file formularesult.cxx.

References GetToken(), GetType(), mpToken, and formula::svMatrixCell.

Referenced by ScFormulaCell::InterpretTail().

◆ GetCellResultType()

formula::StackVar ScFormulaResult::GetCellResultType ( ) const

If type is formula::svMatrixCell return the type of upper left element, else GetType()

Definition at line 258 of file formularesult.cxx.

References GetType(), mpToken, and formula::svMatrixCell.

Referenced by GetErrorOrDouble(), GetResult(), GetResultError(), ScFormulaCell::InterpretTail(), ScFormulaCell::IsEmpty(), IsValue(), and IsValueNoError().

◆ GetDouble()

double ScFormulaResult::GetDouble ( ) const

◆ GetErrorOrDouble()

bool ScFormulaResult::GetErrorOrDouble ( FormulaError rErr,
double &  rVal 
) const

◆ GetHybridFormula()

OUString ScFormulaResult::GetHybridFormula ( ) const

◆ GetMatrix()

ScConstMatrixRef ScFormulaResult::GetMatrix ( ) const

◆ GetMatrixFormulaCellToken()

const ScMatrixFormulaCellToken * ScFormulaResult::GetMatrixFormulaCellToken ( ) const

Get the const ScMatrixFormulaCellToken* if token is of that type, else NULL.

Definition at line 630 of file formularesult.cxx.

References GetType(), mpToken, and formula::svMatrixCell.

Referenced by Assign(), ScFormulaCell::GetMatColsRows(), GetMatrixFormulaCellTokenNonConst(), and ScFormulaResult().

◆ GetMatrixFormulaCellTokenNonConst()

ScMatrixFormulaCellToken * ScFormulaResult::GetMatrixFormulaCellTokenNonConst ( )

Get the ScMatrixFormulaCellToken* if token is of that type, else NULL.

Shouldn't be used externally except by ScFormulaCell::SetMatColsRows().

Definition at line 636 of file formularesult.cxx.

References GetMatrixFormulaCellToken().

Referenced by SetDouble(), ScFormulaCell::SetMatColsRows(), and SetToken().

◆ GetResult()

sc::FormulaResultValue ScFormulaResult::GetResult ( ) const

◆ GetResultError()

FormulaError ScFormulaResult::GetResultError ( ) const

◆ GetString()

const svl::SharedString & ScFormulaResult::GetString ( ) const

◆ GetToken()

formula::FormulaConstTokenRef ScFormulaResult::GetToken ( ) const

May be NULL if SetToken() did so, also if type formula::svDouble or formula::svError!

Definition at line 461 of file formularesult.cxx.

References mbToken, and mpToken.

Referenced by GetCellResultToken(), and ScFormulaCell::GetResultDimensions().

◆ GetType()

formula::StackVar ScFormulaResult::GetType ( ) const

◆ IsEmptyDisplayedAsString()

bool ScFormulaResult::IsEmptyDisplayedAsString ( ) const

If type is formula::svEmptyCell (including matrix upper left) and should be displayed as empty string.

Definition at line 267 of file formularesult.cxx.

References GetType(), mbEmpty, mbEmptyDisplayedAsString, mpToken, p, formula::svHybridCell, and formula::svMatrixCell.

Referenced by ScFormulaCell::IsEmptyDisplayedAsString(), and IsValue().

◆ IsMultiline()

bool ScFormulaResult::IsMultiline ( ) const

Determines whether or not the result is a string containing more than one paragraph.

Definition at line 344 of file formularesult.cxx.

References aStr, GetString(), meMultiline, MULTILINE_FALSE, MULTILINE_TRUE, and MULTILINE_UNKNOWN.

Referenced by GetResult(), and ScFormulaCell::IsMultilineResult().

◆ IsValue()

bool ScFormulaResult::IsValue ( ) const

Test for cell result type formula::svDouble, including upper left if formula::svMatrixCell.

Also included is formula::svError for legacy, because previously an error result was treated like a numeric value at some places in ScFormulaCell. Also included is formula::svEmptyCell as a reference to an empty cell usually is treated as numeric 0. Use GetCellResultType() for details instead.

Definition at line 324 of file formularesult.cxx.

References GetCellResultType(), and IsEmptyDisplayedAsString().

Referenced by ScFormulaCell::CalcAfterLoad(), ScFormulaCell::Interpret(), ScFormulaCell::InterpretTail(), ScFormulaCell::IsValue(), and ScSimpleFormulaCalculator::IsValue().

◆ IsValueNoError()

bool ScFormulaResult::IsValueNoError ( ) const

◆ operator=()

ScFormulaResult & ScFormulaResult::operator= ( const ScFormulaResult r)

Well, guess what ...

Definition at line 134 of file formularesult.cxx.

References Assign().

◆ ResetToDefaults()

void ScFormulaResult::ResetToDefaults ( )
private

Reset mnError, mbEmpty and mbEmptyDisplayedAsString to their defaults prior to assigning other types.

Definition at line 80 of file formularesult.cxx.

References mbEmpty, mbEmptyDisplayedAsString, mbValueCached, meMultiline, mnError, and MULTILINE_UNKNOWN.

Referenced by ResolveToken(), SetDouble(), SetHybridDouble(), SetHybridEmptyDisplayedAsString(), SetHybridFormula(), SetHybridString(), SetMatrix(), and SetToken().

◆ ResolveToken()

void ScFormulaResult::ResolveToken ( const formula::FormulaToken p)
private

If token is of formula::svError set error code and decrement RefCount.

If token is of formula::svEmptyCell set mbEmpty and mbEmptyAsString and decrement RefCount. If token is of formula::svDouble set mfValue and decrement RefCount. Else assign token to mpToken. NULL is valid => svUnknown. Other member variables are set accordingly. @precondition: Token MUST had been IncRef'ed prior to this call! @precondition: An already existing different mpToken MUST had been DecRef'ed prior to this call, p will be assigned to mpToken if not resolved. ATTENTION! Token may get deleted in this call!

Definition at line 89 of file formularesult.cxx.

References mbEmpty, mbEmptyDisplayedAsString, mbToken, mbValueCached, meMultiline, mfValue, mnError, mpToken, MULTILINE_FALSE, p, ResetToDefaults(), formula::svDouble, formula::svEmptyCell, and formula::svError.

Referenced by SetToken().

◆ SetDouble()

void ScFormulaResult::SetDouble ( double  f)

Set direct double.

Shouldn't be used externally except in ScFormulaCell for rounded CalcAsShown or SetErrCode() or SetResultDouble(), see there for condition. If ScMatrixFormulaCellToken the token isn't replaced but upper left result is modified instead, but only if it was of type formula::svDouble before or not set at all.

Definition at line 225 of file formularesult.cxx.

References formula::FormulaToken::DecRef(), GetMatrixFormulaCellTokenNonConst(), mbToken, mbValueCached, meMultiline, mfValue, mpToken, MULTILINE_FALSE, ResetToDefaults(), and ScMatrixFormulaCellToken::SetUpperLeftDouble().

Referenced by Assign(), ScFormulaCell::InterpretTail(), SetHybridDouble(), and ScFormulaCell::SetResultDouble().

◆ SetHybridDouble()

void ScFormulaResult::SetHybridDouble ( double  f)

◆ SetHybridEmptyDisplayedAsString()

void ScFormulaResult::SetHybridEmptyDisplayedAsString ( )

◆ SetHybridFormula()

void ScFormulaResult::SetHybridFormula ( const OUString &  rFormula)

Should only be used by import filters, best in the order SetHybridDouble(), SetHybridString()/SetHybridFormula(), or only SetHybridFormula() for formula string to be compiled later.

Definition at line 607 of file formularesult.cxx.

References aStr, formula::FormulaToken::DecRef(), GetDouble(), GetString(), formula::FormulaToken::IncRef(), mbToken, mpToken, and ResetToDefaults().

Referenced by ScFormulaCell::SetHybridFormula().

◆ SetHybridString()

void ScFormulaResult::SetHybridString ( const svl::SharedString rStr)

Should only be used by import filters, best in the order SetHybridDouble(), SetHybridString()/SetHybridFormula(), or only SetHybridFormula() for formula string to be compiled later.

Definition at line 577 of file formularesult.cxx.

References formula::FormulaToken::DecRef(), GetDouble(), GetHybridFormula(), formula::FormulaToken::IncRef(), mbToken, mpToken, and ResetToDefaults().

Referenced by ScFormulaCell::SetHybridString().

◆ SetMatrix()

void ScFormulaResult::SetMatrix ( SCCOL  nCols,
SCROW  nRows,
const ScConstMatrixRef pMat,
const formula::FormulaToken pUL 
)

◆ SetResultError()

void ScFormulaResult::SetResultError ( FormulaError  nErr)

◆ SetToken()

void ScFormulaResult::SetToken ( const formula::FormulaToken p)

Member Data Documentation

◆ 

union { ... } ScFormulaResult::@31

◆ mbEmpty

bool ScFormulaResult::mbEmpty
private

◆ mbEmptyDisplayedAsString

bool ScFormulaResult::mbEmptyDisplayedAsString
private

Definition at line 66 of file formularesult.hxx.

Referenced by Assign(), IsEmptyDisplayedAsString(), ResetToDefaults(), and ResolveToken().

◆ mbToken

bool ScFormulaResult::mbToken
private

◆ mbValueCached

bool ScFormulaResult::mbValueCached
private

◆ meMultiline

Multiline ScFormulaResult::meMultiline
private

◆ mfValue

double ScFormulaResult::mfValue

◆ mnError

FormulaError ScFormulaResult::mnError
private

◆ mpToken

const formula::FormulaToken* ScFormulaResult::mpToken

◆ MULTILINE_FALSE

const Multiline ScFormulaResult::MULTILINE_FALSE = 1
staticprivate

Definition at line 56 of file formularesult.hxx.

Referenced by IsMultiline(), ResolveToken(), SetDouble(), and SetHybridDouble().

◆ MULTILINE_TRUE

const Multiline ScFormulaResult::MULTILINE_TRUE = 2
staticprivate

Definition at line 57 of file formularesult.hxx.

Referenced by IsMultiline().

◆ MULTILINE_UNKNOWN

const Multiline ScFormulaResult::MULTILINE_UNKNOWN = 0
staticprivate

Definition at line 55 of file formularesult.hxx.

Referenced by IsMultiline(), and ResetToDefaults().


The documentation for this class was generated from the following files: