Bump version to 5.0-14
[LibreOffice.git] / svtools / source / config / extcolorcfg.cxx
blob39eeb0419eb054017438e1db960106ff35d5c24b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <map>
24 #include <svtools/extcolorcfg.hxx>
25 #include <com/sun/star/uno/Any.hxx>
26 #include <com/sun/star/uno/Sequence.hxx>
27 #include <com/sun/star/lang/Locale.hpp>
28 #include <com/sun/star/beans/PropertyValue.hpp>
29 #include <tools/color.hxx>
30 #include <unotools/configitem.hxx>
31 #include <unotools/configpaths.hxx>
32 #include <com/sun/star/uno/Sequence.h>
33 #include <svl/poolitem.hxx>
34 #include <svl/smplhint.hxx>
35 #include <osl/mutex.hxx>
37 #include <vcl/svapp.hxx>
38 #include <vcl/settings.hxx>
39 #include <vcl/event.hxx>
40 #include <rtl/instance.hxx>
41 #include <rtl/strbuf.hxx>
44 using namespace utl;
45 using namespace com::sun::star;
48 namespace svtools
51 sal_Int32 nExtendedColorRefCount_Impl = 0;
52 namespace
54 struct ColorMutex_Impl
55 : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {};
58 ExtendedColorConfig_Impl* ExtendedColorConfig::m_pImpl = NULL;
60 class ExtendedColorConfig_Impl : public utl::ConfigItem, public SfxBroadcaster
62 typedef std::map<OUString, OUString> TDisplayNames;
63 typedef std::map<OUString, ExtendedColorConfigValue> TConfigValues;
64 typedef ::std::vector<TConfigValues::iterator> TMapPos;
65 typedef ::std::pair< TConfigValues, TMapPos > TComponentMapping;
66 typedef std::map<OUString, TComponentMapping> TComponents;
67 TComponents m_aConfigValues;
68 TDisplayNames m_aComponentDisplayNames;
69 ::std::vector<TComponents::iterator> m_aConfigValuesPos;
71 bool m_bEditMode;
72 OUString m_sLoadedScheme;
73 bool m_bIsBroadcastEnabled;
74 static bool m_bLockBroadcast;
75 static bool m_bBroadcastWhenUnlocked;
77 uno::Sequence< OUString> GetPropertyNames(const OUString& rScheme);
78 void FillComponentColors(uno::Sequence < OUString >& _rComponents,const TDisplayNames& _rDisplayNames);
80 virtual void ImplCommit() SAL_OVERRIDE;
82 public:
83 ExtendedColorConfig_Impl(bool bEditMode = false);
84 virtual ~ExtendedColorConfig_Impl();
86 void Load(const OUString& rScheme);
87 void CommitCurrentSchemeName();
88 //changes the name of the current scheme but doesn't load it!
89 void SetCurrentSchemeName(const OUString& rSchemeName) {m_sLoadedScheme = rSchemeName;}
90 bool ExistsScheme(const OUString& _sSchemeName);
91 virtual void Notify( const uno::Sequence<OUString>& aPropertyNames) SAL_OVERRIDE;
93 sal_Int32 GetComponentCount() const;
94 OUString GetComponentName(sal_uInt32 _nPos) const;
95 OUString GetComponentDisplayName(const OUString& _sComponentName) const;
96 sal_Int32 GetComponentColorCount(const OUString& _sName) const;
97 ExtendedColorConfigValue GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const;
99 ExtendedColorConfigValue GetColorConfigValue(const OUString& _sComponentName,const OUString& _sName)
101 TComponents::iterator aFind = m_aConfigValues.find(_sComponentName);
102 if ( aFind != m_aConfigValues.end() )
104 TConfigValues::iterator aFind2 = aFind->second.first.find(_sName);
105 if ( aFind2 != aFind->second.first.end() )
106 return aFind2->second;
108 #if OSL_DEBUG_LEVEL > 0
109 OStringBuffer aMessage( "Could find the required config:\n" );
110 aMessage.append( "component: " );
111 aMessage.append( OUStringToOString( _sComponentName, RTL_TEXTENCODING_UTF8 ) );
112 aMessage.append( "\nname: " );
113 aMessage.append( OUStringToOString( _sName, RTL_TEXTENCODING_UTF8 ) );
114 OSL_FAIL( aMessage.makeStringAndClear().getStr() );
115 #endif
116 return ExtendedColorConfigValue();
118 void SetColorConfigValue(const OUString& _sName,
119 const ExtendedColorConfigValue& rValue );
121 bool AddScheme(const OUString& rNode);
122 bool RemoveScheme(const OUString& rNode);
123 void SetModified(){ConfigItem::SetModified();}
124 void ClearModified(){ConfigItem::ClearModified();}
125 void SettingsChanged();
127 static void DisableBroadcast();
128 static void EnableBroadcast();
129 static bool IsEnableBroadcast();
131 static void LockBroadcast();
132 static void UnlockBroadcast();
134 // #100822#
135 DECL_LINK( DataChangedEventListener, VclWindowEvent* );
138 uno::Sequence< OUString> ExtendedColorConfig_Impl::GetPropertyNames(const OUString& rScheme)
140 uno::Sequence< OUString> aNames(GetNodeNames(rScheme));
141 OUString* pIter = aNames.getArray();
142 OUString* pEnd = pIter + aNames.getLength();
143 OUString sSep("/");
144 for(;pIter != pEnd;++pIter)
146 *pIter = rScheme + sSep + *pIter;
148 return aNames;
151 sal_Int32 ExtendedColorConfig_Impl::GetComponentCount() const
153 return m_aConfigValues.size();
156 sal_Int32 ExtendedColorConfig_Impl::GetComponentColorCount(const OUString& _sName) const
158 sal_Int32 nSize = 0;
159 TComponents::const_iterator aFind = m_aConfigValues.find(_sName);
160 if ( aFind != m_aConfigValues.end() )
162 nSize = aFind->second.first.size();
164 return nSize;
167 ExtendedColorConfigValue ExtendedColorConfig_Impl::GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const
169 TComponents::const_iterator aFind = m_aConfigValues.find(_sName);
170 if ( aFind != m_aConfigValues.end() )
172 if ( _nPos < aFind->second.second.size() )
174 return aFind->second.second[_nPos]->second;
177 return ExtendedColorConfigValue();
180 OUString ExtendedColorConfig_Impl::GetComponentDisplayName(const OUString& _sComponentName) const
182 OUString sRet;
183 TDisplayNames::const_iterator aFind = m_aComponentDisplayNames.find(_sComponentName);
184 if ( aFind != m_aComponentDisplayNames.end() )
185 sRet = aFind->second;
186 return sRet;
189 OUString ExtendedColorConfig_Impl::GetComponentName(sal_uInt32 _nPos) const
191 OUString sRet;
192 if ( _nPos < m_aConfigValuesPos.size() )
193 sRet = m_aConfigValuesPos[_nPos]->first;
194 return sRet;
197 bool ExtendedColorConfig_Impl::m_bLockBroadcast = false;
198 bool ExtendedColorConfig_Impl::m_bBroadcastWhenUnlocked = false;
199 ExtendedColorConfig_Impl::ExtendedColorConfig_Impl(bool bEditMode) :
200 ConfigItem(OUString("Office.ExtendedColorScheme")),
201 m_bEditMode(bEditMode),
202 m_bIsBroadcastEnabled(true)
204 if(!m_bEditMode)
206 //try to register on the root node - if possible
207 uno::Sequence < OUString > aNames(1);
208 EnableNotification( aNames );
210 Load(OUString());
212 // #100822#
213 ::Application::AddEventListener( LINK(this, ExtendedColorConfig_Impl, DataChangedEventListener) );
217 ExtendedColorConfig_Impl::~ExtendedColorConfig_Impl()
219 // #100822#
220 ::Application::RemoveEventListener( LINK(this, ExtendedColorConfig_Impl, DataChangedEventListener) );
223 void ExtendedColorConfig_Impl::DisableBroadcast()
225 if ( ExtendedColorConfig::m_pImpl )
226 ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled = false;
229 void ExtendedColorConfig_Impl::EnableBroadcast()
231 if ( ExtendedColorConfig::m_pImpl )
232 ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled = true;
235 bool ExtendedColorConfig_Impl::IsEnableBroadcast()
237 return ExtendedColorConfig::m_pImpl && ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled;
240 void lcl_addString(uno::Sequence < OUString >& _rSeq,const OUString& _sAdd)
242 OUString* pIter = _rSeq.getArray();
243 OUString* pEnd = pIter + _rSeq.getLength();
244 for(;pIter != pEnd;++pIter)
245 *pIter += _sAdd;
248 void ExtendedColorConfig_Impl::Load(const OUString& rScheme)
250 m_aComponentDisplayNames.clear();
251 m_aConfigValuesPos.clear();
252 m_aConfigValues.clear();
254 // fill display names
255 TDisplayNames aDisplayNameMap;
256 OUString sEntryNames("EntryNames");
257 uno::Sequence < OUString > aComponentNames = GetPropertyNames(sEntryNames);
258 OUString sDisplayName("/DisplayName");
259 OUString* pIter = aComponentNames.getArray();
260 OUString* pEnd = pIter + aComponentNames.getLength();
261 for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
263 uno::Sequence < OUString > aComponentDisplayNames(1);
264 aComponentDisplayNames[0] = *pIter;
265 aComponentDisplayNames[0] += sDisplayName;
266 uno::Sequence< uno::Any > aComponentDisplayNamesValue = GetProperties( aComponentDisplayNames );
267 OUString sComponentDisplayName;
268 if ( aComponentDisplayNamesValue.getLength() && (aComponentDisplayNamesValue[0] >>= sComponentDisplayName) )
270 sal_Int32 nIndex = 0;
271 m_aComponentDisplayNames.insert(TDisplayNames::value_type(pIter->getToken(1,'/',nIndex),sComponentDisplayName));
274 *pIter += "/Entries";
275 uno::Sequence < OUString > aDisplayNames = GetPropertyNames(*pIter);
276 lcl_addString(aDisplayNames,sDisplayName);
278 uno::Sequence< uno::Any > aDisplayNamesValue = GetProperties( aDisplayNames );
280 const OUString* pDispIter = aDisplayNames.getConstArray();
281 const OUString* pDispEnd = pDispIter + aDisplayNames.getLength();
282 for(sal_Int32 j = 0;pDispIter != pDispEnd;++pDispIter,++j)
284 sal_Int32 nIndex = 0;
285 pDispIter->getToken(0,'/',nIndex);
286 OUString sName = pDispIter->copy(nIndex);
287 sName = sName.copy(0,sName.lastIndexOf(sDisplayName));
288 OUString sCurrentDisplayName;
289 aDisplayNamesValue[j] >>= sCurrentDisplayName;
290 aDisplayNameMap.insert(TDisplayNames::value_type(sName,sCurrentDisplayName));
294 // load color settings
295 OUString sScheme(rScheme);
297 if(sScheme.isEmpty())
299 //detect current scheme name
300 uno::Sequence < OUString > aCurrent(1);
301 aCurrent.getArray()[0] = "ExtendedColorScheme/CurrentColorScheme";
302 uno::Sequence< uno::Any > aCurrentVal = GetProperties( aCurrent );
303 aCurrentVal.getConstArray()[0] >>= sScheme;
304 } // if(!sScheme.getLength())
306 m_sLoadedScheme = sScheme;
307 OUString sBase("ExtendedColorScheme/ColorSchemes/");
308 sBase += sScheme;
310 bool bFound = ExistsScheme(sScheme);
311 if ( bFound )
313 aComponentNames = GetPropertyNames(sBase);
314 FillComponentColors(aComponentNames,aDisplayNameMap);
317 if ( m_sLoadedScheme.isEmpty() )
318 m_sLoadedScheme = "default";
320 if ( sScheme != "default" )
322 OUString sDefault("default");
323 if ( ExistsScheme(sDefault) )
325 OUString sBaseDefault("ExtendedColorScheme/ColorSchemes/default");
326 aComponentNames = GetPropertyNames(sBaseDefault);
327 FillComponentColors(aComponentNames,aDisplayNameMap);
330 if ( !bFound && !sScheme.isEmpty() )
332 AddScheme(sScheme);
333 CommitCurrentSchemeName();
337 void ExtendedColorConfig_Impl::FillComponentColors(uno::Sequence < OUString >& _rComponents,const TDisplayNames& _rDisplayNames)
339 const OUString sColorEntries("/Entries");
340 OUString* pIter = _rComponents.getArray();
341 OUString* pEnd = pIter + _rComponents.getLength();
342 for(;pIter != pEnd;++pIter)
344 OUString sComponentName = pIter->copy(pIter->lastIndexOf('/')+1);
345 if ( m_aConfigValues.find(sComponentName) == m_aConfigValues.end() )
347 OUString sEntry = *pIter;
348 sEntry += sColorEntries;
350 uno::Sequence < OUString > aColorNames = GetPropertyNames(sEntry);
351 uno::Sequence < OUString > aDefaultColorNames = aColorNames;
353 const OUString sColor("/Color");
354 const OUString sDefaultColor("/DefaultColor");
355 lcl_addString(aColorNames,sColor);
356 lcl_addString(aDefaultColorNames,sDefaultColor);
357 uno::Sequence< uno::Any > aColors = GetProperties( aColorNames );
358 const uno::Any* pColors = aColors.getConstArray();
360 uno::Sequence< uno::Any > aDefaultColors = GetProperties( aDefaultColorNames );
361 bool bDefaultColorFound = aDefaultColors.getLength() != 0;
362 const uno::Any* pDefaultColors = aDefaultColors.getConstArray();
364 OUString* pColorIter = aColorNames.getArray();
365 OUString* pColorEnd = pColorIter + aColorNames.getLength();
367 m_aConfigValuesPos.push_back(m_aConfigValues.insert(TComponents::value_type(sComponentName,TComponentMapping(TConfigValues(),TMapPos()))).first);
368 TConfigValues& aConfigValues = (*m_aConfigValuesPos.rbegin())->second.first;
369 TMapPos& aConfigValuesPos = (*m_aConfigValuesPos.rbegin())->second.second;
370 for(int i = 0; pColorIter != pColorEnd; ++pColorIter ,++i)
372 if ( aConfigValues.find(*pColorIter) == aConfigValues.end() )
374 sal_Int32 nIndex = 0;
375 pColorIter->getToken(2,'/',nIndex);
376 OUString sName(pColorIter->copy(nIndex)),sDisplayName;
377 OUString sTemp = sName.copy(0,sName.lastIndexOf(sColor));
379 TDisplayNames::const_iterator aFind = _rDisplayNames.find(sTemp);
380 nIndex = 0;
381 sName = sName.getToken(2,'/',nIndex);
382 OSL_ENSURE(aFind != _rDisplayNames.end(),"DisplayName is not in EntryNames config list!");
383 if ( aFind != _rDisplayNames.end() )
384 sDisplayName = aFind->second;
386 OSL_ENSURE(pColors[i].hasValue(),"Color config entry has NIL as color value set!");
387 OSL_ENSURE(pDefaultColors[i].hasValue(),"Color config entry has NIL as color value set!");
388 sal_Int32 nColor = 0,nDefaultColor = 0;
389 pColors[i] >>= nColor;
390 if ( bDefaultColorFound )
391 pDefaultColors[i] >>= nDefaultColor;
392 else
393 nDefaultColor = nColor;
394 ExtendedColorConfigValue aValue(sName,sDisplayName,nColor,nDefaultColor);
395 aConfigValuesPos.push_back(aConfigValues.insert(TConfigValues::value_type(sName,aValue)).first);
397 } // for(int i = 0; pColorIter != pColorEnd; ++pColorIter ,++i)
402 void ExtendedColorConfig_Impl::Notify( const uno::Sequence<OUString>& /*rPropertyNames*/)
404 //loading via notification always uses the default setting
405 Load(OUString());
407 SolarMutexGuard aVclGuard;
409 if(m_bLockBroadcast)
411 m_bBroadcastWhenUnlocked = true;
413 else
414 Broadcast(SfxSimpleHint(SFX_HINT_COLORS_CHANGED));
417 void ExtendedColorConfig_Impl::ImplCommit()
419 if ( m_sLoadedScheme.isEmpty() )
420 return;
421 const OUString sColorEntries("Entries");
422 const OUString sColor("/Color");
423 OUString sBase("ExtendedColorScheme/ColorSchemes/");
424 const OUString s_sSep("/");
425 sBase += m_sLoadedScheme;
427 TComponents::iterator aIter = m_aConfigValues.begin();
428 TComponents::iterator aEnd = m_aConfigValues.end();
429 for( ;aIter != aEnd;++aIter )
431 OUString sEntry = aIter->first;
432 sEntry += sColorEntries;
434 if ( ConfigItem::AddNode(sBase, aIter->first) )
436 OUString sNode = sBase;
437 sNode += s_sSep;
438 sNode += aIter->first;
439 //ConfigItem::AddNode(sNode, sColorEntries);
440 sNode += s_sSep;
441 sNode += sColorEntries;
443 uno::Sequence < beans::PropertyValue > aPropValues(aIter->second.first.size());
444 beans::PropertyValue* pPropValues = aPropValues.getArray();
445 TConfigValues::iterator aConIter = aIter->second.first.begin();
446 TConfigValues::iterator aConEnd = aIter->second.first.end();
447 for (; aConIter != aConEnd; ++aConIter,++pPropValues)
449 pPropValues->Name = sNode + s_sSep + aConIter->first;
450 ConfigItem::AddNode(sNode, aConIter->first);
451 pPropValues->Name += sColor;
452 pPropValues->Value <<= aConIter->second.getColor();
453 // the default color will never be changed
455 OUString s("ExtendedColorScheme/ColorSchemes");
456 SetSetProperties(s, aPropValues);
460 CommitCurrentSchemeName();
463 void ExtendedColorConfig_Impl::CommitCurrentSchemeName()
465 //save current scheme name
466 uno::Sequence < OUString > aCurrent(1);
467 aCurrent.getArray()[0] = "ExtendedColorScheme/CurrentColorScheme";
468 uno::Sequence< uno::Any > aCurrentVal(1);
469 aCurrentVal.getArray()[0] <<= m_sLoadedScheme;
470 PutProperties(aCurrent, aCurrentVal);
473 bool ExtendedColorConfig_Impl::ExistsScheme(const OUString& _sSchemeName)
475 OUString sBase("ExtendedColorScheme/ColorSchemes");
477 uno::Sequence < OUString > aComponentNames = GetPropertyNames(sBase);
478 sBase += "/" + _sSchemeName;
479 const OUString* pCompIter = aComponentNames.getConstArray();
480 const OUString* pCompEnd = pCompIter + aComponentNames.getLength();
481 for(;pCompIter != pCompEnd && *pCompIter != sBase;++pCompIter)
483 return pCompIter != pCompEnd;
486 void ExtendedColorConfig_Impl::SetColorConfigValue(const OUString& _sName, const ExtendedColorConfigValue& rValue )
488 TComponents::iterator aFind = m_aConfigValues.find(_sName);
489 if ( aFind != m_aConfigValues.end() )
491 TConfigValues::iterator aFind2 = aFind->second.first.find(rValue.getName());
492 if ( aFind2 != aFind->second.first.end() )
493 aFind2->second = rValue;
494 SetModified();
498 bool ExtendedColorConfig_Impl::AddScheme(const OUString& rScheme)
500 if(ConfigItem::AddNode(OUString("ExtendedColorScheme/ColorSchemes"), rScheme))
502 m_sLoadedScheme = rScheme;
503 Commit();
504 return true;
506 return false;
509 bool ExtendedColorConfig_Impl::RemoveScheme(const OUString& rScheme)
511 uno::Sequence< OUString > aElements(1);
512 aElements.getArray()[0] = rScheme;
513 return ClearNodeElements(OUString("ExtendedColorScheme/ColorSchemes"), aElements);
516 void ExtendedColorConfig_Impl::SettingsChanged()
518 SolarMutexGuard aVclGuard;
520 Broadcast( SfxSimpleHint( SFX_HINT_COLORS_CHANGED ) );
523 void ExtendedColorConfig_Impl::LockBroadcast()
525 m_bLockBroadcast = true;
528 void ExtendedColorConfig_Impl::UnlockBroadcast()
530 if ( m_bBroadcastWhenUnlocked )
532 m_bBroadcastWhenUnlocked = ExtendedColorConfig::m_pImpl != NULL;
533 if ( m_bBroadcastWhenUnlocked )
535 if ( ExtendedColorConfig_Impl::IsEnableBroadcast() )
537 m_bBroadcastWhenUnlocked = false;
538 ExtendedColorConfig::m_pImpl->Broadcast(SfxSimpleHint(SFX_HINT_COLORS_CHANGED));
542 m_bLockBroadcast = false;
545 IMPL_LINK( ExtendedColorConfig_Impl, DataChangedEventListener, VclWindowEvent*, pEvent )
547 if ( pEvent->GetId() == VCLEVENT_APPLICATION_DATACHANGED )
549 DataChangedEvent* pData = static_cast<DataChangedEvent*>(pEvent->GetData());
550 if ( (pData->GetType() == DataChangedEventType::SETTINGS) &&
551 (pData->GetFlags() & AllSettingsFlags::STYLE) )
553 SettingsChanged();
554 return 1L;
555 } else
556 return 0L;
557 } else
558 return 0L;
565 ExtendedColorConfig::ExtendedColorConfig()
567 ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
568 if ( !m_pImpl )
569 m_pImpl = new ExtendedColorConfig_Impl;
570 ++nExtendedColorRefCount_Impl;
571 StartListening( *m_pImpl);
574 ExtendedColorConfig::~ExtendedColorConfig()
576 ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
577 EndListening( *m_pImpl);
578 if(!--nExtendedColorRefCount_Impl)
580 delete m_pImpl;
581 m_pImpl = 0;
585 ExtendedColorConfigValue ExtendedColorConfig::GetColorValue(const OUString& _sComponentName,const OUString& _sName)const
587 return m_pImpl->GetColorConfigValue(_sComponentName,_sName);
590 sal_Int32 ExtendedColorConfig::GetComponentCount() const
592 return m_pImpl->GetComponentCount();
595 sal_Int32 ExtendedColorConfig::GetComponentColorCount(const OUString& _sName) const
597 return m_pImpl->GetComponentColorCount(_sName);
600 ExtendedColorConfigValue ExtendedColorConfig::GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const
602 return m_pImpl->GetComponentColorConfigValue(_sName,_nPos);
605 OUString ExtendedColorConfig::GetComponentName(sal_uInt32 _nPos) const
607 return m_pImpl->GetComponentName(_nPos);
610 OUString ExtendedColorConfig::GetComponentDisplayName(const OUString& _sComponentName) const
612 return m_pImpl->GetComponentDisplayName(_sComponentName);
615 void ExtendedColorConfig::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
617 SolarMutexGuard aVclGuard;
619 Broadcast( rHint );
622 EditableExtendedColorConfig::EditableExtendedColorConfig() :
623 m_pImpl(new ExtendedColorConfig_Impl),
624 m_bModified(false)
626 ExtendedColorConfig_Impl::LockBroadcast();
629 EditableExtendedColorConfig::~EditableExtendedColorConfig()
631 ExtendedColorConfig_Impl::UnlockBroadcast();
632 if(m_bModified)
633 m_pImpl->SetModified();
634 if(m_pImpl->IsModified())
635 m_pImpl->Commit();
636 delete m_pImpl;
639 void EditableExtendedColorConfig::DeleteScheme(const OUString& rScheme )
641 m_pImpl->RemoveScheme(rScheme);
644 void EditableExtendedColorConfig::AddScheme(const OUString& rScheme )
646 m_pImpl->AddScheme(rScheme);
649 bool EditableExtendedColorConfig::LoadScheme(const OUString& rScheme )
651 if(m_bModified)
652 m_pImpl->SetModified();
653 if(m_pImpl->IsModified())
654 m_pImpl->Commit();
655 m_bModified = false;
656 m_pImpl->Load(rScheme);
657 //the name of the loaded scheme has to be committed separately
658 m_pImpl->CommitCurrentSchemeName();
659 return true;
662 // Changes the name of the current scheme but doesn't load it!
663 void EditableExtendedColorConfig::SetCurrentSchemeName(const OUString& rScheme)
665 m_pImpl->SetCurrentSchemeName(rScheme);
666 m_pImpl->CommitCurrentSchemeName();
669 void EditableExtendedColorConfig::SetColorValue(
670 const OUString& _sName, const ExtendedColorConfigValue& rValue)
672 m_pImpl->SetColorConfigValue(_sName, rValue);
673 m_pImpl->ClearModified();
674 m_bModified = true;
677 void EditableExtendedColorConfig::SetModified()
679 m_bModified = true;
682 void EditableExtendedColorConfig::Commit()
684 if(m_bModified)
685 m_pImpl->SetModified();
686 if(m_pImpl->IsModified())
687 m_pImpl->Commit();
688 m_bModified = false;
691 void EditableExtendedColorConfig::DisableBroadcast()
693 ExtendedColorConfig_Impl::DisableBroadcast();
696 void EditableExtendedColorConfig::EnableBroadcast()
698 ExtendedColorConfig_Impl::EnableBroadcast();
701 sal_Int32 EditableExtendedColorConfig::GetComponentCount() const
703 return m_pImpl->GetComponentCount();
706 sal_Int32 EditableExtendedColorConfig::GetComponentColorCount(const OUString& _sName) const
708 return m_pImpl->GetComponentColorCount(_sName);
711 ExtendedColorConfigValue EditableExtendedColorConfig::GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const
713 return m_pImpl->GetComponentColorConfigValue(_sName,_nPos);
716 OUString EditableExtendedColorConfig::GetComponentName(sal_uInt32 _nPos) const
718 return m_pImpl->GetComponentName(_nPos);
720 }//namespace svtools
722 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */