From 99fdaf683e6403b1d8a70d48ebe0e20194017624 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Thu, 19 Oct 2017 19:23:01 +0200 Subject: Resolves: tdf#113179 merge language attributes early, tdf#108795 follow-up Merging attributes from table to top EditEngine has to be done before colorizing with the range finder, as the resulting merged default item set *overwrites* the items set. Change-Id: I6561201de11344161f61d7d4cf6a7b79d76ba493 (cherry picked from commit 8112af3361fdf15fcf5d3177cd967e1d8d97d5f3) Reviewed-on: https://gerrit.libreoffice.org/43572 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos --- sc/source/ui/app/inputhdl.cxx | 16 ++++++++++++---- sc/source/ui/app/inputwin.cxx | 8 +------- sc/source/ui/inc/inputhdl.hxx | 9 +++++++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index ac72e1123ad1..a84291d721a5 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -2020,7 +2020,8 @@ void ScInputHandler::RemoveRangeFinder() DeleteRangeFinder(); // Deletes the list and the labels on the table } -bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated ) +bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated, + ScEditEngineDefaulter* pTopEngine ) { bool bNewTable = false; @@ -2141,6 +2142,13 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bIn } } + if (pTopEngine) + { + // Necessary to sync SvxAutoCorrect behavior. This has to be + // done before InitRangeFinder() below. + MergeLanguageAttributes( *pTopEngine); + } + // UpdateSpellSettings enables online spelling if needed // -> also call if attributes are unchanged UpdateSpellSettings( true ); // uses pLastPattern @@ -2272,7 +2280,7 @@ bool ScInputHandler::DataChanging( sal_Unicode cTyped, bool bFromCommand ) bInOwnChange = true; // disable ModifyHdl (reset in DataChanged) if ( eMode == SC_INPUT_NONE ) - return StartTable( cTyped, bFromCommand, false ); + return StartTable( cTyped, bFromCommand, false, nullptr ); else return false; } @@ -2488,7 +2496,7 @@ void ScInputHandler::InvalidateAttribs() // --------------- public methods -------------------------------------------- -void ScInputHandler::SetMode( ScInputMode eNewMode, const OUString* pInitText ) +void ScInputHandler::SetMode( ScInputMode eNewMode, const OUString* pInitText, ScEditEngineDefaulter* pTopEngine ) { if ( eMode == eNewMode ) return; @@ -2519,7 +2527,7 @@ void ScInputHandler::SetMode( ScInputMode eNewMode, const OUString* pInitText ) { if (eOldMode == SC_INPUT_NONE) // not if switching between modes { - if (StartTable(0, false, eMode == SC_INPUT_TABLE)) + if (StartTable(0, false, eMode == SC_INPUT_TABLE, pTopEngine)) { if (pActiveViewSh) pActiveViewSh->GetViewData().GetDocShell()->PostEditView( mpEditEngine.get(), aCursorPos ); diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 6ef5adab11c2..dc9c6a336451 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1108,13 +1108,7 @@ void ScTextWnd::StartEditEngine() ScInputHandler* pHdl = mpViewShell->GetInputHandler(); if (pHdl) - { - bool bStarting = !pHdl->IsEditMode(); - pHdl->SetMode(SC_INPUT_TOP); - if (bStarting) - // necessary to sync SvxAutoCorrect behavior - pHdl->MergeLanguageAttributes( *mpEditEngine); - } + pHdl->SetMode(SC_INPUT_TOP, nullptr, mpEditEngine.get()); SfxViewFrame* pViewFrm = SfxViewFrame::Current(); if (pViewFrm) diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx index b4c98b3edc2b..2e632f2d60fd 100644 --- a/sc/source/ui/inc/inputhdl.hxx +++ b/sc/source/ui/inc/inputhdl.hxx @@ -128,9 +128,13 @@ private: * for text or number. * @param bInputActivated true if the cell input mode is activated (via * F2), false otherwise. + * @param pTopEngine top window input line EditEngine. If not nullptr then + * some default attributes are merged to it from the + * table EditEngine. * @return true if the new edit mode has been started. */ - bool StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated ); + bool StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated, + ScEditEngineDefaulter* pTopEngine ); void RemoveSelection(); void UpdateFormulaMode(); static void InvalidateAttribs(); @@ -168,7 +172,8 @@ public: ScInputHandler(); ~ScInputHandler(); - void SetMode( ScInputMode eNewMode, const OUString* pInitText = nullptr ); + void SetMode( ScInputMode eNewMode, const OUString* pInitText = nullptr, + ScEditEngineDefaulter* pTopEngine = nullptr ); bool IsInputMode() const { return (eMode != SC_INPUT_NONE); } bool IsEditMode() const { return (eMode != SC_INPUT_NONE && eMode != SC_INPUT_TYPE); } -- cgit v1.2.3