include/vcl/rendercontext/DrawTextFlags.hxx | 3 sc/inc/patattr.hxx | 1 sc/source/core/data/patattr.cxx | 131 +++++++++++++--------------- vcl/source/control/ctrl.cxx | 6 - vcl/source/gdi/mtfxmldump.cxx | 2 vcl/source/outdev/text.cxx | 8 - 6 files changed, 65 insertions(+), 86 deletions(-)
New commits: commit e8be539b0eba0ec1e4cbea0b4464ff4945fdacb1 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Jul 5 14:59:26 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jul 6 11:08:43 2023 +0200 ScAutoFontColorMode::Black is unused since commit 3537cef02c25c2c2459d7900eed13eeec533b7ae Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Tue May 16 22:10:10 2023 +0900 sc: factor out color from setting vcl::Font from a ItemSet Change-Id: Ia8781d69ed4969eb9617c96c6991cc39ce162e49 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154061 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx index cc37c335cfc0..eacb69fd640b 100644 --- a/sc/inc/patattr.hxx +++ b/sc/inc/patattr.hxx @@ -43,7 +43,6 @@ enum class ScRotateDir : sal_uInt8; enum class ScAutoFontColorMode { Raw, ///< COL_AUTO is returned - Black, ///< always use black Print, ///< black or white, depending on background Display, ///< from style settings, or black/white if needed IgnoreFont, ///< like DISPLAY, but ignore stored font color (assume COL_AUTO) diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index d3a9de543d3a..e2cd22a390c6 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -461,89 +461,82 @@ void ScPatternAttr::fillColor(model::ComplexColor& rComplexColor, const SfxItemS || eAutoMode == ScAutoFontColorMode::IgnoreFont || eAutoMode == ScAutoFontColorMode::IgnoreAll) { - if (eAutoMode == ScAutoFontColorMode::Black) + // get background color from conditional or own set + Color aBackColor; + if ( pCondSet ) { - aColor = COL_BLACK; + const SvxBrushItem* pItem = pCondSet->GetItemIfSet(ATTR_BACKGROUND); + if (!pItem) + pItem = &rItemSet.Get(ATTR_BACKGROUND); + aBackColor = pItem->GetColor(); } else { - // get background color from conditional or own set - Color aBackColor; - if ( pCondSet ) - { - const SvxBrushItem* pItem = pCondSet->GetItemIfSet(ATTR_BACKGROUND); - if (!pItem) - pItem = &rItemSet.Get(ATTR_BACKGROUND); - aBackColor = pItem->GetColor(); - } - else - { - aBackColor = rItemSet.Get(ATTR_BACKGROUND).GetColor(); - } + aBackColor = rItemSet.Get(ATTR_BACKGROUND).GetColor(); + } - // if background color attribute is transparent, use window color for brightness comparisons - if (aBackColor == COL_TRANSPARENT - || eAutoMode == ScAutoFontColorMode::IgnoreBack - || eAutoMode == ScAutoFontColorMode::IgnoreAll) + // if background color attribute is transparent, use window color for brightness comparisons + if (aBackColor == COL_TRANSPARENT + || eAutoMode == ScAutoFontColorMode::IgnoreBack + || eAutoMode == ScAutoFontColorMode::IgnoreAll) + { + if (!comphelper::LibreOfficeKit::isActive()) { - if (!comphelper::LibreOfficeKit::isActive()) + if ( eAutoMode == ScAutoFontColorMode::Print ) + aBackColor = COL_WHITE; + else if ( pBackConfigColor ) { - if ( eAutoMode == ScAutoFontColorMode::Print ) - aBackColor = COL_WHITE; - else if ( pBackConfigColor ) - { - // pBackConfigColor can be used to avoid repeated lookup of the configured color - aBackColor = *pBackConfigColor; - } - else - aBackColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; + // pBackConfigColor can be used to avoid repeated lookup of the configured color + aBackColor = *pBackConfigColor; } else - { - // Get document color from current view instead - SfxViewShell* pSfxViewShell = SfxViewShell::Current(); - ScTabViewShell* pViewShell = dynamic_cast<ScTabViewShell*>(pSfxViewShell); - if (pViewShell) - { - const ScViewData& pViewData = pViewShell->GetViewData(); - const ScViewOptions& aViewOptions = pViewData.GetOptions(); - aBackColor = aViewOptions.GetDocColor(); - } - } - } - - // get system text color for comparison - Color aSysTextColor; - if (eAutoMode == ScAutoFontColorMode::Print) - { - aSysTextColor = COL_BLACK; - } - else if (pTextConfigColor) - { - // pTextConfigColor can be used to avoid repeated lookup of the configured color - aSysTextColor = *pTextConfigColor; + aBackColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; } else { - aSysTextColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor; + // Get document color from current view instead + SfxViewShell* pSfxViewShell = SfxViewShell::Current(); + ScTabViewShell* pViewShell = dynamic_cast<ScTabViewShell*>(pSfxViewShell); + if (pViewShell) + { + const ScViewData& pViewData = pViewShell->GetViewData(); + const ScViewOptions& aViewOptions = pViewData.GetOptions(); + aBackColor = aViewOptions.GetDocColor(); + } } + } - // select the resulting color - if ( aBackColor.IsDark() && aSysTextColor.IsDark() ) - { - // use white instead of dark on dark - aColor = COL_WHITE; - } - else if ( aBackColor.IsBright() && aSysTextColor.IsBright() ) - { - // use black instead of bright on bright - aColor = COL_BLACK; - } - else - { - // use aSysTextColor (black for ScAutoFontColorMode::Print, from style settings otherwise) - aColor = aSysTextColor; - } + // get system text color for comparison + Color aSysTextColor; + if (eAutoMode == ScAutoFontColorMode::Print) + { + aSysTextColor = COL_BLACK; + } + else if (pTextConfigColor) + { + // pTextConfigColor can be used to avoid repeated lookup of the configured color + aSysTextColor = *pTextConfigColor; + } + else + { + aSysTextColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor; + } + + // select the resulting color + if ( aBackColor.IsDark() && aSysTextColor.IsDark() ) + { + // use white instead of dark on dark + aColor = COL_WHITE; + } + else if ( aBackColor.IsBright() && aSysTextColor.IsBright() ) + { + // use black instead of bright on bright + aColor = COL_BLACK; + } + else + { + // use aSysTextColor (black for ScAutoFontColorMode::Print, from style settings otherwise) + aColor = aSysTextColor; } } aComplexColor.setFinalColor(aColor); commit 62127bb799178dfe91ab005db0aad732b85ac1a1 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Jul 5 14:43:05 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jul 6 11:08:34 2023 +0200 DrawTextFlags::HideMnemonic is unused ever since commit 3fbae5dc7e7b200776bbc8a7c2a43e1e04f15a2b Author: Caolán McNamara <caol...@redhat.com> Date: Thu Aug 5 14:57:59 2021 +0100 gtk is the only case auto-accel is true, and the menubar is native gtk there Change-Id: I209a410a231952dcbbb587ed6034fcfec77eaead Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154059 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/vcl/rendercontext/DrawTextFlags.hxx b/include/vcl/rendercontext/DrawTextFlags.hxx index e393bcd2ceaa..4eb4c45b60f9 100644 --- a/include/vcl/rendercontext/DrawTextFlags.hxx +++ b/include/vcl/rendercontext/DrawTextFlags.hxx @@ -41,11 +41,10 @@ enum class DrawTextFlags NewsEllipsis = 0x00004000, WordBreakHyphenation = 0x00008000 | WordBreak, CenterEllipsis = 0x00010000, - HideMnemonic = 0x00020000, }; namespace o3tl { -template <> struct typed_flags<DrawTextFlags> : is_typed_flags<DrawTextFlags, 0x3ffff> +template <> struct typed_flags<DrawTextFlags> : is_typed_flags<DrawTextFlags, 0x1ffff> { }; } diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx index 43b3a2ee659d..e87b587418ff 100644 --- a/vcl/source/control/ctrl.cxx +++ b/vcl/source/control/ctrl.cxx @@ -434,10 +434,7 @@ tools::Rectangle Control::DrawControlText( OutputDevice& _rTargetDevice, const t bool autoacc = ImplGetSVData()->maNWFData.mbAutoAccel; if (autoacc && !mbShowAccelerator) - { rPStr = removeMnemonicFromString( _rStr ); - nPStyle &= ~DrawTextFlags::HideMnemonic; - } if( !GetReferenceDevice() || ( GetReferenceDevice() == &_rTargetDevice ) ) { @@ -459,10 +456,7 @@ tools::Rectangle Control::GetControlTextRect( OutputDevice& _rTargetDevice, cons bool autoacc = ImplGetSVData()->maNWFData.mbAutoAccel; if (autoacc && !mbShowAccelerator) - { rPStr = removeMnemonicFromString( _rStr ); - nPStyle &= ~DrawTextFlags::HideMnemonic; - } if ( !GetReferenceDevice() || ( GetReferenceDevice() == &_rTargetDevice ) ) { diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx index 1b85e23fb584..8726316324de 100644 --- a/vcl/source/gdi/mtfxmldump.cxx +++ b/vcl/source/gdi/mtfxmldump.cxx @@ -114,8 +114,6 @@ OUString convertDrawTextFlagsToString(DrawTextFlags eDrawTextFlags) aStrings.emplace_back("WordBreakHyphenation"); if (eDrawTextFlags & DrawTextFlags::CenterEllipsis) aStrings.emplace_back("CenterEllipsis"); - if (eDrawTextFlags & DrawTextFlags::HideMnemonic) - aStrings.emplace_back("HideMnemonic"); OUString aString; diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 587f98e10010..2c5f9aae06aa 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -2240,8 +2240,6 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const OUString& rStr, } } - bool autoacc = ImplGetSVData()->maNWFData.mbAutoAccel; - if ( nStyle & DrawTextFlags::Disable && ! pVector ) { Color aOldTextColor; @@ -2278,8 +2276,7 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const OUString& rStr, SetTextColor( GetSettings().GetStyleSettings().GetDisableColor() ); DrawText( rPos, aStr, nIndex, nLen, pVector, pDisplayText ); - if (!(GetSettings().GetStyleSettings().GetOptions() & StyleSettingsOptions::NoMnemonics) - && (!autoacc || !(nStyle & DrawTextFlags::HideMnemonic)) ) + if (!(GetSettings().GetStyleSettings().GetOptions() & StyleSettingsOptions::NoMnemonics)) { if ( nMnemonicPos != -1 ) ImplDrawMnemonicLine( nMnemonicX, nMnemonicY, nMnemonicWidth ); @@ -2291,8 +2288,7 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const OUString& rStr, else { DrawText( rPos, aStr, nIndex, nLen, pVector, pDisplayText, pGlyphs ); - if ( !(GetSettings().GetStyleSettings().GetOptions() & StyleSettingsOptions::NoMnemonics) && !pVector - && (!autoacc || !(nStyle & DrawTextFlags::HideMnemonic)) ) + if ( !(GetSettings().GetStyleSettings().GetOptions() & StyleSettingsOptions::NoMnemonics) && !pVector ) { if ( nMnemonicPos != -1 ) ImplDrawMnemonicLine( nMnemonicX, nMnemonicY, nMnemonicWidth );