xref: /aoo42x/main/vcl/source/app/settings.cxx (revision 5e2fdb1b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_vcl.hxx"
26 
27 #include "tools/debug.hxx"
28 
29 #include "i18npool/mslangid.hxx"
30 
31 #include "vcl/svapp.hxx"
32 #include "vcl/event.hxx"
33 #include "vcl/settings.hxx"
34 #include "vcl/i18nhelp.hxx"
35 #include "vcl/configsettings.hxx"
36 #include "vcl/gradient.hxx"
37 #include "vcl/unohelp.hxx"
38 #include "vcl/bitmapex.hxx"
39 
40 #include "unotools/fontcfg.hxx"
41 #include "unotools/localedatawrapper.hxx"
42 #include "unotools/collatorwrapper.hxx"
43 #include "unotools/configmgr.hxx"
44 #include "unotools/confignode.hxx"
45 #include "unotools/syslocaleoptions.hxx"
46 
47 #ifdef WNT
48 #include "tools/prewin.h"
49 #include <windows.h>
50 #include "tools/postwin.h"
51 #endif
52 
53 #include "svdata.hxx"
54 #include "impimagetree.hxx"
55 
56 using namespace rtl;
57 
58 // =======================================================================
59 
60 DBG_NAME( AllSettings )
61 
62 // =======================================================================
63 
64 #define STDSYS_STYLE            (STYLE_OPTION_SCROLLARROW |     \
65                                  STYLE_OPTION_SPINARROW |       \
66                                  STYLE_OPTION_SPINUPDOWN |      \
67                                  STYLE_OPTION_NOMNEMONICS)
68 
69 // =======================================================================
70 ImplMachineData::ImplMachineData()
71 {
72     mnRefCount                  = 1;
73     mnOptions                   = 0;
74     mnScreenOptions             = 0;
75     mnPrintOptions              = 0;
76     mnScreenRasterFontDeviation = 0;
77 }
78 
79 // -----------------------------------------------------------------------
80 
81 ImplMachineData::ImplMachineData( const ImplMachineData& rData )
82 {
83     mnRefCount                  = 1;
84     mnOptions                   = rData.mnOptions;
85     mnScreenOptions             = rData.mnScreenOptions;
86     mnPrintOptions              = rData.mnPrintOptions;
87     mnScreenRasterFontDeviation = rData.mnScreenRasterFontDeviation;
88 }
89 
90 // -----------------------------------------------------------------------
91 
92 MachineSettings::MachineSettings()
93 {
94     mpData = new ImplMachineData();
95 }
96 
97 // -----------------------------------------------------------------------
98 
99 MachineSettings::MachineSettings( const MachineSettings& rSet )
100 {
101     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "MachineSettings: RefCount overflow" );
102 
103     // shared Instance Daten uebernehmen und Referenzcounter erhoehen
104     mpData = rSet.mpData;
105     mpData->mnRefCount++;
106 }
107 
108 // -----------------------------------------------------------------------
109 
110 MachineSettings::~MachineSettings()
111 {
112     // Daten loeschen, wenn letzte Referenz
113     if ( mpData->mnRefCount == 1 )
114         delete mpData;
115     else
116         mpData->mnRefCount--;
117 }
118 
119 // -----------------------------------------------------------------------
120 
121 const MachineSettings& MachineSettings::operator =( const MachineSettings& rSet )
122 {
123     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "MachineSettings: RefCount overflow" );
124 
125     // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
126     rSet.mpData->mnRefCount++;
127 
128     // Daten loeschen, wenn letzte Referenz
129     if ( mpData->mnRefCount == 1 )
130         delete mpData;
131     else
132         mpData->mnRefCount--;
133 
134     mpData = rSet.mpData;
135 
136     return *this;
137 }
138 
139 // -----------------------------------------------------------------------
140 
141 void MachineSettings::CopyData()
142 {
143     // Falls noch andere Referenzen bestehen, dann kopieren
144     if ( mpData->mnRefCount != 1 )
145     {
146         mpData->mnRefCount--;
147         mpData = new ImplMachineData( *mpData );
148     }
149 }
150 
151 // -----------------------------------------------------------------------
152 
153 sal_Bool MachineSettings::operator ==( const MachineSettings& rSet ) const
154 {
155     if ( mpData == rSet.mpData )
156         return sal_True;
157 
158     if ( (mpData->mnOptions                     == rSet.mpData->mnOptions)                  &&
159          (mpData->mnScreenOptions               == rSet.mpData->mnScreenOptions)            &&
160          (mpData->mnPrintOptions                == rSet.mpData->mnPrintOptions)             &&
161          (mpData->mnScreenRasterFontDeviation   == rSet.mpData->mnScreenRasterFontDeviation) )
162         return sal_True;
163     else
164         return sal_False;
165 }
166 
167 // =======================================================================
168 
169 ImplMouseData::ImplMouseData()
170 {
171     mnRefCount                  = 1;
172     mnOptions                   = 0;
173     mnDoubleClkTime             = 500;
174     mnDoubleClkWidth            = 2;
175     mnDoubleClkHeight           = 2;
176     mnStartDragWidth            = 2;
177     mnStartDragHeight           = 2;
178     mnStartDragCode             = MOUSE_LEFT;
179     mnDragMoveCode              = 0;
180     mnDragCopyCode              = KEY_MOD1;
181     mnDragLinkCode              = KEY_SHIFT | KEY_MOD1;
182     mnContextMenuCode           = MOUSE_RIGHT;
183     mnContextMenuClicks         = 1;
184     mbContextMenuDown           = sal_True;
185     mnMiddleButtonAction        = MOUSE_MIDDLE_AUTOSCROLL;
186     mnScrollRepeat              = 100;
187     mnButtonStartRepeat         = 370;
188     mnButtonRepeat              = 90;
189     mnActionDelay               = 250;
190     mnMenuDelay                 = 150;
191     mnFollow                    = MOUSE_FOLLOW_MENU | MOUSE_FOLLOW_DDLIST;
192     mnWheelBehavior             = MOUSE_WHEEL_ALWAYS;
193 }
194 
195 // -----------------------------------------------------------------------
196 
197 ImplMouseData::ImplMouseData( const ImplMouseData& rData )
198 {
199     mnRefCount                  = 1;
200     mnOptions                   = rData.mnOptions;
201     mnDoubleClkTime             = rData.mnDoubleClkTime;
202     mnDoubleClkWidth            = rData.mnDoubleClkWidth;
203     mnDoubleClkHeight           = rData.mnDoubleClkHeight;
204     mnStartDragWidth            = rData.mnStartDragWidth;
205     mnStartDragHeight           = rData.mnStartDragHeight;
206     mnStartDragCode             = rData.mnStartDragCode;
207     mnDragMoveCode              = rData.mnDragMoveCode;
208     mnDragCopyCode              = rData.mnDragCopyCode;
209     mnDragLinkCode              = rData.mnDragLinkCode;
210     mnContextMenuCode           = rData.mnContextMenuCode;
211     mnContextMenuClicks         = rData.mnContextMenuClicks;
212     mbContextMenuDown           = rData.mbContextMenuDown;
213     mnMiddleButtonAction        = rData.mnMiddleButtonAction;
214     mnScrollRepeat              = rData.mnScrollRepeat;
215     mnButtonStartRepeat         = rData.mnButtonStartRepeat;
216     mnButtonRepeat              = rData.mnButtonRepeat;
217     mnActionDelay               = rData.mnActionDelay;
218     mnMenuDelay                 = rData.mnMenuDelay;
219     mnFollow                    = rData.mnFollow;
220     mnWheelBehavior             = rData.mnWheelBehavior;
221 }
222 
223 // -----------------------------------------------------------------------
224 
225 MouseSettings::MouseSettings()
226 {
227     mpData = new ImplMouseData();
228 }
229 
230 // -----------------------------------------------------------------------
231 
232 MouseSettings::MouseSettings( const MouseSettings& rSet )
233 {
234     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "MouseSettings: RefCount overflow" );
235 
236     // shared Instance Daten uebernehmen und Referenzcounter erhoehen
237     mpData = rSet.mpData;
238     mpData->mnRefCount++;
239 }
240 
241 // -----------------------------------------------------------------------
242 
243 MouseSettings::~MouseSettings()
244 {
245     // Daten loeschen, wenn letzte Referenz
246     if ( mpData->mnRefCount == 1 )
247         delete mpData;
248     else
249         mpData->mnRefCount--;
250 }
251 
252 // -----------------------------------------------------------------------
253 
254 const MouseSettings& MouseSettings::operator =( const MouseSettings& rSet )
255 {
256     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "MouseSettings: RefCount overflow" );
257 
258     // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
259     rSet.mpData->mnRefCount++;
260 
261     // Daten loeschen, wenn letzte Referenz
262     if ( mpData->mnRefCount == 1 )
263         delete mpData;
264     else
265         mpData->mnRefCount--;
266 
267     mpData = rSet.mpData;
268 
269     return *this;
270 }
271 
272 // -----------------------------------------------------------------------
273 
274 void MouseSettings::CopyData()
275 {
276     // Falls noch andere Referenzen bestehen, dann kopieren
277     if ( mpData->mnRefCount != 1 )
278     {
279         mpData->mnRefCount--;
280         mpData = new ImplMouseData( *mpData );
281     }
282 }
283 
284 // -----------------------------------------------------------------------
285 
286 sal_Bool MouseSettings::operator ==( const MouseSettings& rSet ) const
287 {
288     if ( mpData == rSet.mpData )
289         return sal_True;
290 
291     if ( (mpData->mnOptions             == rSet.mpData->mnOptions)              &&
292          (mpData->mnDoubleClkTime       == rSet.mpData->mnDoubleClkTime)        &&
293          (mpData->mnDoubleClkWidth      == rSet.mpData->mnDoubleClkWidth)       &&
294          (mpData->mnDoubleClkHeight     == rSet.mpData->mnDoubleClkHeight)      &&
295          (mpData->mnStartDragWidth      == rSet.mpData->mnStartDragWidth)       &&
296          (mpData->mnStartDragHeight     == rSet.mpData->mnStartDragHeight)      &&
297          (mpData->mnStartDragCode       == rSet.mpData->mnStartDragCode)        &&
298          (mpData->mnDragMoveCode        == rSet.mpData->mnDragMoveCode)         &&
299          (mpData->mnDragCopyCode        == rSet.mpData->mnDragCopyCode)         &&
300          (mpData->mnDragLinkCode        == rSet.mpData->mnDragLinkCode)         &&
301          (mpData->mnContextMenuCode     == rSet.mpData->mnContextMenuCode)      &&
302          (mpData->mnContextMenuClicks   == rSet.mpData->mnContextMenuClicks)    &&
303          (mpData->mbContextMenuDown     == rSet.mpData->mbContextMenuDown)      &&
304          (mpData->mnMiddleButtonAction  == rSet.mpData->mnMiddleButtonAction)   &&
305          (mpData->mnScrollRepeat        == rSet.mpData->mnScrollRepeat)         &&
306          (mpData->mnButtonStartRepeat   == rSet.mpData->mnButtonStartRepeat)    &&
307          (mpData->mnButtonRepeat        == rSet.mpData->mnButtonRepeat)         &&
308          (mpData->mnActionDelay         == rSet.mpData->mnActionDelay)          &&
309          (mpData->mnMenuDelay           == rSet.mpData->mnMenuDelay)            &&
310          (mpData->mnFollow              == rSet.mpData->mnFollow)               &&
311          (mpData->mnWheelBehavior       == rSet.mpData->mnWheelBehavior ) )
312         return sal_True;
313     else
314         return sal_False;
315 }
316 
317 // =======================================================================
318 
319 ImplKeyboardData::ImplKeyboardData()
320 {
321     mnRefCount                  = 1;
322     mnOptions                   = 0;
323 }
324 
325 // -----------------------------------------------------------------------
326 
327 ImplKeyboardData::ImplKeyboardData( const ImplKeyboardData& rData )
328 {
329     mnRefCount                  = 1;
330     mnOptions                   = rData.mnOptions;
331 }
332 
333 // -----------------------------------------------------------------------
334 
335 KeyboardSettings::KeyboardSettings()
336 {
337     mpData = new ImplKeyboardData();
338 }
339 
340 // -----------------------------------------------------------------------
341 
342 KeyboardSettings::KeyboardSettings( const KeyboardSettings& rSet )
343 {
344     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "KeyboardSettings: RefCount overflow" );
345 
346     // shared Instance Daten uebernehmen und Referenzcounter erhoehen
347     mpData = rSet.mpData;
348     mpData->mnRefCount++;
349 }
350 
351 // -----------------------------------------------------------------------
352 
353 KeyboardSettings::~KeyboardSettings()
354 {
355     // Daten loeschen, wenn letzte Referenz
356     if ( mpData->mnRefCount == 1 )
357         delete mpData;
358     else
359         mpData->mnRefCount--;
360 }
361 
362 // -----------------------------------------------------------------------
363 
364 const KeyboardSettings& KeyboardSettings::operator =( const KeyboardSettings& rSet )
365 {
366     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "KeyboardSettings: RefCount overflow" );
367 
368     // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
369     rSet.mpData->mnRefCount++;
370 
371     // Daten loeschen, wenn letzte Referenz
372     if ( mpData->mnRefCount == 1 )
373         delete mpData;
374     else
375         mpData->mnRefCount--;
376 
377     mpData = rSet.mpData;
378 
379     return *this;
380 }
381 
382 // -----------------------------------------------------------------------
383 
384 void KeyboardSettings::CopyData()
385 {
386     // Falls noch andere Referenzen bestehen, dann kopieren
387     if ( mpData->mnRefCount != 1 )
388     {
389         mpData->mnRefCount--;
390         mpData = new ImplKeyboardData( *mpData );
391     }
392 }
393 
394 // -----------------------------------------------------------------------
395 
396 sal_Bool KeyboardSettings::operator ==( const KeyboardSettings& rSet ) const
397 {
398     if ( mpData == rSet.mpData )
399         return sal_True;
400 
401     return (mpData->mnOptions == rSet.mpData->mnOptions);
402 }
403 
404 // =======================================================================
405 
406 ImplStyleData::ImplStyleData()
407 {
408     mnRefCount                  = 1;
409     mnScrollBarSize             = 16;
410     mnMinThumbSize              = 16;
411     mnSplitSize                 = 3;
412     mnSpinSize                  = 16;
413     mnIconHorzSpace             = 50;
414     mnIconVertSpace             = 40;
415     mnAntialiasedMin            = 0;
416     mnCursorSize                = 2;
417     mnCursorBlinkTime           = STYLE_CURSOR_NOBLINKTIME;
418     mnScreenZoom                = 100;
419     mnScreenFontZoom            = 100;
420     mnLogoDisplayTime           = LOGO_DISPLAYTIME_STARTTIME;
421     mnDragFullOptions           = DRAGFULL_OPTION_WINDOWMOVE | DRAGFULL_OPTION_WINDOWSIZE |
422                                   DRAGFULL_OPTION_OBJECTMOVE | DRAGFULL_OPTION_OBJECTSIZE |
423                                   DRAGFULL_OPTION_DOCKING    | DRAGFULL_OPTION_SPLIT      |
424                                   DRAGFULL_OPTION_SCROLL;
425     mnAnimationOptions          = 0;
426     mnSelectionOptions          = 0;
427     mnDisplayOptions            = 0;
428     mnOptions                   = 0;
429     mnAutoMnemonic				= 1;
430     mnToolbarIconSize			= STYLE_TOOLBAR_ICONSIZE_UNKNOWN;
431     mnSymbolsStyle				= STYLE_SYMBOLS_AUTO;
432     mnPreferredSymbolsStyle			= STYLE_SYMBOLS_AUTO;
433     mpFontOptions              = NULL;
434 
435     SetStandardStyles();
436 }
437 
438 // -----------------------------------------------------------------------
439 
440 ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
441     maActiveBorderColor( rData.maActiveBorderColor ),
442     maActiveColor( rData.maActiveColor ),
443     maActiveColor2( rData.maActiveColor2 ),
444     maActiveTextColor( rData.maActiveTextColor ),
445     maButtonTextColor( rData.maButtonTextColor ),
446     maButtonRolloverTextColor( rData.maButtonRolloverTextColor ),
447     maCheckedColor( rData.maCheckedColor ),
448     maDarkShadowColor( rData.maDarkShadowColor ),
449     maDeactiveBorderColor( rData.maDeactiveBorderColor ),
450     maDeactiveColor( rData.maDeactiveColor ),
451     maDeactiveColor2( rData.maDeactiveColor2 ),
452     maDeactiveTextColor( rData.maDeactiveTextColor ),
453     maDialogColor( rData.maDialogColor ),
454     maDialogTextColor( rData.maDialogTextColor ),
455     maDisableColor( rData.maDisableColor ),
456     maFaceColor( rData.maFaceColor ),
457     maFieldColor( rData.maFieldColor ),
458     maFieldTextColor( rData.maFieldTextColor ),
459     maFieldRolloverTextColor( rData.maFieldRolloverTextColor ),
460 	maFontColor( rData.maFontColor ),
461     maGroupTextColor( rData.maGroupTextColor ),
462     maHelpColor( rData.maHelpColor ),
463     maHelpTextColor( rData.maHelpTextColor ),
464     maHighlightColor( rData.maHighlightColor ),
465     maHighlightLinkColor( rData.maHighlightLinkColor ),
466     maHighlightTextColor( rData.maHighlightTextColor ),
467     maInfoTextColor( rData.maInfoTextColor ),
468     maLabelTextColor( rData.maLabelTextColor ),
469     maLightBorderColor( rData.maLightBorderColor ),
470     maLightColor( rData.maLightColor ),
471     maLinkColor( rData.maLinkColor ),
472     maMenuBarColor( rData.maMenuBarColor ),
473     maMenuBorderColor( rData.maMenuBorderColor ),
474     maMenuColor( rData.maMenuColor ),
475     maMenuHighlightColor( rData.maMenuHighlightColor ),
476     maMenuHighlightTextColor( rData.maMenuHighlightTextColor ),
477     maMenuTextColor( rData.maMenuTextColor ),
478     maMenuBarTextColor( rData.maMenuBarTextColor ),
479     maMonoColor( rData.maMonoColor ),
480     maRadioCheckTextColor( rData.maRadioCheckTextColor ),
481     maShadowColor( rData.maShadowColor ),
482     maVisitedLinkColor( rData.maVisitedLinkColor ),
483     maWindowColor( rData.maWindowColor ),
484     maWindowTextColor( rData.maWindowTextColor ),
485     maWorkspaceColor( rData.maWorkspaceColor ),
486     maActiveTabColor( rData.maActiveTabColor ),
487     maInactiveTabColor( rData.maInactiveTabColor ),
488     maAppFont( rData.maAppFont ),
489     maHelpFont( rData.maAppFont ),
490     maTitleFont( rData.maTitleFont ),
491     maFloatTitleFont( rData.maFloatTitleFont ),
492     maMenuFont( rData.maMenuFont ),
493     maToolFont( rData.maToolFont ),
494     maLabelFont( rData.maLabelFont ),
495     maInfoFont( rData.maInfoFont ),
496     maRadioCheckFont( rData.maRadioCheckFont ),
497     maPushButtonFont( rData.maPushButtonFont ),
498     maFieldFont( rData.maFieldFont ),
499     maIconFont( rData.maIconFont ),
500     maGroupFont( rData.maGroupFont ),
501     maWorkspaceGradient( rData.maWorkspaceGradient )
502 {
503     mnRefCount                  = 1;
504     mnBorderSize                = rData.mnBorderSize;
505     mnTitleHeight               = rData.mnTitleHeight;
506     mnFloatTitleHeight          = rData.mnFloatTitleHeight;
507     mnTearOffTitleHeight        = rData.mnTearOffTitleHeight;
508     mnMenuBarHeight             = rData.mnMenuBarHeight;
509     mnScrollBarSize             = rData.mnScrollBarSize;
510     mnMinThumbSize              = rData.mnMinThumbSize;
511     mnSplitSize                 = rData.mnSplitSize;
512     mnSpinSize                  = rData.mnSpinSize;
513     mnIconHorzSpace             = rData.mnIconHorzSpace;
514     mnIconVertSpace             = rData.mnIconVertSpace;
515     mnAntialiasedMin            = rData.mnAntialiasedMin;
516     mnCursorSize                = rData.mnCursorSize;
517     mnCursorBlinkTime           = rData.mnCursorBlinkTime;
518     mnScreenZoom                = rData.mnScreenZoom;
519     mnScreenFontZoom            = rData.mnScreenFontZoom;
520     mnLogoDisplayTime           = rData.mnLogoDisplayTime;
521     mnDragFullOptions           = rData.mnDragFullOptions;
522     mnAnimationOptions          = rData.mnAnimationOptions;
523     mnSelectionOptions          = rData.mnSelectionOptions;
524     mnDisplayOptions            = rData.mnDisplayOptions;
525     mnOptions                   = rData.mnOptions;
526 	mnHighContrast				= rData.mnHighContrast;
527 	mnUseSystemUIFonts			= rData.mnUseSystemUIFonts;
528 	mnUseFlatBorders 			= rData.mnUseFlatBorders;
529 	mnUseFlatMenues 			= rData.mnUseFlatMenues;
530     mnAutoMnemonic				= rData.mnAutoMnemonic;
531     mnUseImagesInMenus			= rData.mnUseImagesInMenus;
532     mnSkipDisabledInMenus		= rData.mnSkipDisabledInMenus;
533     mnToolbarIconSize			= rData.mnToolbarIconSize;
534     mnSymbolsStyle				= rData.mnSymbolsStyle;
535     mnPreferredSymbolsStyle			= rData.mnPreferredSymbolsStyle;
536     mpFontOptions               = rData.mpFontOptions;
537 }
538 
539 // -----------------------------------------------------------------------
540 
541 void ImplStyleData::SetStandardStyles()
542 {
543     Font aStdFont( FAMILY_SWISS, Size( 0, 8 ) );
544     aStdFont.SetCharSet( gsl_getSystemTextEncoding() );
545     aStdFont.SetWeight( WEIGHT_NORMAL );
546     aStdFont.SetName( utl::DefaultFontConfiguration::get()->getUserInterfaceFont(com::sun::star::lang::Locale( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("en") ), rtl::OUString(), rtl::OUString() ) ) );
547     maAppFont                   = aStdFont;
548     maHelpFont                  = aStdFont;
549     maMenuFont                  = aStdFont;
550     maToolFont                  = aStdFont;
551     maGroupFont                 = aStdFont;
552     maLabelFont                 = aStdFont;
553     maInfoFont                  = aStdFont;
554     maRadioCheckFont            = aStdFont;
555     maPushButtonFont            = aStdFont;
556     maFieldFont                 = aStdFont;
557     maIconFont                  = aStdFont;
558     maFloatTitleFont            = aStdFont;
559     aStdFont.SetWeight( WEIGHT_BOLD );
560     maTitleFont                 = aStdFont;
561 
562     maFaceColor                 = Color( COL_LIGHTGRAY );
563     maCheckedColor              = Color( 0xCC, 0xCC, 0xCC );
564     maLightColor                = Color( COL_WHITE );
565     maLightBorderColor          = Color( COL_LIGHTGRAY );
566     maShadowColor               = Color( COL_GRAY );
567     maDarkShadowColor           = Color( COL_BLACK );
568     maButtonTextColor           = Color( COL_BLACK );
569     maButtonRolloverTextColor   = Color( COL_BLACK );
570     maRadioCheckTextColor       = Color( COL_BLACK );
571     maGroupTextColor            = Color( COL_BLACK );
572     maLabelTextColor            = Color( COL_BLACK );
573     maInfoTextColor             = Color( COL_BLACK );
574     maWindowColor               = Color( COL_WHITE );
575     maWindowTextColor           = Color( COL_BLACK );
576     maDialogColor               = Color( COL_LIGHTGRAY );
577     maDialogTextColor           = Color( COL_BLACK );
578     maWorkspaceColor            = Color( COL_GRAY );
579     maMonoColor                 = Color( COL_BLACK );
580     maFieldColor                = Color( COL_WHITE );
581     maFieldTextColor            = Color( COL_BLACK );
582     maFieldRolloverTextColor    = Color( COL_BLACK );
583     maActiveColor               = Color( COL_BLUE );
584     maActiveColor2              = Color( COL_BLACK );
585     maActiveTextColor           = Color( COL_WHITE );
586     maActiveBorderColor         = Color( COL_LIGHTGRAY );
587     maDeactiveColor             = Color( COL_GRAY );
588     maDeactiveColor2            = Color( COL_BLACK );
589     maDeactiveTextColor         = Color( COL_LIGHTGRAY );
590     maDeactiveBorderColor       = Color( COL_LIGHTGRAY );
591     maMenuColor                 = Color( COL_LIGHTGRAY );
592     maMenuBarColor              = Color( COL_LIGHTGRAY );
593     maMenuBorderColor           = Color( COL_LIGHTGRAY );
594     maMenuTextColor             = Color( COL_BLACK );
595     maMenuBarTextColor          = Color( COL_BLACK );
596     maMenuHighlightColor        = Color( COL_BLUE );
597     maMenuHighlightTextColor    = Color( COL_WHITE );
598     maHighlightColor            = Color( COL_BLUE );
599     maHighlightTextColor        = Color( COL_WHITE );
600     maActiveTabColor            = Color( COL_WHITE );
601     maInactiveTabColor          = Color( COL_LIGHTGRAY );
602     maDisableColor              = Color( COL_GRAY );
603     maHelpColor                 = Color( 0xFF, 0xFF, 0xE0 );
604     maHelpTextColor             = Color( COL_BLACK );
605     maLinkColor                 = Color( COL_BLUE );
606     maVisitedLinkColor          = Color( 0x00, 0x00, 0xCC );
607     maHighlightLinkColor        = Color( COL_LIGHTBLUE );
608 	maFontColor					= Color( COL_BLACK );
609 
610     mnBorderSize                = 1;
611     mnTitleHeight               = 18;
612     mnFloatTitleHeight          = 13;
613     mnTearOffTitleHeight        = 8;
614     mnMenuBarHeight             = 14;
615 	mnHighContrast				= 0;
616 	mnUseSystemUIFonts			= 1;
617 	mnUseFlatBorders 			= 0;
618 	mnUseFlatMenues 			= 0;
619 	mnUseImagesInMenus			= (sal_uInt16)sal_True;
620 	mnSkipDisabledInMenus		= (sal_uInt16)sal_False;
621 
622     Gradient aGrad( GRADIENT_LINEAR, DEFAULT_WORKSPACE_GRADIENT_START_COLOR, DEFAULT_WORKSPACE_GRADIENT_END_COLOR );
623     maWorkspaceGradient = Wallpaper( aGrad );
624 }
625 
626 // -----------------------------------------------------------------------
627 
628 StyleSettings::StyleSettings()
629 {
630     mpData = new ImplStyleData();
631 }
632 
633 // -----------------------------------------------------------------------
634 
635 StyleSettings::StyleSettings( const StyleSettings& rSet )
636 {
637     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "StyleSettings: RefCount overflow" );
638 
639     // shared Instance Daten uebernehmen und Referenzcounter erhoehen
640     mpData = rSet.mpData;
641     mpData->mnRefCount++;
642 }
643 
644 // -----------------------------------------------------------------------
645 
646 StyleSettings::~StyleSettings()
647 {
648     // Daten loeschen, wenn letzte Referenz
649     if ( mpData->mnRefCount == 1 )
650         delete mpData;
651     else
652         mpData->mnRefCount--;
653 }
654 
655 // -----------------------------------------------------------------------
656 
657 void StyleSettings::Set3DColors( const Color& rColor )
658 {
659     CopyData();
660     mpData->maFaceColor         = rColor;
661     mpData->maLightBorderColor  = rColor;
662     mpData->maMenuBorderColor   = rColor;
663     mpData->maDarkShadowColor   = Color( COL_BLACK );
664     if ( rColor != Color( COL_LIGHTGRAY ) )
665     {
666         mpData->maLightColor    = rColor;
667         mpData->maShadowColor   = rColor;
668         mpData->maLightColor.IncreaseLuminance( 64 );
669         mpData->maShadowColor.DecreaseLuminance( 64 );
670         sal_uLong   nRed    = mpData->maLightColor.GetRed();
671         sal_uLong   nGreen  = mpData->maLightColor.GetGreen();
672         sal_uLong   nBlue   = mpData->maLightColor.GetBlue();
673         nRed   += (sal_uLong)(mpData->maShadowColor.GetRed());
674         nGreen += (sal_uLong)(mpData->maShadowColor.GetGreen());
675         nBlue  += (sal_uLong)(mpData->maShadowColor.GetBlue());
676         mpData->maCheckedColor = Color( (sal_uInt8)(nRed/2), (sal_uInt8)(nGreen/2), (sal_uInt8)(nBlue/2) );
677     }
678     else
679     {
680         mpData->maCheckedColor  = Color( 0x99, 0x99, 0x99 );
681         mpData->maLightColor    = Color( COL_WHITE );
682         mpData->maShadowColor   = Color( COL_GRAY );
683     }
684 }
685 
686 // -----------------------------------------------------------------------
687 
688 ::rtl::OUString StyleSettings::ImplSymbolsStyleToName( sal_uLong nStyle ) const
689 {
690 	switch ( nStyle )
691 	{
692 		case STYLE_SYMBOLS_DEFAULT:    return ::rtl::OUString::createFromAscii( "default" );
693 		case STYLE_SYMBOLS_HICONTRAST: return ::rtl::OUString::createFromAscii( "hicontrast" );
694 		case STYLE_SYMBOLS_INDUSTRIAL: return ::rtl::OUString::createFromAscii( "industrial" );
695 		case STYLE_SYMBOLS_CLASSIC:    return ::rtl::OUString::createFromAscii( "classic" );
696 	}
697 
698 	return ::rtl::OUString::createFromAscii( "auto" );
699 }
700 
701 // -----------------------------------------------------------------------
702 
703 sal_uLong StyleSettings::ImplNameToSymbolsStyle( const ::rtl::OUString &rName ) const
704 {
705 	if ( rName == ::rtl::OUString::createFromAscii( "default" ) )
706 		return STYLE_SYMBOLS_DEFAULT;
707 	else if ( rName == ::rtl::OUString::createFromAscii( "hicontrast" ) )
708 		return STYLE_SYMBOLS_HICONTRAST;
709 	else if ( rName == ::rtl::OUString::createFromAscii( "industrial" ) )
710 		return STYLE_SYMBOLS_INDUSTRIAL;
711 	else if ( rName == ::rtl::OUString::createFromAscii( "classic" ) )
712 		return STYLE_SYMBOLS_CLASSIC;
713 
714 	return STYLE_SYMBOLS_AUTO;
715 }
716 
717 // -----------------------------------------------------------------------
718 
719 /**
720 	The preferred style name can be read from the desktop setting. We
721 	need to find the closest theme name registered in OOo. Therefore
722 	we check if any registered style name is a case-insensitive
723 	substring of the preferred style name.
724 */
725 void StyleSettings::SetPreferredSymbolsStyleName( const ::rtl::OUString &rName )
726 {
727 	if ( rName.getLength() > 0 )
728 	{
729 		::rtl::OUString rNameLowCase( rName.toAsciiLowerCase() );
730 
731 		for( sal_uInt32 n = 0; n <= STYLE_SYMBOLS_THEMES_MAX; n++ )
732 			if ( rNameLowCase.indexOf( ImplSymbolsStyleToName( n ) ) != -1 )
733 				SetPreferredSymbolsStyle( n );
734 	}
735 }
736 
737 // -----------------------------------------------------------------------
738 
739 sal_uLong StyleSettings::GetCurrentSymbolsStyle() const
740 {
741 	// style selected in Tools -> Options... -> OpenOffice.org -> View
742 	sal_uLong nStyle = GetSymbolsStyle();
743 
744 	if ( nStyle == STYLE_SYMBOLS_AUTO || ( !CheckSymbolStyle (nStyle) ) )
745 	{
746 		// the preferred style can be read from the desktop setting by the desktop native widgets modules
747 		sal_uLong nPreferredStyle = GetPreferredSymbolsStyle();
748 
749 		if ( nPreferredStyle == STYLE_SYMBOLS_AUTO || ( !CheckSymbolStyle (nPreferredStyle) ) )
750 		{
751 
752 			// use a hardcoded desktop-specific fallback if no preferred style has been detected
753 			static bool sbFallbackDesktopChecked = false;
754 			static sal_uLong snFallbackDesktopStyle = STYLE_SYMBOLS_DEFAULT;
755 
756 			if ( !sbFallbackDesktopChecked )
757 			{
758 				snFallbackDesktopStyle = GetAutoSymbolsStyle();
759 				sbFallbackDesktopChecked = true;
760 			}
761 
762 			nPreferredStyle = snFallbackDesktopStyle;
763 		}
764 
765 		if (GetHighContrastMode() && CheckSymbolStyle (STYLE_SYMBOLS_HICONTRAST) )
766 		    nStyle = STYLE_SYMBOLS_HICONTRAST;
767 		else
768 		    nStyle = nPreferredStyle;
769 	}
770 
771 	return nStyle;
772 }
773 
774 // -----------------------------------------------------------------------
775 
776 sal_uLong StyleSettings::GetAutoSymbolsStyle() const
777 {
778     sal_uLong                       nRet = STYLE_SYMBOLS_DEFAULT;
779 
780     try
781     {
782         const ::com::sun::star::uno::Any aAny( ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::OPENSOURCECONTEXT ) );
783         sal_Int32 nValue( 0 );
784 
785         aAny >>= nValue;
786     }
787     catch ( ::com::sun::star::uno::Exception& )
788     {
789     }
790 
791     // falback to any existing style
792     if ( ! CheckSymbolStyle (nRet) )
793     {
794         for ( sal_uLong n = 0 ; n <= STYLE_SYMBOLS_THEMES_MAX  ; n++ )
795         {
796             sal_uLong nStyleToCheck = n;
797 
798             // auto is not a real theme => can't be fallback
799             if ( nStyleToCheck == STYLE_SYMBOLS_AUTO )
800                 continue;
801 
802             // will check hicontrast in the end
803             if ( nStyleToCheck == STYLE_SYMBOLS_HICONTRAST )
804                 continue;
805             if ( nStyleToCheck == STYLE_SYMBOLS_THEMES_MAX )
806                 nStyleToCheck = STYLE_SYMBOLS_HICONTRAST;
807 
808             if ( CheckSymbolStyle ( nStyleToCheck ) )
809             {
810                 nRet = nStyleToCheck;
811                 n = STYLE_SYMBOLS_THEMES_MAX;
812             }
813         }
814     }
815 
816     return nRet;
817 }
818 
819 // -----------------------------------------------------------------------
820 
821 bool StyleSettings::CheckSymbolStyle( sal_uLong nStyle ) const
822 {
823     static ImplImageTreeSingletonRef aImageTree;
824     return aImageTree->checkStyle( ImplSymbolsStyleToName( nStyle ) );
825 }
826 
827 // -----------------------------------------------------------------------
828 
829 void StyleSettings::SetStandardStyles()
830 {
831     CopyData();
832     mpData->SetStandardStyles();
833 }
834 
835 // -----------------------------------------------------------------------
836 
837 Color StyleSettings::GetFaceGradientColor() const
838 {
839     // compute a brighter face color that can be used in gradients
840     // for a convex look (eg toolbars)
841 
842     sal_uInt16 h, s, b;
843     GetFaceColor().RGBtoHSB( h, s, b );
844     if( s > 1) s=1;
845     if( b < 98) b=98;
846     return Color( Color::HSBtoRGB( h, s, b ) );
847 }
848 
849 // -----------------------------------------------------------------------
850 
851 Color StyleSettings::GetSeparatorColor() const
852 {
853     // compute a brighter shadow color for separators (used in toolbars or between menubar and toolbars on Windows XP)
854     sal_uInt16 h, s, b;
855     GetShadowColor().RGBtoHSB( h, s, b );
856     b += b/4;
857     s -= s/4;
858     return Color( Color::HSBtoRGB( h, s, b ) );
859 }
860 
861 // -----------------------------------------------------------------------
862 
863 const StyleSettings& StyleSettings::operator =( const StyleSettings& rSet )
864 {
865     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "StyleSettings: RefCount overflow" );
866 
867     // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
868     rSet.mpData->mnRefCount++;
869 
870     // Daten loeschen, wenn letzte Referenz
871     if ( mpData->mnRefCount == 1 )
872         delete mpData;
873     else
874         mpData->mnRefCount--;
875 
876     mpData = rSet.mpData;
877 
878     return *this;
879 }
880 
881 // -----------------------------------------------------------------------
882 
883 void StyleSettings::CopyData()
884 {
885     // Falls noch andere Referenzen bestehen, dann kopieren
886     if ( mpData->mnRefCount != 1 )
887     {
888         mpData->mnRefCount--;
889         mpData = new ImplStyleData( *mpData );
890     }
891 }
892 
893 // -----------------------------------------------------------------------
894 
895 inline sal_Bool ImplIsBackOrWhite( const Color& rColor )
896 {
897     sal_uInt8 nLuminance = rColor.GetLuminance();
898     return ( nLuminance < 8 ) || ( nLuminance > 250 );
899 }
900 
901 sal_Bool StyleSettings::IsHighContrastBlackAndWhite() const
902 {
903     sal_Bool bBWOnly = sal_True;
904 
905     // Only use B&W if fully B&W, like on GNOME.
906     // Some colors like CheckedColor and HighlightColor are not B&W in Windows Standard HC Black,
907     // and we don't want to be B&W then, so check these color first, very probably not B&W.
908 
909     // Unfortunately, GNOME uses a very very dark color (0x000033) instead of BLACK (0x000000)
910 
911     if ( !ImplIsBackOrWhite( GetFaceColor() ) )
912         bBWOnly = sal_False;
913     else if ( !ImplIsBackOrWhite( GetHighlightTextColor() ) )
914         bBWOnly = sal_False;
915     else if ( !ImplIsBackOrWhite( GetWindowColor() ) )
916         bBWOnly = sal_False;
917     else if ( !ImplIsBackOrWhite( GetWindowTextColor() ) )
918         bBWOnly = sal_False;
919     else if ( !ImplIsBackOrWhite( GetButtonTextColor() ) )
920         bBWOnly = sal_False;
921     else if ( !ImplIsBackOrWhite( GetButtonTextColor() ) )
922         bBWOnly = sal_False;
923     else if ( !ImplIsBackOrWhite( GetGroupTextColor() ) )
924         bBWOnly = sal_False;
925     else if ( !ImplIsBackOrWhite( GetLabelTextColor() ) )
926         bBWOnly = sal_False;
927     else if ( !ImplIsBackOrWhite( GetDialogColor() ) )
928         bBWOnly = sal_False;
929     else if ( !ImplIsBackOrWhite( GetFieldColor() ) )
930         bBWOnly = sal_False;
931     else if ( !ImplIsBackOrWhite( GetMenuColor() ) )
932         bBWOnly = sal_False;
933     else if ( !ImplIsBackOrWhite( GetMenuBarColor() ) )
934         bBWOnly = sal_False;
935     else if ( !ImplIsBackOrWhite( GetMenuHighlightColor() ) )
936         bBWOnly = sal_False;
937 
938     return bBWOnly;
939 }
940 
941 // -----------------------------------------------------------------------
942 
943 sal_Bool StyleSettings::operator ==( const StyleSettings& rSet ) const
944 {
945     if ( mpData == rSet.mpData )
946         return sal_True;
947 
948     if ( (mpData->mnOptions                 == rSet.mpData->mnOptions)                  &&
949          (mpData->mnAutoMnemonic			== rSet.mpData->mnAutoMnemonic)				&&
950          (mpData->mnLogoDisplayTime         == rSet.mpData->mnLogoDisplayTime)          &&
951          (mpData->mnDragFullOptions         == rSet.mpData->mnDragFullOptions)          &&
952          (mpData->mnAnimationOptions        == rSet.mpData->mnAnimationOptions)         &&
953          (mpData->mnSelectionOptions        == rSet.mpData->mnSelectionOptions)         &&
954          (mpData->mnDisplayOptions          == rSet.mpData->mnDisplayOptions)           &&
955          (mpData->mnCursorSize              == rSet.mpData->mnCursorSize)               &&
956          (mpData->mnCursorBlinkTime         == rSet.mpData->mnCursorBlinkTime)          &&
957          (mpData->mnBorderSize              == rSet.mpData->mnBorderSize)               &&
958          (mpData->mnTitleHeight             == rSet.mpData->mnTitleHeight)              &&
959          (mpData->mnFloatTitleHeight        == rSet.mpData->mnFloatTitleHeight)         &&
960          (mpData->mnTearOffTitleHeight      == rSet.mpData->mnTearOffTitleHeight)       &&
961          (mpData->mnMenuBarHeight           == rSet.mpData->mnMenuBarHeight)            &&
962          (mpData->mnScrollBarSize           == rSet.mpData->mnScrollBarSize)            &&
963          (mpData->mnMinThumbSize            == rSet.mpData->mnMinThumbSize)             &&
964          (mpData->mnSplitSize               == rSet.mpData->mnSplitSize)                &&
965          (mpData->mnSpinSize                == rSet.mpData->mnSpinSize)                 &&
966          (mpData->mnIconHorzSpace           == rSet.mpData->mnIconHorzSpace)            &&
967          (mpData->mnIconVertSpace           == rSet.mpData->mnIconVertSpace)            &&
968          (mpData->mnAntialiasedMin          == rSet.mpData->mnAntialiasedMin)           &&
969          (mpData->mnScreenZoom              == rSet.mpData->mnScreenZoom)               &&
970          (mpData->mnScreenFontZoom          == rSet.mpData->mnScreenFontZoom)           &&
971          (mpData->mnHighContrast			== rSet.mpData->mnHighContrast)             &&
972          (mpData->mnUseSystemUIFonts		== rSet.mpData->mnUseSystemUIFonts)         &&
973          (mpData->mnUseFlatBorders   		== rSet.mpData->mnUseFlatBorders)           &&
974          (mpData->mnUseFlatMenues   		== rSet.mpData->mnUseFlatMenues)            &&
975          (mpData->mnSymbolsStyle       		== rSet.mpData->mnSymbolsStyle)             &&
976          (mpData->mnPreferredSymbolsStyle   == rSet.mpData->mnPreferredSymbolsStyle)    &&
977          (mpData->maFaceColor               == rSet.mpData->maFaceColor)                &&
978          (mpData->maCheckedColor            == rSet.mpData->maCheckedColor)             &&
979          (mpData->maLightColor              == rSet.mpData->maLightColor)               &&
980          (mpData->maLightBorderColor        == rSet.mpData->maLightBorderColor)         &&
981          (mpData->maShadowColor             == rSet.mpData->maShadowColor)              &&
982          (mpData->maDarkShadowColor         == rSet.mpData->maDarkShadowColor)          &&
983          (mpData->maButtonTextColor         == rSet.mpData->maButtonTextColor)          &&
984          (mpData->maRadioCheckTextColor     == rSet.mpData->maRadioCheckTextColor)      &&
985          (mpData->maGroupTextColor          == rSet.mpData->maGroupTextColor)           &&
986          (mpData->maLabelTextColor          == rSet.mpData->maLabelTextColor)           &&
987          (mpData->maInfoTextColor           == rSet.mpData->maInfoTextColor)            &&
988          (mpData->maWindowColor             == rSet.mpData->maWindowColor)              &&
989          (mpData->maWindowTextColor         == rSet.mpData->maWindowTextColor)          &&
990          (mpData->maDialogColor             == rSet.mpData->maDialogColor)              &&
991          (mpData->maDialogTextColor         == rSet.mpData->maDialogTextColor)          &&
992          (mpData->maWorkspaceColor          == rSet.mpData->maWorkspaceColor)           &&
993          (mpData->maMonoColor               == rSet.mpData->maMonoColor)                &&
994          (mpData->maFieldColor              == rSet.mpData->maFieldColor)               &&
995          (mpData->maFieldTextColor          == rSet.mpData->maFieldTextColor)           &&
996          (mpData->maActiveColor             == rSet.mpData->maActiveColor)              &&
997          (mpData->maActiveColor2            == rSet.mpData->maActiveColor2)             &&
998          (mpData->maActiveTextColor         == rSet.mpData->maActiveTextColor)          &&
999          (mpData->maActiveBorderColor       == rSet.mpData->maActiveBorderColor)        &&
1000          (mpData->maDeactiveColor           == rSet.mpData->maDeactiveColor)            &&
1001          (mpData->maDeactiveColor2          == rSet.mpData->maDeactiveColor2)           &&
1002          (mpData->maDeactiveTextColor       == rSet.mpData->maDeactiveTextColor)        &&
1003          (mpData->maDeactiveBorderColor     == rSet.mpData->maDeactiveBorderColor)      &&
1004          (mpData->maMenuColor               == rSet.mpData->maMenuColor)                &&
1005          (mpData->maMenuBarColor            == rSet.mpData->maMenuBarColor)             &&
1006          (mpData->maMenuBorderColor         == rSet.mpData->maMenuBorderColor)          &&
1007          (mpData->maMenuTextColor           == rSet.mpData->maMenuTextColor)            &&
1008          (mpData->maMenuBarTextColor        == rSet.mpData->maMenuBarTextColor)         &&
1009          (mpData->maMenuHighlightColor      == rSet.mpData->maMenuHighlightColor)       &&
1010          (mpData->maMenuHighlightTextColor  == rSet.mpData->maMenuHighlightTextColor)   &&
1011          (mpData->maHighlightColor          == rSet.mpData->maHighlightColor)           &&
1012          (mpData->maHighlightTextColor      == rSet.mpData->maHighlightTextColor)       &&
1013          (mpData->maActiveTabColor          == rSet.mpData->maActiveTabColor)           &&
1014          (mpData->maInactiveTabColor        == rSet.mpData->maInactiveTabColor)         &&
1015          (mpData->maDisableColor            == rSet.mpData->maDisableColor)             &&
1016          (mpData->maHelpColor               == rSet.mpData->maHelpColor)                &&
1017          (mpData->maHelpTextColor           == rSet.mpData->maHelpTextColor)            &&
1018          (mpData->maLinkColor               == rSet.mpData->maLinkColor)                &&
1019          (mpData->maVisitedLinkColor        == rSet.mpData->maVisitedLinkColor)         &&
1020          (mpData->maHighlightLinkColor      == rSet.mpData->maHighlightLinkColor)       &&
1021          (mpData->maAppFont                 == rSet.mpData->maAppFont)                  &&
1022          (mpData->maHelpFont                == rSet.mpData->maHelpFont)                 &&
1023          (mpData->maTitleFont               == rSet.mpData->maTitleFont)                &&
1024          (mpData->maFloatTitleFont          == rSet.mpData->maFloatTitleFont)           &&
1025          (mpData->maMenuFont                == rSet.mpData->maMenuFont)                 &&
1026          (mpData->maToolFont                == rSet.mpData->maToolFont)                 &&
1027          (mpData->maGroupFont               == rSet.mpData->maGroupFont)                &&
1028          (mpData->maLabelFont               == rSet.mpData->maLabelFont)                &&
1029          (mpData->maInfoFont                == rSet.mpData->maInfoFont)                 &&
1030          (mpData->maRadioCheckFont          == rSet.mpData->maRadioCheckFont)           &&
1031          (mpData->maPushButtonFont          == rSet.mpData->maPushButtonFont)           &&
1032          (mpData->maFieldFont               == rSet.mpData->maFieldFont)                &&
1033          (mpData->maIconFont                == rSet.mpData->maIconFont)					&&
1034          (mpData->mnUseImagesInMenus		== rSet.mpData->mnUseImagesInMenus)			&&
1035          (mpData->mnSkipDisabledInMenus		== rSet.mpData->mnSkipDisabledInMenus)		&&
1036 		 (mpData->maFontColor				== rSet.mpData->maFontColor ))
1037         return sal_True;
1038     else
1039         return sal_False;
1040 }
1041 
1042 // =======================================================================
1043 
1044 ImplMiscData::ImplMiscData()
1045 {
1046     mnRefCount                  = 1;
1047     mnEnableATT					= sal::static_int_cast<sal_uInt16>(~0U);
1048     mnDisablePrinting			= sal::static_int_cast<sal_uInt16>(~0U);
1049     static const char* pEnv = getenv("SAL_DECIMALSEP_ENABLED" ); // set default without UI
1050     mbEnableLocalizedDecimalSep = (pEnv != NULL) ? sal_True : sal_False;
1051 }
1052 
1053 // -----------------------------------------------------------------------
1054 
1055 ImplMiscData::ImplMiscData( const ImplMiscData& rData )
1056 {
1057     mnRefCount                  = 1;
1058     mnEnableATT					= rData.mnEnableATT;
1059     mnDisablePrinting			= rData.mnDisablePrinting;
1060     mbEnableLocalizedDecimalSep = rData.mbEnableLocalizedDecimalSep;
1061 }
1062 
1063 // -----------------------------------------------------------------------
1064 
1065 MiscSettings::MiscSettings()
1066 {
1067     mpData = new ImplMiscData();
1068 }
1069 
1070 // -----------------------------------------------------------------------
1071 
1072 MiscSettings::MiscSettings( const MiscSettings& rSet )
1073 {
1074     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "MiscSettings: RefCount overflow" );
1075 
1076     // shared Instance Daten uebernehmen und Referenzcounter erhoehen
1077     mpData = rSet.mpData;
1078     mpData->mnRefCount++;
1079 }
1080 
1081 // -----------------------------------------------------------------------
1082 
1083 MiscSettings::~MiscSettings()
1084 {
1085     // Daten loeschen, wenn letzte Referenz
1086     if ( mpData->mnRefCount == 1 )
1087         delete mpData;
1088     else
1089         mpData->mnRefCount--;
1090 }
1091 
1092 // -----------------------------------------------------------------------
1093 
1094 const MiscSettings& MiscSettings::operator =( const MiscSettings& rSet )
1095 {
1096     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "MiscSettings: RefCount overflow" );
1097 
1098     // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
1099     rSet.mpData->mnRefCount++;
1100 
1101     // Daten loeschen, wenn letzte Referenz
1102     if ( mpData->mnRefCount == 1 )
1103         delete mpData;
1104     else
1105         mpData->mnRefCount--;
1106 
1107     mpData = rSet.mpData;
1108 
1109     return *this;
1110 }
1111 
1112 // -----------------------------------------------------------------------
1113 
1114 void MiscSettings::CopyData()
1115 {
1116     // Falls noch andere Referenzen bestehen, dann kopieren
1117     if ( mpData->mnRefCount != 1 )
1118     {
1119         mpData->mnRefCount--;
1120         mpData = new ImplMiscData( *mpData );
1121     }
1122 }
1123 
1124 // -----------------------------------------------------------------------
1125 
1126 sal_Bool MiscSettings::operator ==( const MiscSettings& rSet ) const
1127 {
1128     if ( mpData == rSet.mpData )
1129         return sal_True;
1130 
1131     if ( (mpData->mnEnableATT			== rSet.mpData->mnEnableATT ) &&
1132          (mpData->mnDisablePrinting		== rSet.mpData->mnDisablePrinting ) &&
1133          (mpData->mbEnableLocalizedDecimalSep == rSet.mpData->mbEnableLocalizedDecimalSep ) )
1134         return sal_True;
1135     else
1136         return sal_False;
1137 }
1138 
1139 // -----------------------------------------------------------------------
1140 
1141 sal_Bool MiscSettings::GetDisablePrinting() const
1142 {
1143     if( mpData->mnDisablePrinting == (sal_uInt16)~0 )
1144     {
1145         rtl::OUString aEnable =
1146             vcl::SettingsConfigItem::get()->
1147             getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DesktopManagement" ) ),
1148                       rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisablePrinting" ) ) );
1149         mpData->mnDisablePrinting = aEnable.equalsIgnoreAsciiCaseAscii( "true" ) ? 1 : 0;
1150     }
1151 
1152     return (sal_Bool)mpData->mnDisablePrinting;
1153 }
1154 // -----------------------------------------------------------------------
1155 
1156 sal_Bool MiscSettings::GetEnableATToolSupport() const
1157 {
1158 
1159 #ifdef WNT
1160     if( mpData->mnEnableATT == (sal_uInt16)~0 )
1161     {
1162         // Check in the Windows registry if an AT tool wants Accessibility support to
1163         // be activated ..
1164         HKEY hkey;
1165 
1166         if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,
1167             "Software\\OpenOffice\\Accessibility\\AtToolSupport",
1168             &hkey) )
1169         {
1170             DWORD dwType;
1171             sal_uInt8 Data[6]; // possible values: "true", "false", "1", "0", DWORD
1172             DWORD cbData = sizeof(Data);
1173 
1174             if( ERROR_SUCCESS == RegQueryValueEx(hkey, "SupportAssistiveTechnology",
1175                 NULL, &dwType, Data, &cbData) )
1176             {
1177                 switch (dwType)
1178                 {
1179                     case REG_SZ:
1180                         mpData->mnEnableATT = ((0 == stricmp((const char *) Data, "1")) || (0 == stricmp((const char *) Data, "true")));
1181                         break;
1182                     case REG_DWORD:
1183                         mpData->mnEnableATT = (sal_uInt16) (((DWORD *) Data)[0]);
1184                         break;
1185                     default:
1186                         // Unsupported registry type
1187                         break;
1188                 }
1189             }
1190 
1191             RegCloseKey(hkey);
1192         }
1193     }
1194 #endif
1195 
1196 	if( mpData->mnEnableATT == (sal_uInt16)~0 )
1197     {
1198         static const char* pEnv = getenv("SAL_ACCESSIBILITY_ENABLED" );
1199         if( !pEnv || !*pEnv )
1200         {
1201             rtl::OUString aEnable =
1202                 vcl::SettingsConfigItem::get()->
1203                 getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Accessibility" ) ),
1204                           rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableATToolSupport" ) ) );
1205             mpData->mnEnableATT = aEnable.equalsIgnoreAsciiCaseAscii( "true" ) ? 1 : 0;
1206         }
1207         else
1208         {
1209             mpData->mnEnableATT = 1;
1210         }
1211     }
1212 
1213     return (sal_Bool)mpData->mnEnableATT;
1214 }
1215 
1216 // -----------------------------------------------------------------------
1217 
1218 void MiscSettings::SetDisablePrinting( sal_Bool bEnable )
1219 {
1220     if ( bEnable != mpData->mnDisablePrinting )
1221     {
1222         vcl::SettingsConfigItem::get()->
1223             setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DesktopManagement" ) ),
1224                       rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisablePrinting" ) ),
1225                       rtl::OUString::createFromAscii( bEnable ? "true" : "false" ) );
1226         mpData->mnDisablePrinting = bEnable ? 1 : 0;
1227     }
1228 }
1229 
1230 // -----------------------------------------------------------------------
1231 
1232 void MiscSettings::SetEnableATToolSupport( sal_Bool bEnable )
1233 {
1234     if ( bEnable != mpData->mnEnableATT )
1235     {
1236         sal_Bool bDummy;
1237         if( bEnable && !ImplInitAccessBridge(false, bDummy) )
1238             return;
1239 
1240 #ifdef WNT
1241 		HKEY hkey;
1242 
1243         // If the accessibility key in the Windows registry exists, change it synchronously
1244 		if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,
1245 			"Software\\OpenOffice\\Accessibility\\AtToolSupport",
1246 			&hkey) )
1247 		{
1248 			DWORD dwType;
1249 			sal_uInt8 Data[6]; // possible values: "true", "false", 1, 0
1250 			DWORD cbData = sizeof(Data);
1251 
1252 			if( ERROR_SUCCESS == RegQueryValueEx(hkey, "SupportAssistiveTechnology",
1253 				NULL,	&dwType, Data, &cbData) )
1254 			{
1255 				switch (dwType)
1256 				{
1257 					case REG_SZ:
1258 						RegSetValueEx(hkey, "SupportAssistiveTechnology",
1259 							NULL, dwType,
1260 							bEnable ? (sal_uInt8 *) "true" : (sal_uInt8 *) "false",
1261 							bEnable ? sizeof("true") : sizeof("false"));
1262 						break;
1263 					case REG_DWORD:
1264 						((DWORD *) Data)[0] = bEnable ? 1 : 0;
1265 						RegSetValueEx(hkey, "SupportAssistiveTechnology",
1266 							NULL, dwType, Data,	sizeof(DWORD));
1267 						break;
1268 					default:
1269 						// Unsupported registry type
1270 						break;
1271 				}
1272 			}
1273 
1274 			RegCloseKey(hkey);
1275         }
1276 
1277 #endif
1278         vcl::SettingsConfigItem::get()->
1279             setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Accessibility" ) ),
1280                       rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableATToolSupport" ) ),
1281                       rtl::OUString::createFromAscii( bEnable ? "true" : "false" ) );
1282         mpData->mnEnableATT = bEnable ? 1 : 0;
1283     }
1284 }
1285 
1286 void MiscSettings::SetEnableLocalizedDecimalSep( sal_Bool bEnable )
1287 {
1288     CopyData();
1289     mpData->mbEnableLocalizedDecimalSep = bEnable;
1290 }
1291 
1292 sal_Bool MiscSettings::GetEnableLocalizedDecimalSep() const
1293 {
1294     return mpData->mbEnableLocalizedDecimalSep;
1295 }
1296 
1297 // =======================================================================
1298 
1299 ImplNotificationData::ImplNotificationData()
1300 {
1301     mnRefCount                  = 1;
1302     mnOptions                   = 0;
1303 }
1304 
1305 // -----------------------------------------------------------------------
1306 
1307 ImplNotificationData::ImplNotificationData( const ImplNotificationData& rData )
1308 {
1309     mnRefCount                  = 1;
1310     mnOptions                   = rData.mnOptions;
1311 }
1312 
1313 // -----------------------------------------------------------------------
1314 
1315 NotificationSettings::NotificationSettings()
1316 {
1317     mpData = new ImplNotificationData();
1318 }
1319 
1320 // -----------------------------------------------------------------------
1321 
1322 NotificationSettings::NotificationSettings( const NotificationSettings& rSet )
1323 {
1324     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "NotificationSettings: RefCount overflow" );
1325 
1326     // shared Instance Daten uebernehmen und Referenzcounter erhoehen
1327     mpData = rSet.mpData;
1328     mpData->mnRefCount++;
1329 }
1330 
1331 // -----------------------------------------------------------------------
1332 
1333 NotificationSettings::~NotificationSettings()
1334 {
1335     // Daten loeschen, wenn letzte Referenz
1336     if ( mpData->mnRefCount == 1 )
1337         delete mpData;
1338     else
1339         mpData->mnRefCount--;
1340 }
1341 
1342 // -----------------------------------------------------------------------
1343 
1344 const NotificationSettings& NotificationSettings::operator =( const NotificationSettings& rSet )
1345 {
1346     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "NotificationSettings: RefCount overflow" );
1347 
1348     // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
1349     rSet.mpData->mnRefCount++;
1350 
1351     // Daten loeschen, wenn letzte Referenz
1352     if ( mpData->mnRefCount == 1 )
1353         delete mpData;
1354     else
1355         mpData->mnRefCount--;
1356 
1357     mpData = rSet.mpData;
1358 
1359     return *this;
1360 }
1361 
1362 // -----------------------------------------------------------------------
1363 
1364 void NotificationSettings::CopyData()
1365 {
1366     // Falls noch andere Referenzen bestehen, dann kopieren
1367     if ( mpData->mnRefCount != 1 )
1368     {
1369         mpData->mnRefCount--;
1370         mpData = new ImplNotificationData( *mpData );
1371     }
1372 }
1373 
1374 // -----------------------------------------------------------------------
1375 
1376 sal_Bool NotificationSettings::operator ==( const NotificationSettings& rSet ) const
1377 {
1378     if ( mpData == rSet.mpData )
1379         return sal_True;
1380 
1381     return (mpData->mnOptions == rSet.mpData->mnOptions);
1382 }
1383 
1384 // =======================================================================
1385 
1386 ImplHelpData::ImplHelpData()
1387 {
1388     mnRefCount                  = 1;
1389     mnOptions                   = 0;
1390     mnTipDelay                  = 500;
1391     mnTipTimeout                = 3000;
1392     mnBalloonDelay              = 1500;
1393 }
1394 
1395 // -----------------------------------------------------------------------
1396 
1397 ImplHelpData::ImplHelpData( const ImplHelpData& rData )
1398 {
1399     mnRefCount                  = 1;
1400     mnOptions                   = rData.mnOptions;
1401     mnTipDelay                  = rData.mnTipDelay;
1402     mnTipTimeout                = rData.mnTipTimeout;
1403     mnBalloonDelay              = rData.mnBalloonDelay;
1404 }
1405 
1406 // -----------------------------------------------------------------------
1407 
1408 HelpSettings::HelpSettings()
1409 {
1410     mpData = new ImplHelpData();
1411 }
1412 
1413 // -----------------------------------------------------------------------
1414 
1415 HelpSettings::HelpSettings( const HelpSettings& rSet )
1416 {
1417     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "HelpSettings: RefCount overflow" );
1418 
1419     // shared Instance Daten uebernehmen und Referenzcounter erhoehen
1420     mpData = rSet.mpData;
1421     mpData->mnRefCount++;
1422 }
1423 
1424 // -----------------------------------------------------------------------
1425 
1426 HelpSettings::~HelpSettings()
1427 {
1428     // Daten loeschen, wenn letzte Referenz
1429     if ( mpData->mnRefCount == 1 )
1430         delete mpData;
1431     else
1432         mpData->mnRefCount--;
1433 }
1434 
1435 // -----------------------------------------------------------------------
1436 
1437 const HelpSettings& HelpSettings::operator =( const HelpSettings& rSet )
1438 {
1439     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "HelpSettings: RefCount overflow" );
1440 
1441     // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
1442     rSet.mpData->mnRefCount++;
1443 
1444     // Daten loeschen, wenn letzte Referenz
1445     if ( mpData->mnRefCount == 1 )
1446         delete mpData;
1447     else
1448         mpData->mnRefCount--;
1449 
1450     mpData = rSet.mpData;
1451 
1452     return *this;
1453 }
1454 
1455 // -----------------------------------------------------------------------
1456 
1457 void HelpSettings::CopyData()
1458 {
1459     // Falls noch andere Referenzen bestehen, dann kopieren
1460     if ( mpData->mnRefCount != 1 )
1461     {
1462         mpData->mnRefCount--;
1463         mpData = new ImplHelpData( *mpData );
1464     }
1465 }
1466 
1467 // -----------------------------------------------------------------------
1468 
1469 sal_Bool HelpSettings::operator ==( const HelpSettings& rSet ) const
1470 {
1471     if ( mpData == rSet.mpData )
1472         return sal_True;
1473 
1474     if ( (mpData->mnOptions         == rSet.mpData->mnOptions ) &&
1475          (mpData->mnTipDelay        == rSet.mpData->mnTipDelay ) &&
1476          (mpData->mnTipTimeout      == rSet.mpData->mnTipTimeout ) &&
1477          (mpData->mnBalloonDelay    == rSet.mpData->mnBalloonDelay ) )
1478         return sal_True;
1479     else
1480         return sal_False;
1481 }
1482 
1483 // =======================================================================
1484 
1485 ImplAllSettingsData::ImplAllSettingsData()
1486 {
1487     mnRefCount                  = 1;
1488     mnSystemUpdate              = SETTINGS_ALLSETTINGS;
1489     mnWindowUpdate              = SETTINGS_ALLSETTINGS;
1490     meLanguage                  = LANGUAGE_SYSTEM;
1491     meUILanguage                  = LANGUAGE_SYSTEM;
1492     mpLocaleDataWrapper         = NULL;
1493     mpUILocaleDataWrapper       = NULL;
1494     mpCollatorWrapper           = NULL;
1495     mpUICollatorWrapper         = NULL;
1496     mpI18nHelper                = NULL;
1497     mpUII18nHelper              = NULL;
1498 	maMiscSettings.SetEnableLocalizedDecimalSep( maSysLocale.GetOptions().IsDecimalSeparatorAsLocale() );
1499 }
1500 
1501 // -----------------------------------------------------------------------
1502 
1503 ImplAllSettingsData::ImplAllSettingsData( const ImplAllSettingsData& rData ) :
1504     maMouseSettings( rData.maMouseSettings ),
1505     maKeyboardSettings( rData.maKeyboardSettings ),
1506     maStyleSettings( rData.maStyleSettings ),
1507     maMiscSettings( rData.maMiscSettings ),
1508     maNotificationSettings( rData.maNotificationSettings ),
1509     maHelpSettings( rData.maHelpSettings ),
1510     maLocale( rData.maLocale )
1511 {
1512     mnRefCount                  = 1;
1513     mnSystemUpdate              = rData.mnSystemUpdate;
1514     mnWindowUpdate              = rData.mnWindowUpdate;
1515     meLanguage                  = rData.meLanguage;
1516     // Pointer couldn't shared and objects haven't a copy ctor
1517     // So we create the cache objects new, if the GetFunction is
1518     // called
1519     mpLocaleDataWrapper         = NULL;
1520     mpUILocaleDataWrapper       = NULL;
1521     mpCollatorWrapper           = NULL;
1522     mpUICollatorWrapper         = NULL;
1523     mpI18nHelper                = NULL;
1524     mpUII18nHelper              = NULL;
1525 }
1526 
1527 // -----------------------------------------------------------------------
1528 
1529 ImplAllSettingsData::~ImplAllSettingsData()
1530 {
1531     if ( mpLocaleDataWrapper )
1532         delete mpLocaleDataWrapper;
1533     if ( mpUILocaleDataWrapper )
1534         delete mpUILocaleDataWrapper;
1535     if ( mpCollatorWrapper )
1536         delete mpCollatorWrapper;
1537     if ( mpUICollatorWrapper )
1538         delete mpUICollatorWrapper;
1539     if ( mpI18nHelper )
1540         delete mpI18nHelper;
1541     if ( mpUII18nHelper )
1542         delete mpUII18nHelper;
1543 }
1544 
1545 // -----------------------------------------------------------------------
1546 
1547 AllSettings::AllSettings()
1548 {
1549     DBG_CTOR( AllSettings, NULL );
1550 
1551     mpData = new ImplAllSettingsData();
1552 }
1553 
1554 // -----------------------------------------------------------------------
1555 
1556 AllSettings::AllSettings( const AllSettings& rSet )
1557 {
1558     DBG_CTOR( AllSettings, NULL );
1559     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "Settings: RefCount overflow" );
1560 
1561     // shared Instance Daten uebernehmen und Referenzcounter erhoehen
1562     mpData = rSet.mpData;
1563     mpData->mnRefCount++;
1564 }
1565 
1566 // -----------------------------------------------------------------------
1567 
1568 AllSettings::~AllSettings()
1569 {
1570     DBG_DTOR( AllSettings, NULL );
1571 
1572     // Daten loeschen, wenn letzte Referenz
1573     if ( mpData->mnRefCount == 1 )
1574         delete mpData;
1575     else
1576         mpData->mnRefCount--;
1577 }
1578 
1579 // -----------------------------------------------------------------------
1580 
1581 const AllSettings& AllSettings::operator =( const AllSettings& rSet )
1582 {
1583     DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "AllSettings: RefCount overflow" );
1584     DBG_CHKTHIS( AllSettings, NULL );
1585     DBG_CHKOBJ( &rSet, AllSettings, NULL );
1586 
1587     // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
1588     rSet.mpData->mnRefCount++;
1589 
1590     // Daten loeschen, wenn letzte Referenz
1591     if ( mpData->mnRefCount == 1 )
1592         delete mpData;
1593     else
1594         mpData->mnRefCount--;
1595 
1596     mpData = rSet.mpData;
1597 
1598     return *this;
1599 }
1600 
1601 // -----------------------------------------------------------------------
1602 
1603 void AllSettings::CopyData()
1604 {
1605     DBG_CHKTHIS( AllSettings, NULL );
1606 
1607     // Falls noch andere Referenzen bestehen, dann kopieren
1608     if ( mpData->mnRefCount != 1 )
1609     {
1610         mpData->mnRefCount--;
1611         mpData = new ImplAllSettingsData( *mpData );
1612     }
1613 }
1614 
1615 // -----------------------------------------------------------------------
1616 
1617 sal_uLong AllSettings::Update( sal_uLong nFlags, const AllSettings& rSet )
1618 {
1619     DBG_CHKTHIS( AllSettings, NULL );
1620     DBG_CHKOBJ( &rSet, AllSettings, NULL );
1621 
1622     sal_uLong nChangeFlags = 0;
1623 
1624     if ( nFlags & SETTINGS_MACHINE )
1625     {
1626         if ( mpData->maMachineSettings != rSet.mpData->maMachineSettings )
1627         {
1628             CopyData();
1629             mpData->maMachineSettings = rSet.mpData->maMachineSettings;
1630             nChangeFlags |= SETTINGS_MACHINE;
1631         }
1632     }
1633 
1634     if ( nFlags & SETTINGS_MOUSE )
1635     {
1636         if ( mpData->maMouseSettings != rSet.mpData->maMouseSettings )
1637         {
1638             CopyData();
1639             mpData->maMouseSettings = rSet.mpData->maMouseSettings;
1640             nChangeFlags |= SETTINGS_MOUSE;
1641         }
1642     }
1643 
1644     if ( nFlags & SETTINGS_KEYBOARD )
1645     {
1646         if ( mpData->maKeyboardSettings != rSet.mpData->maKeyboardSettings )
1647         {
1648             CopyData();
1649             mpData->maKeyboardSettings = rSet.mpData->maKeyboardSettings;
1650             nChangeFlags |= SETTINGS_KEYBOARD;
1651         }
1652     }
1653 
1654     if ( nFlags & SETTINGS_STYLE )
1655     {
1656         if ( mpData->maStyleSettings != rSet.mpData->maStyleSettings )
1657         {
1658             CopyData();
1659             mpData->maStyleSettings = rSet.mpData->maStyleSettings;
1660             nChangeFlags |= SETTINGS_STYLE;
1661         }
1662     }
1663 
1664     if ( nFlags & SETTINGS_MISC )
1665     {
1666         if ( mpData->maMiscSettings != rSet.mpData->maMiscSettings )
1667         {
1668             CopyData();
1669             mpData->maMiscSettings = rSet.mpData->maMiscSettings;
1670             nChangeFlags |= SETTINGS_MISC;
1671         }
1672     }
1673 
1674     if ( nFlags & SETTINGS_NOTIFICATION )
1675     {
1676         if ( mpData->maNotificationSettings != rSet.mpData->maNotificationSettings )
1677         {
1678             CopyData();
1679             mpData->maNotificationSettings = rSet.mpData->maNotificationSettings;
1680             nChangeFlags |= SETTINGS_NOTIFICATION;
1681         }
1682     }
1683 
1684     if ( nFlags & SETTINGS_HELP )
1685     {
1686         if ( mpData->maHelpSettings != rSet.mpData->maHelpSettings )
1687         {
1688             CopyData();
1689             mpData->maHelpSettings = rSet.mpData->maHelpSettings;
1690             nChangeFlags |= SETTINGS_HELP;
1691         }
1692     }
1693 
1694     if ( nFlags & SETTINGS_INTERNATIONAL )
1695     {
1696         // Nothing, class International is gone.
1697         DBG_ERRORFILE("AllSettings::Update: who calls with SETTINGS_INTERNATIONAL and why? You're flogging a dead horse.");
1698     }
1699 
1700     if ( nFlags & SETTINGS_LOCALE )
1701     {
1702         if ( mpData->meLanguage || rSet.mpData->meLanguage )
1703         {
1704             SetLanguage( rSet.mpData->meLanguage );
1705             nChangeFlags |= SETTINGS_LOCALE;
1706         }
1707     }
1708 
1709     if ( nFlags & SETTINGS_UILOCALE )
1710     {
1711 		// UILocale can't be changed
1712     }
1713 
1714     return nChangeFlags;
1715 }
1716 
1717 // -----------------------------------------------------------------------
1718 
1719 sal_uLong AllSettings::GetChangeFlags( const AllSettings& rSet ) const
1720 {
1721     DBG_CHKTHIS( AllSettings, NULL );
1722     DBG_CHKOBJ( &rSet, AllSettings, NULL );
1723 
1724     sal_uLong nChangeFlags = 0;
1725 
1726     if ( mpData->maMachineSettings != rSet.mpData->maMachineSettings )
1727         nChangeFlags |= SETTINGS_MACHINE;
1728 
1729     if ( mpData->maMouseSettings != rSet.mpData->maMouseSettings )
1730         nChangeFlags |= SETTINGS_MOUSE;
1731 
1732     if ( mpData->maKeyboardSettings != rSet.mpData->maKeyboardSettings )
1733         nChangeFlags |= SETTINGS_KEYBOARD;
1734 
1735     if ( mpData->maStyleSettings != rSet.mpData->maStyleSettings )
1736         nChangeFlags |= SETTINGS_STYLE;
1737 
1738     if ( mpData->maMiscSettings != rSet.mpData->maMiscSettings )
1739         nChangeFlags |= SETTINGS_MISC;
1740 
1741     if ( mpData->maNotificationSettings != rSet.mpData->maNotificationSettings )
1742         nChangeFlags |= SETTINGS_NOTIFICATION;
1743 
1744     if ( mpData->maHelpSettings != rSet.mpData->maHelpSettings )
1745         nChangeFlags |= SETTINGS_HELP;
1746 
1747     if ( mpData->meLanguage || rSet.mpData->meLanguage )
1748         nChangeFlags |= SETTINGS_LOCALE;
1749 
1750     return nChangeFlags;
1751 }
1752 
1753 // -----------------------------------------------------------------------
1754 
1755 sal_Bool AllSettings::operator ==( const AllSettings& rSet ) const
1756 {
1757     DBG_CHKTHIS( AllSettings, NULL );
1758     DBG_CHKOBJ( &rSet, AllSettings, NULL );
1759 
1760     if ( mpData == rSet.mpData )
1761         return sal_True;
1762 
1763     if ( (mpData->maMachineSettings         == rSet.mpData->maMachineSettings)      &&
1764          (mpData->maMouseSettings           == rSet.mpData->maMouseSettings)        &&
1765          (mpData->maKeyboardSettings        == rSet.mpData->maKeyboardSettings)     &&
1766          (mpData->maStyleSettings           == rSet.mpData->maStyleSettings)        &&
1767          (mpData->maMiscSettings            == rSet.mpData->maMiscSettings)         &&
1768          (mpData->maNotificationSettings    == rSet.mpData->maNotificationSettings) &&
1769          (mpData->maHelpSettings            == rSet.mpData->maHelpSettings)         &&
1770          (mpData->mnSystemUpdate            == rSet.mpData->mnSystemUpdate)         &&
1771          (mpData->maLocale					== rSet.mpData->maLocale)				&&
1772          (mpData->mnWindowUpdate            == rSet.mpData->mnWindowUpdate) )
1773     {
1774         return sal_True;
1775     }
1776 	else
1777 		return sal_False;
1778 }
1779 
1780 // -----------------------------------------------------------------------
1781 
1782 void AllSettings::SetLocale( const ::com::sun::star::lang::Locale& rLocale )
1783 {
1784 	CopyData();
1785 
1786 	mpData->maLocale = rLocale;
1787 
1788 	if ( !rLocale.Language.getLength() )
1789 		mpData->meLanguage = LANGUAGE_SYSTEM;
1790 	else
1791 		mpData->meLanguage = MsLangId::convertLocaleToLanguage( rLocale );
1792 	if ( mpData->mpLocaleDataWrapper )
1793 	{
1794 		delete mpData->mpLocaleDataWrapper;
1795 		mpData->mpLocaleDataWrapper = NULL;
1796 	}
1797 	if ( mpData->mpI18nHelper )
1798 	{
1799 		delete mpData->mpI18nHelper;
1800 		mpData->mpI18nHelper = NULL;
1801 	}
1802 }
1803 
1804 // -----------------------------------------------------------------------
1805 
1806 void AllSettings::SetUILocale( const ::com::sun::star::lang::Locale& )
1807 {
1808 	// there is only one UILocale per process
1809 }
1810 
1811 // -----------------------------------------------------------------------
1812 
1813 void AllSettings::SetLanguage( LanguageType eLang )
1814 {
1815 	if ( eLang != mpData->meLanguage )
1816 	{
1817 		CopyData();
1818 
1819 		mpData->meLanguage = eLang;
1820 		MsLangId::convertLanguageToLocale( GetLanguage(), ((AllSettings*)this)->mpData->maLocale );
1821 		if ( mpData->mpLocaleDataWrapper )
1822 		{
1823 			delete mpData->mpLocaleDataWrapper;
1824 			mpData->mpLocaleDataWrapper = NULL;
1825 		}
1826 		if ( mpData->mpI18nHelper )
1827 		{
1828 			delete mpData->mpI18nHelper;
1829 			mpData->mpI18nHelper = NULL;
1830 		}
1831 	}
1832 }
1833 
1834 // -----------------------------------------------------------------------
1835 
1836 void AllSettings::SetUILanguage( LanguageType  )
1837 {
1838 	// there is only one UILanguage per process
1839 }
1840 
1841 // -----------------------------------------------------------------------
1842 
1843 sal_Bool AllSettings::GetLayoutRTL() const
1844 {
1845     static const char* pEnv = getenv("SAL_RTL_ENABLED" );
1846     static int  nUIMirroring = -1;   // -1: undef, 0: auto, 1: on 2: off
1847 
1848     // environment always overrides
1849     if( pEnv )
1850         return true;
1851 
1852     sal_Bool bRTL = sal_False;
1853 
1854     if( nUIMirroring == -1 )
1855     {
1856         nUIMirroring = 0; // ask configuration only once
1857         utl::OConfigurationNode aNode = utl::OConfigurationTreeRoot::tryCreateWithServiceFactory(
1858             vcl::unohelper::GetMultiServiceFactory(),
1859             OUString::createFromAscii( "org.openoffice.Office.Common/I18N/CTL" ) );    // note: case sensisitive !
1860         if ( aNode.isValid() )
1861         {
1862             sal_Bool bTmp = sal_Bool();
1863             ::com::sun::star::uno::Any aValue = aNode.getNodeValue( OUString::createFromAscii( "UIMirroring" ) );
1864             if( aValue >>= bTmp )
1865             {
1866                 // found true or false; if it was nil, nothing is changed
1867                 nUIMirroring = bTmp ? 1 : 2;
1868             }
1869         }
1870     }
1871 
1872     if( nUIMirroring == 0 )  // no config found (eg, setup) or default (nil) was set: check language
1873     {
1874         LanguageType aLang = LANGUAGE_DONTKNOW;
1875         ImplSVData* pSVData = ImplGetSVData();
1876         if ( pSVData->maAppData.mpSettings )
1877             aLang = pSVData->maAppData.mpSettings->GetUILanguage();
1878         bRTL = MsLangId::isRightToLeft( aLang );
1879     }
1880     else
1881         bRTL = (nUIMirroring == 1);
1882 
1883     return bRTL;
1884 }
1885 
1886 // -----------------------------------------------------------------------
1887 
1888 const ::com::sun::star::lang::Locale& AllSettings::GetLocale() const
1889 {
1890     if ( !mpData->maLocale.Language.getLength() )
1891 		mpData->maLocale = mpData->maSysLocale.GetLocale();
1892 
1893     return mpData->maLocale;
1894 }
1895 
1896 // -----------------------------------------------------------------------
1897 
1898 const ::com::sun::star::lang::Locale& AllSettings::GetUILocale() const
1899 {
1900 	// the UILocale is never changed
1901     if ( !mpData->maUILocale.Language.getLength() )
1902 		mpData->maUILocale = mpData->maSysLocale.GetUILocale();
1903 
1904     return mpData->maUILocale;
1905 }
1906 
1907 // -----------------------------------------------------------------------
1908 
1909 LanguageType AllSettings::GetLanguage() const
1910 {
1911 	// meLanguage == LANGUAGE_SYSTEM means: use settings from SvtSysLocale
1912     if ( mpData->meLanguage == LANGUAGE_SYSTEM )
1913         return mpData->maSysLocale.GetLanguage();
1914 
1915     return mpData->meLanguage;
1916 }
1917 
1918 // -----------------------------------------------------------------------
1919 
1920 LanguageType AllSettings::GetUILanguage() const
1921 {
1922 	// the UILanguage is never changed
1923 	return mpData->maSysLocale.GetUILanguage();
1924 }
1925 
1926 // -----------------------------------------------------------------------
1927 
1928 const LocaleDataWrapper& AllSettings::GetLocaleDataWrapper() const
1929 {
1930     if ( !mpData->mpLocaleDataWrapper )
1931         ((AllSettings*)this)->mpData->mpLocaleDataWrapper = new LocaleDataWrapper( vcl::unohelper::GetMultiServiceFactory(), GetLocale() );
1932     return *mpData->mpLocaleDataWrapper;
1933 }
1934 
1935 // -----------------------------------------------------------------------
1936 
1937 const LocaleDataWrapper& AllSettings::GetUILocaleDataWrapper() const
1938 {
1939     if ( !mpData->mpUILocaleDataWrapper )
1940         ((AllSettings*)this)->mpData->mpUILocaleDataWrapper = new LocaleDataWrapper( vcl::unohelper::GetMultiServiceFactory(), GetUILocale() );
1941     return *mpData->mpUILocaleDataWrapper;
1942 }
1943 
1944 // -----------------------------------------------------------------------
1945 
1946 const vcl::I18nHelper& AllSettings::GetLocaleI18nHelper() const
1947 {
1948     if ( !mpData->mpI18nHelper ) {
1949         ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> aFactory(vcl::unohelper::GetMultiServiceFactory());
1950         ((AllSettings*)this)->mpData->mpI18nHelper = new vcl::I18nHelper( aFactory, GetLocale() );
1951     }
1952     return *mpData->mpI18nHelper;
1953 }
1954 
1955 // -----------------------------------------------------------------------
1956 
1957 const vcl::I18nHelper& AllSettings::GetUILocaleI18nHelper() const
1958 {
1959     if ( !mpData->mpUII18nHelper ) {
1960         ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> aFactory(vcl::unohelper::GetMultiServiceFactory());
1961         ((AllSettings*)this)->mpData->mpUII18nHelper = new vcl::I18nHelper( aFactory, GetUILocale() );
1962     }
1963     return *mpData->mpUII18nHelper;
1964 }
1965 
1966 
1967 // -----------------------------------------------------------------------
1968 /*
1969 const CollatorWrapper& AllSettings::GetCollatorWrapper() const
1970 {
1971     if ( !mpData->mpCollatorWrapper )
1972     {
1973         ((AllSettings*)this)->mpData->mpCollatorWrapper = new CollatorWrapper( vcl::unohelper::GetMultiServiceFactory() );
1974         ((AllSettings*)this)->mpData->mpCollatorWrapper->loadDefaultCollator( GetLocale(), 0 );
1975     }
1976     return *mpData->mpCollatorWrapper;
1977 }
1978 */
1979 // -----------------------------------------------------------------------
1980 /*
1981 const CollatorWrapper& AllSettings::GetUICollatorWrapper() const
1982 {
1983     if ( !mpData->mpUICollatorWrapper )
1984     {
1985         ((AllSettings*)this)->mpData->mpUICollatorWrapper = new CollatorWrapper( vcl::unohelper::GetMultiServiceFactory() );
1986         ((AllSettings*)this)->mpData->mpUICollatorWrapper->loadDefaultCollator( GetUILocale(), 0 );
1987     }
1988     return *mpData->mpUICollatorWrapper;
1989 }
1990 */
1991 
1992 void AllSettings::LocaleSettingsChanged( sal_uInt32 nHint )
1993 {
1994 	AllSettings aAllSettings( Application::GetSettings() );
1995 	if ( nHint & SYSLOCALEOPTIONS_HINT_DECSEP )
1996 	{
1997 		MiscSettings aMiscSettings = aAllSettings.GetMiscSettings();
1998 		sal_Bool bIsDecSepAsLocale = aAllSettings.mpData->maSysLocale.GetOptions().IsDecimalSeparatorAsLocale();
1999 		if ( aMiscSettings.GetEnableLocalizedDecimalSep() != bIsDecSepAsLocale )
2000 		{
2001 			aMiscSettings.SetEnableLocalizedDecimalSep( bIsDecSepAsLocale );
2002 			aAllSettings.SetMiscSettings( aMiscSettings );
2003 		}
2004 	}
2005 
2006 	if ( (nHint & SYSLOCALEOPTIONS_HINT_LOCALE) )
2007 		aAllSettings.SetLocale( aAllSettings.mpData->maSysLocale.GetOptions().GetLocale() );
2008 
2009 	Application::SetSettings( aAllSettings );
2010 }
2011