summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2019-11-25 21:35:42 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-11-26 16:26:28 +0100
commitfa42338091ecd96b637ea52984c2642b89966f44 (patch)
tree84087f5259643aac3d4dddcc909703a5adcedd03
parent2849104773b4a32c8582e5e2c989bfc73f90274c (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.cxx2
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitEnums.h8
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx1
-rw-r--r--sc/source/ui/app/inputhdl.cxx57
4 files changed, 68 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index db7ca361ba88..2d8f7290a05d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1187,6 +1187,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); });
@@ -1263,6 +1264,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 829eca07e500..fb4822613724 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -709,6 +709,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;
@@ -831,6 +837,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 f6fc2d8160ea..d5c9b919e0a9 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1389,6 +1389,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 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;