From 6f3899b27156591e65f62649a92c727eb6f5dd03 Mon Sep 17 00:00:00 2001 From: Heiko Tietze Date: Thu, 29 Oct 2020 15:03:44 +0100 Subject: Resolves tdf#137059 - Use application colors for font preview MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Background is set to document's application color now (options > application colors > document) to provide a true WYSIWYG experience (except for modifications to the page background color). Change-Id: Ifd78e667f3eeff3573ff09bcb4d2a9634dd49c99 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105011 Tested-by: Jenkins Tested-by: Caolán McNamara Reviewed-by: Mike Kaganski Reviewed-by: Caolán McNamara --- svx/source/dialog/fntctrl.cxx | 53 +++++++++++++------------------------------ 1 file changed, 16 insertions(+), 37 deletions(-) (limited to 'svx/source/dialog') diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx index edf8b7881297..1b2eb421aad3 100644 --- a/svx/source/dialog/fntctrl.cxx +++ b/svx/source/dialog/fntctrl.cxx @@ -191,7 +191,7 @@ public: SvtLanguageOptions aLanguageOptions; m_bCJKEnabled = aLanguageOptions.IsAnyEnabled(); m_bCTLEnabled = aLanguageOptions.IsCTLFontEnabled(); - + mxBackColor = svtools::ColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; Invalidate100PercentFontWidth(); } @@ -501,13 +501,8 @@ static void SetPrevFontEscapement(SvxFont& rFont, sal_uInt8 nProp, sal_uInt8 nEs void SvxFontPrevWindow::ApplySettings(vcl::RenderContext& rRenderContext) { - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - - svtools::ColorConfig aColorConfig; - Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor); - rRenderContext.SetTextColor(aTextColor); - - rRenderContext.SetBackground(rStyleSettings.GetWindowColor()); + rRenderContext.SetTextColor( svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR).nColor ); + rRenderContext.SetBackground( svtools::ColorConfig().GetColorValue(svtools::DOCCOLOR).nColor ); } void SvxFontPrevWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea) @@ -596,12 +591,6 @@ void SvxFontPrevWindow::ResetColor() Invalidate(); } -void SvxFontPrevWindow::SetBackColor(const Color &rColor) -{ - pImpl->mxBackColor = rColor; - Invalidate(); -} - void SvxFontPrevWindow::SetTextLineColor(const Color &rColor) { pImpl->mxTextLineColor = rColor; @@ -839,17 +828,19 @@ void SvxFontPrevWindow::SetFontWidthScale( sal_uInt16 n ) void SvxFontPrevWindow::AutoCorrectFontColor() { - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - Color aFontColor(rStyleSettings.GetWindowTextColor()); - - if (COL_AUTO == pImpl->maFont.GetColor()) - pImpl->maFont.SetColor(aFontColor); - - if (COL_AUTO == pImpl->maCJKFont.GetColor()) - pImpl->maCJKFont.SetColor(aFontColor); - - if (COL_AUTO == pImpl->maCTLFont.GetColor()) - pImpl->maCTLFont.SetColor(aFontColor); + Color aColor(COL_AUTO); + if ( pImpl->mxBackColor ) aColor = *pImpl->mxBackColor; + const bool bIsDark(aColor.IsDark()); + + aColor = pImpl->maFont.GetColor(); + if (aColor == COL_AUTO) + pImpl->maFont.SetColor( bIsDark ? COL_WHITE : COL_BLACK ); + aColor = pImpl->maCJKFont.GetColor(); + if (aColor == COL_AUTO) + pImpl->maCJKFont.SetColor( bIsDark ? COL_WHITE : COL_BLACK ); + aColor = pImpl->maCTLFont.GetColor(); + if (aColor == COL_AUTO) + pImpl->maCTLFont.SetColor( bIsDark ? COL_WHITE : COL_BLACK ); } void SvxFontPrevWindow::SetFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ) @@ -1017,18 +1008,6 @@ void SvxFontPrevWindow::SetFromItemSet(const SfxItemSet &rSet, bool bPreviewBack rCJKFont.SetTransparent( bTransparent ); rCTLFont.SetTransparent( bTransparent ); - Color aBackCol( COL_TRANSPARENT ); - if( !bPreviewBackgroundToCharacter ) - { - if( GetWhich( rSet, SID_ATTR_BRUSH, nWhich ) ) - { - const SvxBrushItem& rBrush = static_cast( rSet.Get( nWhich ) ); - if( GPOS_NONE == rBrush.GetGraphicPos() ) - aBackCol = rBrush.GetColor(); - } - } - SetBackColor( aBackCol ); - // Font SetPrevFont( rSet, SID_ATTR_CHAR_FONT, rFont ); SetPrevFont( rSet, SID_ATTR_CHAR_CJK_FONT, rCJKFont ); -- cgit