diff options
author | Niklas Nebel <nn@openoffice.org> | 2002-09-11 17:07:20 +0000 |
---|---|---|
committer | Niklas Nebel <nn@openoffice.org> | 2002-09-11 17:07:20 +0000 |
commit | 2ae039d2cb56742446694fc1d3026d613680095c (patch) | |
tree | d44270d972adfc2a59bafe4131fd888d16257987 /sc | |
parent | 89e02e5c54f36d91a3351f01dc2598c092c15519 (diff) |
#102497# changed handling of automatic font color
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/patattr.hxx | 12 | ||||
-rw-r--r-- | sc/source/core/data/patattr.cxx | 59 | ||||
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/app/scmod.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/view/output.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 54 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 12 |
7 files changed, 114 insertions, 49 deletions
diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx index e7041687bb01..7830abde99fa 100644 --- a/sc/inc/patattr.hxx +++ b/sc/inc/patattr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: patattr.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: nn $ $Date: 2002-04-24 13:31:51 $ + * last change: $Author: nn $ $Date: 2002-09-11 18:05:52 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -90,8 +90,10 @@ enum ScAutoFontColorMode SC_AUTOCOL_RAW, // COL_AUTO is returned SC_AUTOCOL_BLACK, // always use black SC_AUTOCOL_PRINT, // black or white, depending on background - SC_AUTOCOL_DISPLAY, // from style settings or white - SC_AUTOCOL_FORCE // like SC_AUTOCOL_DISPLAY, but for all stored font colors + SC_AUTOCOL_DISPLAY, // from style settings, or black/white if needed + SC_AUTOCOL_IGNOREFONT, // like DISPLAY, but ignore stored font color (assume COL_AUTO) + SC_AUTOCOL_IGNOREBACK, // like DISPLAY, but ignore stored background color (use configured color) + SC_AUTOCOL_IGNOREALL // like DISPLAY, but ignore stored font and background colors }; @@ -128,7 +130,7 @@ public: OutputDevice* pOutDev = NULL, const Fraction* pScale = NULL, const SfxItemSet* pCondSet = NULL, - BYTE nScript = 0 ) const; + BYTE nScript = 0, const Color* pBackConfigColor = NULL ) const; void FillEditItemSet( SfxItemSet* pSet, const SfxItemSet* pCondSet = NULL ) const; diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index dea6f9246280..97237b780387 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: patattr.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: nn $ $Date: 2002-09-09 13:57:54 $ + * last change: $Author: nn $ $Date: 2002-09-11 18:06:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,6 +74,7 @@ #include <svx/brshitem.hxx> #include <svx/charreliefitem.hxx> #include <svx/cntritem.hxx> +#include <svx/colorcfg.hxx> #include <svx/colritem.hxx> #include <svx/crsditem.hxx> #include <svx/emphitem.hxx> @@ -104,6 +105,7 @@ #include "globstr.hrc" #include "conditio.hxx" #include "validat.hxx" +#include "scmod.hxx" // STATIC DATA ----------------------------------------------------------- @@ -117,11 +119,6 @@ inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; } // ----------------------------------------------------------------------- -// threshold for automatic text color -#define DARK_COLOR 154 - -// ----------------------------------------------------------------------- - ScPatternAttr::ScPatternAttr( SfxItemSet* pItemSet, const String& rStyleName ) : SfxSetItem ( ATTR_PATTERN, pItemSet ), pName ( new String( rStyleName ) ), @@ -230,7 +227,8 @@ SvStream& __EXPORT ScPatternAttr::Store(SvStream& rStream, USHORT nItemVersion) void ScPatternAttr::GetFont( Font& rFont, ScAutoFontColorMode eAutoMode, OutputDevice* pOutDev, const Fraction* pScale, - const SfxItemSet* pCondSet, BYTE nScript ) const + const SfxItemSet* pCondSet, BYTE nScript, + const Color* pBackConfigColor ) const { // Items auslesen @@ -393,9 +391,10 @@ void ScPatternAttr::GetFont( Font& rFont, ScAutoFontColorMode eAutoMode, rFont.SetSize( Size( 0, (long) nFontHeight ) ); } - // Auszeichnungen + // determine effective font color - if ( ( aColor.GetColor() == COL_AUTO && eAutoMode != SC_AUTOCOL_RAW ) || eAutoMode == SC_AUTOCOL_FORCE ) + if ( ( aColor.GetColor() == COL_AUTO && eAutoMode != SC_AUTOCOL_RAW ) || + eAutoMode == SC_AUTOCOL_IGNOREFONT || eAutoMode == SC_AUTOCOL_IGNOREALL ) { if ( eAutoMode == SC_AUTOCOL_BLACK ) aColor.SetColor( COL_BLACK ); @@ -413,25 +412,49 @@ void ScPatternAttr::GetFont( Font& rFont, ScAutoFontColorMode eAutoMode, else aBackColor = ((const SvxBrushItem&)rMySet.Get( ATTR_BACKGROUND )).GetColor(); - if ( aBackColor != COL_TRANSPARENT && - aBackColor.GetRed() + aBackColor.GetGreen() + aBackColor.GetBlue() < DARK_COLOR ) + // if background color attribute is transparent, use window color for brightness comparisons + if ( aBackColor == COL_TRANSPARENT || + eAutoMode == SC_AUTOCOL_IGNOREBACK || eAutoMode == SC_AUTOCOL_IGNOREALL ) { - // use white if on dark background + if ( eAutoMode == SC_AUTOCOL_PRINT ) + aBackColor.SetColor( COL_WHITE ); + else if ( pBackConfigColor ) + { + // pBackConfigColor can be used to avoid repeated lookup of the configured color + aBackColor = *pBackConfigColor; + } + else + aBackColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svx::DOCCOLOR).nColor ); + } + + // get system text color for comparison + Color aSysTextColor; + if ( eAutoMode == SC_AUTOCOL_PRINT ) + aSysTextColor.SetColor( COL_BLACK ); + else + aSysTextColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor(); + + // select the resulting color + if ( aBackColor.IsDark() && aSysTextColor.IsDark() ) + { + // use white instead of dark on dark aColor.SetColor( COL_WHITE ); } - else if ( eAutoMode == SC_AUTOCOL_DISPLAY || eAutoMode == SC_AUTOCOL_FORCE ) + else if ( aBackColor.IsBright() && aSysTextColor.IsBright() ) { - // use color from style settings for display - aColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor(); + // use black instead of bright on bright + aColor.SetColor( COL_BLACK ); } else { - // use black instead of settings color for printing - aColor.SetColor( COL_BLACK ); + // use aSysTextColor (black for SC_AUTOCOL_PRINT, from style settings otherwise) + aColor = aSysTextColor; } } } + // set font effects + if (rFont.GetWeight() != eWeight) rFont.SetWeight( eWeight ); if (rFont.GetItalic() != eItalic) diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 69fbe7af64f3..cbfda2bc7198 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: inputhdl.cxx,v $ * - * $Revision: 1.37 $ + * $Revision: 1.38 $ * - * last change: $Author: nn $ $Date: 2002-09-09 13:58:54 $ + * last change: $Author: nn $ $Date: 2002-09-11 18:06:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -90,6 +90,7 @@ #include <sfx2/docfile.hxx> #include <sfx2/printer.hxx> #include <offmgr/app.hxx> +#include <svtools/accessibilityoptions.hxx> #include <svtools/zforlist.hxx> #include <vcl/sound.hxx> #ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX @@ -1529,8 +1530,11 @@ BOOL ScInputHandler::StartTable( sal_Unicode cTyped, BOOL bFromCommand ) Color aBackCol = ((const SvxBrushItem&) pPattern->GetItem( ATTR_BACKGROUND )).GetColor(); - if ( aBackCol.GetTransparency() > 0 ) - aBackCol.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svx::DOCCOLOR).nColor ); + ScModule* pScMod = SC_MOD(); + if ( aBackCol.GetTransparency() > 0 || + ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() && + pScMod->GetAccessOptions().GetIsForBorders() ) ) + aBackCol.SetColor( pScMod->GetColorConfig().GetColorValue(svx::DOCCOLOR).nColor ); pEngine->SetBackgroundColor( aBackCol ); // Ausrichtung diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 2489554ca522..3d288c16eec0 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -2,9 +2,9 @@ * * $RCSfile: scmod.cxx,v $ * - * $Revision: 1.29 $ + * $Revision: 1.30 $ * - * last change: $Author: sab $ $Date: 2002-09-09 14:47:06 $ + * last change: $Author: nn $ $Date: 2002-09-11 18:06:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -284,6 +284,10 @@ void ScModule::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) pViewSh->PaintTop(); pViewSh->PaintLeft(); pViewSh->PaintExtras(); + + ScInputHandler* pHdl = pViewSh->GetInputHandler(); + if ( pHdl ) + pHdl->ForgetLastPattern(); // EditEngine BackgroundColor may change } else if ( pViewShell->ISA(ScPreviewShell) ) { diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 14470457e575..9606fc67d41a 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -2,9 +2,9 @@ * * $RCSfile: output.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: nn $ $Date: 2002-08-16 14:44:35 $ + * last change: $Author: nn $ $Date: 2002-09-11 18:07:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -2654,7 +2654,7 @@ void ScOutputData::PrintNoteMarks( const List& rPosList ) { Font aFont; ScAutoFontColorMode eColorMode = bUseStyleColor ? - ( bForceAutoColor ? SC_AUTOCOL_FORCE : SC_AUTOCOL_DISPLAY ) : + ( bForceAutoColor ? SC_AUTOCOL_IGNOREFONT : SC_AUTOCOL_DISPLAY ) : SC_AUTOCOL_PRINT; ((const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)).GetFont(aFont, eColorMode); aFont.SetSize( Size( 0, (long) ( 120 * nPPTY ) ) ); // 6 pt diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 42bc41e7e150..a59493013bfc 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: output2.cxx,v $ * - * $Revision: 1.26 $ + * $Revision: 1.27 $ * - * last change: $Author: nn $ $Date: 2002-09-09 14:00:36 $ + * last change: $Author: nn $ $Date: 2002-09-11 18:07:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -85,6 +85,7 @@ #include <svx/scripttypeitem.hxx> #include <svx/udlnitem.hxx> #include <svx/unolingu.hxx> +#include <svtools/accessibilityoptions.hxx> #include <svtools/zforlist.hxx> #include <vcl/svapp.hxx> #include <vcl/metric.hxx> @@ -138,6 +139,9 @@ class ScDrawStringsVars BOOL bLineBreak; BOOL bPixelToLogic; + BOOL bCellContrast; + + Color aBackConfigColor; // used for ScPatternAttr::GetFont calls public: ScDrawStringsVars(ScOutputData* pData, BOOL bPTL); @@ -194,6 +198,12 @@ ScDrawStringsVars::ScDrawStringsVars(ScOutputData* pData, BOOL bPTL) : pLastCell ( NULL ) { pFormatter = pData->pDoc->GetFormatTable(); + + ScModule* pScMod = SC_MOD(); + bCellContrast = pOutput->bUseStyleColor && + Application::GetSettings().GetStyleSettings().GetHighContrastMode() && + pScMod->GetAccessOptions().GetIsForBorders(); + aBackConfigColor.SetColor( pScMod->GetColorConfig().GetColorValue(svx::DOCCOLOR).nColor ); } ScDrawStringsVars::~ScDrawStringsVars() @@ -214,13 +224,21 @@ void ScDrawStringsVars::SetPattern( const ScPatternAttr* pNew, const SfxItemSet* // Font - ScAutoFontColorMode eColorMode = pOutput->bUseStyleColor ? - ( pOutput->bForceAutoColor ? SC_AUTOCOL_FORCE : SC_AUTOCOL_DISPLAY ) : - SC_AUTOCOL_PRINT; + ScAutoFontColorMode eColorMode; + if ( pOutput->bUseStyleColor ) + { + if ( pOutput->bForceAutoColor ) + eColorMode = bCellContrast ? SC_AUTOCOL_IGNOREALL : SC_AUTOCOL_IGNOREFONT; + else + eColorMode = bCellContrast ? SC_AUTOCOL_IGNOREBACK : SC_AUTOCOL_DISPLAY; + } + else + eColorMode = SC_AUTOCOL_PRINT; + if ( bPixelToLogic ) - pPattern->GetFont( aFont, eColorMode, pFmtDevice, NULL, pCondSet, nScript ); + pPattern->GetFont( aFont, eColorMode, pFmtDevice, NULL, pCondSet, nScript, &aBackConfigColor ); else - pPattern->GetFont( aFont, eColorMode, pFmtDevice, &pOutput->aZoomY, pCondSet, nScript ); + pPattern->GetFont( aFont, eColorMode, pFmtDevice, &pOutput->aZoomY, pCondSet, nScript, &aBackConfigColor ); aFont.SetAlign(ALIGN_BASELINE); // Orientierung @@ -1639,6 +1657,12 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + ScModule* pScMod = SC_MOD(); + sal_Int32 nConfBackColor = pScMod->GetColorConfig().GetColorValue(svx::DOCCOLOR).nColor; + BOOL bCellContrast = bUseStyleColor && + Application::GetSettings().GetStyleSettings().GetHighContrastMode() && + pScMod->GetAccessOptions().GetIsForBorders(); + ScFieldEditEngine* pEngine = NULL; BOOL bHyphenatorSet = FALSE; const ScPatternAttr* pPattern; @@ -1903,9 +1927,8 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) Color aBackCol = ((const SvxBrushItem&) pPattern->GetItem( ATTR_BACKGROUND, pCondSet )).GetColor(); - if ( bUseStyleColor && aBackCol.GetTransparency() > 0 ) - aBackCol.SetColor( SC_MOD()->GetColorConfig(). - GetColorValue(svx::DOCCOLOR).nColor ); + if ( bUseStyleColor && ( aBackCol.GetTransparency() > 0 || bCellContrast ) ) + aBackCol.SetColor( nConfBackColor ); pEngine->SetBackgroundColor( aBackCol ); } @@ -2488,6 +2511,12 @@ void ScOutputData::DrawRotated(BOOL bPixelToLogic) SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + ScModule* pScMod = SC_MOD(); + sal_Int32 nConfBackColor = pScMod->GetColorConfig().GetColorValue(svx::DOCCOLOR).nColor; + BOOL bCellContrast = bUseStyleColor && + Application::GetSettings().GetStyleSettings().GetHighContrastMode() && + pScMod->GetAccessOptions().GetIsForBorders(); + ScFieldEditEngine* pEngine = NULL; BOOL bHyphenatorSet = FALSE; const ScPatternAttr* pPattern; @@ -2690,9 +2719,8 @@ void ScOutputData::DrawRotated(BOOL bPixelToLogic) Color aBackCol = ((const SvxBrushItem&) pPattern->GetItem( ATTR_BACKGROUND, pCondSet )).GetColor(); - if ( bUseStyleColor && aBackCol.GetTransparency() > 0 ) - aBackCol.SetColor( SC_MOD()->GetColorConfig(). - GetColorValue(svx::DOCCOLOR).nColor ); + if ( bUseStyleColor && ( aBackCol.GetTransparency() > 0 || bCellContrast ) ) + aBackCol.SetColor( nConfBackColor ); pEngine->SetBackgroundColor( aBackCol ); } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 1a83fbc385f2..c788bf3613a8 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -2,9 +2,9 @@ * * $RCSfile: viewdata.cxx,v $ * - * $Revision: 1.30 $ + * $Revision: 1.31 $ * - * last change: $Author: nn $ $Date: 2002-09-09 14:00:39 $ + * last change: $Author: nn $ $Date: 2002-09-11 18:07:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,6 +79,7 @@ #include <svx/editstat.hxx> #include <svx/outliner.hxx> #include <svx/unolingu.hxx> +#include <svtools/accessibilityoptions.hxx> #include <vcl/svapp.hxx> #include <vcl/system.hxx> @@ -964,9 +965,12 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich, // Hintergrundfarbe der Zelle Color aBackCol = ((const SvxBrushItem&)pPattern->GetItem(ATTR_BACKGROUND)).GetColor(); - if ( aBackCol.GetTransparency() > 0 || IsSyntaxMode()) + ScModule* pScMod = SC_MOD(); + if ( aBackCol.GetTransparency() > 0 || + ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() && + pScMod->GetAccessOptions().GetIsForBorders() ) ) { - aBackCol.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svx::DOCCOLOR).nColor ); + aBackCol.SetColor( pScMod->GetColorConfig().GetColorValue(svx::DOCCOLOR).nColor ); } pEditView[eWhich]->SetBackgroundColor( aBackCol ); |