30#include <rtl/ustrbuf.hxx>
31#include <com/sun/star/sheet/ExternalLinkInfo.hpp>
32#include <com/sun/star/i18n/ParseResult.hpp>
36#include <unordered_set>
38#include <com/sun/star/uno/Sequence.hxx>
83#define SC_COMPILER_FILE_TAB_SEP '#'
94class CompileFormulaContext;
157 void SetString( rtl_uString* pData, rtl_uString* pDataIgnoreCase );
186 EXTENDED_ERROR_DETECTION_NONE = 0,
188 EXTENDED_ERROR_DETECTION_NAME_NO_BREAK
200 OUStringBuffer& rBuffer,
203 const OUString& rErrRef,
const std::vector<OUString>& rTabNames,
204 const ScComplexRefData& rRef,
bool bSingleRef,
bool bFromRangeName )
const = 0;
206 virtual css::i18n::ParseResult
210 bool bGroupSeparator)
const = 0;
220 const css::uno::Sequence< css::sheet::ExternalLinkInfo>* pExternalLinks )
const = 0;
223 const OUString& rName )
const = 0;
227 OUStringBuffer& rBuffer,
const ScAddress& rPos, sal_uInt16 nFileId,
const OUString& rFileName,
232 OUStringBuffer& rBuffer,
const ScAddress& rPos,
233 sal_uInt16 nFileId,
const OUString& rFileName,
const std::vector<OUString>& rTabNames,
272 static size_t GetAddInMapCount();
306 std::vector<OUString> &GetSetupTabNames()
const;
321 : parameterLocation(
p ), parameter( *
p ), operation( o ) {}
332 bool NextNewToken(
bool bInArray);
333 bool ToUpperAsciiOrI18nIsAscii( OUString& rUpper,
const OUString& rOrg )
const;
346 static void addWhitespace( std::vector<ScCompiler::Whitespace> & rvSpaces,
349 std::vector<Whitespace> NextSymbol(
bool bInArray);
351 bool ParseValue(
const OUString& );
352 bool ParseOpCode(
const OUString&,
bool bInArray );
353 bool ParseOpCode2( std::u16string_view );
355 bool ParseReference(
const OUString& rSymbol,
const OUString* pErrRef =
nullptr );
356 bool ParseSingleReference(
const OUString& rSymbol,
const OUString* pErrRef =
nullptr );
357 bool ParseDoubleReference(
const OUString& rSymbol,
const OUString* pErrRef =
nullptr );
358 bool ParsePredetectedReference(
const OUString& rSymbol );
359 bool ParsePredetectedErrRefReference(
const OUString& rName,
const OUString* pErrRef );
360 bool ParseMacro(
const OUString& );
361 bool ParseNamedRange(
const OUString&,
bool onlyCheck =
false );
362 bool ParseExternalNamedRange(
const OUString& rSymbol,
bool& rbInvalidExternalNameRange );
363 bool ParseDBRange(
const OUString& );
364 bool ParseColRowName(
const OUString& );
365 bool ParseBoolean(
const OUString& );
366 void AutoCorrectParsedSymbol();
367 const ScRangeData* GetRangeData(
SCTAB& rSheet,
const OUString& rUpperName )
const;
369 void AdjustSheetLocalNameRelReferences(
SCTAB nDelta );
370 void SetRelNameReference();
379 bool HasPossibleNamedRangeConflict(
SCTAB nTab)
const;
382 static const CharClass* GetCharClassLocalized();
383 static const CharClass* GetCharClassEnglish();
387 bool bComputeII =
false,
bool bMatrixFlag =
false,
const ScInterpreterContext* pContext =
nullptr );
393 bool bComputeII =
false,
bool bMatrixFlag =
false,
const ScInterpreterContext* pContext =
nullptr );
396 bool bComputeII =
false,
bool bMatrixFlag =
false,
const ScInterpreterContext* pContext =
nullptr );
402 bool bComputeII =
false,
bool bMatrixFlag =
false,
const ScInterpreterContext* pContext =
nullptr );
407 static void DeInit();
410 static void CheckTabQuotes( OUString& aTabName,
417 static sal_Int32 GetDocTabPos(
const OUString& rString );
420 static bool IsEnglishSymbol(
const OUString& rName );
422 bool ParseErrorConstant(
const OUString& );
423 bool ParseTableRefItem(
const OUString& );
424 bool ParseTableRefColumn(
const OUString& );
427 bool GetTokenIfOpCode(
OpCode eOp );
432 void SetAutoCorrection(
bool bVal );
435 void SetRefConvention(
const Convention *pConvP );
446 void SetFormulaLanguage(
const OpCodeMapPtr & xMap );
462 void SetGrammarAndRefConvention(
469 const css::uno::Sequence<
470 css::sheet::ExternalLinkInfo>& rLinks )
472 maExternalLinks = rLinks;
475 void CreateStringFromXMLTokenArray( OUString& rFormula, OUString& rFormulaNmsp );
490 std::unique_ptr<ScTokenArray> CompileString(
const OUString& rFormula );
491 std::unique_ptr<ScTokenArray> CompileString(
const OUString& rFormula,
const OUString& rFormulaNmsp );
501 static bool IsCharFlagAllConventions(
502 OUString
const & rStr, sal_Int32 nPos,
ScCharFlags nFlags );
505 static bool DoubleRefToPosSingleRefScalarCase(
const ScRange& rRange,
ScAddress& rAdr,
515 virtual OUString
FindAddInFunction(
const OUString& rUpperName,
bool bLocalFirst )
const override;
519 virtual void fillAddInToken(::std::vector< css::sheet::FormulaOpCodeMapEntry >& _rVec,
bool _bIsEnglish)
const override;
550 void AnnotateTrimOnDoubleRefs();
bool HasUnhandledPossibleImplicitIntersections() const
css::uno::Sequence< css::sheet::ExternalLinkInfo > maExternalLinks
const ScAddress & GetPos() const
std::unordered_set< formula::FormulaTokenRef > mUnhandledPossibleImplicitIntersections
const ScInterpreterContext * mpInterpreterContext
std::vector< TableRefEntry > maTableRefs
void SetCloseBrackets(bool bVal)
void SetExternalLinks(const css::uno::Sequence< css::sheet::ExternalLinkInfo > &rLinks)
Set external link info for ScAddress::CONV_XL_OOX.
std::vector< PendingImplicitIntersectionOptimization > mPendingImplicitIntersectionOptimizations
ExtendedErrorDetection meExtendedErrorDetection
const CharClass * pCharClass
static const CharClass * pCharClassEnglish
sal_Int32 mnRangeOpPosInSymbol
const std::set< OpCode > & UnhandledPossibleImplicitIntersectionsOpCodes()
static const CharClass * pCharClassLocalized
void SetRefConventionChartOOXML(bool bVal)
bool mbRefConventionChartOOXML
std::vector< OUString > maTabNames
@ EXTENDED_ERROR_DETECTION_NAME_BREAK
const OUString & GetCorrectedFormula() const
void SetExtendedErrorDetection(ExtendedErrorDetection eVal)
sal_Int32 mnCurrentSheetEndPos
std::set< OpCode > mUnhandledPossibleImplicitIntersectionsOpCodes
std::vector< sal_uInt16 > maExternalFiles
sal_uInt16 mnPredetectedReference
ScCharFlags GetCharTableFlags(sal_Unicode c, sal_Unicode cLast)
Access the CharTable flags.
std::queue< OpCode > maPendingOpCodes
OpCodeMapPtr GetOpCodeMap(const sal_Int32 nLanguage) const
Overwrite FormulaCompiler::GetOpCodeMap() forwarding to GetFinalOpCodeMap().
SvNumberFormatter * mpFormatter
Matrix data type that can store values of mixed types.
CAUTION! The following defines must be in the same namespace as the respective type.
virtual css::i18n::ParseResult parseAnyToken(const OUString &rFormula, sal_Int32 nSrcPos, const CharClass *pCharClass, bool bGroupSeparator) const =0
@ SHEET_SEPARATOR
Character between sheet name and address.
const formula::FormulaGrammar::AddressConvention meConv
virtual sal_Unicode getSpecialSymbol(SpecialSymbolType eSymType) const =0
virtual ScCharFlags getCharTableFlags(sal_Unicode c, sal_Unicode cLast) const =0
std::unique_ptr< ScCharFlags[]> mpCharTable
virtual OUString makeExternalNameStr(sal_uInt16 nFileId, const OUString &rFile, const OUString &rName) const =0
virtual void makeExternalRefStr(ScSheetLimits &rLimits, OUStringBuffer &rBuffer, const ScAddress &rPos, sal_uInt16 nFileId, const OUString &rFileName, const std::vector< OUString > &rTabNames, const OUString &rTabName, const ScComplexRefData &rRef) const =0
virtual bool parseExternalName(const OUString &rSymbol, OUString &rFile, OUString &rName, const ScDocument &rDoc, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks) const =0
Parse the symbol string and pick up the file name and the external range name.
virtual void makeExternalRefStr(ScSheetLimits &rLimits, OUStringBuffer &rBuffer, const ScAddress &rPos, sal_uInt16 nFileId, const OUString &rFileName, const OUString &rTabName, const ScSingleRefData &rRef) const =0
virtual void makeRefStr(ScSheetLimits &rLimits, OUStringBuffer &rBuffer, formula::FormulaGrammar::Grammar eGram, const ScAddress &rPos, const OUString &rErrRef, const std::vector< OUString > &rTabNames, const ScComplexRefData &rRef, bool bSingleRef, bool bFromRangeName) const =0
"stack" of currently active ocTableRef tokens
formula::FormulaTokenRef parameter
formula::FormulaTokenRef operation
PendingImplicitIntersectionOptimization(formula::FormulaToken **p, formula::FormulaToken *o)
formula::FormulaToken ** parameterLocation
get or setup tab names for the current grammar
TableRefEntry(formula::FormulaToken *p)
void reset(sal_Unicode c)
Complex reference (a range) into the sheet.
void SetExternalDoubleRef(sal_uInt16 nFileId, const OUString &rTabName, const ScComplexRefData &rRef)
void SetDouble(double fVal)
void SetString(rtl_uString *pData, rtl_uString *pDataIgnoreCase)
struct ScRawToken::@17::@24 table
void SetDoubleReference(const ScComplexRefData &rRef)
short nJump[FORMULA_MAXJUMPCOUNT+1]
void SetExternalSingleRef(sal_uInt16 nFileId, const OUString &rTabName, const ScSingleRefData &rRef)
void SetOpCode(OpCode eCode)
struct ScRawToken::@17::@19 whitespace
struct ScRawToken::@17::@20 sbyte
void SetName(sal_Int16 nSheet, sal_uInt16 nIndex)
bool IsValidReference(const ScDocument &rDoc) const
If the token is a non-external reference, determine if the reference is valid.
struct ScRawToken::@17::@25 sharedstring
void SetSingleReference(const ScSingleRefData &rRef)
void SetErrorConstant(FormulaError nErr)
formula::StackVar GetType() const
only delete via Delete()
struct ScRawToken::@17::@21 extref
void SetExternalName(sal_uInt16 nFileId, const OUString &rName)
rtl_uString * mpDataIgnoreCase
formula::ParamClass eInForceArray
struct ScRawToken::@17::@23 name
ScTableRefToken::Item eItem
void SetExternal(const OUString &rStr)
struct ScRawToken::@17::@22 extname
formula::FormulaToken * CreateToken(ScSheetLimits &rLimits) const
Single reference (one address) into the sheet.
::boost::intrusive_ptr< formula::FormulaToken > ScTokenRef