[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - sc/source
Marco Cecchetti (via logerrit)
logerrit at kemper.freedesktop.org
Wed Apr 29 07:54:45 UTC 2020
sc/source/ui/app/inputhdl.cxx | 74 ++++++++++++++++++++-----
sc/source/ui/app/inputwin.cxx | 42 ++++++++------
sc/source/ui/view/cellsh3.cxx | 121 +++++++++++++++++++++++++++++++++++++++--
sc/source/ui/view/tabvwshc.cxx | 8 +-
4 files changed, 208 insertions(+), 37 deletions(-)
New commits:
commit 1bb432503f0fb3af12f1405f343c5305206907c4
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
AuthorDate: Tue Feb 25 14:07:28 2020 +0100
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Apr 29 09:54:27 2020 +0200
lok: remove sum and equal buttons from the formula bar
This patch removes sum and equal buttons from the formula bar in the
lok case. A tentative to limit that to the mobile case has been done
however the formula input bar is created before than the client view
so we are not able to use the LibreOfficeKit::isMobile check.
Change-Id: Icb820a0d77eb9295046997d2f3690d7f8b39680d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89453
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 3dd89beb22ae..60a2a2b93c79 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -199,10 +199,16 @@ ScInputWindow::ScInputWindow( vcl::Window* pParent, const SfxBindings* pBind ) :
InsertSeparator (1);
InsertItem (SID_INPUT_FUNCTION, Image(StockImage::Yes, RID_BMP_INPUT_FUNCTION), ToolBoxItemBits::NONE, 2);
}
- InsertItem (SID_INPUT_SUM, Image(StockImage::Yes, RID_BMP_INPUT_SUM), ToolBoxItemBits::NONE, 3);
- InsertItem (SID_INPUT_EQUAL, Image(StockImage::Yes, RID_BMP_INPUT_EQUAL), ToolBoxItemBits::NONE, 4);
- InsertItem (SID_INPUT_CANCEL, Image(StockImage::Yes, RID_BMP_INPUT_CANCEL), ToolBoxItemBits::NONE, 5);
- InsertItem (SID_INPUT_OK, Image(StockImage::Yes, RID_BMP_INPUT_OK), ToolBoxItemBits::NONE, 6);
+
+ // sigma and euqal buttons
+ if (!mpViewShell->isLOKMobilePhone())
+ {
+ InsertItem (SID_INPUT_SUM, Image(StockImage::Yes, RID_BMP_INPUT_SUM), ToolBoxItemBits::NONE, 3);
+ InsertItem (SID_INPUT_EQUAL, Image(StockImage::Yes, RID_BMP_INPUT_EQUAL), ToolBoxItemBits::NONE, 4);
+ InsertItem (SID_INPUT_CANCEL, Image(StockImage::Yes, RID_BMP_INPUT_CANCEL), ToolBoxItemBits::NONE, 5);
+ InsertItem (SID_INPUT_OK, Image(StockImage::Yes, RID_BMP_INPUT_OK), ToolBoxItemBits::NONE, 6);
+ }
+
if (!comphelper::LibreOfficeKit::isActive())
{
InsertSeparator (7);
@@ -224,23 +230,27 @@ ScInputWindow::ScInputWindow( vcl::Window* pParent, const SfxBindings* pBind ) :
SetHelpId (SID_INPUT_FUNCTION, HID_INSWIN_CALC);
}
- SetItemText (SID_INPUT_SUM, ScResId( SCSTR_QHELP_BTNSUM ) );
- SetHelpId (SID_INPUT_SUM, HID_INSWIN_SUMME);
+ // sigma and euqal buttons
+ if (!mpViewShell->isLOKMobilePhone())
+ {
+ SetItemText (SID_INPUT_SUM, ScResId( SCSTR_QHELP_BTNSUM ) );
+ SetHelpId (SID_INPUT_SUM, HID_INSWIN_SUMME);
- SetItemText (SID_INPUT_EQUAL, ScResId( SCSTR_QHELP_BTNEQUAL ) );
- SetHelpId (SID_INPUT_EQUAL, HID_INSWIN_FUNC);
+ SetItemText (SID_INPUT_EQUAL, ScResId( SCSTR_QHELP_BTNEQUAL ) );
+ SetHelpId (SID_INPUT_EQUAL, HID_INSWIN_FUNC);
- SetItemText ( SID_INPUT_CANCEL, ScResId( SCSTR_QHELP_BTNCANCEL ) );
- SetHelpId ( SID_INPUT_CANCEL, HID_INSWIN_CANCEL );
+ SetItemText ( SID_INPUT_CANCEL, ScResId( SCSTR_QHELP_BTNCANCEL ) );
+ SetHelpId ( SID_INPUT_CANCEL, HID_INSWIN_CANCEL );
- SetItemText ( SID_INPUT_OK, ScResId( SCSTR_QHELP_BTNOK ) );
- SetHelpId ( SID_INPUT_OK, HID_INSWIN_OK );
+ SetItemText ( SID_INPUT_OK, ScResId( SCSTR_QHELP_BTNOK ) );
+ SetHelpId ( SID_INPUT_OK, HID_INSWIN_OK );
- EnableItem( SID_INPUT_CANCEL, false );
- EnableItem( SID_INPUT_OK, false );
+ EnableItem( SID_INPUT_CANCEL, false );
+ EnableItem( SID_INPUT_OK, false );
- HideItem( SID_INPUT_CANCEL );
- HideItem( SID_INPUT_OK );
+ HideItem( SID_INPUT_CANCEL );
+ HideItem( SID_INPUT_OK );
+ }
SetHelpId( HID_SC_INPUTWIN ); // For the whole input row
commit 470cc5f279aa18f3d03633762e712882c6d115a4
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
AuthorDate: Wed Feb 12 15:01:19 2020 +0100
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Apr 29 09:54:12 2020 +0200
lok: formula bar: send whole function list
Change-Id: Ibbd142652f3190387700f820e56c494b61bfa658
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89199
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index cc686f65834b..f18995f4fc35 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1309,6 +1309,10 @@ void ScInputHandler::ShowFuncList( const ::std::vector< OUString > & rFuncStrVec
{
if (rFuncStrVec.size())
{
+ auto aPos = pFormulaData->begin();
+ sal_uInt32 nCurIndex = std::distance(aPos, miAutoPosFormula);
+ const sal_uInt32 nSize = pFormulaData->size();
+
OUString aFuncNameStr;
OUString aDescFuncNameStr;
OStringBuffer aPayload;
@@ -1335,6 +1339,9 @@ void ScInputHandler::ShowFuncList( const ::std::vector< OUString > & rFuncStrVec
if ( !ppFDesc->getFunctionName().isEmpty() )
{
aPayload.append("{");
+ aPayload.append("\"index\": ");
+ aPayload.append(OString::number(nCurIndex));
+ aPayload.append(", ");
aPayload.append("\"signature\": \"");
aPayload.append(escapeJSON(ppFDesc->getSignature()));
aPayload.append("\", ");
@@ -1343,6 +1350,9 @@ void ScInputHandler::ShowFuncList( const ::std::vector< OUString > & rFuncStrVec
aPayload.append("\"}, ");
}
}
+ ++nCurIndex;
+ if (nCurIndex == nSize)
+ nCurIndex = 0;
}
sal_Int32 nLen = aPayload.getLength();
aPayload[nLen - 2] = ' ';
@@ -1514,15 +1524,36 @@ void completeFunction( EditView* pView, const OUString& rInsert, bool& rParInser
pView->SetSelection(aSel);
pView->SelectCurrentWord();
+ bool bNoInitialLetter = false;
+ OUString aSelectedText = pView->GetSelected();
+ OUString aOld = pView->GetEditEngine()->GetText(0);
+ // in case we want just insert a function and not completing
+ if ( comphelper::LibreOfficeKit::isActive() )
+ {
+ if ( aOld == "=" )
+ {
+ bNoInitialLetter = true;
+ aSel.nStartPos = 1;
+ aSel.nEndPos = 1;
+ pView->SetSelection(aSel);
+ }
+ else if ( aSelectedText.startsWith("()") )
+ {
+ bNoInitialLetter = true;
+ ++aSel.nStartPos;
+ ++aSel.nEndPos;
+ pView->SetSelection(aSel);
+ }
+ }
// a dot and underscore are word separators so we need special
// treatment for any formula containing a dot or underscore
- if(rInsert.indexOf(".") != -1 || rInsert.indexOf("_") != -1)
+ if(!bNoInitialLetter && (rInsert.indexOf(".") != -1 || rInsert.indexOf("_") != -1))
{
// need to make sure that we replace also the part before the dot
// go through the word to find the match with the insert string
aSel = pView->GetSelection();
ESelection aOldSelection = aSel;
- OUString aSelectedText = pView->GetSelected();
+
if ( needToExtendSelection( aSelectedText, rInsert ) )
{
while(needToExtendSelection(aSelectedText, rInsert))
@@ -1553,7 +1584,6 @@ void completeFunction( EditView* pView, const OUString& rInsert, bool& rParInser
// Do not insert parentheses after function names if there already are some
// (e.g. if the function name was edited).
ESelection aWordSel = pView->GetSelection();
- OUString aOld = pView->GetEditEngine()->GetText(0);
// aWordSel.EndPos points one behind string if word at end
if (aWordSel.nEndPos < aOld.getLength())
@@ -1612,16 +1642,34 @@ void ScInputHandler::PasteFunctionData()
void ScInputHandler::LOKPasteFunctionData( sal_uInt32 nIndex )
{
- if (pFormulaData && miAutoPosFormula != pFormulaData->end() && nIndex < pFormulaData->size())
- {
- auto aPos = pFormulaData->begin();
- sal_uInt32 nCurIndex = std::distance(aPos, miAutoPosFormula);
- nIndex += nCurIndex;
- if (nIndex >= pFormulaData->size())
- nIndex -= pFormulaData->size();
- std::advance(aPos, nIndex);
- miAutoPosFormula = aPos;
- PasteFunctionData();
+ if (pActiveViewSh && (pTopView || pTableView))
+ {
+ bool bEdit = false;
+ OUString aFormula;
+ EditView* pEditView = pTopView ? pTopView : pTableView;
+ const EditEngine* pEditEngine = pEditView->GetEditEngine();
+ if (pEditEngine)
+ {
+ aFormula = pEditEngine->GetText(0);
+ bEdit = aFormula.getLength() > 1 && (aFormula[0] == '=' || aFormula[0] == '+' || aFormula[0] == '-');
+ }
+
+ if ( !bEdit )
+ {
+ OUString aNewFormula('=');
+ if ( aFormula.startsWith("=") )
+ aNewFormula = aFormula;
+
+ InputReplaceSelection( aNewFormula );
+ }
+
+ if (pFormulaData && nIndex < pFormulaData->size())
+ {
+ auto aPos = pFormulaData->begin();
+ std::advance(aPos, nIndex);
+ miAutoPosFormula = aPos;
+ PasteFunctionData();
+ }
}
}
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 2125ebcf0d05..6b9b40cb075d 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -20,6 +20,7 @@
#include <scitems.hxx>
#include <editeng/editview.hxx>
#include <editeng/editeng.hxx>
+#include <formula/formulahelper.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
@@ -42,6 +43,7 @@
#include <cellsh.hxx>
#include <inputhdl.hxx>
#include <editable.hxx>
+#include <funcdesc.hxx>
#include <markdata.hxx>
#include <scabstdlg.hxx>
#include <columnspanset.hxx>
@@ -56,6 +58,103 @@
using sc::HMMToTwips;
using sc::TwipsToEvenHMM;
+namespace
+{
+/// Rid ourselves of unwanted " quoted json characters.
+OString escapeJSON(const OUString &aStr)
+{
+ OUString aEscaped = aStr;
+ aEscaped = aEscaped.replaceAll("\n", " ");
+ aEscaped = aEscaped.replaceAll("\"", "'");
+ return OUStringToOString(aEscaped, RTL_TEXTENCODING_UTF8);
+}
+
+void lcl_lokGetWholeFunctionList()
+{
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (comphelper::LibreOfficeKit::isActive()
+ && pViewShell && pViewShell->isLOKMobilePhone())
+ {
+ const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
+ sal_uInt32 nListCount = pFuncList->GetCount();
+ std::set<OUString> aFuncNameOrderedSet;
+ for(sal_uInt32 i = 0; i < nListCount; ++i)
+ {
+ const ScFuncDesc* pDesc = pFuncList->GetFunction( i );
+ if ( pDesc->mxFuncName )
+ {
+ aFuncNameOrderedSet.insert(*pDesc->mxFuncName);
+ }
+ }
+ ScFunctionMgr* pFuncManager = ScGlobal::GetStarCalcFunctionMgr();
+ if (pFuncManager && aFuncNameOrderedSet.size())
+ {
+ OStringBuffer aPayload;
+ aPayload.append("{ \"wholeList\": true, ");
+ aPayload.append("\"categories\": [ ");
+
+ formula::FormulaHelper aHelper(pFuncManager);
+ sal_uInt32 nCategoryCount = pFuncManager->getCount();
+ for (sal_uInt32 i = 0; i < nCategoryCount; ++i)
+ {
+ OUString sCategoryName = pFuncManager->GetCategoryName(i);
+ aPayload.append("{");
+ aPayload.append("\"name\": \"");
+ aPayload.append(escapeJSON(sCategoryName));
+ aPayload.append("\"}, ");
+ }
+ sal_Int32 nLen = aPayload.getLength();
+ aPayload[nLen - 2] = ' ';
+ aPayload[nLen - 1] = ']';
+ aPayload.append(", ");
+
+ OUString aDescFuncNameStr;
+ aPayload.append("\"functions\": [ ");
+ sal_uInt32 nCurIndex = 0;
+ for (const OUString& aFuncNameStr : aFuncNameOrderedSet)
+ {
+ aDescFuncNameStr = aFuncNameStr + "()";
+ sal_Int32 nNextFStart = 0;
+ const formula::IFunctionDescription* ppFDesc;
+ ::std::vector< OUString > aArgs;
+ OUString eqPlusFuncName = "=" + aDescFuncNameStr;
+ if ( aHelper.GetNextFunc( eqPlusFuncName, false, nNextFStart, nullptr, &ppFDesc, &aArgs ) )
+ {
+ if ( ppFDesc && !ppFDesc->getFunctionName().isEmpty() )
+ {
+ if (ppFDesc->getCategory())
+ {
+ aPayload.append("{");
+ aPayload.append("\"index\": ");
+ aPayload.append(OString::number(nCurIndex));
+ aPayload.append(", ");
+ aPayload.append("\"category\": ");
+ aPayload.append(OString::number(ppFDesc->getCategory()->getNumber()));
+ aPayload.append(", ");
+ aPayload.append("\"signature\": \"");
+ aPayload.append(escapeJSON(ppFDesc->getSignature()));
+ aPayload.append("\", ");
+ aPayload.append("\"description\": \"");
+ aPayload.append(escapeJSON(ppFDesc->getDescription()));
+ aPayload.append("\"}, ");
+ }
+ }
+ }
+ ++nCurIndex;
+ }
+ nLen = aPayload.getLength();
+ aPayload[nLen - 2] = ' ';
+ aPayload[nLen - 1] = ']';
+ aPayload.append(" }");
+
+ OString s = aPayload.makeStringAndClear();
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CALC_FUNCTION_LIST, s.getStr());
+ }
+ }
+}
+
+} // end namespace
+
void ScCellShell::Execute( SfxRequest& rReq )
{
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
@@ -316,11 +415,23 @@ void ScCellShell::Execute( SfxRequest& rReq )
case SID_OPENDLG_FUNCTION:
{
- sal_uInt16 nId = SID_OPENDLG_FUNCTION;
- SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
- SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
- bool bVis = comphelper::LibreOfficeKit::isActive() || pWnd == nullptr;
- pScMod->SetRefDialog( nId, bVis );
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (comphelper::LibreOfficeKit::isActive()
+ && pViewShell && pViewShell->isLOKMobilePhone())
+ {
+ // not set the dialog id in the mobile case or we would
+ // not be able to get cell address pasted in the edit view
+ // by just tapping on them
+ lcl_lokGetWholeFunctionList();
+ }
+ else
+ {
+ sal_uInt16 nId = SID_OPENDLG_FUNCTION;
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+ bool bVis = comphelper::LibreOfficeKit::isActive() || pWnd == nullptr;
+ pScMod->SetRefDialog( nId, bVis );
+ }
rReq.Ignore();
}
break;
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 61e776d8b798..1f0cd9bf737b 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -434,9 +434,11 @@ VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog(
case SID_OPENDLG_FUNCTION:
{
- // dialog checks, what is in the cell
-
- pResult = VclPtr<ScFormulaDlg>::Create( pB, pCW, pParent, &GetViewData(),ScGlobal::GetStarCalcFunctionMgr() );
+ if (!isLOKMobilePhone())
+ {
+ // dialog checks, what is in the cell
+ pResult = VclPtr<ScFormulaDlg>::Create( pB, pCW, pParent, &GetViewData(),ScGlobal::GetStarCalcFunctionMgr() );
+ }
}
break;
More information about the Libreoffice-commits
mailing list