Kaydet (Commit) bda9193e authored tarafından Juergen Funk's avatar Juergen Funk Kaydeden (comit) Samuel Mehrbrodt

Fix fdo#58161 UI: White Paragraph style invisible in Styles Drop-Down

Use the Color-Class-function "IsDark" and "IsBright" for decision to
make a change of the font-color with DecreaseContrast or DecreaseLuminance.

The change is only in the Styles Drop-Down

Change-Id: I65ac4a0bd2f72ab95e61ce2f70bca009e4f06725
Reviewed-on: https://gerrit.libreoffice.org/11716Reviewed-by: 's avatarSamuel Mehrbrodt <s.mehrbrodt@gmail.com>
Tested-by: 's avatarSamuel Mehrbrodt <s.mehrbrodt@gmail.com>
üst 31432c44
...@@ -158,7 +158,7 @@ private: ...@@ -158,7 +158,7 @@ private:
PopupMenu m_aMenu; PopupMenu m_aMenu;
void ReleaseFocus(); void ReleaseFocus();
Color TestColorsVisible(const Color &FontCol, const Color &BackCol);
DECL_LINK( MenuSelectHdl, Menu * ); DECL_LINK( MenuSelectHdl, Menu * );
}; };
...@@ -653,23 +653,38 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt ) ...@@ -653,23 +653,38 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
pDevice->SetFont( aFont ); pDevice->SetFont( aFont );
// text color, when we are not selected Color aFontCol, aBackCol;
bool IsNotSelect = rUDEvt.GetItemId() != GetSelectEntryPos();
// text color
pItem = aItemSet.GetItem( SID_ATTR_CHAR_COLOR ); pItem = aItemSet.GetItem( SID_ATTR_CHAR_COLOR );
if ( pItem && rUDEvt.GetItemId() != GetSelectEntryPos() ) if ( NULL != pItem )
{ aFontCol = Color( static_cast< const SvxColorItem* >( pItem )->GetValue() );
Color aColor( static_cast< const SvxColorItem* >( pItem )->GetValue() ); else
if ( aColor != COL_AUTO ) aFontCol = COL_AUTO;
pDevice->SetTextColor( aColor );
}
// background color // background color
pItem = aItemSet.GetItem( SID_ATTR_BRUSH ); pItem = aItemSet.GetItem( SID_ATTR_BRUSH );
if ( pItem && rUDEvt.GetItemId() != GetSelectEntryPos() ) if ( NULL != pItem )
aBackCol = Color( static_cast< const SvxBrushItem* >( pItem )->GetColor() );
else
aBackCol = COL_AUTO;
// test is the font-, background-color not different, then change the Font-Color
if( (aFontCol != COL_AUTO) || (aBackCol != COL_AUTO) )
aFontCol = TestColorsVisible(aFontCol, (aBackCol != COL_AUTO) ? aBackCol : pDevice->GetBackground().GetColor());
// text color, when we are not selected
if ( (aFontCol != COL_AUTO) && IsNotSelect )
pDevice->SetTextColor( aFontCol );
// background color
if (pItem && IsNotSelect)
{ {
Color aColor( static_cast< const SvxBrushItem* >( pItem )->GetColor() ); // background color, when we are not selected
if ( aColor != COL_AUTO ) if ( aBackCol != COL_AUTO )
{ {
pDevice->SetFillColor( aColor ); pDevice->SetFillColor( aBackCol );
pDevice->DrawRect( rUDEvt.GetRect() ); pDevice->DrawRect( rUDEvt.GetRect() );
} }
...@@ -732,6 +747,31 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt ) ...@@ -732,6 +747,31 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
} }
} }
// test is the color between Font- and background-color to be identify
// return is always the Font-Color
// when both light or dark, change the Contrast
// in other case do not change the origin color
// when the color is R=G=B=128 the DecreaseContast make 128 the need a exception
Color SvxStyleBox_Impl::TestColorsVisible(const Color &FontCol, const Color &BackCol)
{
const sal_uInt8 ChgVal = 60; // increase/decrease the Contrast
Color retCol = FontCol;
if ((FontCol.IsDark() == BackCol.IsDark()) && (FontCol.IsBright() == BackCol.IsBright()))
{
sal_uInt8 lumi = retCol.GetLuminance();
if((lumi > 120) && (lumi < 140))
retCol.DecreaseLuminance(ChgVal / 2);
else
retCol.DecreaseContrast(ChgVal);
}
return retCol;
}
static bool lcl_GetDocFontList( const FontList** ppFontList, SvxFontNameBox_Impl* pBox ) static bool lcl_GetDocFontList( const FontList** ppFontList, SvxFontNameBox_Impl* pBox )
{ {
bool bChanged = false; bool bChanged = false;
......
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