summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorNiklas Nebel <nn@openoffice.org>2002-03-11 13:08:12 +0000
committerNiklas Nebel <nn@openoffice.org>2002-03-11 13:08:12 +0000
commit3dc85b908b9c29b4c5f8dbb0403f2bec7ac70761 (patch)
treefdb0f9ea1c3e9ca0eacf9dfe51190ab2fc134488 /sc/source/core
parent9cf2d24d032713105631cbe00d40b4c72e63161c (diff)
#97022# handling of automatic font color
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/data/column2.cxx10
-rw-r--r--sc/source/core/data/global.cxx6
-rw-r--r--sc/source/core/data/patattr.cxx51
-rw-r--r--sc/source/core/tool/editutil.cxx7
-rw-r--r--sc/source/core/tool/interpr1.cxx7
5 files changed, 60 insertions, 21 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 36d7ea089d55..d07183a36aee 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: column2.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: nn $ $Date: 2002-03-04 19:25:17 $
+ * last change: $Author: nn $ $Date: 2002-03-11 14:01:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -709,7 +709,8 @@ long ScColumn::GetNeededSize( USHORT nRow, OutputDevice* pDev,
{
Fraction aFontZoom = ( eOrient == SVX_ORIENTATION_STANDARD ) ? rZoomX : rZoomY;
Font aFont;
- pPattern->GetFont( aFont, pDev, &aFontZoom, pCondSet, nScript );
+ // font color doesn't matter here
+ pPattern->GetFont( aFont, SC_AUTOCOL_BLACK, pDev, &aFontZoom, pCondSet, nScript );
pDev->SetFont(aFont);
}
@@ -1019,7 +1020,8 @@ USHORT ScColumn::GetOptimalColWidth( OutputDevice* pDev, double nPPTX, double nP
{ // alles eins bis auf NumberFormate
const ScPatternAttr* pPattern = GetPattern( 0 );
Font aFont;
- pPattern->GetFont( aFont, pDev, &rZoomX, NULL );
+ // font color doesn't matter here
+ pPattern->GetFont( aFont, SC_AUTOCOL_BLACK, pDev, &rZoomX, NULL );
pDev->SetFont( aFont );
const SvxMarginItem* pMargin = (const SvxMarginItem*) &pPattern->GetItem(ATTR_MARGIN);
long nMargin = (long) ( pMargin->GetLeftMargin() * nPPTX ) +
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index c5dec6cf5cf6..434d08ecb3d1 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: global.cxx,v $
*
- * $Revision: 1.22 $
+ * $Revision: 1.23 $
*
- * last change: $Author: nn $ $Date: 2001-11-12 20:01:58 $
+ * last change: $Author: nn $ $Date: 2002-03-11 14:01:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -715,7 +715,7 @@ void ScGlobal::InitTextHeight(SfxItemPool* pPool)
VirtualDevice aVirtWindow( *pDefaultDev );
aVirtWindow.SetMapMode(MAP_PIXEL);
Font aDefFont;
- pPattern->GetFont(aDefFont, &aVirtWindow);
+ pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, &aVirtWindow); // font color doesn't matter here
aVirtWindow.SetFont(aDefFont);
nDefFontHeight = (USHORT) aVirtWindow.PixelToLogic(Size(0, aVirtWindow.GetTextHeight()),
MAP_TWIP).Height();
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index a7fbb4913c01..93140de74ed1 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.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: nn $ $Date: 2002-01-30 08:53:52 $
+ * last change: $Author: nn $ $Date: 2002-03-11 14:01:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -92,6 +92,7 @@
#include <svtools/intitem.hxx>
#include <svtools/zforlist.hxx>
#include <vcl/outdev.hxx>
+#include <vcl/svapp.hxx>
#include "patattr.hxx"
#include "docpool.hxx"
@@ -115,6 +116,11 @@ 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 ) ),
@@ -221,7 +227,8 @@ SvStream& __EXPORT ScPatternAttr::Store(SvStream& rStream, USHORT nItemVersion)
return rStream;
}
-void ScPatternAttr::GetFont( Font& rFont, OutputDevice* pOutDev, const Fraction* pScale,
+void ScPatternAttr::GetFont( Font& rFont, ScAutoFontColorMode eAutoMode,
+ OutputDevice* pOutDev, const Fraction* pScale,
const SfxItemSet* pCondSet, BYTE nScript ) const
{
// Items auslesen
@@ -387,13 +394,41 @@ void ScPatternAttr::GetFont( Font& rFont, OutputDevice* pOutDev, const Fraction*
// Auszeichnungen
- if ( aColor.GetColor() == COL_AUTO )
+ if ( aColor.GetColor() == COL_AUTO && eAutoMode != SC_AUTOCOL_RAW )
{
- // WindowTextColor from StyleSettings should be used only when painting!
- // As long as GetFont is used for many different cases, always use black, so
- // there is no disappearing text with default style settings, and printing works.
+ if ( eAutoMode == SC_AUTOCOL_BLACK )
+ aColor.SetColor( COL_BLACK );
+ else
+ {
+ // get background color from conditional or own set
+ Color aBackColor;
+ if ( pCondSet )
+ {
+ const SfxPoolItem* pItem;
+ if ( pCondSet->GetItemState( ATTR_BACKGROUND, TRUE, &pItem ) != SFX_ITEM_SET )
+ pItem = &rMySet.Get( ATTR_BACKGROUND );
+ aBackColor = ((const SvxBrushItem*)pItem)->GetColor();
+ }
+ else
+ aBackColor = ((const SvxBrushItem&)rMySet.Get( ATTR_BACKGROUND )).GetColor();
- aColor.SetColor( COL_BLACK );
+ if ( aBackColor != COL_TRANSPARENT &&
+ aBackColor.GetRed() + aBackColor.GetGreen() + aBackColor.GetBlue() < DARK_COLOR )
+ {
+ // use white if on dark background
+ aColor.SetColor( COL_WHITE );
+ }
+ else if ( eAutoMode == SC_AUTOCOL_DISPLAY )
+ {
+ // use color from style settings for display
+ aColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
+ }
+ else
+ {
+ // use black instead of settings color for printing
+ aColor.SetColor( COL_BLACK );
+ }
+ }
}
if (rFont.GetWeight() != eWeight)
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index f0c7532025b6..188017da30be 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: editutil.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: nn $ $Date: 2001-11-12 20:02:52 $
+ * last change: $Author: nn $ $Date: 2002-03-11 14:03:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -186,7 +186,8 @@ Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, BOOL bForceToT
if (!nTextHeight)
{ // leere Zelle
Font aFont;
- pPattern->GetFont( aFont, pDev, &aZoomY );
+ // font color doesn't matter here
+ pPattern->GetFont( aFont, SC_AUTOCOL_BLACK, pDev, &aZoomY );
pDev->SetFont(aFont);
nTextHeight = pDev->GetTextHeight() + nTopMargin +
(long) ( pMargin->GetBottomMargin() * nPPTY );
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 6ee203394033..04fc0d3f2965 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: interpr1.cxx,v $
*
- * $Revision: 1.21 $
+ * $Revision: 1.22 $
*
- * last change: $Author: er $ $Date: 2001-09-06 13:36:03 $
+ * last change: $Author: nn $ $Date: 2002-03-11 14:03:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1269,7 +1269,8 @@ void ScInterpreter::ScCell()
Font aDefFont;
pPrinter->SetMapMode( MAP_TWIP );
- pDok->GetDefPattern()->GetFont( aDefFont, pPrinter );
+ // font color doesn't matter here
+ pDok->GetDefPattern()->GetFont( aDefFont, SC_AUTOCOL_BLACK, pPrinter );
pPrinter->SetFont( aDefFont );
long nZeroWidth = pPrinter->GetTextWidth( String( '0' ) );
pPrinter->SetFont( aOldFont );