26#include <com/sun/star/sheet/ComplexReference.hpp>
27#include <com/sun/star/sheet/ExternalReference.hpp>
28#include <com/sun/star/sheet/ReferenceFlags.hpp>
29#include <com/sun/star/sheet/AddressConvention.hpp>
30#include <com/sun/star/sheet/NameToken.hpp>
31#include <com/sun/star/table/CellAddress.hpp>
39#include <unonames.hxx>
40#include <compiler.hxx>
41#include <tokenarray.hxx>
59 return aFormulaParserMap_Impl;
77 mnConv( sheet::AddressConvention::UNSPECIFIED ),
79 mbIgnoreSpaces( true ),
80 mbCompileFAP( false ),
81 mbRefConventionChartOOXML( false )
83 mpDocShell->GetDocument().AddUnoObject(*
this);
96 if ( rHint.
GetId() == SfxHintId::Dying )
115 sheet::FormulaLanguage::OOXML :
116 (
mbEnglish ? sheet::FormulaLanguage::ENGLISH : sheet::FormulaLanguage::NATIVE));
130 const OUString& aFormula,
const table::CellAddress& rReferencePos )
133 uno::Sequence<sheet::FormulaToken> aRet;
145 std::unique_ptr<ScTokenArray> pCode = aCompiler.
CompileString( aFormula );
153 const uno::Sequence<sheet::FormulaToken>& aTokens,
const table::CellAddress& rReferencePos )
170 aRet =
aBuffer.makeStringAndClear();
185 const OUString& aPropertyName,
const uno::Any& aValue )
196 throw lang::IllegalArgumentException();
234 throw lang::IllegalArgumentException();
244 throw lang::IllegalArgumentException();
249 throw lang::IllegalArgumentException();
252 throw beans::UnknownPropertyException(aPropertyName);
288 throw beans::UnknownPropertyException(aPropertyName);
299 rAPI.RelativeColumn = 0;
300 rAPI.RelativeRow = 0;
301 rAPI.RelativeSheet = 0;
303 sal_Int32 nFlags = 0;
304 if ( rRef.IsColRel() )
306 nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
307 rAPI.RelativeColumn = rRef.Col();
310 rAPI.Column = rRef.Col();
312 if ( rRef.IsRowRel() )
314 nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
315 rAPI.RelativeRow = rRef.Row();
318 rAPI.Row = rRef.Row();
320 if ( rRef.IsColDeleted() ) nFlags |= sheet::ReferenceFlags::COLUMN_DELETED;
321 if ( rRef.IsRowDeleted() ) nFlags |= sheet::ReferenceFlags::ROW_DELETED;
322 if ( rRef.IsFlag3D() ) nFlags |= sheet::ReferenceFlags::SHEET_3D;
323 if ( rRef.IsRelName() ) nFlags |= sheet::ReferenceFlags::RELATIVE_NAME;
329 sal_Int32 nFlags = 0;
332 nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
333 rAPI.RelativeColumn = rRef.
Col();
338 rAPI.RelativeColumn = 0;
339 rAPI.Column = rRef.
Col();
344 nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
345 rAPI.RelativeRow = rRef.
Row();
350 rAPI.RelativeRow = 0;
351 rAPI.Row = rRef.
Row();
356 nFlags |= sheet::ReferenceFlags::SHEET_RELATIVE;
357 rAPI.RelativeSheet = rRef.
Tab();
362 rAPI.RelativeSheet = 0;
363 rAPI.Sheet = rRef.
Tab();
366 if ( rRef.
IsColDeleted() ) nFlags |= sheet::ReferenceFlags::COLUMN_DELETED;
367 if ( rRef.
IsRowDeleted() ) nFlags |= sheet::ReferenceFlags::ROW_DELETED;
368 if ( rRef.
IsTabDeleted() ) nFlags |= sheet::ReferenceFlags::SHEET_DELETED;
369 if ( rRef.
IsFlag3D() ) nFlags |= sheet::ReferenceFlags::SHEET_3D;
370 if ( rRef.
IsRelName() ) nFlags |= sheet::ReferenceFlags::RELATIVE_NAME;
375 ScTokenArray& rTokenArray,
const uno::Sequence<sheet::FormulaToken>& rSequence )
381 uno::Sequence<sheet::FormulaToken>& rSequence,
const ScTokenArray& rTokenArray )
383 sal_Int32 nLen =
static_cast<sal_Int32
>(rTokenArray.
GetLen());
387 rSequence.realloc(nLen);
388 auto pSequence = rSequence.getArray();
392 sheet::FormulaToken& rAPI = pSequence[
nPos];
401 rAPI.Data <<=
static_cast<sal_Int32
>(rToken.
GetByte());
406 rAPI.Data <<= OUString( rToken.
GetChar());
411 rAPI.Data <<=
aBuf.makeStringAndClear();
430 sheet::SingleReference aSingleRef;
432 rAPI.Data <<= aSingleRef;
437 sheet::ComplexReference aCompRef;
440 rAPI.Data <<= aCompRef;
445 sheet::NameToken aNameToken;
446 aNameToken.Index =
static_cast<sal_Int32
>( rToken.
GetIndex() );
447 aNameToken.Sheet = rToken.
GetSheet();
448 rAPI.Data <<= aNameToken;
457 sheet::SingleReference aSingleRef;
462 aSingleRef.Sheet =
static_cast< sal_Int32
>( nCacheId );
463 sheet::ExternalReference aExtRef;
465 aExtRef.Reference <<= aSingleRef;
466 rAPI.Data <<= aExtRef;
472 sheet::ComplexReference aComplRef;
478 aComplRef.Reference1.Sheet =
static_cast< sal_Int32
>( nCacheId );
480 aComplRef.Reference2.Sheet =
481 aComplRef.Reference1.Sheet +
483 sheet::ExternalReference aExtRef;
485 aExtRef.Reference <<= aComplRef;
486 rAPI.Data <<= aExtRef;
492 sheet::ExternalReference aExtRef;
495 rAPI.Data <<= aExtRef;
508 rAPI.OpCode =
static_cast<sal_Int32
>(eOpCode);
512 rSequence.realloc(0);
516:
formula::FormulaOpCodeMapperObj(
std::move(_pCompiler))
void SetFormulaLanguage(const OpCodeMapPtr &xMap)
Set symbol map if not empty.
void SetExternalLinks(const css::uno::Sequence< css::sheet::ExternalLinkInfo > &rLinks)
Set external link info for ScAddress::CONV_XL_OOX.
void SetRefConventionChartOOXML(bool bVal)
void SetRefConvention(const Convention *pConvP)
OpCodeMapPtr GetOpCodeMap(const sal_Int32 nLanguage) const
Overwrite FormulaCompiler::GetOpCodeMap() forwarding to GetFinalOpCodeMap().
std::unique_ptr< ScTokenArray > CompileString(const OUString &rFormula)
Tokenize formula expression string into an array of tokens.
const ScDocument & GetDocument() const
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
void RemoveUnoObject(SfxListener &rObject)
Use this guard when performing something from the API that might query values from external reference...
ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const
Get a cache table instance for specified table and table index.
static bool FillMixedArray(css::uno::Any &rAny, ScDocument &rDoc, const ScRange &rRange, bool bAllowNV=false)
static SC_DLLPUBLIC void ConvertToTokenSequence(const ScDocument &rDoc, css::uno::Sequence< css::sheet::FormulaToken > &rSequence, const ScTokenArray &rTokenArray)
static SC_DLLPUBLIC bool ConvertToTokenArray(ScDocument &rDoc, ScTokenArray &rTokenArray, const css::uno::Sequence< css::sheet::FormulaToken > &rSequence)
static void FillScAddress(ScAddress &rScAddress, const css::table::CellAddress &rApiAddress)
css::uno::Type const & get()
const OUString & getString() const
#define SAL_WARN(area, stream)
#define SAL_N_ELEMENTS(arr)
#define SC_SIMPLE_SERVICE_INFO(ClassName, ClassNameAscii, ServiceAscii)
#define SC_IMPL_DUMMY_PROPERTY_LISTENER(ClassName)
OStringBuffer & padToLength(OStringBuffer &rBuffer, sal_Int32 nLength, char cFill='\0')
Single reference (one address) into the sheet.
bool IsRowDeleted() const
bool IsTabDeleted() const
bool IsColDeleted() const
static o3tl::span< const SfxItemPropertyMapEntry > lcl_GetFormulaParserMap()
static void lcl_SingleRefToApi(sheet::SingleReference &rAPI, const ScSingleRefData &rRef)
static void lcl_ExternalRefToApi(sheet::SingleReference &rAPI, const ScSingleRefData &rRef)
const formula::FormulaGrammar::AddressConvention aConvMap[]
constexpr sal_Int16 nConvMapCount
constexpr OUStringLiteral SC_SERVICENAME_FORMULAPARS
constexpr OUStringLiteral SC_UNO_REF_CONV_CHARTOOXML
constexpr OUStringLiteral SC_UNO_OPCODEMAP
constexpr OUStringLiteral SC_UNO_COMPILEENGLISH
constexpr OUStringLiteral SC_UNO_COMPILEFAP
constexpr OUStringLiteral SC_UNO_EXTERNALLINKS
constexpr OUStringLiteral SC_UNO_FORMULACONVENTION
constexpr OUStringLiteral SC_UNO_IGNORELEADING
std::unique_ptr< char[]> aBuffer