Resolves: tdf#108795 merge table EditEngine language attributes to input line

... when editing there, so the SvxAutoCorrect behaviour is synchronized.
Depends on commit 06d14411a447cd798d1f0678a3c5e06f5278a1cb that disentangles
the stateful SvxAutoCorrect instance.

Change-Id: Ic6aac1f2acc36b500144be50a20a4784a3ba62dc
Reviewed-on: https://gerrit.libreoffice.org/41521
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 9be7701..f9435aa 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2185,6 +2185,14 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bIn
    return bNewTable;
}

void ScInputHandler::MergeLanguageAttributes( ScEditEngineDefaulter& rDestEngine ) const
{
    const SfxItemSet& rSrcSet = mpEditEngine->GetDefaults();
    rDestEngine.SetDefaultItem( rSrcSet.Get( EE_CHAR_LANGUAGE ));
    rDestEngine.SetDefaultItem( rSrcSet.Get( EE_CHAR_LANGUAGE_CJK ));
    rDestEngine.SetDefaultItem( rSrcSet.Get( EE_CHAR_LANGUAGE_CTL ));
}

static void lcl_SetTopSelection( EditView* pEditView, ESelection& rSel )
{
    OSL_ENSURE( rSel.nStartPara==0 && rSel.nEndPara==0, "SetTopSelection: Para != 0" );
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index c69dae4..dca3101 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1108,7 +1108,13 @@ 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);
    }

    SfxViewFrame* pViewFrm = SfxViewFrame::Current();
    if (pViewFrm)
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
index 0301b0a..99fd54f 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -180,6 +180,7 @@ public:
    const ScAddress& GetCursorPos() const   { return aCursorPos; }

    bool            GetTextAndFields( ScEditEngineDefaulter& rDestEngine );
    void            MergeLanguageAttributes( ScEditEngineDefaulter& rDestEngine ) const;

    bool            KeyInput( const KeyEvent& rKEvt, bool bStartEdit );
    void            EnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL );