diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2020-03-01 14:08:20 -0500 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-03-11 13:38:53 +0100 |
commit | 6b84dfabbb5f6930f9ac582f8c1dd9f467fd068c (patch) | |
tree | c188afa2081ffbf1eef7d1069b8ca8bd46e80519 /editeng | |
parent | 1b8fddee057901dc02480ac8dcb9cbabb0f80ba7 (diff) |
editeng: lok: send cursor visibility event when restoring update mode
When the default text is removed from a TextBox within a slide,
the cursor visibility is inadvertendly set to false and never
restored (because the LOK notification is disabled due to treating
the ShowCursor during SetUpdateMode as an activation of the TextBox,
and that is supressed to avoid messing up the cursor when creating
a new view).
We add a new flag to SetUpdateMode to flag whether this is an
activation or we are restoring a previously active window (TextBox)
due to a temporary disabling (to clear the default text).
Three unit-tests added not just to check and validate the fix,
but to also simulate two different ways of entering edit mode,
first by single-clicking on the text and then double-clicking
outside the text, but within the TextBox.
Change-Id: Icaaabc2a897f614f5ce162b71fadccff22ecda02
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90301
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 9 | ||||
-rw-r--r-- | editeng/source/editeng/editview.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 6 | ||||
-rw-r--r-- | editeng/source/outliner/outliner.cxx | 5 |
4 files changed, 13 insertions, 9 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index d547615299d2..7b13ec03b3b0 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -1455,11 +1455,14 @@ sal_uInt32 EditEngine::CalcTextWidth() return nWidth; } -void EditEngine::SetUpdateMode( bool bUpdate ) +void EditEngine::SetUpdateMode(bool bUpdate, bool bRestoring) { pImpEditEngine->SetUpdateMode( bUpdate ); - if ( pImpEditEngine->pActiveView ) - pImpEditEngine->pActiveView->ShowCursor( false, false, /*bActivate=*/true ); + if (pImpEditEngine->pActiveView) + { + // Not an activation if we are restoring the previous update mode. + pImpEditEngine->pActiveView->ShowCursor(false, false, /*bActivate=*/!bRestoring); + } } bool EditEngine::GetUpdateMode() const diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index 2854314004b1..20a4baeaee04 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -483,7 +483,7 @@ void EditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bActivat if (pParent && pParent->GetLOKWindowId() != 0) return; - OString aPayload = OString::boolean(true); + static const OString aPayload = OString::boolean(true); pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr()); pImpEditView->mpViewShell->NotifyOtherViews(LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload); } diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 3fd010ba3d0e..f327c54420b8 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -3925,12 +3925,12 @@ EditPaM ImpEditEngine::ConnectContents( sal_Int32 nLeftNode, bool bBackward ) void ImpEditEngine::SetUpdateMode( bool bUp, EditView* pCurView, bool bForceUpdate ) { - bool bChanged = ( GetUpdateMode() != bUp ); + const bool bChanged = (GetUpdateMode() != bUp); - // When switching from sal_True to sal_False, all selections were visible, + // When switching from true to false, all selections were visible, // => paint over // the other hand, were all invisible => paint - // If !bFormatted, e.g. after SetText, then if UpdateMode=sal_True + // If !bFormatted, e.g. after SetText, then if UpdateMode=true // formatting is not needed immediately, probably because more text is coming. // At latest it is formatted at a Paint/CalcTextWidth. bUpdate = bUp; diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 342e5878889f..6398d6cad69a 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -407,7 +407,7 @@ void Outliner::SetText( const OUString& rText, Paragraph* pPara ) { DBG_ASSERT(pPara,"SetText:No Para"); - bool bUpdate = pEditEngine->GetUpdateMode(); + const bool bUpdate = pEditEngine->GetUpdateMode(); pEditEngine->SetUpdateMode( false ); ImplBlockInsertionCallbacks( true ); @@ -483,7 +483,8 @@ void Outliner::SetText( const OUString& rText, Paragraph* pPara ) DBG_ASSERT(pParaList->GetParagraphCount()==pEditEngine->GetParagraphCount(),"SetText failed!"); bFirstParaIsEmpty = false; ImplBlockInsertionCallbacks( false ); - pEditEngine->SetUpdateMode( bUpdate ); + // Restore the update mode. + pEditEngine->SetUpdateMode(bUpdate, /*bRestoring=*/true); } // pView == 0 -> Ignore tabs |