diff options
author | Heiko Tietze <tietze.heiko@gmail.com> | 2020-10-29 15:03:44 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-11-03 22:02:24 +0100 |
commit | 6f3899b27156591e65f62649a92c727eb6f5dd03 (patch) | |
tree | 742b41745e770fbf73ada4d5cea395a262219813 | |
parent | 2a7a62c09582ec24247022a94e929610d141a4c9 (diff) |
Resolves tdf#137059 - Use application colors for font preview
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 <caolanm@redhat.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | cui/source/dialogs/FontFeaturesDialog.cxx | 3 | ||||
-rw-r--r-- | cui/source/tabpages/chardlg.cxx | 23 | ||||
-rw-r--r-- | include/svx/fntctrl.hxx | 1 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/Condition.cxx | 1 | ||||
-rw-r--r-- | svx/source/dialog/fntctrl.cxx | 53 | ||||
-rw-r--r-- | sw/source/ui/config/optpage.cxx | 2 |
6 files changed, 24 insertions, 59 deletions
diff --git a/cui/source/dialogs/FontFeaturesDialog.cxx b/cui/source/dialogs/FontFeaturesDialog.cxx index a34912d5d0f2..c1e79b4515d7 100644 --- a/cui/source/dialogs/FontFeaturesDialog.cxx +++ b/cui/source/dialogs/FontFeaturesDialog.cxx @@ -26,9 +26,6 @@ FontFeaturesDialog::FontFeaturesDialog(weld::Window* pParent, OUString const& rF , m_xContentGrid(m_xBuilder->weld_container("contentGrid")) , m_xPreviewWindow(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWindow)) { - svtools::ColorConfig aColorConfig; - Color aFillColor(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor); - m_aPreviewWindow.SetBackColor(aFillColor); initialize(); } diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index 4ec72e217772..1000dbf0983e 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -1346,15 +1346,6 @@ void SvxCharEffectsPage::EnableNoneFontColor() m_bEnableNoneFontColor = true; } -Color SvxCharEffectsPage::GetPreviewFontColor(const Color& rColor) const -{ - if (rColor == COL_AUTO) - return COL_BLACK; - if (m_bEnableNoneFontColor && rColor == COL_NONE_COLOR) - return COL_BLACK; - return rColor; -} - SvxCharEffectsPage::~SvxCharEffectsPage() { m_xUnderlineColorLB.reset(); @@ -1431,9 +1422,10 @@ void SvxCharEffectsPage::UpdatePreview_Impl() SvxFont& rCTLFont = GetPreviewCTLFont(); const Color& rSelectedColor = m_xFontColorLB->GetSelectEntryColor(); - rFont.SetColor(GetPreviewFontColor(rSelectedColor)); - rCJKFont.SetColor(GetPreviewFontColor(rSelectedColor)); - rCTLFont.SetColor(GetPreviewFontColor(rSelectedColor)); + rFont.SetColor(rSelectedColor); + rCJKFont.SetColor(rSelectedColor); + rCTLFont.SetColor(rSelectedColor); + m_aPreviewWin.AutoCorrectFontColor(); // handle color COL_AUTO FontLineStyle eUnderline = static_cast<FontLineStyle>(m_xUnderlineLB->get_active_id().toInt32()); FontLineStyle eOverline = static_cast<FontLineStyle>(m_xOverlineLB->get_active_id().toInt32()); @@ -1544,9 +1536,10 @@ void SvxCharEffectsPage::ResetColor_Impl( const SfxItemSet& rSet ) const SvxColorItem& rItem = static_cast<const SvxColorItem&>(rSet.Get( nWhich )); Color aColor = rItem.GetValue(); - rFont.SetColor(GetPreviewFontColor(aColor)); - rCJKFont.SetColor(GetPreviewFontColor(aColor)); - rCTLFont.SetColor(GetPreviewFontColor(aColor)); + rFont.SetColor(aColor); + rCJKFont.SetColor(aColor); + rCTLFont.SetColor(aColor); + m_aPreviewWin.AutoCorrectFontColor(); // handle color COL_AUTO m_aPreviewWin.Invalidate(); diff --git a/include/svx/fntctrl.hxx b/include/svx/fntctrl.hxx index c84289ac9017..1751c3ac85bb 100644 --- a/include/svx/fntctrl.hxx +++ b/include/svx/fntctrl.hxx @@ -49,7 +49,6 @@ public: SvxFont& GetCTLFont(); void SetColor( const Color& rColor ); void ResetColor(); - void SetBackColor( const Color& rColor ); void SetTextLineColor(const Color& rColor); void SetOverlineColor(const Color& rColor); void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override; diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx index 9f7b8bbd5ccd..2b44e1e549be 100644 --- a/reportdesign/source/ui/dlg/Condition.cxx +++ b/reportdesign/source/ui/dlg/Condition.cxx @@ -324,7 +324,6 @@ void Condition::updateToolbar(const uno::Reference< report::XReportControlFormat aFont.SetRelief( static_cast< FontRelief >( _xReportControlFormat->getCharRelief() ) ); aFont.SetColor( Color(_xReportControlFormat->getCharColor()) ); m_aPreview.SetFont( aFont, aFont, aFont ); - m_aPreview.SetBackColor( Color(_xReportControlFormat->getControlBackground()) ); m_aPreview.SetTextLineColor( Color( _xReportControlFormat->getCharUnderlineColor() ) ); } catch( const Exception& ) 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<const SvxBrushItem&>( 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 ); diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index b6cf6eac134c..69f873cdf2cd 100644 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -1984,8 +1984,6 @@ void SwRedlineOptionsTabPage::InitFontStyle(SvxFontPrevWindow& rExampleWin, cons rExampleWin.SetFont( rFont, rCJKFont,rCTLFont ); rExampleWin.SetPreviewText(rText); - - rExampleWin.SetBackColor(aBackCol); } SwCompareOptionsTabPage::SwCompareOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) |