Kaydet (Commit) cc223fa1 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

VCL keep / return the original set TextEngine font

TextEngine::SetFont copies the font parameter and then modifies
its color, transparency, fill color and alignment, so passing the
same font again will not be detected as the same font.

Therefore this patch stores the original font in addition to the
modified one and also returns that one on the GetFont call.

This allows us to merge the font setup in VclMultiLineEdit's
ImplInitSettings and ApplySettings into a common function.

Change-Id: I618d283ecd0ae14faf9b87a3aceec6ca1c37b526
Reviewed-on: https://gerrit.libreoffice.org/72788
Tested-by: Jenkins
Reviewed-by: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
üst 9b6a9a1f
...@@ -106,6 +106,7 @@ class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster ...@@ -106,6 +106,7 @@ class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster
std::unique_ptr<LocaleDataWrapper> mpLocaleDataWrapper; std::unique_ptr<LocaleDataWrapper> mpLocaleDataWrapper;
vcl::Font maFont; vcl::Font maFont;
vcl::Font maOrigFont; // original font from SetFont
Color maTextColor; Color maTextColor;
sal_Int32 mnMaxTextLen; sal_Int32 mnMaxTextLen;
...@@ -220,7 +221,7 @@ public: ...@@ -220,7 +221,7 @@ public:
sal_Int32 GetTextLen( const TextSelection& rSel ) const; sal_Int32 GetTextLen( const TextSelection& rSel ) const;
void SetFont( const vcl::Font& rFont ); void SetFont( const vcl::Font& rFont );
const vcl::Font& GetFont() const { return maFont; } const vcl::Font& GetFont() const { return maOrigFont; }
void SetLeftMargin( sal_uInt16 n ); void SetLeftMargin( sal_uInt16 n );
......
...@@ -98,7 +98,10 @@ protected: ...@@ -98,7 +98,10 @@ protected:
TextView* GetTextView() const; TextView* GetTextView() const;
ExtTextEngine* GetTextEngine() const; ExtTextEngine* GetTextEngine() const;
virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; void ApplySettings(vcl::RenderContext&) override;
void ApplyBackgroundSettings(vcl::RenderContext&, const StyleSettings&);
void ApplyFontSettings(vcl::RenderContext&, const StyleSettings&);
public: public:
VclMultiLineEdit( vcl::Window* pParent, VclMultiLineEdit( vcl::Window* pParent,
WinBits nWinStyle ); WinBits nWinStyle );
......
...@@ -170,8 +170,9 @@ void TextEngine::SetActiveView( TextView* pTextView ) ...@@ -170,8 +170,9 @@ void TextEngine::SetActiveView( TextView* pTextView )
void TextEngine::SetFont( const vcl::Font& rFont ) void TextEngine::SetFont( const vcl::Font& rFont )
{ {
if ( rFont == maFont ) if (rFont == maOrigFont)
return; return;
maOrigFont = rFont;
maFont = rFont; maFont = rFont;
// #i40221# As the font's color now defaults to transparent (since i35764) // #i40221# As the font's color now defaults to transparent (since i35764)
...@@ -206,9 +207,9 @@ void TextEngine::SetFont( const vcl::Font& rFont ) ...@@ -206,9 +207,9 @@ void TextEngine::SetFont( const vcl::Font& rFont )
for ( auto nView = mpViews->size(); nView; ) for ( auto nView = mpViews->size(); nView; )
{ {
TextView* pView = (*mpViews)[ --nView ]; TextView* pView = (*mpViews)[ --nView ];
pView->GetWindow()->SetInputContext( InputContext( GetFont(), !pView->IsReadOnly() ? InputContextFlags::Text|InputContextFlags::ExtText : InputContextFlags::NONE ) ); pView->GetWindow()->SetInputContext(InputContext(maFont, !pView->IsReadOnly()
? InputContextFlags::Text|InputContextFlags::ExtText : InputContextFlags::NONE));
} }
} }
void TextEngine::SetMaxTextLen( sal_Int32 nLen ) void TextEngine::SetMaxTextLen( sal_Int32 nLen )
......
...@@ -913,36 +913,8 @@ WinBits VclMultiLineEdit::ImplInitStyle( WinBits nStyle ) ...@@ -913,36 +913,8 @@ WinBits VclMultiLineEdit::ImplInitStyle( WinBits nStyle )
return nStyle; return nStyle;
} }
void VclMultiLineEdit::ApplySettings(vcl::RenderContext& rRenderContext) void VclMultiLineEdit::ApplyBackgroundSettings(vcl::RenderContext& rRenderContext, const StyleSettings& rStyleSettings)
{ {
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()) if (IsPaintTransparent())
{ {
pImpVclMEdit->GetTextWindow()->SetPaintTransparent(true); pImpVclMEdit->GetTextWindow()->SetPaintTransparent(true);
...@@ -962,10 +934,8 @@ void VclMultiLineEdit::ApplySettings(vcl::RenderContext& rRenderContext) ...@@ -962,10 +934,8 @@ void VclMultiLineEdit::ApplySettings(vcl::RenderContext& rRenderContext)
} }
} }
void VclMultiLineEdit::ImplInitSettings(bool bBackground) void VclMultiLineEdit::ApplyFontSettings(vcl::RenderContext& rRenderContext, const StyleSettings& rStyleSettings)
{ {
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
// The Font has to be adjusted, as the TextEngine does not take care of // The Font has to be adjusted, as the TextEngine does not take care of
// TextColor/Background // TextColor/Background
...@@ -977,38 +947,36 @@ void VclMultiLineEdit::ImplInitSettings(bool bBackground) ...@@ -977,38 +947,36 @@ void VclMultiLineEdit::ImplInitSettings(bool bBackground)
vcl::Font aFont = rStyleSettings.GetFieldFont(); vcl::Font aFont = rStyleSettings.GetFieldFont();
aFont.SetTransparent(IsPaintTransparent()); aFont.SetTransparent(IsPaintTransparent());
ApplyControlFont(*this, aFont); ApplyControlFont(rRenderContext, aFont);
vcl::Font TheFont = GetFont(); vcl::Font TheFont = rRenderContext.GetFont();
TheFont.SetColor(aTextColor); TheFont.SetColor(aTextColor);
if (IsPaintTransparent()) if (IsPaintTransparent())
TheFont.SetFillColor(COL_TRANSPARENT); TheFont.SetFillColor(COL_TRANSPARENT);
else else
TheFont.SetFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor()); TheFont.SetFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());
pImpVclMEdit->GetTextWindow()->SetFont(TheFont); pImpVclMEdit->GetTextWindow()->SetFont(TheFont);
pImpVclMEdit->GetTextWindow()->GetTextEngine()->SetFont(TheFont); pImpVclMEdit->GetTextWindow()->GetTextEngine()->SetFont(TheFont);
pImpVclMEdit->GetTextWindow()->SetTextColor(aTextColor); 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) 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() void VclMultiLineEdit::Modify()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment