diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2019-11-25 21:35:42 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-11-26 16:26:28 +0100 |
commit | fa42338091ecd96b637ea52984c2642b89966f44 (patch) | |
tree | 84087f5259643aac3d4dddcc909703a5adcedd03 /sc | |
parent | 2849104773b4a32c8582e5e2c989bfc73f90274c (diff) |
lok: calc formula bar tunneling: function list callback
Added a lok callback for sending the list of functions matching the
current characters typed by the user.
Change-Id: Ia971fc55ec5eb961b4098592a8049dd0eed3ba14
Reviewed-on: https://gerrit.libreoffice.org/83750
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 950a8280a055..640ea40060e0 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -1022,6 +1022,11 @@ bool lcl_hasSingleToken(const OUString& s, sal_Unicode c) void ScInputHandler::ShowArgumentsTip( OUString& rSelText ) { + if (comphelper::LibreOfficeKit::isActive()) + { + return; + } + ScDocShell* pDocSh = pActiveViewSh->GetViewData().GetDocShell(); const sal_Unicode cSep = ScCompiler::GetNativeSymbolChar(ocSep); const sal_Unicode cSheetSep = lcl_getSheetSeparator(&pDocSh->GetDocument()); @@ -1276,6 +1281,58 @@ bool ScInputHandler::GetFuncName( OUString& aStart, OUString& aResult ) void ScInputHandler::ShowFuncList( const ::std::vector< OUString > & rFuncStrVec ) { + if (comphelper::LibreOfficeKit::isActive()) + { + SfxViewShell* pViewShell = SfxViewShell::Current(); + if (pViewShell && rFuncStrVec.size()) + { + OUString aFuncNameStr; + OUString aDescFuncNameStr; + OStringBuffer aPayload; + aPayload.append("[ "); + for (const OUString& rFunc : rFuncStrVec) + { + if ( rFunc[rFunc.getLength()-1] == cParenthesesReplacement ) + { + aFuncNameStr = rFunc.copy(0, rFunc.getLength()-1); + } + else + { + aFuncNameStr = rFunc; + } + + FormulaHelper aHelper(ScGlobal::GetStarCalcFunctionMgr()); + aDescFuncNameStr = aFuncNameStr + "()"; + sal_Int32 nNextFStart = 0; + const IFunctionDescription* ppFDesc; + ::std::vector< OUString > aArgs; + OUString eqPlusFuncName = "=" + aDescFuncNameStr; + if ( aHelper.GetNextFunc( eqPlusFuncName, false, nNextFStart, nullptr, &ppFDesc, &aArgs ) ) + { + if ( !ppFDesc->getFunctionName().isEmpty() ) + { + aPayload.append("{"); + aPayload.append("\"signature\": \""); + OUString aSignature = ppFDesc->getSignature(); + aPayload.append(OUStringToOString(aSignature, RTL_TEXTENCODING_UTF8)); + aPayload.append("\", "); + aPayload.append("\"description\": \""); + OUString aFuncDescr = ppFDesc->getDescription(); + aPayload.append(OUStringToOString(aFuncDescr, RTL_TEXTENCODING_UTF8)); + aPayload.append("\"}, "); + } + } + } + sal_Int32 nLen = aPayload.getLength(); + aPayload[nLen - 2] = ' '; + aPayload[nLen - 1] = ']'; + + OString s = aPayload.makeStringAndClear(); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CALC_FUNCTION_LIST, s.getStr()); + } + return; + } + OUStringBuffer aTipStr; OUString aFuncNameStr; OUString aDescFuncNameStr; |