LibreOffice Module sc (master)  1
Public Member Functions | Private Types | Private Member Functions | Static 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...
 
svl::SharedString GetString () 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...
 
const 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...
 

Static Private Member Functions

static void IncrementTokenRef (const formula::FormulaToken *&rp)
 

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
 
static const sal_uInt16 MAX_TOKENREF_COUNT = 0xf000
 

Detailed Description

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

Definition at line 53 of file formularesult.hxx.

Member Typedef Documentation

typedef unsigned char ScFormulaResult::Multiline
private

Definition at line 55 of file formularesult.hxx.

Constructor & Destructor Documentation

ScFormulaResult::ScFormulaResult ( )

Effectively type svUnknown.

Definition at line 25 of file formularesult.cxx.

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

Same comments as for SetToken() apply!

Definition at line 66 of file formularesult.cxx.

References SetToken().

ScFormulaResult::~ScFormulaResult ( )

Definition at line 77 of file formularesult.cxx.

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

Member Function Documentation

void ScFormulaResult::Assign ( const ScFormulaResult r)
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 471 of file formularesult.cxx.

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

Referenced by ScFormulaCell::InterpretTail().

formula::StackVar ScFormulaResult::GetCellResultType ( ) const

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

Definition at line 260 of file formularesult.cxx.

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

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

double ScFormulaResult::GetDouble ( ) const
bool ScFormulaResult::GetErrorOrDouble ( FormulaError rErr,
double &  rVal 
) const
const OUString & ScFormulaResult::GetHybridFormula ( ) const
ScConstMatrixRef ScFormulaResult::GetMatrix ( ) const
const ScMatrixFormulaCellToken * ScFormulaResult::GetMatrixFormulaCellToken ( ) const

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

Definition at line 634 of file formularesult.cxx.

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

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

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 640 of file formularesult.cxx.

References GetMatrixFormulaCellToken().

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

sc::FormulaResultValue ScFormulaResult::GetResult ( ) const
FormulaError ScFormulaResult::GetResultError ( ) const
svl::SharedString ScFormulaResult::GetString ( ) const
formula::FormulaConstTokenRef ScFormulaResult::GetToken ( ) const

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

Definition at line 464 of file formularesult.cxx.

References mbToken, and mpToken.

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

formula::StackVar ScFormulaResult::GetType ( ) const
static void ScFormulaResult::IncrementTokenRef ( const formula::FormulaToken *&  rp)
inlinestaticprivate
bool ScFormulaResult::IsEmptyDisplayedAsString ( ) const
bool ScFormulaResult::IsMultiline ( ) const

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

Definition at line 347 of file formularesult.cxx.

References aStr, svl::SharedString::getString(), GetString(), svl::SharedString::isEmpty(), meMultiline, MULTILINE_FALSE, MULTILINE_TRUE, and MULTILINE_UNKNOWN.

Referenced by ScFormulaCell::IsMultilineResult().

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 327 of file formularesult.cxx.

References GetCellResultType(), and IsEmptyDisplayedAsString().

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

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

Well, guess what ...

Definition at line 137 of file formularesult.cxx.

References Assign().

void ScFormulaResult::ResetToDefaults ( )
private

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

Definition at line 83 of file formularesult.cxx.

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

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

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. : Token MUST had been IncRef'ed prior to this call! : 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 92 of file formularesult.cxx.

References formula::FormulaToken::DecRef(), formula::FormulaToken::GetDouble(), formula::FormulaToken::GetError(), formula::FormulaToken::GetType(), mbEmpty, mbEmptyDisplayedAsString, mbToken, mbValueCached, meMultiline, mfValue, mnError, mpToken, MULTILINE_FALSE, ResetToDefaults(), formula::svDouble, formula::svEmptyCell, and formula::svError.

Referenced by SetToken().

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 227 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().

void ScFormulaResult::SetHybridDouble ( double  f)
void ScFormulaResult::SetHybridEmptyDisplayedAsString ( )
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 611 of file formularesult.cxx.

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

Referenced by ScFormulaCell::SetHybridFormula().

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 581 of file formularesult.cxx.

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

Referenced by ScFormulaCell::SetHybridString().

void ScFormulaResult::SetMatrix ( SCCOL  nCols,
SCROW  nRows,
const ScConstMatrixRef pMat,
const formula::FormulaToken pUL 
)
void ScFormulaResult::SetResultError ( FormulaError  nErr)
void ScFormulaResult::SetToken ( const formula::FormulaToken p)

Member Data Documentation

union { ... }
const sal_uInt16 ScFormulaResult::MAX_TOKENREF_COUNT = 0xf000
staticprivate

Definition at line 63 of file formularesult.hxx.

Referenced by IncrementTokenRef().

bool ScFormulaResult::mbEmpty
private
bool ScFormulaResult::mbEmptyDisplayedAsString
private

Definition at line 81 of file formularesult.hxx.

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

bool ScFormulaResult::mbToken
private
bool ScFormulaResult::mbValueCached
private
Multiline ScFormulaResult::meMultiline
private
double ScFormulaResult::mfValue
FormulaError ScFormulaResult::mnError
private
const formula::FormulaToken* ScFormulaResult::mpToken
const Multiline ScFormulaResult::MULTILINE_FALSE = 1
staticprivate

Definition at line 57 of file formularesult.hxx.

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

const Multiline ScFormulaResult::MULTILINE_TRUE = 2
staticprivate

Definition at line 58 of file formularesult.hxx.

Referenced by IsMultiline().

const Multiline ScFormulaResult::MULTILINE_UNKNOWN = 0
staticprivate

Definition at line 56 of file formularesult.hxx.

Referenced by IsMultiline(), and ResetToDefaults().


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