summaryrefslogtreecommitdiff
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
parent9cf2d24d032713105631cbe00d40b4c72e63161c (diff)
#97022# handling of automatic font color
-rw-r--r--sc/inc/patattr.hxx19
-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
-rw-r--r--sc/source/filter/excel/excrecds.cxx13
-rw-r--r--sc/source/filter/xcl97/xcl97rec.cxx7
-rw-r--r--sc/source/ui/docshell/docsh3.cxx8
-rw-r--r--sc/source/ui/inc/output.hxx7
-rw-r--r--sc/source/ui/inc/printfun.hxx6
11 files changed, 101 insertions, 40 deletions
diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index f4eb2562a6d1..c207fcf7b93a 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: patattr.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: er $ $Date: 2001-08-10 18:01:16 $
+ * last change: $Author: nn $ $Date: 2002-03-11 13:59:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -82,6 +82,18 @@ class ScStyleSheet;
class SvNumberFormatter;
class ScDocument;
+
+// how to treat COL_AUTO in GetFont:
+
+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
+};
+
+
class ScPatternAttr: public SfxSetItem
{
String* pName;
@@ -111,7 +123,8 @@ public:
void ClearItems( const USHORT* pWhich );
void DeleteUnchanged( const ScPatternAttr* pOldAttrs );
- void GetFont( Font& rFont, OutputDevice* pOutDev = NULL,
+ void GetFont( Font& rFont, ScAutoFontColorMode eAutoMode,
+ OutputDevice* pOutDev = NULL,
const Fraction* pScale = NULL,
const SfxItemSet* pCondSet = NULL,
BYTE nScript = 0 ) const;
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 );
diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx
index cf6e4dbbf7bf..ce54fe630c7a 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: excrecds.cxx,v $
*
- * $Revision: 1.38 $
+ * $Revision: 1.39 $
*
- * last change: $Author: nn $ $Date: 2002-03-04 19:33:18 $
+ * last change: $Author: nn $ $Date: 2002-03-11 14:05:34 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1342,7 +1342,8 @@ ExcRichStr::ExcRichStr( ExcCell& rExcCell, String& rText, const ScPatternAttr* p
// first font is the cell font, following font changes are stored in richstring
Font* pFont = new Font;
- pAttr->GetFont( *pFont );
+ //! #97022# change to SC_AUTOCOL_RAW and handle COL_AUTO
+ pAttr->GetFont( *pFont, SC_AUTOCOL_BLACK );
USHORT nLastFontIndex = rFontList.Add( pFont );
for( nPar = 0 ; nPar < nParCnt ; )
@@ -1419,7 +1420,8 @@ ExcRichStr::ExcRichStr( ExcCell& rExcCell, String& rText, const ScPatternAttr* p
aPatAttr.GetFromEditItemSet( &aItemSet );
Font* pFont = new Font;
- aPatAttr.GetFont( *pFont );
+ //! #97022# change to SC_AUTOCOL_RAW and handle COL_AUTO
+ aPatAttr.GetFont( *pFont, SC_AUTOCOL_BLACK );
if( bWasHLink )
{
pFont->SetColor( Color( COL_LIGHTBLUE ) );
@@ -3664,7 +3666,8 @@ void UsedAttrList::AddNewXF( const ScPatternAttr* pAttr, const BOOL bStyle, cons
if( pAttr )
{
Font* pFont = new Font;
- pAttr->GetFont( *pFont );
+ //! #97022# change to SC_AUTOCOL_RAW and handle COL_AUTO
+ pAttr->GetFont( *pFont, SC_AUTOCOL_BLACK );
nFontIndex = rFntLst.Add( pFont );
if ( bForceAltNumForm )
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index 2f260183ac99..7d5570de7a20 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xcl97rec.cxx,v $
*
- * $Revision: 1.39 $
+ * $Revision: 1.40 $
*
- * last change: $Author: dr $ $Date: 2001-11-28 16:42:22 $
+ * last change: $Author: nn $ $Date: 2002-03-11 14:06:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1667,7 +1667,8 @@ XclCf::XclCf( const ScCondFormatEntry& r, RootData& rRD ) :
{
Font aFont;
ScPatternAttr aPattAttr( new SfxItemSet( rSet ) );
- aPattAttr.GetFont( aFont );
+ //! #97022# change to SC_AUTOCOL_RAW and handle COL_AUTO
+ aPattAttr.GetFont( aFont, SC_AUTOCOL_BLACK );
BOOL bItalic = ( bHasItalic && aFont.GetItalic() != ITALIC_NONE );
BOOL bStrikeOut = ( bHasStrikeOut && aFont.GetStrikeout() != STRIKEOUT_NONE );
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index a82c92952ade..cccb850d04c6 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: docsh3.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: er $ $Date: 2002-01-21 16:27:48 $
+ * last change: $Author: nn $ $Date: 2002-03-11 14:07:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -373,7 +373,7 @@ void ScDocShell::CalcOutputFactor()
Font aOldFont = pPrinter->GetFont();
pPrinter->SetMapMode(MAP_PIXEL);
- pPattern->GetFont(aDefFont, pPrinter);
+ pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, pPrinter); // font color doesn't matter here
pPrinter->SetFont(aDefFont);
nPrinterWidth = pPrinter->PixelToLogic( Size( pPrinter->GetTextWidth(aTestString), 0 ),
MAP_100TH_MM ).Width();
@@ -385,7 +385,7 @@ void ScDocShell::CalcOutputFactor()
VirtualDevice aVirtWindow( *Application::GetDefaultDevice() );
aVirtWindow.SetMapMode(MAP_PIXEL);
- pPattern->GetFont(aDefFont, &aVirtWindow);
+ pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, &aVirtWindow); // font color doesn't matter here
aVirtWindow.SetFont(aDefFont);
nWindowWidth = aVirtWindow.GetTextWidth(aTestString);
nWindowWidth = (long) ( nWindowWidth / ScGlobal::nScreenPPTX * HMM_PER_TWIPS );
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index a9ceec8fa508..210d961d500c 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: output.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: nn $ $Date: 2001-05-09 19:15:47 $
+ * last change: $Author: nn $ $Date: 2002-03-11 14:08:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -150,6 +150,8 @@ private:
BOOL bPagebreakMode; // Seitenumbruch-Vorschau
BOOL bSolidBackground; // weiss statt transparent
+ BOOL bUseStyleColor;
+
BOOL bSyntaxMode; // Syntax-Highlighting
Color* pValueColor;
Color* pTextColor;
@@ -199,6 +201,7 @@ public:
void SetViewShell( ScTabViewShell* pSh ) { pViewShell = pSh; }
void SetSolidBackground( BOOL bSet ) { bSolidBackground = bSet; }
+ void SetUseStyleColor( BOOL bSet ) { bUseStyleColor = bSet; }
void SetEditCell( USHORT nCol, USHORT nRow );
void SetSyntaxMode( BOOL bNewMode );
diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx
index 2ac842e2bcfd..2026b233d211 100644
--- a/sc/source/ui/inc/printfun.hxx
+++ b/sc/source/ui/inc/printfun.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: printfun.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: nn $ $Date: 2002-02-27 19:34:18 $
+ * last change: $Author: nn $ $Date: 2002-03-11 14:08:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -194,6 +194,7 @@ private:
Point aOffset; // mit Faktor aus Seitenformat skaliert
USHORT nManualZoom; // Zoom in Preview (Prozent)
BOOL bClearWin; // Ausgabe vorher loeschen
+ BOOL bUseStyleColor;
USHORT nPrintTab;
long nPageStart; // Offset fuer erste Seite
@@ -294,6 +295,7 @@ public:
void SetDateTime( const Date& rDate, const Time& rTime );
void SetClearFlag( BOOL bFlag );
+ void SetUseStyleColor( BOOL bFlag );
BOOL UpdatePages();