summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-07-14 16:52:23 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2022-07-26 16:54:49 +0200
commita6586ab2e6a5bb352f2958067cbe88095b6e2ada (patch)
tree0e695f1450f207df510857d6a752f44ebe2943a0
parent7974cea6c788e02d7c36573e2d10dcc51884f70e (diff)
lok: formulabar: handle mobile IME
Change-Id: I7cb69efaebb42020353133e590a161b2e4bc5210 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137086 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Mert Tumer <mert.tumer@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137457 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--sc/source/ui/app/inputhdl.cxx2
-rw-r--r--sc/source/ui/app/inputwin.cxx45
2 files changed, 36 insertions, 11 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 56ba5cfd9e72..99b8be0284a8 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -4108,7 +4108,7 @@ void ScInputHandler::InputCommand( const CommandEvent& rCEvt )
{
if (pTableView)
pTableView->Command( rCEvt );
- if (pTopView && !comphelper::LibreOfficeKit::isActive())
+ if (pTopView)
pTopView->Command( rCEvt );
if ( rCEvt.GetCommand() == CommandEventId::EndExtTextInput )
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 395499a683d7..4ecd18c01bbf 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -412,9 +412,18 @@ void ScInputWindow::StartFormula()
EditView* pView = mxTextWindow->GetEditView();
if (pView)
{
+ sal_Int32 nStartPara = 0, nEndPara = 0;
if (comphelper::LibreOfficeKit::isActive())
+ {
TextGrabFocus();
- pView->SetSelection( ESelection(0, nStartPos, 0, nEndPos) );
+ if (pViewSh && !pViewSh->isLOKDesktop())
+ {
+ nStartPara = nEndPara = pView->GetEditEngine()->GetParagraphCount() ?
+ (pView->GetEditEngine()->GetParagraphCount() - 1) : 0;
+ nStartPos = nEndPos = pView->GetEditEngine()->GetTextLen(nStartPara);
+ }
+ }
+ pView->SetSelection(ESelection(nStartPara, nStartPos, nEndPara, nEndPos));
pScMod->InputChanged(pView);
SetOkCancelMode();
pView->SetEditEngineUpdateLayout(true);
@@ -1779,10 +1788,26 @@ bool ScTextWnd::Command( const CommandEvent& rCEvt )
// see vcl/jsdialog/executor.cxx "textselection" event
const Point* pParaPoint = static_cast<const Point*>(rCEvt.GetEventData());
Point aSelectionStartEnd = rCEvt.GetMousePosPixel();
- m_xEditView->SetSelection(
- ESelection((pParaPoint ? pParaPoint->X() : 0), aSelectionStartEnd.X(),
- (pParaPoint ? pParaPoint->Y() : 0), aSelectionStartEnd.Y()));
+ sal_Int32 nParaStart, nParaEnd, nPosStart, nPosEnd;
+
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if (pViewSh && pViewSh->isLOKMobilePhone())
+ {
+ // We use IME - do not select anything, put cursor at the end
+ nParaStart = nParaEnd = m_xEditView->GetEditEngine()->GetParagraphCount() ?
+ (m_xEditView->GetEditEngine()->GetParagraphCount() - 1) : 0;
+ nPosStart = nPosEnd = m_xEditView->GetEditEngine()->GetTextLen(nParaStart);
+ }
+ else
+ {
+ nParaStart = pParaPoint ? pParaPoint->X() : 0;
+ nParaEnd = pParaPoint ? pParaPoint->Y() : 0;
+ nPosStart = aSelectionStartEnd.X();
+ nPosEnd = aSelectionStartEnd.Y();
+ }
+
+ m_xEditView->SetSelection(ESelection(nParaStart, nPosStart, nParaEnd, nPosEnd));
SC_MOD()->InputSelection( m_xEditView.get() );
bConsumed = true;
@@ -1944,12 +1969,6 @@ static sal_Int32 findFirstNonMatchingChar(const OUString& rStr1, const OUString&
void ScTextWnd::SetTextString( const OUString& rNewString )
{
- if (comphelper::LibreOfficeKit::isActive())
- {
- ESelection aSel = m_xEditView ? m_xEditView->GetSelection() : ESelection();
- ScInputHandler::LOKSendFormulabarUpdate(SfxViewShell::Current(), rNewString, aSel);
- }
-
// Ideally it would be best to create on demand the EditEngine/EditView here, but... for
// the initialisation scenario where a cell is first clicked on we end up with the text in the
// inputbar window scrolled to the bottom if we do that here ( because the tableview and topview
@@ -2024,6 +2043,12 @@ void ScTextWnd::SetTextString( const OUString& rNewString )
bInputMode = false;
}
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ ESelection aSel = m_xEditView ? m_xEditView->GetSelection() : ESelection();
+ ScInputHandler::LOKSendFormulabarUpdate(SfxViewShell::Current(), rNewString, aSel);
+ }
+
SetScrollBarRange();
DoScroll();
}