xref: /AOO41X/main/svtools/source/config/extcolorcfg.cxx (revision 5900e8ec128faec89519683efce668ccd8cc6084)
1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5900e8ecSAndrew Rist  * distributed with this work for additional information
6*5900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*5900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*5900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist  * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
17*5900e8ecSAndrew Rist  * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*5900e8ecSAndrew Rist  *************************************************************/
21*5900e8ecSAndrew Rist 
22*5900e8ecSAndrew Rist 
23cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
24cdf0e10cSrcweir #include "precompiled_svtools.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <svtools/extcolorcfg.hxx>
27cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
28cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
29cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp>
30cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
31cdf0e10cSrcweir #include <tools/color.hxx>
32cdf0e10cSrcweir #include <tools/debug.hxx>
33cdf0e10cSrcweir #include <unotools/configitem.hxx>
34cdf0e10cSrcweir #include <unotools/configpathes.hxx>
35cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h>
36cdf0e10cSrcweir #include <svl/poolitem.hxx> //Any2Bool
37cdf0e10cSrcweir #include <svl/smplhint.hxx>
38cdf0e10cSrcweir #include <vos/mutex.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir  /* #100822# ----
41cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
42cdf0e10cSrcweir  ------------- */
43cdf0e10cSrcweir #include <vcl/svapp.hxx>
44cdf0e10cSrcweir #include <vcl/event.hxx>
45cdf0e10cSrcweir #include <rtl/instance.hxx>
46cdf0e10cSrcweir #include <rtl/strbuf.hxx>
47cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 
50cdf0e10cSrcweir //-----------------------------------------------------------------------------
51cdf0e10cSrcweir using namespace utl;
52cdf0e10cSrcweir using namespace rtl;
53cdf0e10cSrcweir using namespace com::sun::star;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace svtools
56cdf0e10cSrcweir {
57cdf0e10cSrcweir 
58cdf0e10cSrcweir #define C2U(cChar) OUString::createFromAscii(cChar)
59cdf0e10cSrcweir sal_Int32            nExtendedColorRefCount_Impl = 0;
60cdf0e10cSrcweir namespace
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     struct ColorMutex_Impl
63cdf0e10cSrcweir         : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {};
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir ExtendedColorConfig_Impl*    ExtendedColorConfig::m_pImpl = NULL;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir /* -----------------------------16.01.01 15:36--------------------------------
69cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
70cdf0e10cSrcweir class ExtendedColorConfig_Impl : public utl::ConfigItem, public SfxBroadcaster
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 	DECLARE_STL_USTRINGACCESS_MAP( ::rtl::OUString, TDisplayNames);
73cdf0e10cSrcweir 	DECLARE_STL_USTRINGACCESS_MAP(ExtendedColorConfigValue,TConfigValues);
74cdf0e10cSrcweir 	typedef ::std::vector<TConfigValues::iterator> TMapPos;
75cdf0e10cSrcweir 	typedef ::std::pair< TConfigValues, TMapPos > TComponentMapping;
76cdf0e10cSrcweir 	DECLARE_STL_USTRINGACCESS_MAP(TComponentMapping,TComponents);
77cdf0e10cSrcweir 	TComponents			m_aConfigValues;
78cdf0e10cSrcweir 	TDisplayNames		m_aComponentDisplayNames;
79cdf0e10cSrcweir 	::std::vector<TComponents::iterator> m_aConfigValuesPos;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     sal_Bool            m_bEditMode;
82cdf0e10cSrcweir     rtl::OUString       m_sLoadedScheme;
83cdf0e10cSrcweir 	sal_Bool			m_bIsBroadcastEnabled;
84cdf0e10cSrcweir     static sal_Bool     m_bLockBroadcast;
85cdf0e10cSrcweir     static sal_Bool     m_bBroadcastWhenUnlocked;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString> GetPropertyNames(const rtl::OUString& rScheme);
88cdf0e10cSrcweir 	void FillComponentColors(uno::Sequence < ::rtl::OUString >& _rComponents,const TDisplayNames& _rDisplayNames);
89cdf0e10cSrcweir public:
90cdf0e10cSrcweir     ExtendedColorConfig_Impl(sal_Bool bEditMode = sal_False);
91cdf0e10cSrcweir     virtual ~ExtendedColorConfig_Impl();
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     void                            Load(const rtl::OUString& rScheme);
94cdf0e10cSrcweir     void                            CommitCurrentSchemeName();
95cdf0e10cSrcweir     //changes the name of the current scheme but doesn't load it!
SetCurrentSchemeName(const rtl::OUString & rSchemeName)96cdf0e10cSrcweir     void                            SetCurrentSchemeName(const rtl::OUString& rSchemeName) {m_sLoadedScheme = rSchemeName;}
97cdf0e10cSrcweir 	sal_Bool						ExistsScheme(const ::rtl::OUString& _sSchemeName);
98cdf0e10cSrcweir     virtual void                    Commit();
99cdf0e10cSrcweir     virtual void                    Notify( const uno::Sequence<rtl::OUString>& aPropertyNames);
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	sal_Int32						GetComponentCount() const;
102cdf0e10cSrcweir 	::rtl::OUString					GetComponentName(sal_uInt32 _nPos) const;
103cdf0e10cSrcweir 	::rtl::OUString					GetComponentDisplayName(const ::rtl::OUString& _sComponentName) const;
104cdf0e10cSrcweir 	sal_Int32						GetComponentColorCount(const ::rtl::OUString& _sName) const;
105cdf0e10cSrcweir 	ExtendedColorConfigValue		GetComponentColorConfigValue(const ::rtl::OUString& _sName,sal_uInt32 _nPos) const;
106cdf0e10cSrcweir 
GetColorConfigValue(const::rtl::OUString & _sComponentName,const::rtl::OUString & _sName)107cdf0e10cSrcweir     ExtendedColorConfigValue GetColorConfigValue(const ::rtl::OUString& _sComponentName,const ::rtl::OUString& _sName)
108cdf0e10cSrcweir 	{
109cdf0e10cSrcweir 		TComponents::iterator aFind = m_aConfigValues.find(_sComponentName);
110cdf0e10cSrcweir 		if ( aFind != m_aConfigValues.end() )
111cdf0e10cSrcweir 		{
112cdf0e10cSrcweir 			TConfigValues::iterator aFind2 = aFind->second.first.find(_sName);
113cdf0e10cSrcweir 			if ( aFind2 != aFind->second.first.end() )
114cdf0e10cSrcweir 				return aFind2->second;
115cdf0e10cSrcweir         }
116cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
117cdf0e10cSrcweir         ::rtl::OStringBuffer aMessage( "Could find the required config:\n" );
118cdf0e10cSrcweir         aMessage.append( "component: " );
119cdf0e10cSrcweir         aMessage.append( ::rtl::OUStringToOString( _sComponentName, RTL_TEXTENCODING_UTF8 ) );
120cdf0e10cSrcweir         aMessage.append( "\nname: " );
121cdf0e10cSrcweir         aMessage.append( ::rtl::OUStringToOString( _sName, RTL_TEXTENCODING_UTF8 ) );
122cdf0e10cSrcweir 		OSL_ENSURE( 0, aMessage.makeStringAndClear().getStr() );
123cdf0e10cSrcweir #endif
124cdf0e10cSrcweir 		return ExtendedColorConfigValue();
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir     void                            SetColorConfigValue(const ::rtl::OUString& _sName,
127cdf0e10cSrcweir                                                             const ExtendedColorConfigValue& rValue );
128cdf0e10cSrcweir 
GetLoadedScheme() const129cdf0e10cSrcweir     const rtl::OUString&            GetLoadedScheme() const {return m_sLoadedScheme;}
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString> GetSchemeNames();
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     sal_Bool                        AddScheme(const rtl::OUString& rNode);
134cdf0e10cSrcweir     sal_Bool                        RemoveScheme(const rtl::OUString& rNode);
SetModified()135cdf0e10cSrcweir     void                            SetModified(){ConfigItem::SetModified();}
ClearModified()136cdf0e10cSrcweir     void                            ClearModified(){ConfigItem::ClearModified();}
137cdf0e10cSrcweir     void                            SettingsChanged();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	static void						DisableBroadcast();
140cdf0e10cSrcweir 	static void						EnableBroadcast();
141cdf0e10cSrcweir 	static sal_Bool					IsEnableBroadcast();
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     static void                     LockBroadcast();
144cdf0e10cSrcweir     static void                     UnlockBroadcast();
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     // #100822#
147cdf0e10cSrcweir     DECL_LINK( DataChangedEventListener, VclWindowEvent* );
148cdf0e10cSrcweir };
149cdf0e10cSrcweir 
150cdf0e10cSrcweir /* -----------------------------16.01.01 15:36--------------------------------
151cdf0e10cSrcweir 
152cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
GetPropertyNames(const rtl::OUString & rScheme)153cdf0e10cSrcweir uno::Sequence< OUString> ExtendedColorConfig_Impl::GetPropertyNames(const rtl::OUString& rScheme)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     uno::Sequence< OUString> aNames(GetNodeNames(rScheme));
156cdf0e10cSrcweir     ::rtl::OUString* pIter = aNames.getArray();
157cdf0e10cSrcweir     ::rtl::OUString* pEnd	 = pIter + aNames.getLength();
158cdf0e10cSrcweir     ::rtl::OUString sSep(RTL_CONSTASCII_USTRINGPARAM("/"));
159cdf0e10cSrcweir     for(;pIter != pEnd;++pIter)
160cdf0e10cSrcweir     {
161cdf0e10cSrcweir 	    *pIter = rScheme + sSep + *pIter;
162cdf0e10cSrcweir     }
163cdf0e10cSrcweir     return aNames;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentCount() const166cdf0e10cSrcweir sal_Int32 ExtendedColorConfig_Impl::GetComponentCount() const
167cdf0e10cSrcweir {
168cdf0e10cSrcweir 	return m_aConfigValues.size();
169cdf0e10cSrcweir }
170cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentColorCount(const::rtl::OUString & _sName) const171cdf0e10cSrcweir sal_Int32 ExtendedColorConfig_Impl::GetComponentColorCount(const ::rtl::OUString& _sName) const
172cdf0e10cSrcweir {
173cdf0e10cSrcweir 	sal_Int32 nSize = 0;
174cdf0e10cSrcweir 	TComponents::const_iterator aFind = m_aConfigValues.find(_sName);
175cdf0e10cSrcweir     if ( aFind != m_aConfigValues.end() )
176cdf0e10cSrcweir 	{
177cdf0e10cSrcweir 		nSize = aFind->second.first.size();
178cdf0e10cSrcweir 	}
179cdf0e10cSrcweir 	return nSize;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentColorConfigValue(const::rtl::OUString & _sName,sal_uInt32 _nPos) const182cdf0e10cSrcweir ExtendedColorConfigValue ExtendedColorConfig_Impl::GetComponentColorConfigValue(const ::rtl::OUString& _sName,sal_uInt32 _nPos) const
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	TComponents::const_iterator aFind = m_aConfigValues.find(_sName);
185cdf0e10cSrcweir     if ( aFind != m_aConfigValues.end() )
186cdf0e10cSrcweir 	{
187cdf0e10cSrcweir 		if ( _nPos < aFind->second.second.size() )
188cdf0e10cSrcweir 		{
189cdf0e10cSrcweir 			return aFind->second.second[_nPos]->second;
190cdf0e10cSrcweir 		}
191cdf0e10cSrcweir 	}
192cdf0e10cSrcweir 	return ExtendedColorConfigValue();
193cdf0e10cSrcweir }
194cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentDisplayName(const::rtl::OUString & _sComponentName) const195cdf0e10cSrcweir ::rtl::OUString	ExtendedColorConfig_Impl::GetComponentDisplayName(const ::rtl::OUString& _sComponentName) const
196cdf0e10cSrcweir {
197cdf0e10cSrcweir 	::rtl::OUString sRet;
198cdf0e10cSrcweir 	TDisplayNames::const_iterator aFind = m_aComponentDisplayNames.find(_sComponentName);
199cdf0e10cSrcweir     if ( aFind != m_aComponentDisplayNames.end() )
200cdf0e10cSrcweir 		sRet = aFind->second;
201cdf0e10cSrcweir 	return sRet;
202cdf0e10cSrcweir }
203cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentName(sal_uInt32 _nPos) const204cdf0e10cSrcweir ::rtl::OUString ExtendedColorConfig_Impl::GetComponentName(sal_uInt32 _nPos) const
205cdf0e10cSrcweir {
206cdf0e10cSrcweir 	::rtl::OUString sRet;
207cdf0e10cSrcweir 	if ( _nPos < m_aConfigValuesPos.size() )
208cdf0e10cSrcweir 		sRet = m_aConfigValuesPos[_nPos]->first;
209cdf0e10cSrcweir 	return sRet;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir // -----------------------------------------------------------------------------
212cdf0e10cSrcweir /* -----------------------------22.03.2002 14:37------------------------------
213cdf0e10cSrcweir 
214cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
215cdf0e10cSrcweir sal_Bool ExtendedColorConfig_Impl::m_bLockBroadcast = sal_False;
216cdf0e10cSrcweir sal_Bool ExtendedColorConfig_Impl::m_bBroadcastWhenUnlocked = sal_False;
ExtendedColorConfig_Impl(sal_Bool bEditMode)217cdf0e10cSrcweir ExtendedColorConfig_Impl::ExtendedColorConfig_Impl(sal_Bool bEditMode) :
218cdf0e10cSrcweir     ConfigItem(C2U("Office.ExtendedColorScheme")),
219cdf0e10cSrcweir     m_bEditMode(bEditMode),
220cdf0e10cSrcweir 	m_bIsBroadcastEnabled(sal_True)
221cdf0e10cSrcweir {
222cdf0e10cSrcweir     if(!m_bEditMode)
223cdf0e10cSrcweir     {
224cdf0e10cSrcweir         //try to register on the root node - if possible
225cdf0e10cSrcweir         uno::Sequence < ::rtl::OUString > aNames(1);
226cdf0e10cSrcweir         EnableNotification( aNames );
227cdf0e10cSrcweir     }
228cdf0e10cSrcweir     Load(::rtl::OUString());
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     // #100822#
231cdf0e10cSrcweir     ::Application::AddEventListener( LINK(this, ExtendedColorConfig_Impl, DataChangedEventListener) );
232cdf0e10cSrcweir 
233cdf0e10cSrcweir }
234cdf0e10cSrcweir /* -----------------------------25.03.2002 12:28------------------------------
235cdf0e10cSrcweir 
236cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
~ExtendedColorConfig_Impl()237cdf0e10cSrcweir ExtendedColorConfig_Impl::~ExtendedColorConfig_Impl()
238cdf0e10cSrcweir {
239cdf0e10cSrcweir 	// #100822#
240cdf0e10cSrcweir 	::Application::RemoveEventListener( LINK(this, ExtendedColorConfig_Impl, DataChangedEventListener) );
241cdf0e10cSrcweir }
242cdf0e10cSrcweir // -----------------------------------------------------------------------------
DisableBroadcast()243cdf0e10cSrcweir void ExtendedColorConfig_Impl::DisableBroadcast()
244cdf0e10cSrcweir {
245cdf0e10cSrcweir     if ( ExtendedColorConfig::m_pImpl )
246cdf0e10cSrcweir 	    ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled = sal_False;
247cdf0e10cSrcweir }
248cdf0e10cSrcweir // -----------------------------------------------------------------------------
EnableBroadcast()249cdf0e10cSrcweir void ExtendedColorConfig_Impl::EnableBroadcast()
250cdf0e10cSrcweir {
251cdf0e10cSrcweir     if ( ExtendedColorConfig::m_pImpl )
252cdf0e10cSrcweir 	    ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled = sal_True;
253cdf0e10cSrcweir }
254cdf0e10cSrcweir // -----------------------------------------------------------------------------
IsEnableBroadcast()255cdf0e10cSrcweir sal_Bool ExtendedColorConfig_Impl::IsEnableBroadcast()
256cdf0e10cSrcweir {
257cdf0e10cSrcweir     return ExtendedColorConfig::m_pImpl ? ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled : sal_False;
258cdf0e10cSrcweir }
259cdf0e10cSrcweir /* -----------------------------22.03.2002 14:38------------------------------
260cdf0e10cSrcweir 
261cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
lcl_addString(uno::Sequence<::rtl::OUString> & _rSeq,const::rtl::OUString & _sAdd)262cdf0e10cSrcweir void lcl_addString(uno::Sequence < ::rtl::OUString >& _rSeq,const ::rtl::OUString& _sAdd)
263cdf0e10cSrcweir {
264cdf0e10cSrcweir 	::rtl::OUString* pIter = _rSeq.getArray();
265cdf0e10cSrcweir 	::rtl::OUString* pEnd  = pIter + _rSeq.getLength();
266cdf0e10cSrcweir 	for(;pIter != pEnd;++pIter)
267cdf0e10cSrcweir 		*pIter += _sAdd;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir // -----------------------------------------------------------------------------
Load(const rtl::OUString & rScheme)270cdf0e10cSrcweir void ExtendedColorConfig_Impl::Load(const rtl::OUString& rScheme)
271cdf0e10cSrcweir {
272cdf0e10cSrcweir 	m_aComponentDisplayNames.clear();
273cdf0e10cSrcweir 	m_aConfigValuesPos.clear();
274cdf0e10cSrcweir 	m_aConfigValues.clear();
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	// fill display names
277cdf0e10cSrcweir 	TDisplayNames aDisplayNameMap;
278cdf0e10cSrcweir 	::rtl::OUString sEntryNames(RTL_CONSTASCII_USTRINGPARAM("EntryNames"));
279cdf0e10cSrcweir 	uno::Sequence < ::rtl::OUString > aComponentNames = GetPropertyNames(sEntryNames);
280cdf0e10cSrcweir 	::rtl::OUString sDisplayName(RTL_CONSTASCII_USTRINGPARAM("/DisplayName"));
281cdf0e10cSrcweir 	::rtl::OUString* pIter = aComponentNames.getArray();
282cdf0e10cSrcweir 	::rtl::OUString* pEnd  = pIter + aComponentNames.getLength();
283cdf0e10cSrcweir 	for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
284cdf0e10cSrcweir 	{
285cdf0e10cSrcweir 		uno::Sequence < ::rtl::OUString > aComponentDisplayNames(1);
286cdf0e10cSrcweir 		aComponentDisplayNames[0] = *pIter;
287cdf0e10cSrcweir 		aComponentDisplayNames[0] += sDisplayName;
288cdf0e10cSrcweir 		uno::Sequence< uno::Any > aComponentDisplayNamesValue = GetProperties( aComponentDisplayNames );
289cdf0e10cSrcweir 		::rtl::OUString sComponentDisplayName;
290cdf0e10cSrcweir 		if ( aComponentDisplayNamesValue.getLength() && (aComponentDisplayNamesValue[0] >>= sComponentDisplayName) )
291cdf0e10cSrcweir 		{
292cdf0e10cSrcweir 			sal_Int32 nIndex = 0;
293cdf0e10cSrcweir 			m_aComponentDisplayNames.insert(TDisplayNames::value_type(pIter->getToken(1,'/',nIndex),sComponentDisplayName));
294cdf0e10cSrcweir 		}
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 		*pIter += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/Entries"));
297cdf0e10cSrcweir 		uno::Sequence < ::rtl::OUString > aDisplayNames = GetPropertyNames(*pIter);
298cdf0e10cSrcweir 		lcl_addString(aDisplayNames,sDisplayName);
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 		uno::Sequence< uno::Any > aDisplayNamesValue = GetProperties( aDisplayNames );
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 		const ::rtl::OUString* pDispIter = aDisplayNames.getConstArray();
303cdf0e10cSrcweir 		const ::rtl::OUString* pDispEnd  = pDispIter + aDisplayNames.getLength();
304cdf0e10cSrcweir 		for(sal_Int32 j = 0;pDispIter != pDispEnd;++pDispIter,++j)
305cdf0e10cSrcweir 		{
306cdf0e10cSrcweir 			sal_Int32 nIndex = 0;
307cdf0e10cSrcweir 			pDispIter->getToken(0,'/',nIndex);
308cdf0e10cSrcweir 			::rtl::OUString sName = pDispIter->copy(nIndex);
309cdf0e10cSrcweir 			sName = sName.copy(0,sName.lastIndexOf(sDisplayName));
310cdf0e10cSrcweir 			::rtl::OUString sCurrentDisplayName;
311cdf0e10cSrcweir 			aDisplayNamesValue[j] >>= sCurrentDisplayName;
312cdf0e10cSrcweir 			aDisplayNameMap.insert(TDisplayNames::value_type(sName,sCurrentDisplayName));
313cdf0e10cSrcweir 		}
314cdf0e10cSrcweir 	}
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 	// load color settings
317cdf0e10cSrcweir     rtl::OUString sScheme(rScheme);
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     if(!sScheme.getLength())
320cdf0e10cSrcweir     {
321cdf0e10cSrcweir         //detect current scheme name
322cdf0e10cSrcweir         uno::Sequence < ::rtl::OUString > aCurrent(1);
323cdf0e10cSrcweir 		aCurrent.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/CurrentColorScheme"));
324cdf0e10cSrcweir         uno::Sequence< uno::Any > aCurrentVal = GetProperties( aCurrent );
325cdf0e10cSrcweir         aCurrentVal.getConstArray()[0] >>= sScheme;
326cdf0e10cSrcweir     } // if(!sScheme.getLength())
327cdf0e10cSrcweir 
328cdf0e10cSrcweir     m_sLoadedScheme = sScheme;
329cdf0e10cSrcweir 	::rtl::OUString sBase(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/ColorSchemes/"));
330cdf0e10cSrcweir 	sBase += sScheme;
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 	sal_Bool bFound = ExistsScheme(sScheme);
333cdf0e10cSrcweir 	if ( bFound )
334cdf0e10cSrcweir 	{
335cdf0e10cSrcweir 		aComponentNames = GetPropertyNames(sBase);
336cdf0e10cSrcweir 		FillComponentColors(aComponentNames,aDisplayNameMap);
337cdf0e10cSrcweir 	} // if ( bFound )
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 	if ( !m_sLoadedScheme.getLength() )
340cdf0e10cSrcweir 		m_sLoadedScheme = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("default"));
341cdf0e10cSrcweir 
342cdf0e10cSrcweir 	if ( !sScheme.equalsAscii("default") )
343cdf0e10cSrcweir 	{
344cdf0e10cSrcweir 		::rtl::OUString sDefault(RTL_CONSTASCII_USTRINGPARAM("default"));
345cdf0e10cSrcweir 		if ( ExistsScheme(sDefault) )
346cdf0e10cSrcweir 		{
347cdf0e10cSrcweir 			::rtl::OUString sBaseDefault(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/ColorSchemes/default"));
348cdf0e10cSrcweir 			aComponentNames = GetPropertyNames(sBaseDefault);
349cdf0e10cSrcweir 			FillComponentColors(aComponentNames,aDisplayNameMap);
350cdf0e10cSrcweir 		}
351cdf0e10cSrcweir 	} // if ( !sScheme.equalsAscii("default") )
352cdf0e10cSrcweir 	if ( !bFound && sScheme.getLength() )
353cdf0e10cSrcweir 	{
354cdf0e10cSrcweir 		AddScheme(sScheme);
355cdf0e10cSrcweir 		CommitCurrentSchemeName();
356cdf0e10cSrcweir 	}
357cdf0e10cSrcweir }
358cdf0e10cSrcweir // -----------------------------------------------------------------------------
FillComponentColors(uno::Sequence<::rtl::OUString> & _rComponents,const TDisplayNames & _rDisplayNames)359cdf0e10cSrcweir void ExtendedColorConfig_Impl::FillComponentColors(uno::Sequence < ::rtl::OUString >& _rComponents,const TDisplayNames& _rDisplayNames)
360cdf0e10cSrcweir {
361cdf0e10cSrcweir 	const ::rtl::OUString sColorEntries(RTL_CONSTASCII_USTRINGPARAM("/Entries"));
362cdf0e10cSrcweir 	::rtl::OUString* pIter = _rComponents.getArray();
363cdf0e10cSrcweir 	::rtl::OUString* pEnd  = pIter + _rComponents.getLength();
364cdf0e10cSrcweir 	for(;pIter != pEnd;++pIter)
365cdf0e10cSrcweir 	{
366cdf0e10cSrcweir 		::rtl::OUString sComponentName = pIter->copy(pIter->lastIndexOf('/')+1);
367cdf0e10cSrcweir 		if ( m_aConfigValues.find(sComponentName) == m_aConfigValues.end() )
368cdf0e10cSrcweir 		{
369cdf0e10cSrcweir 			::rtl::OUString sEntry = *pIter;
370cdf0e10cSrcweir 			sEntry += sColorEntries;
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 			uno::Sequence < ::rtl::OUString > aColorNames = GetPropertyNames(sEntry);
373cdf0e10cSrcweir             uno::Sequence < ::rtl::OUString > aDefaultColorNames = aColorNames;
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 			const ::rtl::OUString sColor(RTL_CONSTASCII_USTRINGPARAM("/Color"));
376cdf0e10cSrcweir             const ::rtl::OUString sDefaultColor(RTL_CONSTASCII_USTRINGPARAM("/DefaultColor"));
377cdf0e10cSrcweir 			lcl_addString(aColorNames,sColor);
378cdf0e10cSrcweir             lcl_addString(aDefaultColorNames,sDefaultColor);
379cdf0e10cSrcweir 			uno::Sequence< uno::Any > aColors = GetProperties( aColorNames );
380cdf0e10cSrcweir 			const uno::Any* pColors = aColors.getConstArray();
381cdf0e10cSrcweir 
382cdf0e10cSrcweir             uno::Sequence< uno::Any > aDefaultColors = GetProperties( aDefaultColorNames );
383cdf0e10cSrcweir             bool bDefaultColorFound = aDefaultColors.getLength() != 0;
384cdf0e10cSrcweir 			const uno::Any* pDefaultColors = aDefaultColors.getConstArray();
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 			::rtl::OUString* pColorIter = aColorNames.getArray();
387cdf0e10cSrcweir 			::rtl::OUString* pColorEnd  = pColorIter + aColorNames.getLength();
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 			m_aConfigValuesPos.push_back(m_aConfigValues.insert(TComponents::value_type(sComponentName,TComponentMapping(TConfigValues(),TMapPos()))).first);
390cdf0e10cSrcweir 			TConfigValues& aConfigValues = (*m_aConfigValuesPos.rbegin())->second.first;
391cdf0e10cSrcweir 			TMapPos& aConfigValuesPos = (*m_aConfigValuesPos.rbegin())->second.second;
392cdf0e10cSrcweir 			for(int i = 0; pColorIter != pColorEnd; ++pColorIter ,++i)
393cdf0e10cSrcweir 			{
394cdf0e10cSrcweir 				if ( aConfigValues.find(*pColorIter) == aConfigValues.end() )
395cdf0e10cSrcweir 				{
396cdf0e10cSrcweir 					sal_Int32 nIndex = 0;
397cdf0e10cSrcweir 					pColorIter->getToken(2,'/',nIndex);
398cdf0e10cSrcweir                     ::rtl::OUString sName(pColorIter->copy(nIndex)),sDisplayName;
399cdf0e10cSrcweir 					::rtl::OUString sTemp = sName.copy(0,sName.lastIndexOf(sColor));
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 					TDisplayNames::const_iterator aFind = _rDisplayNames.find(sTemp);
402cdf0e10cSrcweir 					nIndex = 0;
403cdf0e10cSrcweir 					sName = sName.getToken(2,'/',nIndex);
404cdf0e10cSrcweir 					OSL_ENSURE(aFind != _rDisplayNames.end(),"DisplayName is not in EntryNames config list!");
405cdf0e10cSrcweir 					if ( aFind != _rDisplayNames.end() )
406cdf0e10cSrcweir 						sDisplayName = aFind->second;
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 					OSL_ENSURE(pColors[i].hasValue(),"Color config entry has NIL as color value set!");
409cdf0e10cSrcweir                     OSL_ENSURE(pDefaultColors[i].hasValue(),"Color config entry has NIL as color value set!");
410cdf0e10cSrcweir                     sal_Int32 nColor = 0,nDefaultColor = 0;
411cdf0e10cSrcweir 					pColors[i] >>= nColor;
412cdf0e10cSrcweir                     if ( bDefaultColorFound )
413cdf0e10cSrcweir                         pDefaultColors[i] >>= nDefaultColor;
414cdf0e10cSrcweir                     else
415cdf0e10cSrcweir                         nDefaultColor = nColor;
416cdf0e10cSrcweir                     ExtendedColorConfigValue aValue(sName,sDisplayName,nColor,nDefaultColor);
417cdf0e10cSrcweir 					aConfigValuesPos.push_back(aConfigValues.insert(TConfigValues::value_type(sName,aValue)).first);
418cdf0e10cSrcweir 				}
419cdf0e10cSrcweir 			} // for(int i = 0; pColorIter != pColorEnd; ++pColorIter ,++i)
420cdf0e10cSrcweir 		}
421cdf0e10cSrcweir 	}
422cdf0e10cSrcweir }
423cdf0e10cSrcweir /* -----------------------------22.03.2002 14:38------------------------------
424cdf0e10cSrcweir 
425cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
Notify(const uno::Sequence<OUString> &)426cdf0e10cSrcweir void    ExtendedColorConfig_Impl::Notify( const uno::Sequence<OUString>& /*rPropertyNames*/)
427cdf0e10cSrcweir {
428cdf0e10cSrcweir     //loading via notification always uses the default setting
429cdf0e10cSrcweir     Load(::rtl::OUString());
430cdf0e10cSrcweir 
431cdf0e10cSrcweir     vos::OGuard aVclGuard( Application::GetSolarMutex() );
432cdf0e10cSrcweir 
433cdf0e10cSrcweir     if(m_bLockBroadcast)
434cdf0e10cSrcweir 	{
435cdf0e10cSrcweir         m_bBroadcastWhenUnlocked = sal_True;
436cdf0e10cSrcweir 	}
437cdf0e10cSrcweir     else
438cdf0e10cSrcweir         Broadcast(SfxSimpleHint(SFX_HINT_COLORS_CHANGED));
439cdf0e10cSrcweir }
440cdf0e10cSrcweir /* -----------------------------22.03.2002 14:38------------------------------
441cdf0e10cSrcweir 
442cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
Commit()443cdf0e10cSrcweir void ExtendedColorConfig_Impl::Commit()
444cdf0e10cSrcweir {
445cdf0e10cSrcweir 	if ( !m_sLoadedScheme.getLength() )
446cdf0e10cSrcweir 		return;
447cdf0e10cSrcweir 	const ::rtl::OUString sColorEntries(RTL_CONSTASCII_USTRINGPARAM("Entries"));
448cdf0e10cSrcweir 	const ::rtl::OUString sColor(RTL_CONSTASCII_USTRINGPARAM("/Color"));
449cdf0e10cSrcweir     const ::rtl::OUString sDefaultColor(RTL_CONSTASCII_USTRINGPARAM("/DefaultColor"));
450cdf0e10cSrcweir 	::rtl::OUString sBase(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/ColorSchemes/"));
451cdf0e10cSrcweir 	const ::rtl::OUString s_sSep(RTL_CONSTASCII_USTRINGPARAM("/"));
452cdf0e10cSrcweir 	sBase += m_sLoadedScheme;
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 	TComponents::iterator aIter = m_aConfigValues.begin();
455cdf0e10cSrcweir 	TComponents::iterator aEnd = m_aConfigValues.end();
456cdf0e10cSrcweir     for( ;aIter != aEnd;++aIter )
457cdf0e10cSrcweir 	{
458cdf0e10cSrcweir 		::rtl::OUString sEntry = aIter->first;
459cdf0e10cSrcweir 		sEntry += sColorEntries;
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 		if ( ConfigItem::AddNode(sBase, aIter->first) )
462cdf0e10cSrcweir 		{
463cdf0e10cSrcweir 			rtl::OUString sNode = sBase;
464cdf0e10cSrcweir 			sNode += s_sSep;
465cdf0e10cSrcweir 			sNode += aIter->first;
466cdf0e10cSrcweir 			//ConfigItem::AddNode(sNode, sColorEntries);
467cdf0e10cSrcweir 			sNode += s_sSep;
468cdf0e10cSrcweir 			sNode += sColorEntries;
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 			uno::Sequence < beans::PropertyValue > aPropValues(aIter->second.first.size());
471cdf0e10cSrcweir 			beans::PropertyValue* pPropValues = aPropValues.getArray();
472cdf0e10cSrcweir 			TConfigValues::iterator aConIter = aIter->second.first.begin();
473cdf0e10cSrcweir 			TConfigValues::iterator aConEnd  = aIter->second.first.end();
474cdf0e10cSrcweir 			for (; aConIter != aConEnd; ++aConIter,++pPropValues)
475cdf0e10cSrcweir 			{
476cdf0e10cSrcweir 				pPropValues->Name = sNode + s_sSep + aConIter->first;
477cdf0e10cSrcweir 				ConfigItem::AddNode(sNode, aConIter->first);
478cdf0e10cSrcweir 				pPropValues->Name += sColor;
479cdf0e10cSrcweir 				pPropValues->Value <<= aConIter->second.getColor();
480cdf0e10cSrcweir                 // the default color will never be changed
481cdf0e10cSrcweir 			}
482cdf0e10cSrcweir 			::rtl::OUString s(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/ColorSchemes"));
483cdf0e10cSrcweir 			SetSetProperties(s, aPropValues);
484cdf0e10cSrcweir 		}
485cdf0e10cSrcweir 	}
486cdf0e10cSrcweir 
487cdf0e10cSrcweir     CommitCurrentSchemeName();
488cdf0e10cSrcweir }
489cdf0e10cSrcweir /* -----------------11.12.2002 10:42-----------------
490cdf0e10cSrcweir  *
491cdf0e10cSrcweir  * --------------------------------------------------*/
CommitCurrentSchemeName()492cdf0e10cSrcweir void ExtendedColorConfig_Impl::CommitCurrentSchemeName()
493cdf0e10cSrcweir {
494cdf0e10cSrcweir     //save current scheme name
495cdf0e10cSrcweir     uno::Sequence < ::rtl::OUString > aCurrent(1);
496cdf0e10cSrcweir     aCurrent.getArray()[0] = C2U("ExtendedColorScheme/CurrentColorScheme");
497cdf0e10cSrcweir     uno::Sequence< uno::Any > aCurrentVal(1);
498cdf0e10cSrcweir     aCurrentVal.getArray()[0] <<= m_sLoadedScheme;
499cdf0e10cSrcweir     PutProperties(aCurrent, aCurrentVal);
500cdf0e10cSrcweir }
501cdf0e10cSrcweir // -----------------------------------------------------------------------------
ExistsScheme(const::rtl::OUString & _sSchemeName)502cdf0e10cSrcweir sal_Bool ExtendedColorConfig_Impl::ExistsScheme(const ::rtl::OUString& _sSchemeName)
503cdf0e10cSrcweir {
504cdf0e10cSrcweir 	::rtl::OUString sBase(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/ColorSchemes"));
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 	uno::Sequence < ::rtl::OUString > aComponentNames = GetPropertyNames(sBase);
507cdf0e10cSrcweir 	sBase += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + _sSchemeName;
508cdf0e10cSrcweir 	const ::rtl::OUString* pCompIter = aComponentNames.getConstArray();
509cdf0e10cSrcweir 	const ::rtl::OUString* pCompEnd	 = pCompIter + aComponentNames.getLength();
510cdf0e10cSrcweir 	for(;pCompIter != pCompEnd && *pCompIter != sBase;++pCompIter)
511cdf0e10cSrcweir 		;
512cdf0e10cSrcweir 	return pCompIter != pCompEnd;
513cdf0e10cSrcweir }
514cdf0e10cSrcweir // -----------------------------------------------------------------------------
515cdf0e10cSrcweir /* -----------------------------25.03.2002 12:19------------------------------
516cdf0e10cSrcweir 
517cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
SetColorConfigValue(const::rtl::OUString & _sName,const ExtendedColorConfigValue & rValue)518cdf0e10cSrcweir void ExtendedColorConfig_Impl::SetColorConfigValue(const ::rtl::OUString& _sName, const ExtendedColorConfigValue& rValue )
519cdf0e10cSrcweir {
520cdf0e10cSrcweir 	TComponents::iterator aFind = m_aConfigValues.find(_sName);
521cdf0e10cSrcweir     if ( aFind != m_aConfigValues.end() )
522cdf0e10cSrcweir     {
523cdf0e10cSrcweir 		TConfigValues::iterator aFind2 = aFind->second.first.find(rValue.getName());
524cdf0e10cSrcweir 		if ( aFind2 != aFind->second.first.end() )
525cdf0e10cSrcweir 			aFind2->second = rValue;
526cdf0e10cSrcweir         SetModified();
527cdf0e10cSrcweir     }
528cdf0e10cSrcweir }
529cdf0e10cSrcweir /* -----------------------------25.03.2002 15:22------------------------------
530cdf0e10cSrcweir 
531cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
GetSchemeNames()532cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> ExtendedColorConfig_Impl::GetSchemeNames()
533cdf0e10cSrcweir {
534cdf0e10cSrcweir     return GetNodeNames(C2U("ExtendedColorScheme/ColorSchemes"));
535cdf0e10cSrcweir }
536cdf0e10cSrcweir /* -----------------------------09.04.2002 17:19------------------------------
537cdf0e10cSrcweir 
538cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
AddScheme(const rtl::OUString & rScheme)539cdf0e10cSrcweir sal_Bool ExtendedColorConfig_Impl::AddScheme(const rtl::OUString& rScheme)
540cdf0e10cSrcweir {
541cdf0e10cSrcweir     if(ConfigItem::AddNode(C2U("ExtendedColorScheme/ColorSchemes"), rScheme))
542cdf0e10cSrcweir     {
543cdf0e10cSrcweir         m_sLoadedScheme = rScheme;
544cdf0e10cSrcweir         Commit();
545cdf0e10cSrcweir         return sal_True;
546cdf0e10cSrcweir     }
547cdf0e10cSrcweir     return sal_False;
548cdf0e10cSrcweir }
549cdf0e10cSrcweir /* -----------------------------09.04.2002 17:19------------------------------
550cdf0e10cSrcweir 
551cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
RemoveScheme(const rtl::OUString & rScheme)552cdf0e10cSrcweir sal_Bool ExtendedColorConfig_Impl::RemoveScheme(const rtl::OUString& rScheme)
553cdf0e10cSrcweir {
554cdf0e10cSrcweir     uno::Sequence< rtl::OUString > aElements(1);
555cdf0e10cSrcweir     aElements.getArray()[0] = rScheme;
556cdf0e10cSrcweir     return ClearNodeElements(C2U("ExtendedColorScheme/ColorSchemes"), aElements);
557cdf0e10cSrcweir }
558cdf0e10cSrcweir /* -----------------------------2002/06/20 13:03------------------------------
559cdf0e10cSrcweir 
560cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
SettingsChanged()561cdf0e10cSrcweir void ExtendedColorConfig_Impl::SettingsChanged()
562cdf0e10cSrcweir {
563cdf0e10cSrcweir     vos::OGuard aVclGuard( Application::GetSolarMutex() );
564cdf0e10cSrcweir 
565cdf0e10cSrcweir     Broadcast( SfxSimpleHint( SFX_HINT_COLORS_CHANGED ) );
566cdf0e10cSrcweir }
567cdf0e10cSrcweir /* -----------------11.12.2002 09:21-----------------
568cdf0e10cSrcweir  *
569cdf0e10cSrcweir  * --------------------------------------------------*/
LockBroadcast()570cdf0e10cSrcweir void ExtendedColorConfig_Impl::LockBroadcast()
571cdf0e10cSrcweir {
572cdf0e10cSrcweir     m_bLockBroadcast = sal_True;
573cdf0e10cSrcweir }
574cdf0e10cSrcweir /* -----------------11.12.2002 09:21-----------------
575cdf0e10cSrcweir  *
576cdf0e10cSrcweir  * --------------------------------------------------*/
UnlockBroadcast()577cdf0e10cSrcweir void ExtendedColorConfig_Impl::UnlockBroadcast()
578cdf0e10cSrcweir {
579cdf0e10cSrcweir     if ( m_bBroadcastWhenUnlocked )
580cdf0e10cSrcweir     {
581cdf0e10cSrcweir         m_bBroadcastWhenUnlocked = ExtendedColorConfig::m_pImpl != NULL;
582cdf0e10cSrcweir     	if ( m_bBroadcastWhenUnlocked )
583cdf0e10cSrcweir 		{
584cdf0e10cSrcweir 			if ( ExtendedColorConfig::m_pImpl->IsEnableBroadcast() )
585cdf0e10cSrcweir 			{
586cdf0e10cSrcweir 				m_bBroadcastWhenUnlocked = sal_False;
587cdf0e10cSrcweir 				ExtendedColorConfig::m_pImpl->Broadcast(SfxSimpleHint(SFX_HINT_COLORS_CHANGED));
588cdf0e10cSrcweir 			}
589cdf0e10cSrcweir 		}
590cdf0e10cSrcweir     }
591cdf0e10cSrcweir     m_bLockBroadcast = sal_False;
592cdf0e10cSrcweir }
593cdf0e10cSrcweir /* -----------------------------2002/08/16 12:07 -----------------------------
594cdf0e10cSrcweir    #100822#
595cdf0e10cSrcweir  --------------------------------------------------------------------------- */
IMPL_LINK(ExtendedColorConfig_Impl,DataChangedEventListener,VclWindowEvent *,pEvent)596cdf0e10cSrcweir IMPL_LINK( ExtendedColorConfig_Impl, DataChangedEventListener, VclWindowEvent*, pEvent )
597cdf0e10cSrcweir {
598cdf0e10cSrcweir 	if ( pEvent->GetId() == VCLEVENT_APPLICATION_DATACHANGED )
599cdf0e10cSrcweir 	{
600cdf0e10cSrcweir 		DataChangedEvent* pData = (DataChangedEvent*)(pEvent->GetData());
601cdf0e10cSrcweir 		if ( (pData->GetType() == DATACHANGED_SETTINGS) &&
602cdf0e10cSrcweir     	     (pData->GetFlags() & SETTINGS_STYLE) )
603cdf0e10cSrcweir 	    {
604cdf0e10cSrcweir 		    SettingsChanged();
605cdf0e10cSrcweir 			return 1L;
606cdf0e10cSrcweir     	} else
607cdf0e10cSrcweir     		return 0L;
608cdf0e10cSrcweir 	} else
609cdf0e10cSrcweir     	return 0L;
610cdf0e10cSrcweir }
611cdf0e10cSrcweir 
612cdf0e10cSrcweir // ---------------------------------------------------------------------------
613cdf0e10cSrcweir 
614cdf0e10cSrcweir // ---------------------------------------------------------------------------
615cdf0e10cSrcweir 
ExtendedColorConfig()616cdf0e10cSrcweir ExtendedColorConfig::ExtendedColorConfig()
617cdf0e10cSrcweir {
618cdf0e10cSrcweir     ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
619cdf0e10cSrcweir     if ( !m_pImpl )
620cdf0e10cSrcweir         m_pImpl = new ExtendedColorConfig_Impl;
621cdf0e10cSrcweir     ++nExtendedColorRefCount_Impl;
622cdf0e10cSrcweir     StartListening( *m_pImpl);
623cdf0e10cSrcweir }
624cdf0e10cSrcweir /* -----------------------------16.01.01 15:36--------------------------------
625cdf0e10cSrcweir 
626cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
~ExtendedColorConfig()627cdf0e10cSrcweir ExtendedColorConfig::~ExtendedColorConfig()
628cdf0e10cSrcweir {
629cdf0e10cSrcweir     ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
630cdf0e10cSrcweir     EndListening( *m_pImpl);
631cdf0e10cSrcweir     if(!--nExtendedColorRefCount_Impl)
632cdf0e10cSrcweir     {
633cdf0e10cSrcweir         delete m_pImpl;
634cdf0e10cSrcweir         m_pImpl = 0;
635cdf0e10cSrcweir     }
636cdf0e10cSrcweir }
637cdf0e10cSrcweir /* -----------------------------11.04.2002 11:49------------------------------
638cdf0e10cSrcweir 
639cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
GetColorValue(const::rtl::OUString & _sComponentName,const::rtl::OUString & _sName) const640cdf0e10cSrcweir ExtendedColorConfigValue ExtendedColorConfig::GetColorValue(const ::rtl::OUString& _sComponentName,const ::rtl::OUString& _sName)const
641cdf0e10cSrcweir {
642cdf0e10cSrcweir     return m_pImpl->GetColorConfigValue(_sComponentName,_sName);
643cdf0e10cSrcweir }
644cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentCount() const645cdf0e10cSrcweir sal_Int32 ExtendedColorConfig::GetComponentCount() const
646cdf0e10cSrcweir {
647cdf0e10cSrcweir 	return m_pImpl->GetComponentCount();
648cdf0e10cSrcweir }
649cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentColorCount(const::rtl::OUString & _sName) const650cdf0e10cSrcweir sal_Int32 ExtendedColorConfig::GetComponentColorCount(const ::rtl::OUString& _sName) const
651cdf0e10cSrcweir {
652cdf0e10cSrcweir 	return m_pImpl->GetComponentColorCount(_sName);
653cdf0e10cSrcweir }
654cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentColorConfigValue(const::rtl::OUString & _sName,sal_uInt32 _nPos) const655cdf0e10cSrcweir ExtendedColorConfigValue ExtendedColorConfig::GetComponentColorConfigValue(const ::rtl::OUString& _sName,sal_uInt32 _nPos) const
656cdf0e10cSrcweir {
657cdf0e10cSrcweir 	return m_pImpl->GetComponentColorConfigValue(_sName,_nPos);
658cdf0e10cSrcweir }
659cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentName(sal_uInt32 _nPos) const660cdf0e10cSrcweir ::rtl::OUString ExtendedColorConfig::GetComponentName(sal_uInt32 _nPos) const
661cdf0e10cSrcweir {
662cdf0e10cSrcweir 	return m_pImpl->GetComponentName(_nPos);
663cdf0e10cSrcweir }
664cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentDisplayName(const::rtl::OUString & _sComponentName) const665cdf0e10cSrcweir ::rtl::OUString ExtendedColorConfig::GetComponentDisplayName(const ::rtl::OUString& _sComponentName) const
666cdf0e10cSrcweir {
667cdf0e10cSrcweir 	return m_pImpl->GetComponentDisplayName(_sComponentName);
668cdf0e10cSrcweir }
669cdf0e10cSrcweir // -----------------------------------------------------------------------------
670cdf0e10cSrcweir /* -----------------------------12.04.2002 09:25------------------------------
671cdf0e10cSrcweir 
672cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
Notify(SfxBroadcaster &,const SfxHint & rHint)673cdf0e10cSrcweir void ExtendedColorConfig::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir     vos::OGuard aVclGuard( Application::GetSolarMutex() );
676cdf0e10cSrcweir 
677cdf0e10cSrcweir     Broadcast( rHint );
678cdf0e10cSrcweir }
679cdf0e10cSrcweir /* -----------------------------25.03.2002 12:01------------------------------
680cdf0e10cSrcweir 
681cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
EditableExtendedColorConfig()682cdf0e10cSrcweir EditableExtendedColorConfig::EditableExtendedColorConfig() :
683cdf0e10cSrcweir     m_pImpl(new ExtendedColorConfig_Impl),
684cdf0e10cSrcweir 	m_bModified(sal_False)
685cdf0e10cSrcweir {
686cdf0e10cSrcweir     m_pImpl->LockBroadcast();
687cdf0e10cSrcweir }
688cdf0e10cSrcweir /*-- 25.03.2002 12:03:08---------------------------------------------------
689cdf0e10cSrcweir 
690cdf0e10cSrcweir   -----------------------------------------------------------------------*/
~EditableExtendedColorConfig()691cdf0e10cSrcweir EditableExtendedColorConfig::~EditableExtendedColorConfig()
692cdf0e10cSrcweir {
693cdf0e10cSrcweir     m_pImpl->UnlockBroadcast();
694cdf0e10cSrcweir     if(m_bModified)
695cdf0e10cSrcweir 		m_pImpl->SetModified();
696cdf0e10cSrcweir     if(m_pImpl->IsModified())
697cdf0e10cSrcweir         m_pImpl->Commit();
698cdf0e10cSrcweir     delete m_pImpl;
699cdf0e10cSrcweir }
700cdf0e10cSrcweir 
701cdf0e10cSrcweir /*-- 25.03.2002 12:03:15---------------------------------------------------
702cdf0e10cSrcweir 
703cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetSchemeNames() const704cdf0e10cSrcweir uno::Sequence< ::rtl::OUString >  EditableExtendedColorConfig::GetSchemeNames() const
705cdf0e10cSrcweir {
706cdf0e10cSrcweir     return m_pImpl->GetSchemeNames();
707cdf0e10cSrcweir }
708cdf0e10cSrcweir /*-- 25.03.2002 12:03:16---------------------------------------------------
709cdf0e10cSrcweir 
710cdf0e10cSrcweir   -----------------------------------------------------------------------*/
DeleteScheme(const::rtl::OUString & rScheme)711cdf0e10cSrcweir void EditableExtendedColorConfig::DeleteScheme(const ::rtl::OUString& rScheme )
712cdf0e10cSrcweir {
713cdf0e10cSrcweir     m_pImpl->RemoveScheme(rScheme);
714cdf0e10cSrcweir }
715cdf0e10cSrcweir /*-- 25.03.2002 12:03:16---------------------------------------------------
716cdf0e10cSrcweir 
717cdf0e10cSrcweir   -----------------------------------------------------------------------*/
AddScheme(const::rtl::OUString & rScheme)718cdf0e10cSrcweir void EditableExtendedColorConfig::AddScheme(const ::rtl::OUString& rScheme )
719cdf0e10cSrcweir {
720cdf0e10cSrcweir     m_pImpl->AddScheme(rScheme);
721cdf0e10cSrcweir }
722cdf0e10cSrcweir /*-- 25.03.2002 12:03:16---------------------------------------------------
723cdf0e10cSrcweir 
724cdf0e10cSrcweir   -----------------------------------------------------------------------*/
LoadScheme(const::rtl::OUString & rScheme)725cdf0e10cSrcweir sal_Bool EditableExtendedColorConfig::LoadScheme(const ::rtl::OUString& rScheme )
726cdf0e10cSrcweir {
727cdf0e10cSrcweir     if(m_bModified)
728cdf0e10cSrcweir 		m_pImpl->SetModified();
729cdf0e10cSrcweir 	if(m_pImpl->IsModified())
730cdf0e10cSrcweir 		m_pImpl->Commit();
731cdf0e10cSrcweir 	m_bModified = sal_False;
732cdf0e10cSrcweir 	m_pImpl->Load(rScheme);
733cdf0e10cSrcweir     //the name of the loaded scheme has to be committed separately
734cdf0e10cSrcweir     m_pImpl->CommitCurrentSchemeName();
735cdf0e10cSrcweir 	return sal_True;
736cdf0e10cSrcweir }
737cdf0e10cSrcweir /*-- 25.03.2002 12:03:16---------------------------------------------------
738cdf0e10cSrcweir 
739cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetCurrentSchemeName() const740cdf0e10cSrcweir const ::rtl::OUString& EditableExtendedColorConfig::GetCurrentSchemeName()const
741cdf0e10cSrcweir {
742cdf0e10cSrcweir     return m_pImpl->GetLoadedScheme();
743cdf0e10cSrcweir }
744cdf0e10cSrcweir /* -----------------11.12.2002 10:56-----------------
745cdf0e10cSrcweir  *  changes the name of the current scheme but doesn't load it!
746cdf0e10cSrcweir  * --------------------------------------------------*/
SetCurrentSchemeName(const::rtl::OUString & rScheme)747cdf0e10cSrcweir void EditableExtendedColorConfig::SetCurrentSchemeName(const ::rtl::OUString& rScheme)
748cdf0e10cSrcweir {
749cdf0e10cSrcweir     m_pImpl->SetCurrentSchemeName(rScheme);
750cdf0e10cSrcweir     m_pImpl->CommitCurrentSchemeName();
751cdf0e10cSrcweir }
752cdf0e10cSrcweir /*-- 25.03.2002 12:03:17---------------------------------------------------
753cdf0e10cSrcweir 
754cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetColorValue(const::rtl::OUString & _sComponentName,const::rtl::OUString & _sName) const755cdf0e10cSrcweir ExtendedColorConfigValue EditableExtendedColorConfig::GetColorValue(const ::rtl::OUString& _sComponentName,
756cdf0e10cSrcweir     const ::rtl::OUString& _sName)const
757cdf0e10cSrcweir {
758cdf0e10cSrcweir     return m_pImpl->GetColorConfigValue(_sComponentName,_sName);
759cdf0e10cSrcweir }
760cdf0e10cSrcweir /*-- 25.03.2002 12:03:17---------------------------------------------------
761cdf0e10cSrcweir 
762cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetColorValue(const::rtl::OUString & _sName,const ExtendedColorConfigValue & rValue)763cdf0e10cSrcweir void EditableExtendedColorConfig::SetColorValue(
764cdf0e10cSrcweir     const ::rtl::OUString& _sName, const ExtendedColorConfigValue& rValue)
765cdf0e10cSrcweir {
766cdf0e10cSrcweir     m_pImpl->SetColorConfigValue(_sName, rValue);
767cdf0e10cSrcweir 	m_pImpl->ClearModified();
768cdf0e10cSrcweir 	m_bModified = sal_True;
769cdf0e10cSrcweir }
770cdf0e10cSrcweir /* -----------------------------10.04.2002 13:22------------------------------
771cdf0e10cSrcweir 
772cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
SetModified()773cdf0e10cSrcweir void EditableExtendedColorConfig::SetModified()
774cdf0e10cSrcweir {
775cdf0e10cSrcweir     m_bModified = sal_True;
776cdf0e10cSrcweir }
777cdf0e10cSrcweir /* -----------------15.10.2002 14:51-----------------
778cdf0e10cSrcweir  *
779cdf0e10cSrcweir  * --------------------------------------------------*/
Commit()780cdf0e10cSrcweir void EditableExtendedColorConfig::Commit()
781cdf0e10cSrcweir {
782cdf0e10cSrcweir     if(m_bModified)
783cdf0e10cSrcweir         m_pImpl->SetModified();
784cdf0e10cSrcweir     if(m_pImpl->IsModified())
785cdf0e10cSrcweir         m_pImpl->Commit();
786cdf0e10cSrcweir     m_bModified = sal_False;
787cdf0e10cSrcweir }
788cdf0e10cSrcweir // -----------------------------------------------------------------------------
DisableBroadcast()789cdf0e10cSrcweir void EditableExtendedColorConfig::DisableBroadcast()
790cdf0e10cSrcweir {
791cdf0e10cSrcweir 	m_pImpl->DisableBroadcast();
792cdf0e10cSrcweir }
793cdf0e10cSrcweir // -----------------------------------------------------------------------------
EnableBroadcast()794cdf0e10cSrcweir void EditableExtendedColorConfig::EnableBroadcast()
795cdf0e10cSrcweir {
796cdf0e10cSrcweir 	m_pImpl->EnableBroadcast();
797cdf0e10cSrcweir }
798cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentCount() const799cdf0e10cSrcweir sal_Int32 EditableExtendedColorConfig::GetComponentCount() const
800cdf0e10cSrcweir {
801cdf0e10cSrcweir 	return m_pImpl->GetComponentCount();
802cdf0e10cSrcweir }
803cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentColorCount(const::rtl::OUString & _sName) const804cdf0e10cSrcweir sal_Int32 EditableExtendedColorConfig::GetComponentColorCount(const ::rtl::OUString& _sName) const
805cdf0e10cSrcweir {
806cdf0e10cSrcweir 	return m_pImpl->GetComponentColorCount(_sName);
807cdf0e10cSrcweir }
808cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentColorConfigValue(const::rtl::OUString & _sName,sal_uInt32 _nPos) const809cdf0e10cSrcweir ExtendedColorConfigValue EditableExtendedColorConfig::GetComponentColorConfigValue(const ::rtl::OUString& _sName,sal_uInt32 _nPos) const
810cdf0e10cSrcweir {
811cdf0e10cSrcweir 	return m_pImpl->GetComponentColorConfigValue(_sName,_nPos);
812cdf0e10cSrcweir }
813cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentName(sal_uInt32 _nPos) const814cdf0e10cSrcweir ::rtl::OUString EditableExtendedColorConfig::GetComponentName(sal_uInt32 _nPos) const
815cdf0e10cSrcweir {
816cdf0e10cSrcweir 	return m_pImpl->GetComponentName(_nPos);
817cdf0e10cSrcweir }
818cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetComponentDisplayName(const::rtl::OUString & _sComponentName) const819cdf0e10cSrcweir ::rtl::OUString EditableExtendedColorConfig::GetComponentDisplayName(const ::rtl::OUString& _sComponentName) const
820cdf0e10cSrcweir {
821cdf0e10cSrcweir 	return m_pImpl->GetComponentDisplayName(_sComponentName);
822cdf0e10cSrcweir }
823cdf0e10cSrcweir }//namespace svtools
824