fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svtools / source / config / extcolorcfg.cxx
blobeee51dd35c2696174677a62d3b2716710646a9c2
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 <svtools/extcolorcfg.hxx>
21 #include <com/sun/star/uno/Any.hxx>
22 #include <com/sun/star/uno/Sequence.hxx>
23 #include <com/sun/star/lang/Locale.hpp>
24 #include <com/sun/star/beans/PropertyValue.hpp>
25 #include <tools/color.hxx>
26 #include <unotools/configitem.hxx>
27 #include <unotools/configpaths.hxx>
28 #include <com/sun/star/uno/Sequence.h>
29 #include <svl/poolitem.hxx> //Any2Bool
30 #include <svl/smplhint.hxx>
31 #include <osl/mutex.hxx>
33 #include <vcl/svapp.hxx>
34 #include <vcl/event.hxx>
35 #include <rtl/instance.hxx>
36 #include <rtl/strbuf.hxx>
37 #include <comphelper/stl_types.hxx>
40 //-----------------------------------------------------------------------------
41 using namespace utl;
42 using namespace com::sun::star;
45 namespace svtools
48 sal_Int32 nExtendedColorRefCount_Impl = 0;
49 namespace
51 struct ColorMutex_Impl
52 : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {};
55 ExtendedColorConfig_Impl* ExtendedColorConfig::m_pImpl = NULL;
57 class ExtendedColorConfig_Impl : public utl::ConfigItem, public SfxBroadcaster
59 DECLARE_STL_USTRINGACCESS_MAP( OUString, TDisplayNames);
60 DECLARE_STL_USTRINGACCESS_MAP(ExtendedColorConfigValue,TConfigValues);
61 typedef ::std::vector<TConfigValues::iterator> TMapPos;
62 typedef ::std::pair< TConfigValues, TMapPos > TComponentMapping;
63 DECLARE_STL_USTRINGACCESS_MAP(TComponentMapping,TComponents);
64 TComponents m_aConfigValues;
65 TDisplayNames m_aComponentDisplayNames;
66 ::std::vector<TComponents::iterator> m_aConfigValuesPos;
68 sal_Bool m_bEditMode;
69 OUString m_sLoadedScheme;
70 sal_Bool m_bIsBroadcastEnabled;
71 static sal_Bool m_bLockBroadcast;
72 static sal_Bool m_bBroadcastWhenUnlocked;
74 uno::Sequence< OUString> GetPropertyNames(const OUString& rScheme);
75 void FillComponentColors(uno::Sequence < OUString >& _rComponents,const TDisplayNames& _rDisplayNames);
76 public:
77 ExtendedColorConfig_Impl(sal_Bool bEditMode = sal_False);
78 virtual ~ExtendedColorConfig_Impl();
80 void Load(const OUString& rScheme);
81 void CommitCurrentSchemeName();
82 //changes the name of the current scheme but doesn't load it!
83 void SetCurrentSchemeName(const OUString& rSchemeName) {m_sLoadedScheme = rSchemeName;}
84 sal_Bool ExistsScheme(const OUString& _sSchemeName);
85 virtual void Commit();
86 virtual void Notify( const uno::Sequence<OUString>& aPropertyNames);
88 sal_Int32 GetComponentCount() const;
89 OUString GetComponentName(sal_uInt32 _nPos) const;
90 OUString GetComponentDisplayName(const OUString& _sComponentName) const;
91 sal_Int32 GetComponentColorCount(const OUString& _sName) const;
92 ExtendedColorConfigValue GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const;
94 ExtendedColorConfigValue GetColorConfigValue(const OUString& _sComponentName,const OUString& _sName)
96 TComponents::iterator aFind = m_aConfigValues.find(_sComponentName);
97 if ( aFind != m_aConfigValues.end() )
99 TConfigValues::iterator aFind2 = aFind->second.first.find(_sName);
100 if ( aFind2 != aFind->second.first.end() )
101 return aFind2->second;
103 #if OSL_DEBUG_LEVEL > 0
104 OStringBuffer aMessage( "Could find the required config:\n" );
105 aMessage.append( "component: " );
106 aMessage.append( OUStringToOString( _sComponentName, RTL_TEXTENCODING_UTF8 ) );
107 aMessage.append( "\nname: " );
108 aMessage.append( OUStringToOString( _sName, RTL_TEXTENCODING_UTF8 ) );
109 OSL_FAIL( aMessage.makeStringAndClear().getStr() );
110 #endif
111 return ExtendedColorConfigValue();
113 void SetColorConfigValue(const OUString& _sName,
114 const ExtendedColorConfigValue& rValue );
116 const OUString& GetLoadedScheme() const {return m_sLoadedScheme;}
118 sal_Bool AddScheme(const OUString& rNode);
119 sal_Bool RemoveScheme(const OUString& rNode);
120 void SetModified(){ConfigItem::SetModified();}
121 void ClearModified(){ConfigItem::ClearModified();}
122 void SettingsChanged();
124 static void DisableBroadcast();
125 static void EnableBroadcast();
126 static sal_Bool IsEnableBroadcast();
128 static void LockBroadcast();
129 static void UnlockBroadcast();
131 // #100822#
132 DECL_LINK( DataChangedEventListener, VclWindowEvent* );
135 uno::Sequence< OUString> ExtendedColorConfig_Impl::GetPropertyNames(const OUString& rScheme)
137 uno::Sequence< OUString> aNames(GetNodeNames(rScheme));
138 OUString* pIter = aNames.getArray();
139 OUString* pEnd = pIter + aNames.getLength();
140 OUString sSep("/");
141 for(;pIter != pEnd;++pIter)
143 *pIter = rScheme + sSep + *pIter;
145 return aNames;
147 // -----------------------------------------------------------------------------
148 sal_Int32 ExtendedColorConfig_Impl::GetComponentCount() const
150 return m_aConfigValues.size();
152 // -----------------------------------------------------------------------------
153 sal_Int32 ExtendedColorConfig_Impl::GetComponentColorCount(const OUString& _sName) const
155 sal_Int32 nSize = 0;
156 TComponents::const_iterator aFind = m_aConfigValues.find(_sName);
157 if ( aFind != m_aConfigValues.end() )
159 nSize = aFind->second.first.size();
161 return nSize;
163 // -----------------------------------------------------------------------------
164 ExtendedColorConfigValue ExtendedColorConfig_Impl::GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const
166 TComponents::const_iterator aFind = m_aConfigValues.find(_sName);
167 if ( aFind != m_aConfigValues.end() )
169 if ( _nPos < aFind->second.second.size() )
171 return aFind->second.second[_nPos]->second;
174 return ExtendedColorConfigValue();
176 // -----------------------------------------------------------------------------
177 OUString ExtendedColorConfig_Impl::GetComponentDisplayName(const OUString& _sComponentName) const
179 OUString sRet;
180 TDisplayNames::const_iterator aFind = m_aComponentDisplayNames.find(_sComponentName);
181 if ( aFind != m_aComponentDisplayNames.end() )
182 sRet = aFind->second;
183 return sRet;
185 // -----------------------------------------------------------------------------
186 OUString ExtendedColorConfig_Impl::GetComponentName(sal_uInt32 _nPos) const
188 OUString sRet;
189 if ( _nPos < m_aConfigValuesPos.size() )
190 sRet = m_aConfigValuesPos[_nPos]->first;
191 return sRet;
194 sal_Bool ExtendedColorConfig_Impl::m_bLockBroadcast = sal_False;
195 sal_Bool ExtendedColorConfig_Impl::m_bBroadcastWhenUnlocked = sal_False;
196 ExtendedColorConfig_Impl::ExtendedColorConfig_Impl(sal_Bool bEditMode) :
197 ConfigItem(OUString("Office.ExtendedColorScheme")),
198 m_bEditMode(bEditMode),
199 m_bIsBroadcastEnabled(sal_True)
201 if(!m_bEditMode)
203 //try to register on the root node - if possible
204 uno::Sequence < OUString > aNames(1);
205 EnableNotification( aNames );
207 Load(OUString());
209 // #100822#
210 ::Application::AddEventListener( LINK(this, ExtendedColorConfig_Impl, DataChangedEventListener) );
214 ExtendedColorConfig_Impl::~ExtendedColorConfig_Impl()
216 // #100822#
217 ::Application::RemoveEventListener( LINK(this, ExtendedColorConfig_Impl, DataChangedEventListener) );
219 // -----------------------------------------------------------------------------
220 void ExtendedColorConfig_Impl::DisableBroadcast()
222 if ( ExtendedColorConfig::m_pImpl )
223 ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled = sal_False;
225 // -----------------------------------------------------------------------------
226 void ExtendedColorConfig_Impl::EnableBroadcast()
228 if ( ExtendedColorConfig::m_pImpl )
229 ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled = sal_True;
231 // -----------------------------------------------------------------------------
232 sal_Bool ExtendedColorConfig_Impl::IsEnableBroadcast()
234 return ExtendedColorConfig::m_pImpl ? ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled : sal_False;
237 void lcl_addString(uno::Sequence < OUString >& _rSeq,const OUString& _sAdd)
239 OUString* pIter = _rSeq.getArray();
240 OUString* pEnd = pIter + _rSeq.getLength();
241 for(;pIter != pEnd;++pIter)
242 *pIter += _sAdd;
244 // -----------------------------------------------------------------------------
245 void ExtendedColorConfig_Impl::Load(const OUString& rScheme)
247 m_aComponentDisplayNames.clear();
248 m_aConfigValuesPos.clear();
249 m_aConfigValues.clear();
251 // fill display names
252 TDisplayNames aDisplayNameMap;
253 OUString sEntryNames("EntryNames");
254 uno::Sequence < OUString > aComponentNames = GetPropertyNames(sEntryNames);
255 OUString sDisplayName("/DisplayName");
256 OUString* pIter = aComponentNames.getArray();
257 OUString* pEnd = pIter + aComponentNames.getLength();
258 for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
260 uno::Sequence < OUString > aComponentDisplayNames(1);
261 aComponentDisplayNames[0] = *pIter;
262 aComponentDisplayNames[0] += sDisplayName;
263 uno::Sequence< uno::Any > aComponentDisplayNamesValue = GetProperties( aComponentDisplayNames );
264 OUString sComponentDisplayName;
265 if ( aComponentDisplayNamesValue.getLength() && (aComponentDisplayNamesValue[0] >>= sComponentDisplayName) )
267 sal_Int32 nIndex = 0;
268 m_aComponentDisplayNames.insert(TDisplayNames::value_type(pIter->getToken(1,'/',nIndex),sComponentDisplayName));
271 *pIter += OUString("/Entries");
272 uno::Sequence < OUString > aDisplayNames = GetPropertyNames(*pIter);
273 lcl_addString(aDisplayNames,sDisplayName);
275 uno::Sequence< uno::Any > aDisplayNamesValue = GetProperties( aDisplayNames );
277 const OUString* pDispIter = aDisplayNames.getConstArray();
278 const OUString* pDispEnd = pDispIter + aDisplayNames.getLength();
279 for(sal_Int32 j = 0;pDispIter != pDispEnd;++pDispIter,++j)
281 sal_Int32 nIndex = 0;
282 pDispIter->getToken(0,'/',nIndex);
283 OUString sName = pDispIter->copy(nIndex);
284 sName = sName.copy(0,sName.lastIndexOf(sDisplayName));
285 OUString sCurrentDisplayName;
286 aDisplayNamesValue[j] >>= sCurrentDisplayName;
287 aDisplayNameMap.insert(TDisplayNames::value_type(sName,sCurrentDisplayName));
291 // load color settings
292 OUString sScheme(rScheme);
294 if(sScheme.isEmpty())
296 //detect current scheme name
297 uno::Sequence < OUString > aCurrent(1);
298 aCurrent.getArray()[0] = OUString("ExtendedColorScheme/CurrentColorScheme");
299 uno::Sequence< uno::Any > aCurrentVal = GetProperties( aCurrent );
300 aCurrentVal.getConstArray()[0] >>= sScheme;
301 } // if(!sScheme.getLength())
303 m_sLoadedScheme = sScheme;
304 OUString sBase("ExtendedColorScheme/ColorSchemes/");
305 sBase += sScheme;
307 sal_Bool bFound = ExistsScheme(sScheme);
308 if ( bFound )
310 aComponentNames = GetPropertyNames(sBase);
311 FillComponentColors(aComponentNames,aDisplayNameMap);
314 if ( m_sLoadedScheme.isEmpty() )
315 m_sLoadedScheme = OUString("default");
317 if ( sScheme != "default" )
319 OUString sDefault("default");
320 if ( ExistsScheme(sDefault) )
322 OUString sBaseDefault("ExtendedColorScheme/ColorSchemes/default");
323 aComponentNames = GetPropertyNames(sBaseDefault);
324 FillComponentColors(aComponentNames,aDisplayNameMap);
327 if ( !bFound && !sScheme.isEmpty() )
329 AddScheme(sScheme);
330 CommitCurrentSchemeName();
333 // -----------------------------------------------------------------------------
334 void ExtendedColorConfig_Impl::FillComponentColors(uno::Sequence < OUString >& _rComponents,const TDisplayNames& _rDisplayNames)
336 const OUString sColorEntries("/Entries");
337 OUString* pIter = _rComponents.getArray();
338 OUString* pEnd = pIter + _rComponents.getLength();
339 for(;pIter != pEnd;++pIter)
341 OUString sComponentName = pIter->copy(pIter->lastIndexOf('/')+1);
342 if ( m_aConfigValues.find(sComponentName) == m_aConfigValues.end() )
344 OUString sEntry = *pIter;
345 sEntry += sColorEntries;
347 uno::Sequence < OUString > aColorNames = GetPropertyNames(sEntry);
348 uno::Sequence < OUString > aDefaultColorNames = aColorNames;
350 const OUString sColor("/Color");
351 const OUString sDefaultColor("/DefaultColor");
352 lcl_addString(aColorNames,sColor);
353 lcl_addString(aDefaultColorNames,sDefaultColor);
354 uno::Sequence< uno::Any > aColors = GetProperties( aColorNames );
355 const uno::Any* pColors = aColors.getConstArray();
357 uno::Sequence< uno::Any > aDefaultColors = GetProperties( aDefaultColorNames );
358 bool bDefaultColorFound = aDefaultColors.getLength() != 0;
359 const uno::Any* pDefaultColors = aDefaultColors.getConstArray();
361 OUString* pColorIter = aColorNames.getArray();
362 OUString* pColorEnd = pColorIter + aColorNames.getLength();
364 m_aConfigValuesPos.push_back(m_aConfigValues.insert(TComponents::value_type(sComponentName,TComponentMapping(TConfigValues(),TMapPos()))).first);
365 TConfigValues& aConfigValues = (*m_aConfigValuesPos.rbegin())->second.first;
366 TMapPos& aConfigValuesPos = (*m_aConfigValuesPos.rbegin())->second.second;
367 for(int i = 0; pColorIter != pColorEnd; ++pColorIter ,++i)
369 if ( aConfigValues.find(*pColorIter) == aConfigValues.end() )
371 sal_Int32 nIndex = 0;
372 pColorIter->getToken(2,'/',nIndex);
373 OUString sName(pColorIter->copy(nIndex)),sDisplayName;
374 OUString sTemp = sName.copy(0,sName.lastIndexOf(sColor));
376 TDisplayNames::const_iterator aFind = _rDisplayNames.find(sTemp);
377 nIndex = 0;
378 sName = sName.getToken(2,'/',nIndex);
379 OSL_ENSURE(aFind != _rDisplayNames.end(),"DisplayName is not in EntryNames config list!");
380 if ( aFind != _rDisplayNames.end() )
381 sDisplayName = aFind->second;
383 OSL_ENSURE(pColors[i].hasValue(),"Color config entry has NIL as color value set!");
384 OSL_ENSURE(pDefaultColors[i].hasValue(),"Color config entry has NIL as color value set!");
385 sal_Int32 nColor = 0,nDefaultColor = 0;
386 pColors[i] >>= nColor;
387 if ( bDefaultColorFound )
388 pDefaultColors[i] >>= nDefaultColor;
389 else
390 nDefaultColor = nColor;
391 ExtendedColorConfigValue aValue(sName,sDisplayName,nColor,nDefaultColor);
392 aConfigValuesPos.push_back(aConfigValues.insert(TConfigValues::value_type(sName,aValue)).first);
394 } // for(int i = 0; pColorIter != pColorEnd; ++pColorIter ,++i)
399 void ExtendedColorConfig_Impl::Notify( const uno::Sequence<OUString>& /*rPropertyNames*/)
401 //loading via notification always uses the default setting
402 Load(OUString());
404 SolarMutexGuard aVclGuard;
406 if(m_bLockBroadcast)
408 m_bBroadcastWhenUnlocked = sal_True;
410 else
411 Broadcast(SfxSimpleHint(SFX_HINT_COLORS_CHANGED));
414 void ExtendedColorConfig_Impl::Commit()
416 if ( m_sLoadedScheme.isEmpty() )
417 return;
418 const OUString sColorEntries("Entries");
419 const OUString sColor("/Color");
420 OUString sBase("ExtendedColorScheme/ColorSchemes/");
421 const OUString s_sSep("/");
422 sBase += m_sLoadedScheme;
424 TComponents::iterator aIter = m_aConfigValues.begin();
425 TComponents::iterator aEnd = m_aConfigValues.end();
426 for( ;aIter != aEnd;++aIter )
428 OUString sEntry = aIter->first;
429 sEntry += sColorEntries;
431 if ( ConfigItem::AddNode(sBase, aIter->first) )
433 OUString sNode = sBase;
434 sNode += s_sSep;
435 sNode += aIter->first;
436 //ConfigItem::AddNode(sNode, sColorEntries);
437 sNode += s_sSep;
438 sNode += sColorEntries;
440 uno::Sequence < beans::PropertyValue > aPropValues(aIter->second.first.size());
441 beans::PropertyValue* pPropValues = aPropValues.getArray();
442 TConfigValues::iterator aConIter = aIter->second.first.begin();
443 TConfigValues::iterator aConEnd = aIter->second.first.end();
444 for (; aConIter != aConEnd; ++aConIter,++pPropValues)
446 pPropValues->Name = sNode + s_sSep + aConIter->first;
447 ConfigItem::AddNode(sNode, aConIter->first);
448 pPropValues->Name += sColor;
449 pPropValues->Value <<= aConIter->second.getColor();
450 // the default color will never be changed
452 OUString s("ExtendedColorScheme/ColorSchemes");
453 SetSetProperties(s, aPropValues);
457 CommitCurrentSchemeName();
460 void ExtendedColorConfig_Impl::CommitCurrentSchemeName()
462 //save current scheme name
463 uno::Sequence < OUString > aCurrent(1);
464 aCurrent.getArray()[0] = OUString("ExtendedColorScheme/CurrentColorScheme");
465 uno::Sequence< uno::Any > aCurrentVal(1);
466 aCurrentVal.getArray()[0] <<= m_sLoadedScheme;
467 PutProperties(aCurrent, aCurrentVal);
469 // -----------------------------------------------------------------------------
470 sal_Bool ExtendedColorConfig_Impl::ExistsScheme(const OUString& _sSchemeName)
472 OUString sBase("ExtendedColorScheme/ColorSchemes");
474 uno::Sequence < OUString > aComponentNames = GetPropertyNames(sBase);
475 sBase += OUString("/") + _sSchemeName;
476 const OUString* pCompIter = aComponentNames.getConstArray();
477 const OUString* pCompEnd = pCompIter + aComponentNames.getLength();
478 for(;pCompIter != pCompEnd && *pCompIter != sBase;++pCompIter)
480 return pCompIter != pCompEnd;
483 void ExtendedColorConfig_Impl::SetColorConfigValue(const OUString& _sName, const ExtendedColorConfigValue& rValue )
485 TComponents::iterator aFind = m_aConfigValues.find(_sName);
486 if ( aFind != m_aConfigValues.end() )
488 TConfigValues::iterator aFind2 = aFind->second.first.find(rValue.getName());
489 if ( aFind2 != aFind->second.first.end() )
490 aFind2->second = rValue;
491 SetModified();
495 sal_Bool ExtendedColorConfig_Impl::AddScheme(const OUString& rScheme)
497 if(ConfigItem::AddNode(OUString("ExtendedColorScheme/ColorSchemes"), rScheme))
499 m_sLoadedScheme = rScheme;
500 Commit();
501 return sal_True;
503 return sal_False;
506 sal_Bool ExtendedColorConfig_Impl::RemoveScheme(const OUString& rScheme)
508 uno::Sequence< OUString > aElements(1);
509 aElements.getArray()[0] = rScheme;
510 return ClearNodeElements(OUString("ExtendedColorScheme/ColorSchemes"), aElements);
513 void ExtendedColorConfig_Impl::SettingsChanged()
515 SolarMutexGuard aVclGuard;
517 Broadcast( SfxSimpleHint( SFX_HINT_COLORS_CHANGED ) );
520 void ExtendedColorConfig_Impl::LockBroadcast()
522 m_bLockBroadcast = sal_True;
525 void ExtendedColorConfig_Impl::UnlockBroadcast()
527 if ( m_bBroadcastWhenUnlocked )
529 m_bBroadcastWhenUnlocked = ExtendedColorConfig::m_pImpl != NULL;
530 if ( m_bBroadcastWhenUnlocked )
532 if ( ExtendedColorConfig::m_pImpl->IsEnableBroadcast() )
534 m_bBroadcastWhenUnlocked = sal_False;
535 ExtendedColorConfig::m_pImpl->Broadcast(SfxSimpleHint(SFX_HINT_COLORS_CHANGED));
539 m_bLockBroadcast = sal_False;
542 IMPL_LINK( ExtendedColorConfig_Impl, DataChangedEventListener, VclWindowEvent*, pEvent )
544 if ( pEvent->GetId() == VCLEVENT_APPLICATION_DATACHANGED )
546 DataChangedEvent* pData = (DataChangedEvent*)(pEvent->GetData());
547 if ( (pData->GetType() == DATACHANGED_SETTINGS) &&
548 (pData->GetFlags() & SETTINGS_STYLE) )
550 SettingsChanged();
551 return 1L;
552 } else
553 return 0L;
554 } else
555 return 0L;
558 // ---------------------------------------------------------------------------
560 // ---------------------------------------------------------------------------
562 ExtendedColorConfig::ExtendedColorConfig()
564 ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
565 if ( !m_pImpl )
566 m_pImpl = new ExtendedColorConfig_Impl;
567 ++nExtendedColorRefCount_Impl;
568 StartListening( *m_pImpl);
571 ExtendedColorConfig::~ExtendedColorConfig()
573 ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
574 EndListening( *m_pImpl);
575 if(!--nExtendedColorRefCount_Impl)
577 delete m_pImpl;
578 m_pImpl = 0;
582 ExtendedColorConfigValue ExtendedColorConfig::GetColorValue(const OUString& _sComponentName,const OUString& _sName)const
584 return m_pImpl->GetColorConfigValue(_sComponentName,_sName);
586 // -----------------------------------------------------------------------------
587 sal_Int32 ExtendedColorConfig::GetComponentCount() const
589 return m_pImpl->GetComponentCount();
591 // -----------------------------------------------------------------------------
592 sal_Int32 ExtendedColorConfig::GetComponentColorCount(const OUString& _sName) const
594 return m_pImpl->GetComponentColorCount(_sName);
596 // -----------------------------------------------------------------------------
597 ExtendedColorConfigValue ExtendedColorConfig::GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const
599 return m_pImpl->GetComponentColorConfigValue(_sName,_nPos);
601 // -----------------------------------------------------------------------------
602 OUString ExtendedColorConfig::GetComponentName(sal_uInt32 _nPos) const
604 return m_pImpl->GetComponentName(_nPos);
606 // -----------------------------------------------------------------------------
607 OUString ExtendedColorConfig::GetComponentDisplayName(const OUString& _sComponentName) const
609 return m_pImpl->GetComponentDisplayName(_sComponentName);
612 void ExtendedColorConfig::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
614 SolarMutexGuard aVclGuard;
616 Broadcast( rHint );
619 EditableExtendedColorConfig::EditableExtendedColorConfig() :
620 m_pImpl(new ExtendedColorConfig_Impl),
621 m_bModified(sal_False)
623 m_pImpl->LockBroadcast();
626 EditableExtendedColorConfig::~EditableExtendedColorConfig()
628 m_pImpl->UnlockBroadcast();
629 if(m_bModified)
630 m_pImpl->SetModified();
631 if(m_pImpl->IsModified())
632 m_pImpl->Commit();
633 delete m_pImpl;
636 void EditableExtendedColorConfig::DeleteScheme(const OUString& rScheme )
638 m_pImpl->RemoveScheme(rScheme);
641 void EditableExtendedColorConfig::AddScheme(const OUString& rScheme )
643 m_pImpl->AddScheme(rScheme);
646 sal_Bool EditableExtendedColorConfig::LoadScheme(const OUString& rScheme )
648 if(m_bModified)
649 m_pImpl->SetModified();
650 if(m_pImpl->IsModified())
651 m_pImpl->Commit();
652 m_bModified = sal_False;
653 m_pImpl->Load(rScheme);
654 //the name of the loaded scheme has to be committed separately
655 m_pImpl->CommitCurrentSchemeName();
656 return sal_True;
659 // Changes the name of the current scheme but doesn't load it!
660 void EditableExtendedColorConfig::SetCurrentSchemeName(const OUString& rScheme)
662 m_pImpl->SetCurrentSchemeName(rScheme);
663 m_pImpl->CommitCurrentSchemeName();
666 void EditableExtendedColorConfig::SetColorValue(
667 const OUString& _sName, const ExtendedColorConfigValue& rValue)
669 m_pImpl->SetColorConfigValue(_sName, rValue);
670 m_pImpl->ClearModified();
671 m_bModified = sal_True;
674 void EditableExtendedColorConfig::SetModified()
676 m_bModified = sal_True;
679 void EditableExtendedColorConfig::Commit()
681 if(m_bModified)
682 m_pImpl->SetModified();
683 if(m_pImpl->IsModified())
684 m_pImpl->Commit();
685 m_bModified = sal_False;
687 // -----------------------------------------------------------------------------
688 void EditableExtendedColorConfig::DisableBroadcast()
690 m_pImpl->DisableBroadcast();
692 // -----------------------------------------------------------------------------
693 void EditableExtendedColorConfig::EnableBroadcast()
695 m_pImpl->EnableBroadcast();
697 // -----------------------------------------------------------------------------
698 sal_Int32 EditableExtendedColorConfig::GetComponentCount() const
700 return m_pImpl->GetComponentCount();
702 // -----------------------------------------------------------------------------
703 sal_Int32 EditableExtendedColorConfig::GetComponentColorCount(const OUString& _sName) const
705 return m_pImpl->GetComponentColorCount(_sName);
707 // -----------------------------------------------------------------------------
708 ExtendedColorConfigValue EditableExtendedColorConfig::GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const
710 return m_pImpl->GetComponentColorConfigValue(_sName,_nPos);
712 // -----------------------------------------------------------------------------
713 OUString EditableExtendedColorConfig::GetComponentName(sal_uInt32 _nPos) const
715 return m_pImpl->GetComponentName(_nPos);
717 }//namespace svtools
719 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */