tdf#127403 Revert "VCL keep / return the original set TextEngine font"

This reverts commit cc223fa12a61ba0e580b884386a7f5d7efd0541f.

All the other attenps to fix this seem to cause timeouts in the
Jenkins clang_dbgutil build. I don't have one around and no time
to investigate further, so let's see, if the revert passes.

Change-Id: Ib915185eaf79073523351705baf28df3c62906f1
Reviewed-on: https://gerrit.libreoffice.org/83654
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
diff --git a/include/vcl/texteng.hxx b/include/vcl/texteng.hxx
index f265ec1..60aa359 100644
--- a/include/vcl/texteng.hxx
+++ b/include/vcl/texteng.hxx
@@ -106,7 +106,6 @@ class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster
    std::unique_ptr<LocaleDataWrapper> mpLocaleDataWrapper;

    vcl::Font           maFont;
    vcl::Font           maOrigFont;  // original font from SetFont
    Color               maTextColor;

    sal_Int32           mnMaxTextLen;
@@ -221,7 +220,7 @@ public:
    sal_Int32           GetTextLen( const TextSelection& rSel ) const;

    void                SetFont( const vcl::Font& rFont );
    const vcl::Font&    GetFont() const { return maOrigFont; }
    const vcl::Font&    GetFont() const { return maFont; }

    void                SetLeftMargin( sal_uInt16 n );

diff --git a/include/vcl/vclmedit.hxx b/include/vcl/vclmedit.hxx
index 1cb3b81..61367af 100644
--- a/include/vcl/vclmedit.hxx
+++ b/include/vcl/vclmedit.hxx
@@ -97,10 +97,7 @@ protected:
    TextView*       GetTextView() const;
    ExtTextEngine*  GetTextEngine() const;

    void ApplySettings(vcl::RenderContext&) override;
    void ApplyBackgroundSettings(vcl::RenderContext&, const StyleSettings&);
    void ApplyFontSettings(vcl::RenderContext&, const StyleSettings&);

    virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
public:
                    VclMultiLineEdit( vcl::Window* pParent,
                                      WinBits nWinStyle );
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index 8f1b27c..397a1de 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -167,9 +167,8 @@ void TextEngine::SetActiveView( TextView* pTextView )

void TextEngine::SetFont( const vcl::Font& rFont )
{
    if (rFont == maOrigFont)
    if ( rFont == maFont )
        return;
    maOrigFont = rFont;

    maFont = rFont;
    // #i40221# As the font's color now defaults to transparent (since i35764)
@@ -204,9 +203,9 @@ void TextEngine::SetFont( const vcl::Font& rFont )
    for ( auto nView = mpViews->size(); nView; )
    {
        TextView* pView = (*mpViews)[ --nView ];
        pView->GetWindow()->SetInputContext(InputContext(maFont, !pView->IsReadOnly()
            ? InputContextFlags::Text|InputContextFlags::ExtText : InputContextFlags::NONE));
        pView->GetWindow()->SetInputContext( InputContext( GetFont(), !pView->IsReadOnly() ? InputContextFlags::Text|InputContextFlags::ExtText : InputContextFlags::NONE ) );
    }

}

void TextEngine::SetMaxTextLen( sal_Int32 nLen )
diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx
index cc2b52e..0225f79 100644
--- a/vcl/source/edit/vclmedit.cxx
+++ b/vcl/source/edit/vclmedit.cxx
@@ -914,8 +914,36 @@ WinBits VclMultiLineEdit::ImplInitStyle( WinBits nStyle )
    return nStyle;
}

void VclMultiLineEdit::ApplyBackgroundSettings(vcl::RenderContext& rRenderContext, const StyleSettings& rStyleSettings)
void VclMultiLineEdit::ApplySettings(vcl::RenderContext& rRenderContext)
{
    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();

    // The Font has to be adjusted, as the TextEngine does not take care of
    // TextColor/Background

    Color aTextColor = rStyleSettings.GetFieldTextColor();
    if (IsControlForeground())
        aTextColor = GetControlForeground();

    if (!IsEnabled())
        aTextColor = rStyleSettings.GetDisableColor();

    vcl::Font aFont = rStyleSettings.GetFieldFont();
    aFont.SetTransparent(IsPaintTransparent());
    ApplyControlFont(rRenderContext, aFont);

    vcl::Font theFont = rRenderContext.GetFont();
    theFont.SetColor(aTextColor);
    if (IsPaintTransparent())
        theFont.SetFillColor(COL_TRANSPARENT);
    else
        theFont.SetFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());

    pImpVclMEdit->GetTextWindow()->SetFont(theFont);
    // FIXME: next call causes infinite invalidation loop, rethink how to properly fix this situation
    // pImpVclMEdit->GetTextWindow()->GetTextEngine()->SetFont(theFont);
    pImpVclMEdit->GetTextWindow()->SetTextColor(aTextColor);

    if (IsPaintTransparent())
    {
        pImpVclMEdit->GetTextWindow()->SetPaintTransparent(true);
@@ -935,8 +963,10 @@ void VclMultiLineEdit::ApplyBackgroundSettings(vcl::RenderContext& rRenderContex
    }
}

void VclMultiLineEdit::ApplyFontSettings(vcl::RenderContext& rRenderContext, const StyleSettings& rStyleSettings)
void VclMultiLineEdit::ImplInitSettings(bool bBackground)
{
    const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();

    // The Font has to be adjusted, as the TextEngine does not take care of
    // TextColor/Background

@@ -948,36 +978,38 @@ void VclMultiLineEdit::ApplyFontSettings(vcl::RenderContext& rRenderContext, con

    vcl::Font aFont = rStyleSettings.GetFieldFont();
    aFont.SetTransparent(IsPaintTransparent());
    ApplyControlFont(rRenderContext, aFont);
    ApplyControlFont(*this, aFont);

    vcl::Font TheFont = rRenderContext.GetFont();
    vcl::Font TheFont = GetFont();
    TheFont.SetColor(aTextColor);
    if (IsPaintTransparent())
        TheFont.SetFillColor(COL_TRANSPARENT);
    else
        TheFont.SetFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());

    pImpVclMEdit->GetTextWindow()->SetFont(TheFont);
    pImpVclMEdit->GetTextWindow()->GetTextEngine()->SetFont(TheFont);
    pImpVclMEdit->GetTextWindow()->SetTextColor(aTextColor);
}

void VclMultiLineEdit::ApplySettings(vcl::RenderContext& rRenderContext)
{
    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();

    ApplyFontSettings(rRenderContext, rStyleSettings);
    ApplyBackgroundSettings(rRenderContext, rStyleSettings);
}

void VclMultiLineEdit::ImplInitSettings(bool bBackground)
{
    const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();

    ApplyFontSettings(*this, rStyleSettings);

    if (bBackground)
        ApplyBackgroundSettings(*this, rStyleSettings);
    {
        if (IsPaintTransparent())
        {
            pImpVclMEdit->GetTextWindow()->SetPaintTransparent(true);
            pImpVclMEdit->GetTextWindow()->SetBackground();
            pImpVclMEdit->GetTextWindow()->SetControlBackground();
            SetBackground();
            SetControlBackground();
        }
        else
        {
            if (IsControlBackground())
                pImpVclMEdit->GetTextWindow()->SetBackground(GetControlBackground());
            else
                pImpVclMEdit->GetTextWindow()->SetBackground(rStyleSettings.GetFieldColor());
            // also adjust for VclMultiLineEdit as the TextComponent might hide Scrollbars
            SetBackground(pImpVclMEdit->GetTextWindow()->GetBackground());
        }
    }
}

void VclMultiLineEdit::Modify()