diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2019-11-25 21:35:42 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-05-17 10:51:58 +0200 |
commit | 581767d4d66362b344bd9cd1dcf6e765d8d2b4f8 (patch) | |
tree | 8e3dbd34e768a76f6ede89f35acd27307f2ea872 | |
parent | 94eee55880f61788934dc20a1f7bded88a0f9fcf (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>
-rw-r--r-- | desktop/source/lib/init.cxx | 2 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKitEnums.h | 8 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 57 |
4 files changed, 68 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 0ec91fe23d58..806f43c30118 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1394,6 +1394,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) case LOK_CALLBACK_TEXT_VIEW_SELECTION: case LOK_CALLBACK_INVALIDATE_HEADER: case LOK_CALLBACK_WINDOW: + case LOK_CALLBACK_CALC_FUNCTION_LIST: { const auto& pos = std::find_if(m_queue.rbegin(), m_queue.rend(), [type] (const queue_type::value_type& elem) { return (elem.Type == type); }); @@ -1470,6 +1471,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: case LOK_CALLBACK_TEXT_VIEW_SELECTION: case LOK_CALLBACK_VIEW_CURSOR_VISIBLE: + case LOK_CALLBACK_CALC_FUNCTION_LIST: { const int nViewId = lcl_getViewId(payload); removeAll( diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index cfb046baf8d7..c621fb8d4f82 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -715,6 +715,12 @@ typedef enum * the description. */ LOK_CALLBACK_JSDIALOG = 46, + + /** + * Send the list of functions whose name starts with the characters entered + * by the user in the formula input bar. + */ + LOK_CALLBACK_CALC_FUNCTION_LIST = 47 } LibreOfficeKitCallbackType; @@ -837,6 +843,8 @@ static inline const char* lokCallbackTypeToString(int nType) return "LOK_CALLBACK_REFERENCE_MARKS"; case LOK_CALLBACK_JSDIALOG: return "LOK_CALLBACK_JSDIALOG"; + case LOK_CALLBACK_CALC_FUNCTION_LIST: + return "LOK_CALLBACK_CALC_FUNCTION_LIST"; } assert(!"Unknown LibreOfficeKitCallbackType type."); diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index b4fe85f2c939..87675fb0e1c4 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -1381,6 +1381,7 @@ callback (gpointer pData) case LOK_CALLBACK_CELL_AUTO_FILL_AREA: case LOK_CALLBACK_TABLE_SELECTED: case LOK_CALLBACK_JSDIALOG: + case LOK_CALLBACK_CALC_FUNCTION_LIST: { // TODO: Implement me break; diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 33975e24baf5..a620908c07f4 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -1028,6 +1028,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()); @@ -1282,6 +1287,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; |