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