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