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