mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Add custom functions conversion
This commit is contained in:
@ -402,13 +402,14 @@ const bool StringPtgParser::parseToPtgs(const std::wstring& assembled_formula, R
|
||||
}
|
||||
else
|
||||
{
|
||||
SyntaxPtg::extract_CustomFunction(operand_str, number);
|
||||
func = PtgFuncVar::create(L"USER_DEFINED_FUNCTION", OperandPtg::ptg_REFERENCE);
|
||||
if(!func)
|
||||
{
|
||||
// EXCEPT::LE::WhatIsTheFuck("Ftab_Cetab doesn't contain info about user-defined function (0xFF).", __FUNCTION__);
|
||||
}
|
||||
ptg_stack.push(func);
|
||||
rgce.addPtg(PtgPtr(new PtgNameX(operand_str, OperandPtg::ptg_REFERENCE)));
|
||||
rgce.addPtg(PtgPtr(new PtgName(number, OperandPtg::ptg_REFERENCE)));
|
||||
}
|
||||
}
|
||||
else if(SyntaxPtg::extract_UndefinedName(it, itEnd)) // Shall be placed strongly after extract_PtgName
|
||||
|
||||
@ -853,6 +853,20 @@ const bool SyntaxPtg::extract_FutureFunction(const std::wstring &funcName, unsig
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
const void SyntaxPtg::extract_CustomFunction(const std::wstring &funcName, unsigned int& out_num)
|
||||
{
|
||||
auto funcNum = XMLSTUFF::definenames2index(funcName);
|
||||
if(funcNum != 0xFFFFFFFF)
|
||||
{
|
||||
out_num = funcNum;
|
||||
}
|
||||
else
|
||||
{
|
||||
out_num = XMLSTUFF::AddDefinedName(funcName);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
const void SyntaxPtg::remove_extraSymbols(std::wstring::const_iterator& first, std::wstring::const_iterator& last)
|
||||
{
|
||||
|
||||
@ -87,6 +87,7 @@ public:
|
||||
|
||||
static const bool extract_PtgFunc(std::wstring::const_iterator& first, std::wstring::const_iterator last, std::wstring& out_str);
|
||||
static const bool extract_FutureFunction(const std::wstring &funcName, unsigned int& out_num);
|
||||
static const void extract_CustomFunction(const std::wstring &funcName, unsigned int& out_num);
|
||||
static const void remove_extraSymbols(std::wstring::const_iterator& first, std::wstring::const_iterator& last);
|
||||
};
|
||||
|
||||
|
||||
@ -248,7 +248,14 @@ namespace OOX
|
||||
return FunctionsVector;
|
||||
for(auto i = namesStart; i < XLS::GlobalWorkbookInfo::arDefineNames_static.size(); i++)
|
||||
{
|
||||
FunctionsVector.push_back(createFutureFunction(XLS::GlobalWorkbookInfo::arDefineNames_static[i]));
|
||||
if(XLS::GlobalWorkbookInfo::arDefineNames_static[i].substr(0, 6) == L"_xlfn.")
|
||||
{
|
||||
FunctionsVector.push_back(createFutureFunction(XLS::GlobalWorkbookInfo::arDefineNames_static[i]));
|
||||
}
|
||||
else
|
||||
{
|
||||
FunctionsVector.push_back(createCustomFunction(XLS::GlobalWorkbookInfo::arDefineNames_static[i]));
|
||||
}
|
||||
}
|
||||
return FunctionsVector;
|
||||
}
|
||||
@ -294,6 +301,7 @@ namespace OOX
|
||||
auto ptr(new XLSB::Name);
|
||||
XLS::BaseObjectPtr objectPtr(ptr);
|
||||
|
||||
ptr->chKey = 0;
|
||||
ptr->fHidden = true;
|
||||
ptr->fFunc = true;
|
||||
ptr->fOB = false;
|
||||
@ -316,5 +324,33 @@ namespace OOX
|
||||
return objectPtr;
|
||||
}
|
||||
|
||||
XLS::BaseObjectPtr CDefinedNames::createCustomFunction(const std::wstring& funcName)
|
||||
{
|
||||
auto ptr(new XLSB::Name);
|
||||
XLS::BaseObjectPtr objectPtr(ptr);
|
||||
|
||||
ptr->chKey = 0;
|
||||
ptr->fHidden = false;
|
||||
ptr->fFunc = true;
|
||||
ptr->fOB = true;
|
||||
ptr->fProc = true;
|
||||
ptr->fCalcExp = false;
|
||||
ptr->fGrp = false;
|
||||
ptr->fPublished = false;
|
||||
ptr->fBuiltin = false;
|
||||
ptr->fWorkbookParam = false;
|
||||
ptr->itab = 0xFFFFFFFF;
|
||||
ptr->comment.setSize(0xFFFFFFFF);
|
||||
|
||||
ptr->description.setSize(0xFFFFFFFF);
|
||||
ptr->helpTopic.setSize(0xFFFFFFFF);
|
||||
ptr->unusedstring1.setSize(0xFFFFFFFF);
|
||||
ptr->unusedstring2.setSize(0xFFFFFFFF);
|
||||
|
||||
ptr->fFutureFunction = false;
|
||||
ptr->name = funcName;
|
||||
return objectPtr;
|
||||
}
|
||||
|
||||
} //Spreadsheet
|
||||
} // namespace OOX
|
||||
|
||||
@ -109,6 +109,7 @@ namespace OOX
|
||||
|
||||
private:
|
||||
XLS::BaseObjectPtr createFutureFunction(const std::wstring& funcName);
|
||||
XLS::BaseObjectPtr createCustomFunction(const std::wstring& custom);
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user