xref: /AOO41X/main/svtools/source/config/colorcfg.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svtools.hxx"
30 
31 #include <svtools/colorcfg.hxx>
32 #include <com/sun/star/uno/Any.hxx>
33 #include <com/sun/star/uno/Sequence.hxx>
34 #include <com/sun/star/lang/Locale.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <tools/color.hxx>
37 #include <tools/debug.hxx>
38 #include <unotools/configitem.hxx>
39 #include <unotools/configpathes.hxx>
40 #include <com/sun/star/uno/Sequence.h>
41 #include <svl/poolitem.hxx> //Any2Bool
42 #include <svl/smplhint.hxx>
43 #include <vos/mutex.hxx>
44 
45 #include <itemholder2.hxx>
46 
47  /* #100822# ----
48 #include <vcl/wrkwin.hxx>
49  ------------- */
50 #include <vcl/svapp.hxx>
51 #include <vcl/event.hxx>
52 #include <rtl/instance.hxx>
53 
54 //-----------------------------------------------------------------------------
55 using namespace utl;
56 using namespace rtl;
57 using namespace com::sun::star;
58 
59 namespace svtools
60 {
61 
62 #define C2U(cChar) OUString::createFromAscii(cChar)
63 static const sal_Char cColor[] = "/Color";
64 static const sal_Char cColorSchemes[] = "ColorSchemes/";
65 sal_Int32            nColorRefCount_Impl = 0;
66 namespace
67 {
68     struct ColorMutex_Impl
69         : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {};
70 }
71 
72 ColorConfig_Impl*    ColorConfig::m_pImpl = NULL;
73 
74 /* -----------------------------16.01.01 15:36--------------------------------
75  ---------------------------------------------------------------------------*/
76 class ColorConfig_Impl : public utl::ConfigItem
77 {
78     ColorConfigValue    m_aConfigValues[ColorConfigEntryCount];
79     sal_Bool            m_bEditMode;
80     rtl::OUString       m_sIsVisible;
81     rtl::OUString       m_sLoadedScheme;
82 
83     uno::Sequence< ::rtl::OUString> GetPropertyNames(const rtl::OUString& rScheme);
84 public:
85     ColorConfig_Impl(sal_Bool bEditMode = sal_False);
86     virtual ~ColorConfig_Impl();
87 
88     void                            Load(const rtl::OUString& rScheme);
89     void                            CommitCurrentSchemeName();
90     //changes the name of the current scheme but doesn't load it!
91     void                            SetCurrentSchemeName(const rtl::OUString& rSchemeName) {m_sLoadedScheme = rSchemeName;}
92     virtual void                    Commit();
93     virtual void                    Notify( const uno::Sequence<rtl::OUString>& aPropertyNames);
94 
95     const ColorConfigValue&         GetColorConfigValue(ColorConfigEntry eValue)
96                                                             {return m_aConfigValues[eValue];}
97     void                            SetColorConfigValue(ColorConfigEntry eValue,
98                                                             const ColorConfigValue& rValue );
99 
100     const rtl::OUString&            GetLoadedScheme() const {return m_sLoadedScheme;}
101 
102     uno::Sequence< ::rtl::OUString> GetSchemeNames();
103 
104     sal_Bool                        AddScheme(const rtl::OUString& rNode);
105     sal_Bool                        RemoveScheme(const rtl::OUString& rNode);
106     void                            SetModified(){ConfigItem::SetModified();}
107     void                            ClearModified(){ConfigItem::ClearModified();}
108     void                            SettingsChanged();
109 
110     // #100822#
111     DECL_LINK( DataChangedEventListener, VclWindowEvent* );
112 
113 	void ImplUpdateApplicationSettings();
114 };
115 
116 /* -----------------------------16.01.01 15:36--------------------------------
117 
118  ---------------------------------------------------------------------------*/
119 uno::Sequence< OUString> ColorConfig_Impl::GetPropertyNames(const rtl::OUString& rScheme)
120 {
121     uno::Sequence<OUString> aNames(2 * ColorConfigEntryCount);
122 	OUString* pNames = aNames.getArray();
123     struct ColorConfigEntryData_Impl
124     {
125         const sal_Char* cName;
126         sal_Int32       nLength;
127         rtl_TextEncoding eEncoding;
128         sal_Bool bCanBeVisible;
129     };
130     static const ColorConfigEntryData_Impl cNames[] =
131     {
132         { RTL_CONSTASCII_USTRINGPARAM("/DocColor")        ,sal_False },
133         { RTL_CONSTASCII_USTRINGPARAM("/DocBoundaries")   ,sal_True },
134         { RTL_CONSTASCII_USTRINGPARAM("/AppBackground")   ,sal_False },
135         { RTL_CONSTASCII_USTRINGPARAM("/ObjectBoundaries"),sal_True },
136         { RTL_CONSTASCII_USTRINGPARAM("/TableBoundaries") ,sal_True },
137         { RTL_CONSTASCII_USTRINGPARAM("/FontColor")		,sal_False },
138         { RTL_CONSTASCII_USTRINGPARAM("/Links")           ,sal_True },
139         { RTL_CONSTASCII_USTRINGPARAM("/LinksVisited")    ,sal_True },
140         { RTL_CONSTASCII_USTRINGPARAM("/Anchor")          ,sal_False },
141         { RTL_CONSTASCII_USTRINGPARAM("/Spell")     ,sal_False },
142         { RTL_CONSTASCII_USTRINGPARAM("/SmartTags")     ,sal_False },
143         { RTL_CONSTASCII_USTRINGPARAM("/WriterTextGrid")  ,sal_False },
144         { RTL_CONSTASCII_USTRINGPARAM("/WriterFieldShadings"),sal_True },
145         { RTL_CONSTASCII_USTRINGPARAM("/WriterIdxShadings")     ,sal_True },
146         { RTL_CONSTASCII_USTRINGPARAM("/WriterDirectCursor")    ,sal_True },
147         { RTL_CONSTASCII_USTRINGPARAM("/WriterScriptIndicator")    ,sal_False },
148         { RTL_CONSTASCII_USTRINGPARAM("/WriterSectionBoundaries")    ,sal_True },
149         { RTL_CONSTASCII_USTRINGPARAM("/WriterPageBreaks")    ,sal_False },
150         { RTL_CONSTASCII_USTRINGPARAM("/HTMLSGML")        ,sal_False },
151         { RTL_CONSTASCII_USTRINGPARAM("/HTMLComment")     ,sal_False },
152         { RTL_CONSTASCII_USTRINGPARAM("/HTMLKeyword")     ,sal_False },
153         { RTL_CONSTASCII_USTRINGPARAM("/HTMLUnknown")     ,sal_False },
154         { RTL_CONSTASCII_USTRINGPARAM("/CalcGrid")        ,sal_False },
155         { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreak"), sal_False },
156         { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreakManual"), sal_False },
157         { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreakAutomatic"), sal_False },
158         { RTL_CONSTASCII_USTRINGPARAM("/CalcDetective")   ,sal_False },
159         { RTL_CONSTASCII_USTRINGPARAM("/CalcDetectiveError")   ,sal_False },
160         { RTL_CONSTASCII_USTRINGPARAM("/CalcReference")   ,sal_False },
161         { RTL_CONSTASCII_USTRINGPARAM("/CalcNotesBackground") ,sal_False },
162         { RTL_CONSTASCII_USTRINGPARAM("/DrawGrid")        ,sal_True },
163         { RTL_CONSTASCII_USTRINGPARAM("/DrawDrawing")     ,sal_False },
164         { RTL_CONSTASCII_USTRINGPARAM("/DrawFill")        ,sal_False },
165         { RTL_CONSTASCII_USTRINGPARAM("/BASICIdentifier"),  sal_False },
166         { RTL_CONSTASCII_USTRINGPARAM("/BASICComment")   ,  sal_False },
167         { RTL_CONSTASCII_USTRINGPARAM("/BASICNumber")    ,  sal_False },
168         { RTL_CONSTASCII_USTRINGPARAM("/BASICString")    ,  sal_False },
169         { RTL_CONSTASCII_USTRINGPARAM("/BASICOperator")  ,  sal_False },
170         { RTL_CONSTASCII_USTRINGPARAM("/BASICKeyword")   ,  sal_False },
171         { RTL_CONSTASCII_USTRINGPARAM("/BASICError"),  sal_False },
172 		{ RTL_CONSTASCII_USTRINGPARAM("/SQLIdentifier"),  sal_False },
173 		{ RTL_CONSTASCII_USTRINGPARAM("/SQLNumber"),  sal_False },
174 		{ RTL_CONSTASCII_USTRINGPARAM("/SQLString"),  sal_False },
175 		{ RTL_CONSTASCII_USTRINGPARAM("/SQLOperator"),  sal_False },
176 		{ RTL_CONSTASCII_USTRINGPARAM("/SQLKeyword"),  sal_False },
177 		{ RTL_CONSTASCII_USTRINGPARAM("/SQLParameter"),  sal_False },
178 		{ RTL_CONSTASCII_USTRINGPARAM("/SQLComment"),  sal_False }
179     };
180     int nIndex = 0;
181     OUString sColor = C2U(cColor);
182     OUString sBase(C2U(cColorSchemes));
183 	sBase += utl::wrapConfigurationElementName(rScheme);
184     const int nCount = ColorConfigEntryCount;
185     for(sal_Int32 i = 0; i < 4 * nCount; i+= 4)
186     {
187 		rtl::OUString sBaseName(sBase);
188         sal_Int32 nPos = i / 4;
189         sBaseName += OUString(cNames[nPos].cName, cNames[nPos].nLength, cNames[nPos].eEncoding);
190         pNames[nIndex] += sBaseName;
191         pNames[nIndex++] += sColor;
192         if(cNames[nPos].bCanBeVisible)
193         {
194             pNames[nIndex] += sBaseName;
195             pNames[nIndex++] += m_sIsVisible;
196         }
197     }
198     aNames.realloc(nIndex);
199     return aNames;
200 }
201 /* -----------------------------22.03.2002 14:37------------------------------
202 
203  ---------------------------------------------------------------------------*/
204 ColorConfig_Impl::ColorConfig_Impl(sal_Bool bEditMode) :
205     ConfigItem(C2U("Office.UI/ColorScheme")),
206     m_bEditMode(bEditMode),
207     m_sIsVisible(C2U("/IsVisible"))
208 {
209     if(!m_bEditMode)
210     {
211         //try to register on the root node - if possible
212         uno::Sequence < ::rtl::OUString > aNames(1);
213         EnableNotification( aNames );
214     }
215     Load(::rtl::OUString());
216 
217 	ImplUpdateApplicationSettings();
218 
219     // #100822#
220     ::Application::AddEventListener( LINK(this, ColorConfig_Impl, DataChangedEventListener) );
221 
222 }
223 /* -----------------------------25.03.2002 12:28------------------------------
224 
225  ---------------------------------------------------------------------------*/
226 ColorConfig_Impl::~ColorConfig_Impl()
227 {
228 	// #100822#
229 	::Application::RemoveEventListener( LINK(this, ColorConfig_Impl, DataChangedEventListener) );
230 }
231 /* -----------------------------22.03.2002 14:38------------------------------
232 
233  ---------------------------------------------------------------------------*/
234 void ColorConfig_Impl::Load(const rtl::OUString& rScheme)
235 {
236     rtl::OUString sScheme(rScheme);
237     if(!sScheme.getLength())
238     {
239         //detect current scheme name
240         uno::Sequence < ::rtl::OUString > aCurrent(1);
241         aCurrent.getArray()[0] = C2U("CurrentColorScheme");
242         uno::Sequence< uno::Any > aCurrentVal = GetProperties( aCurrent );
243         aCurrentVal.getConstArray()[0] >>= sScheme;
244     }
245     m_sLoadedScheme = sScheme;
246     //
247     uno::Sequence < ::rtl::OUString > aColorNames = GetPropertyNames(sScheme);
248     uno::Sequence< uno::Any > aColors = GetProperties( aColorNames );
249     const uno::Any* pColors = aColors.getConstArray();
250     const ::rtl::OUString* pColorNames = aColorNames.getConstArray();
251     sal_Int32 nIndex = 0;
252     for(int i = 0; i < 2 * ColorConfigEntryCount && aColors.getLength() > nIndex; i+= 2)
253     {
254         if(pColors[nIndex].hasValue())
255             pColors[nIndex] >>= m_aConfigValues[i / 2].nColor;
256         else
257             m_aConfigValues[i/2].nColor = COL_AUTO;
258         nIndex++;
259 		if(nIndex >= aColors.getLength())
260 			break;
261         //test for visibility property
262         if(pColorNames[nIndex].match(m_sIsVisible, pColorNames[nIndex].getLength() - m_sIsVisible.getLength()))
263              m_aConfigValues[i / 2].bIsVisible = Any2Bool(pColors[nIndex++]);
264     }
265 }
266 /* -----------------------------22.03.2002 14:38------------------------------
267 
268  ---------------------------------------------------------------------------*/
269 void    ColorConfig_Impl::Notify( const uno::Sequence<OUString>& )
270 {
271     //loading via notification always uses the default setting
272     Load(::rtl::OUString());
273 	NotifyListeners(0);
274 }
275 /* -----------------------------22.03.2002 14:38------------------------------
276 
277  ---------------------------------------------------------------------------*/
278 void ColorConfig_Impl::Commit()
279 {
280     uno::Sequence < ::rtl::OUString > aColorNames = GetPropertyNames(m_sLoadedScheme);
281     uno::Sequence < beans::PropertyValue > aPropValues(aColorNames.getLength());
282     beans::PropertyValue* pPropValues = aPropValues.getArray();
283     const ::rtl::OUString* pColorNames = aColorNames.getConstArray();
284     sal_Int32 nIndex = 0;
285     const uno::Type& rBoolType = ::getBooleanCppuType();
286     for(int i = 0; i < 2 * ColorConfigEntryCount && aColorNames.getLength() > nIndex; i+= 2)
287     {
288         pPropValues[nIndex].Name = pColorNames[nIndex];
289         //save automatic colors as void value
290         if(COL_AUTO != sal::static_int_cast<ColorData>(m_aConfigValues[i/2].nColor))
291             pPropValues[nIndex].Value <<= m_aConfigValues[i/2].nColor;
292 
293         nIndex++;
294         if(nIndex >= aColorNames.getLength())
295 			break;
296         //test for visibility property
297         if(pColorNames[nIndex].match(m_sIsVisible, pColorNames[nIndex].getLength() - m_sIsVisible.getLength()))
298         {
299 			 pPropValues[nIndex].Name = pColorNames[nIndex];
300              pPropValues[nIndex].Value.setValue(&m_aConfigValues[i/2].bIsVisible, rBoolType);
301              nIndex++;
302         }
303     }
304     rtl::OUString sNode(C2U("ColorSchemes"));
305     SetSetProperties(sNode, aPropValues);
306 
307     CommitCurrentSchemeName();
308 }
309 /* -----------------11.12.2002 10:42-----------------
310  *
311  * --------------------------------------------------*/
312 void ColorConfig_Impl::CommitCurrentSchemeName()
313 {
314     //save current scheme name
315     uno::Sequence < ::rtl::OUString > aCurrent(1);
316     aCurrent.getArray()[0] = C2U("CurrentColorScheme");
317     uno::Sequence< uno::Any > aCurrentVal(1);
318     aCurrentVal.getArray()[0] <<= m_sLoadedScheme;
319     PutProperties(aCurrent, aCurrentVal);
320 }
321 /* -----------------------------25.03.2002 12:19------------------------------
322 
323  ---------------------------------------------------------------------------*/
324 void ColorConfig_Impl::SetColorConfigValue(ColorConfigEntry eValue, const ColorConfigValue& rValue )
325 {
326     if(rValue != m_aConfigValues[eValue])
327     {
328         m_aConfigValues[eValue] = rValue;
329         SetModified();
330     }
331 }
332 /* -----------------------------25.03.2002 15:22------------------------------
333 
334  ---------------------------------------------------------------------------*/
335 uno::Sequence< ::rtl::OUString> ColorConfig_Impl::GetSchemeNames()
336 {
337     return GetNodeNames(C2U("ColorSchemes"));
338 }
339 /* -----------------------------09.04.2002 17:19------------------------------
340 
341  ---------------------------------------------------------------------------*/
342 sal_Bool ColorConfig_Impl::AddScheme(const rtl::OUString& rScheme)
343 {
344     if(ConfigItem::AddNode(C2U("ColorSchemes"), rScheme))
345     {
346         m_sLoadedScheme = rScheme;
347         Commit();
348         return sal_True;
349     }
350     return sal_False;
351 }
352 /* -----------------------------09.04.2002 17:19------------------------------
353 
354  ---------------------------------------------------------------------------*/
355 sal_Bool ColorConfig_Impl::RemoveScheme(const rtl::OUString& rScheme)
356 {
357     uno::Sequence< rtl::OUString > aElements(1);
358     aElements.getArray()[0] = rScheme;
359     return ClearNodeElements(C2U("ColorSchemes"), aElements);
360 }
361 /* -----------------------------2002/06/20 13:03------------------------------
362 
363  ---------------------------------------------------------------------------*/
364 void ColorConfig_Impl::SettingsChanged()
365 {
366     vos::OGuard aVclGuard( Application::GetSolarMutex() );
367 
368 	ImplUpdateApplicationSettings();
369 
370     NotifyListeners(0);
371 }
372 /* -----------------------------2002/08/16 12:07 -----------------------------
373    #100822#
374  --------------------------------------------------------------------------- */
375 IMPL_LINK( ColorConfig_Impl, DataChangedEventListener, VclWindowEvent*, pEvent )
376 {
377 	if ( pEvent->GetId() == VCLEVENT_APPLICATION_DATACHANGED )
378 	{
379 		DataChangedEvent* pData = (DataChangedEvent*)(pEvent->GetData());
380 		if ( (pData->GetType() == DATACHANGED_SETTINGS) &&
381     	     (pData->GetFlags() & SETTINGS_STYLE) )
382 	    {
383 		    SettingsChanged();
384 			return 1L;
385     	} else
386     		return 0L;
387 	} else
388     	return 0L;
389 }
390 
391 // ---------------------------------------------------------------------------
392 
393 /** updates the font color in the vcl window settings */
394 void ColorConfig_Impl::ImplUpdateApplicationSettings()
395 {
396     Application* pApp = GetpApp();
397 	if( pApp )
398 	{
399 		AllSettings aSettings = pApp->GetSettings();
400 		StyleSettings aStyleSettings( aSettings.GetStyleSettings() );
401 
402 		ColorConfigValue aRet = GetColorConfigValue(svtools::FONTCOLOR);
403 		if(COL_AUTO == sal::static_int_cast<ColorData>(aRet.nColor))
404 			aRet.nColor = ColorConfig::GetDefaultColor(svtools::FONTCOLOR).GetColor();
405 
406 	    Color aFontColor(aRet.nColor);
407 
408 		if( aStyleSettings.GetFontColor() != aFontColor )
409 		{
410 			aStyleSettings.SetFontColor( aFontColor );
411 
412 			aSettings.SetStyleSettings( aStyleSettings );
413 			pApp->SetSettings( aSettings );
414 		}
415 	}
416 }
417 
418 // ---------------------------------------------------------------------------
419 
420 ColorConfig::ColorConfig()
421 {
422     ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
423     if ( !m_pImpl )
424     {
425         m_pImpl = new ColorConfig_Impl;
426         ItemHolder2::holdConfigItem(E_COLORCFG);
427     }
428     ++nColorRefCount_Impl;
429     m_pImpl->AddListener(this);
430 }
431 /* -----------------------------16.01.01 15:36--------------------------------
432 
433  ---------------------------------------------------------------------------*/
434 ColorConfig::~ColorConfig()
435 {
436     ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
437     m_pImpl->RemoveListener(this);
438     if(!--nColorRefCount_Impl)
439     {
440         delete m_pImpl;
441         m_pImpl = 0;
442     }
443 }
444 /* -----------------------------11.04.2002 11:49------------------------------
445 
446  ---------------------------------------------------------------------------*/
447 Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry)
448 {
449     static const sal_Int32 aAutoColors[] =
450     {
451         0, // DOCCOLOR
452         0xc0c0c0, // DOCBOUNDARIES
453         0x808080, // APPBACKGROUND
454         0xc0c0c0, // OBJECTBOUNDARIES
455         0xc0c0c0, // TABLEBOUNDARIES
456         0, // FONTCOLOR
457         0xcc, // LINKS
458         0x80, // LINKSVISITED
459         0, // ANCHOR
460         0xff0000, // SPELL
461         COL_LIGHTMAGENTA,// SMARTTAGS
462         0xc0c0c0, // WRITERTEXTGRID
463         0xc0c0c0, // WRITERFIELDSHADIN
464         0xc0c0c0, // WRITERIDXSHADINGS
465         0, // WRITERDIRECTCURSOR
466         COL_GREEN,  //WRITERSCRIPTINDICATOR
467         0xc0c0c0, //WRITERSECTIONBOUNDARIES
468         COL_BLUE, //WRITERPAGEBREAKS,
469         COL_LIGHTBLUE, // HTMLSGML
470         COL_LIGHTGREEN, // HTMLCOMMENT
471         COL_LIGHTRED, // HTMLKEYWORD
472         COL_GRAY, // HTMLUNKNOWN
473         COL_LIGHTGRAY, // CALCGRID
474         COL_BLUE, //CALCPAGEBREAK
475         0x2300dc, //CALCPAGEBREAKMANUAL
476         COL_GRAY, //CALCPAGEBREAKAUTOMATIC
477         COL_LIGHTBLUE, // CALCDETECTIVE
478         COL_LIGHTRED, // CALCDETECTIVEERROR
479         COL_LIGHTRED, // CALCREFERENCE
480         0xffffc0, // CALCNOTESBACKGROUND
481         0xc0c0c0, // DRAWGRID
482         0, // DRAWDRAWING
483         0xb8ff, // DRAWFILL
484         COL_GREEN, // BASICIDENTIFIER,
485         COL_GRAY,// BASICCOMMENT   ,
486         COL_LIGHTRED,// BASICNUMBER    ,
487         COL_LIGHTRED,// BASICSTRING    ,
488         COL_BLUE, // BASICOPERATOR  ,
489         COL_BLUE, // BASICKEYWORD   ,
490         COL_RED, //BASICERROR
491 		0x009900, // SQLIDENTIFIER
492 		0x000000, // SQLNUMBER
493 		0xCE7B00, // SQLSTRING
494 		0x000000, // SQLOPERATOR
495 		0x0000E6, // SQLKEYWORD
496 		0x259D9D, // SQLPARAMTER
497 		0x969696,// SQLCOMMENT
498     };
499     Color aRet;
500     switch(eEntry)
501     {
502         case DOCCOLOR :
503             aRet = Application::GetSettings().GetStyleSettings().GetWindowColor();
504         	break;
505 
506         case APPBACKGROUND :
507 			aRet = Application::GetSettings().GetStyleSettings().GetWorkspaceColor();
508 			break;
509 
510         case SPELL :
511         case DRAWDRAWING :
512         case SMARTTAGS :
513         {
514             const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
515                 aRet = rStyleSettings.GetHighContrastMode() ?
516                     rStyleSettings.GetDialogTextColor().GetColor() : aAutoColors[eEntry];
517         }
518         break;
519 
520         case DRAWFILL            :
521                 aRet = /*rStyleSettings.GetHighContrastMode() ?
522 					rStyleSettings.OutlineMode??? : */	aAutoColors[eEntry];
523         break;
524 
525 		case FONTCOLOR :
526             aRet = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
527 			break;
528 
529 		case LINKS :
530             aRet = Application::GetSettings().GetStyleSettings().GetLinkColor();
531 			break;
532 
533 		case LINKSVISITED :
534             aRet = Application::GetSettings().GetStyleSettings().GetVisitedLinkColor();
535 			break;
536 
537         default:
538             aRet = aAutoColors[eEntry];
539     }
540     return aRet;
541 }
542 /* -----------------------------11.04.2002 11:49------------------------------
543 
544  ---------------------------------------------------------------------------*/
545 ColorConfigValue ColorConfig::GetColorValue(ColorConfigEntry eEntry, sal_Bool bSmart)const
546 {
547     ColorConfigValue aRet = m_pImpl->GetColorConfigValue(eEntry);
548     if(bSmart)
549     {
550         if(COL_AUTO == sal::static_int_cast<ColorData>(aRet.nColor))
551             aRet.nColor = ColorConfig::GetDefaultColor(eEntry).GetColor();
552         //#103495# don't allow grey between 40% and 60% as application background
553         const sal_uInt8 nRed = COLORDATA_RED( aRet.nColor);
554         if(eEntry == APPBACKGROUND &&
555                 (nRed == COLORDATA_GREEN( aRet.nColor)) &&
556                     (nRed == COLORDATA_BLUE( aRet.nColor)) &&
557                 nRed > 102 && nRed < 153 )
558         {
559             aRet.nColor = RGB_COLORDATA(153, 153, 153);
560         }
561     }
562 
563     return aRet;
564 }
565 /* -----------------------------25.03.2002 12:01------------------------------
566 
567  ---------------------------------------------------------------------------*/
568 EditableColorConfig::EditableColorConfig() :
569     m_pImpl(new ColorConfig_Impl),
570 	m_bModified(sal_False)
571 {
572     m_pImpl->BlockBroadcasts(sal_True);
573 }
574 /*-- 25.03.2002 12:03:08---------------------------------------------------
575 
576   -----------------------------------------------------------------------*/
577 EditableColorConfig::~EditableColorConfig()
578 {
579     m_pImpl->BlockBroadcasts(sal_False);
580     if(m_bModified)
581 		m_pImpl->SetModified();
582     if(m_pImpl->IsModified())
583         m_pImpl->Commit();
584     delete m_pImpl;
585 }
586 
587 /*-- 25.03.2002 12:03:15---------------------------------------------------
588 
589   -----------------------------------------------------------------------*/
590 uno::Sequence< ::rtl::OUString >  EditableColorConfig::GetSchemeNames() const
591 {
592     return m_pImpl->GetSchemeNames();
593 }
594 /*-- 25.03.2002 12:03:16---------------------------------------------------
595 
596   -----------------------------------------------------------------------*/
597 void EditableColorConfig::DeleteScheme(const ::rtl::OUString& rScheme )
598 {
599     m_pImpl->RemoveScheme(rScheme);
600 }
601 /*-- 25.03.2002 12:03:16---------------------------------------------------
602 
603   -----------------------------------------------------------------------*/
604 void EditableColorConfig::AddScheme(const ::rtl::OUString& rScheme )
605 {
606     m_pImpl->AddScheme(rScheme);
607 }
608 /*-- 25.03.2002 12:03:16---------------------------------------------------
609 
610   -----------------------------------------------------------------------*/
611 sal_Bool EditableColorConfig::LoadScheme(const ::rtl::OUString& rScheme )
612 {
613     if(m_bModified)
614 		m_pImpl->SetModified();
615 	if(m_pImpl->IsModified())
616 		m_pImpl->Commit();
617 	m_bModified = sal_False;
618 	m_pImpl->Load(rScheme);
619     //the name of the loaded scheme has to be committed separately
620     m_pImpl->CommitCurrentSchemeName();
621 	return sal_True;
622 }
623 /*-- 25.03.2002 12:03:16---------------------------------------------------
624 
625   -----------------------------------------------------------------------*/
626 const ::rtl::OUString& EditableColorConfig::GetCurrentSchemeName()const
627 {
628     return m_pImpl->GetLoadedScheme();
629 }
630 /* -----------------11.12.2002 10:56-----------------
631  *  changes the name of the current scheme but doesn't load it!
632  * --------------------------------------------------*/
633 void EditableColorConfig::SetCurrentSchemeName(const ::rtl::OUString& rScheme)
634 {
635     m_pImpl->SetCurrentSchemeName(rScheme);
636     m_pImpl->CommitCurrentSchemeName();
637 }
638 /*-- 25.03.2002 12:03:17---------------------------------------------------
639 
640   -----------------------------------------------------------------------*/
641 const ColorConfigValue& EditableColorConfig::GetColorValue(
642     ColorConfigEntry eEntry)const
643 {
644     return m_pImpl->GetColorConfigValue(eEntry);
645 }
646 /*-- 25.03.2002 12:03:17---------------------------------------------------
647 
648   -----------------------------------------------------------------------*/
649 void EditableColorConfig::SetColorValue(
650     ColorConfigEntry eEntry, const ColorConfigValue& rValue)
651 {
652     m_pImpl->SetColorConfigValue(eEntry, rValue);
653 	m_pImpl->ClearModified();
654 	m_bModified = sal_True;
655 }
656 /* -----------------------------10.04.2002 13:22------------------------------
657 
658  ---------------------------------------------------------------------------*/
659 void EditableColorConfig::SetModified()
660 {
661     m_bModified = sal_True;
662 }
663 /* -----------------15.10.2002 14:51-----------------
664  *
665  * --------------------------------------------------*/
666 void EditableColorConfig::Commit()
667 {
668     if(m_bModified)
669         m_pImpl->SetModified();
670     if(m_pImpl->IsModified())
671         m_pImpl->Commit();
672     m_bModified = sal_False;
673 }
674 // -----------------------------------------------------------------------------
675 void EditableColorConfig::DisableBroadcast()
676 {
677     m_pImpl->BlockBroadcasts(sal_True);
678 }
679 // -----------------------------------------------------------------------------
680 void EditableColorConfig::EnableBroadcast()
681 {
682     m_pImpl->BlockBroadcasts(sal_False);
683 }
684 // -----------------------------------------------------------------------------
685 
686 }//namespace svtools
687