namespace com::sun::star::uno { template <typename > class Sequence; } namespace formula { class FormulaTokenArray; }
namespace svl {
class SharedString; class SharedStringPool;
}
// RecalcMode access only via TokenArray SetExclusiveRecalcMode...() / // IsRecalcMode...()
// Only one of the exclusive bits can be set and one must be set, // handled by TokenArray SetExclusiveRecalcMode...() methods. // Exclusive bits are ordered by priority, AddRecalcMode() relies on that. enumclass ScRecalcMode : sal_uInt8
{
ALWAYS = 0x01, // exclusive, always
ONLOAD_MUST = 0x02, // exclusive, always after load
ONLOAD_ONCE = 0x04, // exclusive, once after load, import filter
ONLOAD_LENIENT = 0x08, // exclusive, lenient after load (eg. macros not always, aliens, ...)
NORMAL = 0x10, // exclusive
FORCED = 0x20, // combined, also if cell isn't visible, for macros with side effects
ONREFMOVE = 0x40, // combined, if reference was moved
EMask = ALWAYS | ONLOAD_MUST | ONLOAD_LENIENT | ONLOAD_ONCE | NORMAL // mask of exclusive bits
}; namespace o3tl
{ template<> struct typed_flags<ScRecalcMode> : is_typed_flags<ScRecalcMode, 0x7f> {};
}
class FORMULA_DLLPUBLIC FormulaTokenArrayReferencesIterator
{ private:
FormulaToken** maIter;
FormulaToken** maEnd;
void nextReference()
{ while (maIter != maEnd)
{ switch ((*maIter)->GetType())
{ case svSingleRef: case svDoubleRef: case svExternalSingleRef: case svExternalDoubleRef: return; default:
++maIter;
}
}
}
class FORMULA_DLLPUBLIC FormulaTokenArray
{ protected:
std::unique_ptr<FormulaToken*[]> pCode; // Token code array
FormulaToken** pRPN; // RPN array
sal_uInt16 nLen; // Length of token array
sal_uInt16 nRPN; // Length of RPN array
FormulaError nError; // Error code
ScRecalcMode nMode; // Flags to indicate when to recalc this code bool bHyperLink :1; // If HYPERLINK() occurs in the formula. bool mbFromRangeName :1; // If this array originates from a named expression bool mbShareable :1; // Whether or not it can be shared with adjacent cells. bool mbFinalized :1; // Whether code arrays have their final used size and no more tokens can be added.
/// Also used by the compiler. The token MUST had been allocated with new!
FormulaToken* Add( FormulaToken* );
public: enum ReplaceMode
{
CODE_ONLY, ///< replacement only in pCode
CODE_AND_RPN ///< replacement in pCode and pRPN
};
/** Also used by the compiler. The token MUST had been allocated with new! @paramnOffset AbsoluteoffsetinpCodeofthetokentobereplaced. @parameMode IfCODE_ONLYonlythetokeninpCodeatnOffsetisreplaced. IfCODE_AND_RPNthetokeninpCodeatnOffsetisreplaced; iftheoriginaltokenwasalsoreferencedinthepRPNarray thenthatreferenceisreplacedwithareferencetothenew tokenaswell.
*/
FormulaToken* ReplaceToken( sal_uInt16 nOffset, FormulaToken*, ReplaceMode eMode );
FormulaToken* ReplaceRPNToken( sal_uInt16 nOffset, FormulaToken* );
/** Remove a sequence of tokens from pCode array, and pRPN array if the tokensarereferencedthere.
/// Return pCode[nIdx], or nullptr if nIdx is out of bounds
FormulaToken* TokenAt( sal_uInt16 nIdx) const
{ if (nIdx >= nLen) return nullptr; return pCode[nIdx];
}
/// Peek at nIdx-1 if not out of bounds, decrements nIdx if successful. Returns NULL if not.
FormulaToken* PeekPrev( sal_uInt16 & nIdx ) const;
/// Return the opcode at pCode[nIdx-1], ocNone if nIdx-1 is out of bounds
OpCode OpCodeBefore( sal_uInt16 nIdx) const
{ if (nIdx == 0 || nIdx > nLen) return ocNone;
/// Assign pRPN to point to a newly created array filled with the data from pData void CreateNewRPNArrayFromData( FormulaToken** pData, sal_uInt16 nSize )
{
pRPN = new FormulaToken*[ nSize ];
nRPN = nSize;
memcpy( pRPN, pData, nSize * sizeof( FormulaToken* ) );
}
/** Exclusive bits already set in nMode are zero'ed, nBits maycontaincombinedbits,butonlyoneexclusivebit
may be set! */ void SetMaskedRecalcMode( ScRecalcMode nBits )
{ nMode = GetCombinedBitsRecalcMode() | nBits; }
/** Bits aren't set directly but validated and handled accordingtopriorityifmorethanoneexclusivebit
was set. */ void AddRecalcMode( ScRecalcMode nBits );
/** Get OpCode of the most outer function */ inline OpCode GetOuterFuncOpCode() const;
/** Operators +,-,*,/,^,&,=,<>,<,>,<=,>=
with DoubleRef in Formula? */ bool HasMatrixDoubleRefOps() const;
virtual FormulaToken* AddOpCode(OpCode e);
/** Adds the single token to array. DerivedclassesmustoverrideitwhentheywanttosupportderivedclassesfromFormulaToken. @returntruewhenanerroroccurs
*/ virtualbool AddFormulaToken( const css::sheet::FormulaToken& rToken, svl::SharedStringPool& rSPool,
ExternalReferenceHelper* pExtRef );
/** fill the array with the tokens from the sequence. ItcallsAddFormulaTokenforeachtokeninthelist. @param_aSequencethetokentoadd @returntruewhenanerroroccurs
*/ bool Fill( const css::uno::Sequence<css::sheet::FormulaToken>& rSequence,
svl::SharedStringPool& rSPool, ExternalReferenceHelper* pExtRef );
/** *Dosomecheckingbasedontheindividualtokens.Fornow,weusethis *onlytocheckwhetherwecanvectorizethetokenarray.
*/ virtualvoid CheckToken( const FormulaToken& t );
/** Clones the token and then adds the clone to the pCode array. Forjustnew'edtokensuseAdd()insteadofcloningitagain. UsethisAddToken()whenaddingatokenfromanotherorigin.
*/
FormulaToken* AddToken( const FormulaToken& );
/** Assignment with incrementing references of FormulaToken entries
(not copied!) */
FormulaTokenArray& operator=( const FormulaTokenArray& );
FormulaTokenArray& operator=( FormulaTokenArray&& );
/** Determines if this formula needs any changes to convert it to something previousversionsofOOocouldconsume(PlainOldFormula,pre-ODFF,or
also ODFF) */ bool NeedsPodfRewrite( const MissingConventionODF & rConv );
/** Determines if this formula needs any changes to convert it to OOXML. */ bool NeedsOoxmlRewrite();
/** Rewrites to Plain Old Formula or OOXML, substituting missing parameters. The
FormulaTokenArray* returned is new'ed. */
FormulaTokenArray* RewriteMissing( const MissingConvention & rConv );
/** Determines if this formula may be followed by a reference. */ bool MayReferenceFollow();
/** Re-intern SharedString in case the SharedStringPool differs. */ void ReinternStrings( svl::SharedStringPool& rPool );
};
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.