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