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