/** Store a variable formula cell result, balancing between runtime performance
and memory consumption. */ class ScFormulaResult
{ typedefunsignedchar Multiline; staticconst Multiline MULTILINE_UNKNOWN = 0; staticconst Multiline MULTILINE_FALSE = 1; staticconst Multiline MULTILINE_TRUE = 2;
union
{ double mfValue; // double result direct for performance and memory consumption const formula::FormulaToken* mpToken; // if not, result token obtained from interpreter
}; bool mbToken :1; // whether content of union is a token bool mbNoneRefCnt :1; // if token was added when using RefCntPolicy::None bool mbEmpty :1; // empty cell result bool mbEmptyDisplayedAsString :1; // only if mbEmpty // If set it implies that the result is a simple double (in mfValue) and no error bool mbValueCached :1;
Multiline meMultiline :2; // result is multiline
FormulaError mnError; // error code
/** Reset mnError, mbEmpty and mbEmptyDisplayedAsString to their defaults
prior to assigning other types */ void ResetToDefaults();
/** If token is of formula::svError set error code and decrement RefCount. Iftokenisofformula::svEmptyCellsetmbEmptyandmbEmptyAsStringand decrementRefCount. Iftokenisofformula::svDoublesetmfValueanddecrementRefCount. ElseassigntokentompToken.NULLisvalid=>svUnknown. Othermembervariablesaresetaccordingly. @precondition:TokenMUSThadbeenIncRef'edpriortothiscall! @precondition:AnalreadyexistingdifferentmpTokenMUSThadbeen DecRef'edpriortothiscall,pwillbeassignedtompTokenifnot resolved.
ATTENTION! Token may get deleted in this call! */ void ResolveToken( const formula::FormulaToken * p );
public: /** Effectively type svUnknown. */
ScFormulaResult();
ScFormulaResult( const ScFormulaResult & r );
/** Same comments as for SetToken() apply! */ explicit ScFormulaResult( const formula::FormulaToken* p );
~ScFormulaResult();
/** Well, guess what ... */
ScFormulaResult& operator=( const ScFormulaResult & r );
/** Assignment as in operator=() but without return */ void Assign( const ScFormulaResult & r );
/** Sets a direct double if token type is formula::svDouble, or mbEmpty if formula::svEmptyCell,elsetoken.IfpisNULL,thatissetaswell,effectively resultinginGetType()==svUnknown.Ifthealreadyexistingresultis ScMatrixFormulaCellToken,theupperleftissettotoken.
ATTENTION!formula::FormulaTokenhadtobeallocatedusing'new'andifoftype formula::svDoubleandnoRefCountwassetmaynotbeusedafterthiscall
because it was deleted after decrement! */ void SetToken( const formula::FormulaToken* p );
/** May be NULL if SetToken() did so, also if type formula::svDouble or formula::svError! */
formula::FormulaConstTokenRef GetToken() 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! */
formula::FormulaConstTokenRef GetCellResultToken() const;
/** Return type of result, including formula::svError, formula::svEmptyCell, formula::svDouble and
formula::svMatrixCell. */
formula::StackVar GetType() const;
/** If type is formula::svMatrixCell return the type of upper left element, else
GetType() */
formula::StackVar GetCellResultType() const;
/** If type is formula::svEmptyCell (including matrix upper left) and should be
displayed as empty string */ bool IsEmptyDisplayedAsString() const;
/** Test for cell result type formula::svDouble, including upper left if formula::svMatrixCell.Alsoincludedisformula::svErrorforlegacy,becausepreviously anerrorresultwastreatedlikeanumericvalueatsomeplacesin ScFormulaCell.Alsoincludedisformula::svEmptyCellasareferencetoanempty cellusuallyistreatedasnumeric0.UseGetCellResultType()for
details instead. */ bool IsValue() const;
bool IsValueNoError() const;
/** Determines whether or not the result is a string containing more than
one paragraph */ bool IsMultiline() const;
/** Get error code if set or GetCellResultType() is formula::svError or svUnknown,
else 0. */
FormulaError GetResultError() const;
/** Set error code, don't touch token or double. */ void SetResultError( FormulaError nErr );
/** Set direct double. Shouldn't be used externally except in ScFormulaCellforroundedCalcAsShownorSetErrCode()or SetResultDouble(),seethereforcondition.If ScMatrixFormulaCellTokenthetokenisn'treplacedbutupper leftresultismodifiedinstead,butonlyifitwasoftype formula::svDoublebeforeornotsetatall.
*/ void SetDouble( double f );
/** Return value if type formula::svDouble or formula::svHybridCell or formula::svMatrixCell and upper
left formula::svDouble, else 0.0 */ double GetDouble() const;
/** Return string if type formula::svString or formula::svHybridCell or formula::svMatrixCell and
upper left formula::svString, else empty string. */ const svl::SharedString & GetString() const;
/** Return matrix if type formula::svMatrixCell and ScMatrix present, else NULL. */
ScConstMatrixRef GetMatrix() const;
/** Return formula string if type formula::svHybridCell, else empty string. */
OUString GetHybridFormula() const;
/** Should only be used by import filters, best in the order SetHybridDouble(),SetHybridString(),oronlySetHybridFormula()for
formula string to be compiled later. */ void SetHybridDouble( double f );
/** Should only be used by import filters, best in the order SetHybridDouble(),SetHybridString()/SetHybridFormula(),oronly
SetHybridFormula() for formula string to be compiled later. */ void SetHybridString( const svl::SharedString & rStr );
/** Should only be used by import filters, best in the order SetHybridDouble(),SetHybridFormula(),
SetHybridEmptyDisplayedAsString() must be last. */ void SetHybridEmptyDisplayedAsString();
/** Should only be used by import filters, best in the order SetHybridDouble(),SetHybridString()/SetHybridFormula(),oronly
SetHybridFormula() for formula string to be compiled later. */ void SetHybridFormula( const OUString & rFormula );
/** Get the const ScMatrixFormulaCellToken* if token is of that type, else
NULL. */ const ScMatrixFormulaCellToken* GetMatrixFormulaCellToken() const;
/** Get the ScMatrixFormulaCellToken* if token is of that type, else NULL.
Shouldn't be used externally except by ScFormulaCell::SetMatColsRows(). */
ScMatrixFormulaCellToken* GetMatrixFormulaCellTokenNonConst();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.