Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <svtools/colorcfg.hxx>
22 : #include <com/sun/star/uno/Any.hxx>
23 : #include <com/sun/star/uno/Sequence.hxx>
24 : #include <com/sun/star/lang/Locale.hpp>
25 : #include <com/sun/star/beans/PropertyValue.hpp>
26 : #include <comphelper/processfactory.hxx>
27 : #include <unotools/configitem.hxx>
28 : #include <unotools/confignode.hxx>
29 : #include <unotools/configpaths.hxx>
30 : #include <com/sun/star/uno/Sequence.h>
31 : #include <svl/poolitem.hxx>
32 : #include <svl/smplhint.hxx>
33 : #include <osl/mutex.hxx>
34 :
35 : #include <itemholder2.hxx>
36 :
37 : /* #100822# ----
38 : #include <vcl/wrkwin.hxx>
39 : ------------- */
40 : #include <vcl/svapp.hxx>
41 : #include <vcl/event.hxx>
42 : #include <vcl/settings.hxx>
43 : #include <rtl/instance.hxx>
44 :
45 :
46 : using namespace utl;
47 : using namespace com::sun::star;
48 :
49 :
50 : namespace svtools
51 : {
52 :
53 : static const sal_Char cColor[] = "/Color";
54 : static const sal_Char cColorSchemes[] = "ColorSchemes/";
55 : sal_Int32 nColorRefCount_Impl = 0;
56 : namespace
57 : {
58 : struct ColorMutex_Impl
59 : : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {};
60 : }
61 :
62 : ColorConfig_Impl* ColorConfig::m_pImpl = NULL;
63 :
64 : class ColorConfig_Impl : public utl::ConfigItem
65 : {
66 : ColorConfigValue m_aConfigValues[ColorConfigEntryCount];
67 : bool m_bEditMode;
68 : OUString m_sIsVisible;
69 : OUString m_sLoadedScheme;
70 : bool m_bAutoDetectSystemHC;
71 :
72 : uno::Sequence< OUString> GetPropertyNames(const OUString& rScheme);
73 : public:
74 : ColorConfig_Impl(bool bEditMode = false);
75 : virtual ~ColorConfig_Impl();
76 :
77 : void Load(const OUString& rScheme);
78 : void CommitCurrentSchemeName();
79 : //changes the name of the current scheme but doesn't load it!
80 0 : void SetCurrentSchemeName(const OUString& rSchemeName) {m_sLoadedScheme = rSchemeName;}
81 : virtual void Commit() SAL_OVERRIDE;
82 : virtual void Notify( const uno::Sequence<OUString>& aPropertyNames) SAL_OVERRIDE;
83 :
84 90591 : const ColorConfigValue& GetColorConfigValue(ColorConfigEntry eValue)
85 90591 : {return m_aConfigValues[eValue];}
86 : void SetColorConfigValue(ColorConfigEntry eValue,
87 : const ColorConfigValue& rValue );
88 :
89 0 : const OUString& GetLoadedScheme() const {return m_sLoadedScheme;}
90 :
91 : uno::Sequence< OUString> GetSchemeNames();
92 :
93 : bool AddScheme(const OUString& rNode);
94 : bool RemoveScheme(const OUString& rNode);
95 24 : void SetModified(){ConfigItem::SetModified();}
96 12 : void ClearModified(){ConfigItem::ClearModified();}
97 : void SettingsChanged();
98 89084 : bool GetAutoDetectSystemHC() {return m_bAutoDetectSystemHC;}
99 :
100 : // #100822#
101 : DECL_LINK( DataChangedEventListener, VclWindowEvent* );
102 :
103 : void ImplUpdateApplicationSettings();
104 : };
105 :
106 126 : uno::Sequence< OUString> ColorConfig_Impl::GetPropertyNames(const OUString& rScheme)
107 : {
108 126 : uno::Sequence<OUString> aNames(2 * ColorConfigEntryCount);
109 126 : OUString* pNames = aNames.getArray();
110 : struct ColorConfigEntryData_Impl
111 : {
112 : const sal_Char* cName;
113 : sal_Int32 nLength;
114 : rtl_TextEncoding eEncoding;
115 : bool bCanBeVisible;
116 : };
117 : static const ColorConfigEntryData_Impl cNames[] =
118 : {
119 : { RTL_CONSTASCII_USTRINGPARAM("/DocColor") ,false },
120 : { RTL_CONSTASCII_USTRINGPARAM("/DocBoundaries") ,true },
121 : { RTL_CONSTASCII_USTRINGPARAM("/AppBackground") ,false },
122 : { RTL_CONSTASCII_USTRINGPARAM("/ObjectBoundaries"),true },
123 : { RTL_CONSTASCII_USTRINGPARAM("/TableBoundaries") ,true },
124 : { RTL_CONSTASCII_USTRINGPARAM("/FontColor") ,false },
125 : { RTL_CONSTASCII_USTRINGPARAM("/Links") ,true },
126 : { RTL_CONSTASCII_USTRINGPARAM("/LinksVisited") ,true },
127 : { RTL_CONSTASCII_USTRINGPARAM("/Spell") ,false },
128 : { RTL_CONSTASCII_USTRINGPARAM("/SmartTags") ,false },
129 : { RTL_CONSTASCII_USTRINGPARAM("/Shadow") , true },
130 : { RTL_CONSTASCII_USTRINGPARAM("/WriterTextGrid") ,false },
131 : { RTL_CONSTASCII_USTRINGPARAM("/WriterFieldShadings"),true },
132 : { RTL_CONSTASCII_USTRINGPARAM("/WriterIdxShadings") ,true },
133 : { RTL_CONSTASCII_USTRINGPARAM("/WriterDirectCursor") ,true },
134 : { RTL_CONSTASCII_USTRINGPARAM("/WriterScriptIndicator") ,false },
135 : { RTL_CONSTASCII_USTRINGPARAM("/WriterSectionBoundaries") ,true },
136 : { RTL_CONSTASCII_USTRINGPARAM("/WriterHeaderFooterMark") ,false },
137 : { RTL_CONSTASCII_USTRINGPARAM("/WriterPageBreaks") ,false },
138 : { RTL_CONSTASCII_USTRINGPARAM("/HTMLSGML") ,false },
139 : { RTL_CONSTASCII_USTRINGPARAM("/HTMLComment") ,false },
140 : { RTL_CONSTASCII_USTRINGPARAM("/HTMLKeyword") ,false },
141 : { RTL_CONSTASCII_USTRINGPARAM("/HTMLUnknown") ,false },
142 : { RTL_CONSTASCII_USTRINGPARAM("/CalcGrid") ,false },
143 : { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreak"), false },
144 : { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreakManual"), false },
145 : { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreakAutomatic"), false },
146 : { RTL_CONSTASCII_USTRINGPARAM("/CalcDetective") ,false },
147 : { RTL_CONSTASCII_USTRINGPARAM("/CalcDetectiveError") ,false },
148 : { RTL_CONSTASCII_USTRINGPARAM("/CalcReference") ,false },
149 : { RTL_CONSTASCII_USTRINGPARAM("/CalcNotesBackground") ,false },
150 : { RTL_CONSTASCII_USTRINGPARAM("/DrawGrid") ,true },
151 : { RTL_CONSTASCII_USTRINGPARAM("/BASICIdentifier"), false },
152 : { RTL_CONSTASCII_USTRINGPARAM("/BASICComment") , false },
153 : { RTL_CONSTASCII_USTRINGPARAM("/BASICNumber") , false },
154 : { RTL_CONSTASCII_USTRINGPARAM("/BASICString") , false },
155 : { RTL_CONSTASCII_USTRINGPARAM("/BASICOperator") , false },
156 : { RTL_CONSTASCII_USTRINGPARAM("/BASICKeyword") , false },
157 : { RTL_CONSTASCII_USTRINGPARAM("/BASICError"), false },
158 : { RTL_CONSTASCII_USTRINGPARAM("/SQLIdentifier"), false },
159 : { RTL_CONSTASCII_USTRINGPARAM("/SQLNumber"), false },
160 : { RTL_CONSTASCII_USTRINGPARAM("/SQLString"), false },
161 : { RTL_CONSTASCII_USTRINGPARAM("/SQLOperator"), false },
162 : { RTL_CONSTASCII_USTRINGPARAM("/SQLKeyword"), false },
163 : { RTL_CONSTASCII_USTRINGPARAM("/SQLParameter"), false },
164 : { RTL_CONSTASCII_USTRINGPARAM("/SQLComment"), false }
165 : };
166 126 : int nIndex = 0;
167 252 : OUString sColor = cColor;
168 252 : OUString sBase(cColorSchemes);
169 126 : sBase += utl::wrapConfigurationElementName(rScheme);
170 126 : const int nCount = ColorConfigEntryCount;
171 5922 : for(sal_Int32 i = 0; i < 4 * nCount; i+= 4)
172 : {
173 5796 : OUString sBaseName(sBase);
174 5796 : sal_Int32 nPos = i / 4;
175 5796 : sBaseName += OUString(cNames[nPos].cName, cNames[nPos].nLength, cNames[nPos].eEncoding);
176 5796 : pNames[nIndex] += sBaseName;
177 5796 : pNames[nIndex++] += sColor;
178 5796 : if(cNames[nPos].bCanBeVisible)
179 : {
180 1386 : pNames[nIndex] += sBaseName;
181 1386 : pNames[nIndex++] += m_sIsVisible;
182 : }
183 5796 : }
184 126 : aNames.realloc(nIndex);
185 252 : return aNames;
186 : }
187 :
188 90 : ColorConfig_Impl::ColorConfig_Impl(bool bEditMode) :
189 : ConfigItem("Office.UI/ColorScheme"),
190 : m_bEditMode(bEditMode),
191 : m_sIsVisible("/IsVisible"),
192 90 : m_bAutoDetectSystemHC(true)
193 : {
194 90 : if(!m_bEditMode)
195 : {
196 : //try to register on the root node - if possible
197 90 : uno::Sequence < OUString > aNames(1);
198 90 : EnableNotification( aNames );
199 : }
200 90 : Load(OUString());
201 :
202 90 : ImplUpdateApplicationSettings();
203 :
204 : // #100822#
205 90 : ::Application::AddEventListener( LINK(this, ColorConfig_Impl, DataChangedEventListener) );
206 :
207 90 : }
208 :
209 129 : ColorConfig_Impl::~ColorConfig_Impl()
210 : {
211 : // #100822#
212 43 : ::Application::RemoveEventListener( LINK(this, ColorConfig_Impl, DataChangedEventListener) );
213 86 : }
214 :
215 114 : void ColorConfig_Impl::Load(const OUString& rScheme)
216 : {
217 114 : OUString sScheme(rScheme);
218 114 : if(sScheme.isEmpty())
219 : {
220 : //detect current scheme name
221 114 : uno::Sequence < OUString > aCurrent(1);
222 114 : aCurrent.getArray()[0] = "CurrentColorScheme";
223 228 : uno::Sequence< uno::Any > aCurrentVal = GetProperties( aCurrent );
224 228 : aCurrentVal.getConstArray()[0] >>= sScheme;
225 : }
226 114 : m_sLoadedScheme = sScheme;
227 :
228 228 : uno::Sequence < OUString > aColorNames = GetPropertyNames(sScheme);
229 228 : uno::Sequence< uno::Any > aColors = GetProperties( aColorNames );
230 114 : const uno::Any* pColors = aColors.getConstArray();
231 114 : const OUString* pColorNames = aColorNames.getConstArray();
232 114 : sal_Int32 nIndex = 0;
233 5244 : for(int i = 0; i < 2 * ColorConfigEntryCount && aColors.getLength() > nIndex; i+= 2)
234 : {
235 5244 : if(pColors[nIndex].hasValue())
236 0 : pColors[nIndex] >>= m_aConfigValues[i / 2].nColor;
237 : else
238 5244 : m_aConfigValues[i/2].nColor = COL_AUTO;
239 5244 : nIndex++;
240 5244 : if(nIndex >= aColors.getLength())
241 114 : break;
242 : //test for visibility property
243 5130 : if(pColorNames[nIndex].endsWith(m_sIsVisible))
244 1254 : m_aConfigValues[i / 2].bIsVisible = Any2Bool(pColors[nIndex++]);
245 : }
246 : // fdo#71511: check if we are running in a11y autodetect
247 : {
248 114 : utl::OConfigurationNode aNode = utl::OConfigurationTreeRoot::tryCreateWithComponentContext(comphelper::getProcessComponentContext(),OUString("org.openoffice.Office.Common/Accessibility") );
249 114 : if(aNode.isValid())
250 : {
251 114 : uno::Any aValue = aNode.getNodeValue(OUString("AutoDetectSystemHC"));
252 114 : aValue >>= m_bAutoDetectSystemHC;
253 114 : }
254 114 : }
255 114 : }
256 :
257 24 : void ColorConfig_Impl::Notify( const uno::Sequence<OUString>& )
258 : {
259 : //loading via notification always uses the default setting
260 24 : Load(OUString());
261 24 : NotifyListeners(0);
262 24 : }
263 :
264 12 : void ColorConfig_Impl::Commit()
265 : {
266 12 : uno::Sequence < OUString > aColorNames = GetPropertyNames(m_sLoadedScheme);
267 24 : uno::Sequence < beans::PropertyValue > aPropValues(aColorNames.getLength());
268 12 : beans::PropertyValue* pPropValues = aPropValues.getArray();
269 12 : const OUString* pColorNames = aColorNames.getConstArray();
270 12 : sal_Int32 nIndex = 0;
271 12 : const uno::Type& rBoolType = ::getBooleanCppuType();
272 552 : for(int i = 0; i < 2 * ColorConfigEntryCount && aColorNames.getLength() > nIndex; i+= 2)
273 : {
274 552 : pPropValues[nIndex].Name = pColorNames[nIndex];
275 : //save automatic colors as void value
276 552 : if(COL_AUTO != sal::static_int_cast<ColorData>(m_aConfigValues[i/2].nColor))
277 0 : pPropValues[nIndex].Value <<= m_aConfigValues[i/2].nColor;
278 :
279 552 : nIndex++;
280 552 : if(nIndex >= aColorNames.getLength())
281 12 : break;
282 : //test for visibility property
283 540 : if(pColorNames[nIndex].endsWith(m_sIsVisible))
284 : {
285 132 : pPropValues[nIndex].Name = pColorNames[nIndex];
286 132 : pPropValues[nIndex].Value.setValue(&m_aConfigValues[i/2].bIsVisible, rBoolType);
287 132 : nIndex++;
288 : }
289 : }
290 24 : OUString sNode("ColorSchemes");
291 12 : SetSetProperties(sNode, aPropValues);
292 :
293 24 : CommitCurrentSchemeName();
294 12 : }
295 :
296 12 : void ColorConfig_Impl::CommitCurrentSchemeName()
297 : {
298 : //save current scheme name
299 12 : uno::Sequence < OUString > aCurrent(1);
300 12 : aCurrent.getArray()[0] = "CurrentColorScheme";
301 24 : uno::Sequence< uno::Any > aCurrentVal(1);
302 12 : aCurrentVal.getArray()[0] <<= m_sLoadedScheme;
303 24 : PutProperties(aCurrent, aCurrentVal);
304 12 : }
305 :
306 12 : void ColorConfig_Impl::SetColorConfigValue(ColorConfigEntry eValue, const ColorConfigValue& rValue )
307 : {
308 12 : if(rValue != m_aConfigValues[eValue])
309 : {
310 12 : m_aConfigValues[eValue] = rValue;
311 12 : SetModified();
312 : }
313 12 : }
314 :
315 0 : uno::Sequence< OUString> ColorConfig_Impl::GetSchemeNames()
316 : {
317 0 : return GetNodeNames("ColorSchemes");
318 : }
319 :
320 0 : bool ColorConfig_Impl::AddScheme(const OUString& rScheme)
321 : {
322 0 : if(ConfigItem::AddNode("ColorSchemes", rScheme))
323 : {
324 0 : m_sLoadedScheme = rScheme;
325 0 : Commit();
326 0 : return true;
327 : }
328 0 : return false;
329 : }
330 :
331 0 : bool ColorConfig_Impl::RemoveScheme(const OUString& rScheme)
332 : {
333 0 : uno::Sequence< OUString > aElements(1);
334 0 : aElements.getArray()[0] = rScheme;
335 0 : return ClearNodeElements("ColorSchemes", aElements);
336 : }
337 :
338 43 : void ColorConfig_Impl::SettingsChanged()
339 : {
340 43 : SolarMutexGuard aVclGuard;
341 :
342 43 : ImplUpdateApplicationSettings();
343 :
344 43 : NotifyListeners(0);
345 43 : }
346 :
347 3106144 : IMPL_LINK( ColorConfig_Impl, DataChangedEventListener, VclWindowEvent*, pEvent )
348 : {
349 1553072 : if ( pEvent->GetId() == VCLEVENT_APPLICATION_DATACHANGED )
350 : {
351 47 : DataChangedEvent* pData = (DataChangedEvent*)(pEvent->GetData());
352 94 : if ( (pData->GetType() == DATACHANGED_SETTINGS) &&
353 47 : (pData->GetFlags() & SETTINGS_STYLE) )
354 : {
355 43 : SettingsChanged();
356 43 : return 1L;
357 : } else
358 4 : return 0L;
359 : } else
360 1553025 : return 0L;
361 : }
362 :
363 :
364 :
365 : /** updates the font color in the vcl window settings */
366 133 : void ColorConfig_Impl::ImplUpdateApplicationSettings()
367 : {
368 133 : Application* pApp = GetpApp();
369 133 : if( pApp )
370 : {
371 133 : AllSettings aSettings = pApp->GetSettings();
372 266 : StyleSettings aStyleSettings( aSettings.GetStyleSettings() );
373 :
374 133 : ColorConfigValue aRet = GetColorConfigValue(svtools::FONTCOLOR);
375 133 : if(COL_AUTO == sal::static_int_cast<ColorData>(aRet.nColor))
376 133 : aRet.nColor = ColorConfig::GetDefaultColor(svtools::FONTCOLOR).GetColor();
377 :
378 133 : Color aFontColor(aRet.nColor);
379 :
380 133 : if( aStyleSettings.GetFontColor() != aFontColor )
381 : {
382 0 : aStyleSettings.SetFontColor( aFontColor );
383 :
384 0 : aSettings.SetStyleSettings( aStyleSettings );
385 0 : pApp->SetSettings( aSettings );
386 133 : }
387 : }
388 133 : }
389 :
390 :
391 :
392 13813 : ColorConfig::ColorConfig()
393 : {
394 13813 : ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
395 13813 : if ( !m_pImpl )
396 : {
397 78 : m_pImpl = new ColorConfig_Impl;
398 78 : svtools::ItemHolder2::holdConfigItem(E_COLORCFG);
399 : }
400 13813 : ++nColorRefCount_Impl;
401 13813 : m_pImpl->AddListener(this);
402 13813 : }
403 :
404 27336 : ColorConfig::~ColorConfig()
405 : {
406 13425 : ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
407 13425 : m_pImpl->RemoveListener(this);
408 13425 : if(!--nColorRefCount_Impl)
409 : {
410 31 : delete m_pImpl;
411 31 : m_pImpl = 0;
412 13425 : }
413 13911 : }
414 :
415 89172 : Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry)
416 : {
417 : static const sal_Int32 aAutoColors[] =
418 : {
419 : COL_WHITE, // DOCCOLOR
420 : 0xc0c0c0, // DOCBOUNDARIES
421 : 0x808080, // APPBACKGROUND
422 : 0xc0c0c0, // OBJECTBOUNDARIES
423 : 0xc0c0c0, // TABLEBOUNDARIES
424 : COL_BLACK, // FONTCOLOR
425 : 0xcc, // LINKS
426 : 0x80, // LINKSVISITED
427 : 0xff0000, // SPELL
428 : COL_LIGHTMAGENTA,// SMARTTAGS
429 : COL_GRAY, // SHADOWCOLOR
430 : 0xc0c0c0, // WRITERTEXTGRID
431 : 0xc0c0c0, // WRITERFIELDSHADIN
432 : 0xc0c0c0, // WRITERIDXSHADINGS
433 : 0, // WRITERDIRECTCURSOR
434 : COL_GREEN, //WRITERSCRIPTINDICATOR
435 : 0xc0c0c0, //WRITERSECTIONBOUNDARIES
436 : 0x0369a3, //WRITERHEADERFOOTERMARK,
437 : COL_BLUE, //WRITERPAGEBREAKS,
438 : COL_LIGHTBLUE, // HTMLSGML
439 : COL_LIGHTGREEN, // HTMLCOMMENT
440 : COL_LIGHTRED, // HTMLKEYWORD
441 : COL_GRAY, // HTMLUNKNOWN
442 : COL_LIGHTGRAY, // CALCGRID
443 : COL_BLUE, //CALCPAGEBREAK
444 : 0x2300dc, //CALCPAGEBREAKMANUAL
445 : COL_GRAY, //CALCPAGEBREAKAUTOMATIC
446 : COL_LIGHTBLUE, // CALCDETECTIVE
447 : COL_LIGHTRED, // CALCDETECTIVEERROR
448 : 0xef0fff, // CALCREFERENCE
449 : 0xffffc0, // CALCNOTESBACKGROUND
450 : 0xc0c0c0, // DRAWGRID
451 : COL_GREEN, // BASICIDENTIFIER,
452 : COL_GRAY,// BASICCOMMENT ,
453 : COL_LIGHTRED,// BASICNUMBER ,
454 : COL_LIGHTRED,// BASICSTRING ,
455 : COL_BLUE, // BASICOPERATOR ,
456 : COL_BLUE, // BASICKEYWORD ,
457 : COL_RED, //BASICERROR
458 : 0x009900, // SQLIDENTIFIER
459 : 0x000000, // SQLNUMBER
460 : 0xCE7B00, // SQLSTRING
461 : 0x000000, // SQLOPERATOR
462 : 0x0000E6, // SQLKEYWORD
463 : 0x259D9D, // SQLPARAMTER
464 : 0x969696,// SQLCOMMENT
465 : };
466 89172 : Color aRet;
467 89172 : switch(eEntry)
468 : {
469 : case APPBACKGROUND :
470 2760 : aRet = Application::GetSettings().GetStyleSettings().GetWorkspaceColor();
471 2760 : break;
472 :
473 : case LINKS :
474 107 : aRet = Application::GetSettings().GetStyleSettings().GetLinkColor();
475 107 : break;
476 :
477 : case LINKSVISITED :
478 77 : aRet = Application::GetSettings().GetStyleSettings().GetVisitedLinkColor();
479 77 : break;
480 :
481 : default:
482 86228 : aRet = aAutoColors[eEntry];
483 : }
484 : // fdo#71511: if in autodetected a11y HC mode, do pull background color from theme
485 89172 : if(m_pImpl && m_pImpl->GetAutoDetectSystemHC())
486 : {
487 0 : switch(eEntry)
488 : {
489 : case DOCCOLOR :
490 0 : aRet = Application::GetSettings().GetStyleSettings().GetWindowColor();
491 0 : break;
492 : case FONTCOLOR :
493 0 : aRet = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
494 0 : break;
495 : default:
496 0 : break;
497 : }
498 : }
499 89172 : return aRet;
500 : }
501 :
502 90446 : ColorConfigValue ColorConfig::GetColorValue(ColorConfigEntry eEntry, bool bSmart) const
503 : {
504 90446 : ColorConfigValue aRet = m_pImpl->GetColorConfigValue(eEntry);
505 90446 : if(bSmart)
506 : {
507 88867 : if(COL_AUTO == sal::static_int_cast<ColorData>(aRet.nColor))
508 88867 : aRet.nColor = ColorConfig::GetDefaultColor(eEntry).GetColor();
509 : }
510 :
511 90446 : return aRet;
512 : }
513 :
514 0 : void ColorConfig::Reload()
515 : {
516 0 : m_pImpl->Load(OUString());
517 0 : }
518 :
519 12 : EditableColorConfig::EditableColorConfig() :
520 12 : m_pImpl(new ColorConfig_Impl),
521 24 : m_bModified(false)
522 : {
523 12 : m_pImpl->BlockBroadcasts(true);
524 12 : }
525 :
526 12 : EditableColorConfig::~EditableColorConfig()
527 : {
528 12 : m_pImpl->BlockBroadcasts(false);
529 12 : if(m_bModified)
530 12 : m_pImpl->SetModified();
531 12 : if(m_pImpl->IsModified())
532 12 : m_pImpl->Commit();
533 12 : delete m_pImpl;
534 12 : }
535 :
536 0 : uno::Sequence< OUString > EditableColorConfig::GetSchemeNames() const
537 : {
538 0 : return m_pImpl->GetSchemeNames();
539 : }
540 :
541 0 : void EditableColorConfig::DeleteScheme(const OUString& rScheme )
542 : {
543 0 : m_pImpl->RemoveScheme(rScheme);
544 0 : }
545 :
546 0 : void EditableColorConfig::AddScheme(const OUString& rScheme )
547 : {
548 0 : m_pImpl->AddScheme(rScheme);
549 0 : }
550 :
551 0 : bool EditableColorConfig::LoadScheme(const OUString& rScheme )
552 : {
553 0 : if(m_bModified)
554 0 : m_pImpl->SetModified();
555 0 : if(m_pImpl->IsModified())
556 0 : m_pImpl->Commit();
557 0 : m_bModified = false;
558 0 : m_pImpl->Load(rScheme);
559 : //the name of the loaded scheme has to be committed separately
560 0 : m_pImpl->CommitCurrentSchemeName();
561 0 : return true;
562 : }
563 :
564 0 : const OUString& EditableColorConfig::GetCurrentSchemeName()const
565 : {
566 0 : return m_pImpl->GetLoadedScheme();
567 : }
568 :
569 : // Changes the name of the current scheme but doesn't load it!
570 0 : void EditableColorConfig::SetCurrentSchemeName(const OUString& rScheme)
571 : {
572 0 : m_pImpl->SetCurrentSchemeName(rScheme);
573 0 : m_pImpl->CommitCurrentSchemeName();
574 0 : }
575 :
576 12 : const ColorConfigValue& EditableColorConfig::GetColorValue(
577 : ColorConfigEntry eEntry)const
578 : {
579 12 : return m_pImpl->GetColorConfigValue(eEntry);
580 : }
581 :
582 12 : void EditableColorConfig::SetColorValue(
583 : ColorConfigEntry eEntry, const ColorConfigValue& rValue)
584 : {
585 12 : m_pImpl->SetColorConfigValue(eEntry, rValue);
586 12 : m_pImpl->ClearModified();
587 12 : m_bModified = true;
588 12 : }
589 :
590 0 : void EditableColorConfig::SetModified()
591 : {
592 0 : m_bModified = true;
593 0 : }
594 :
595 0 : void EditableColorConfig::Commit()
596 : {
597 0 : if(m_bModified)
598 0 : m_pImpl->SetModified();
599 0 : if(m_pImpl->IsModified())
600 0 : m_pImpl->Commit();
601 0 : m_bModified = false;
602 0 : }
603 :
604 0 : void EditableColorConfig::DisableBroadcast()
605 : {
606 0 : m_pImpl->BlockBroadcasts(true);
607 0 : }
608 :
609 0 : void EditableColorConfig::EnableBroadcast()
610 : {
611 0 : m_pImpl->BlockBroadcasts(false);
612 0 : }
613 :
614 :
615 : }//namespace svtools
616 :
617 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|