1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: settings.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
33 #include "tools/debug.hxx"
34 #include "i18npool/mslangid.hxx"
35 #include "vcl/svapp.hxx"
36 #include "vcl/svdata.hxx"
37 #include "vcl/event.hxx"
38 #include "vcl/settings.hxx"
39 #include "vcl/i18nhelp.hxx"
40 #include "vcl/fontcfg.hxx"
41 #include "vcl/configsettings.hxx"
42 #include "vcl/gradient.hxx"
43 #include "vcl/unohelp.hxx"
44 #include "unotools/localedatawrapper.hxx"
45 #include "unotools/collatorwrapper.hxx"
46 #include "unotools/configmgr.hxx"
47 #include "unotools/confignode.hxx"
50 #include "tools/prewin.h"
52 #include "tools/postwin.h"
57 // =======================================================================
59 DBG_NAME( AllSettings
)
61 // =======================================================================
63 #define STDSYS_STYLE (STYLE_OPTION_SCROLLARROW | \
64 STYLE_OPTION_SPINARROW | \
65 STYLE_OPTION_SPINUPDOWN | \
66 STYLE_OPTION_NOMNEMONICS)
68 // =======================================================================
70 ImplMachineData::ImplMachineData()
76 mnScreenRasterFontDeviation
= 0;
79 // -----------------------------------------------------------------------
81 ImplMachineData::ImplMachineData( const ImplMachineData
& rData
)
84 mnOptions
= rData
.mnOptions
;
85 mnScreenOptions
= rData
.mnScreenOptions
;
86 mnPrintOptions
= rData
.mnPrintOptions
;
87 mnScreenRasterFontDeviation
= rData
.mnScreenRasterFontDeviation
;
90 // -----------------------------------------------------------------------
92 MachineSettings::MachineSettings()
94 mpData
= new ImplMachineData();
97 // -----------------------------------------------------------------------
99 MachineSettings::MachineSettings( const MachineSettings
& rSet
)
101 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "MachineSettings: RefCount overflow" );
103 // shared Instance Daten uebernehmen und Referenzcounter erhoehen
104 mpData
= rSet
.mpData
;
105 mpData
->mnRefCount
++;
108 // -----------------------------------------------------------------------
110 MachineSettings::~MachineSettings()
112 // Daten loeschen, wenn letzte Referenz
113 if ( mpData
->mnRefCount
== 1 )
116 mpData
->mnRefCount
--;
119 // -----------------------------------------------------------------------
121 const MachineSettings
& MachineSettings::operator =( const MachineSettings
& rSet
)
123 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "MachineSettings: RefCount overflow" );
125 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
126 rSet
.mpData
->mnRefCount
++;
128 // Daten loeschen, wenn letzte Referenz
129 if ( mpData
->mnRefCount
== 1 )
132 mpData
->mnRefCount
--;
134 mpData
= rSet
.mpData
;
139 // -----------------------------------------------------------------------
141 void MachineSettings::CopyData()
143 // Falls noch andere Referenzen bestehen, dann kopieren
144 if ( mpData
->mnRefCount
!= 1 )
146 mpData
->mnRefCount
--;
147 mpData
= new ImplMachineData( *mpData
);
151 // -----------------------------------------------------------------------
153 BOOL
MachineSettings::operator ==( const MachineSettings
& rSet
) const
155 if ( mpData
== rSet
.mpData
)
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
) )
167 // =======================================================================
169 ImplMouseData::ImplMouseData()
173 mnDoubleClkTime
= 500;
174 mnDoubleClkWidth
= 2;
175 mnDoubleClkHeight
= 2;
176 mnStartDragWidth
= 2;
177 mnStartDragHeight
= 2;
178 mnStartDragCode
= MOUSE_LEFT
;
180 mnDragCopyCode
= KEY_MOD1
;
181 mnDragLinkCode
= KEY_SHIFT
| KEY_MOD1
;
182 mnContextMenuCode
= MOUSE_RIGHT
;
183 mnContextMenuClicks
= 1;
184 mbContextMenuDown
= TRUE
;
185 mnMiddleButtonAction
= MOUSE_MIDDLE_AUTOSCROLL
;
186 mnScrollRepeat
= 100;
187 mnButtonStartRepeat
= 370;
191 mnFollow
= MOUSE_FOLLOW_MENU
| MOUSE_FOLLOW_DDLIST
;
192 mnWheelBehavior
= MOUSE_WHEEL_FOCUS_ONLY
;
195 // -----------------------------------------------------------------------
197 ImplMouseData::ImplMouseData( const ImplMouseData
& rData
)
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
;
223 // -----------------------------------------------------------------------
225 MouseSettings::MouseSettings()
227 mpData
= new ImplMouseData();
230 // -----------------------------------------------------------------------
232 MouseSettings::MouseSettings( const MouseSettings
& rSet
)
234 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "MouseSettings: RefCount overflow" );
236 // shared Instance Daten uebernehmen und Referenzcounter erhoehen
237 mpData
= rSet
.mpData
;
238 mpData
->mnRefCount
++;
241 // -----------------------------------------------------------------------
243 MouseSettings::~MouseSettings()
245 // Daten loeschen, wenn letzte Referenz
246 if ( mpData
->mnRefCount
== 1 )
249 mpData
->mnRefCount
--;
252 // -----------------------------------------------------------------------
254 const MouseSettings
& MouseSettings::operator =( const MouseSettings
& rSet
)
256 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "MouseSettings: RefCount overflow" );
258 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
259 rSet
.mpData
->mnRefCount
++;
261 // Daten loeschen, wenn letzte Referenz
262 if ( mpData
->mnRefCount
== 1 )
265 mpData
->mnRefCount
--;
267 mpData
= rSet
.mpData
;
272 // -----------------------------------------------------------------------
274 void MouseSettings::CopyData()
276 // Falls noch andere Referenzen bestehen, dann kopieren
277 if ( mpData
->mnRefCount
!= 1 )
279 mpData
->mnRefCount
--;
280 mpData
= new ImplMouseData( *mpData
);
284 // -----------------------------------------------------------------------
286 BOOL
MouseSettings::operator ==( const MouseSettings
& rSet
) const
288 if ( mpData
== rSet
.mpData
)
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
) )
317 // =======================================================================
319 ImplKeyboardData::ImplKeyboardData()
325 // -----------------------------------------------------------------------
327 ImplKeyboardData::ImplKeyboardData( const ImplKeyboardData
& rData
)
330 mnOptions
= rData
.mnOptions
;
333 // -----------------------------------------------------------------------
335 KeyboardSettings::KeyboardSettings()
337 mpData
= new ImplKeyboardData();
340 // -----------------------------------------------------------------------
342 KeyboardSettings::KeyboardSettings( const KeyboardSettings
& rSet
)
344 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "KeyboardSettings: RefCount overflow" );
346 // shared Instance Daten uebernehmen und Referenzcounter erhoehen
347 mpData
= rSet
.mpData
;
348 mpData
->mnRefCount
++;
351 // -----------------------------------------------------------------------
353 KeyboardSettings::~KeyboardSettings()
355 // Daten loeschen, wenn letzte Referenz
356 if ( mpData
->mnRefCount
== 1 )
359 mpData
->mnRefCount
--;
362 // -----------------------------------------------------------------------
364 const KeyboardSettings
& KeyboardSettings::operator =( const KeyboardSettings
& rSet
)
366 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "KeyboardSettings: RefCount overflow" );
368 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
369 rSet
.mpData
->mnRefCount
++;
371 // Daten loeschen, wenn letzte Referenz
372 if ( mpData
->mnRefCount
== 1 )
375 mpData
->mnRefCount
--;
377 mpData
= rSet
.mpData
;
382 // -----------------------------------------------------------------------
384 void KeyboardSettings::CopyData()
386 // Falls noch andere Referenzen bestehen, dann kopieren
387 if ( mpData
->mnRefCount
!= 1 )
389 mpData
->mnRefCount
--;
390 mpData
= new ImplKeyboardData( *mpData
);
394 // -----------------------------------------------------------------------
396 BOOL
KeyboardSettings::operator ==( const KeyboardSettings
& rSet
) const
398 if ( mpData
== rSet
.mpData
)
401 if ( (mpData
->mnOptions
== rSet
.mpData
->mnOptions
) )
407 // =======================================================================
409 ImplStyleData::ImplStyleData()
412 mnScrollBarSize
= 16;
416 mnIconHorzSpace
= 50;
417 mnIconVertSpace
= 40;
418 mnAntialiasedMin
= 0;
420 mnCursorBlinkTime
= STYLE_CURSOR_NOBLINKTIME
;
422 mnScreenFontZoom
= 100;
423 mnRadioButtonStyle
= 0;
425 mnPushButtonStyle
= 0;
426 mnTabControlStyle
= 0;
427 mnLogoDisplayTime
= LOGO_DISPLAYTIME_STARTTIME
;
428 mnDragFullOptions
= 0;
429 mnAnimationOptions
= 0;
430 mnSelectionOptions
= 0;
431 mnDisplayOptions
= 0;
434 mnToolbarIconSize
= STYLE_TOOLBAR_ICONSIZE_UNKNOWN
;
435 mnSymbolsStyle
= STYLE_SYMBOLS_AUTO
;
436 mnPreferredSymbolsStyle
= STYLE_SYMBOLS_AUTO
;
441 // -----------------------------------------------------------------------
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
)
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 mnRadioButtonStyle
= rData
.mnRadioButtonStyle
;
524 mnCheckBoxStyle
= rData
.mnCheckBoxStyle
;
525 mnPushButtonStyle
= rData
.mnPushButtonStyle
;
526 mnTabControlStyle
= rData
.mnTabControlStyle
;
527 mnLogoDisplayTime
= rData
.mnLogoDisplayTime
;
528 mnDragFullOptions
= rData
.mnDragFullOptions
;
529 mnAnimationOptions
= rData
.mnAnimationOptions
;
530 mnSelectionOptions
= rData
.mnSelectionOptions
;
531 mnDisplayOptions
= rData
.mnDisplayOptions
;
532 mnOptions
= rData
.mnOptions
;
533 mnHighContrast
= rData
.mnHighContrast
;
534 mnUseSystemUIFonts
= rData
.mnUseSystemUIFonts
;
535 mnUseFlatBorders
= rData
.mnUseFlatBorders
;
536 mnUseFlatMenues
= rData
.mnUseFlatMenues
;
537 mnAutoMnemonic
= rData
.mnAutoMnemonic
;
538 mnUseImagesInMenus
= rData
.mnUseImagesInMenus
;
539 mnSkipDisabledInMenus
= rData
.mnSkipDisabledInMenus
;
540 mnToolbarIconSize
= rData
.mnToolbarIconSize
;
541 mnSymbolsStyle
= rData
.mnSymbolsStyle
;
542 mnPreferredSymbolsStyle
= rData
.mnPreferredSymbolsStyle
;
545 // -----------------------------------------------------------------------
547 void ImplStyleData::SetStandardStyles()
549 Font
aStdFont( FAMILY_SWISS
, Size( 0, 10 ) );
550 aStdFont
.SetCharSet( gsl_getSystemTextEncoding() );
551 aStdFont
.SetWeight( WEIGHT_NORMAL
);
552 aStdFont
.SetName( vcl::DefaultFontConfiguration::get()->getUserInterfaceFont(com::sun::star::lang::Locale( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("en") ), rtl::OUString(), rtl::OUString() ) ) );
553 maAppFont
= aStdFont
;
554 maHelpFont
= aStdFont
;
555 maMenuFont
= aStdFont
;
556 maToolFont
= aStdFont
;
557 maGroupFont
= aStdFont
;
558 maLabelFont
= aStdFont
;
559 maInfoFont
= aStdFont
;
560 maRadioCheckFont
= aStdFont
;
561 maPushButtonFont
= aStdFont
;
562 maFieldFont
= aStdFont
;
563 maIconFont
= aStdFont
;
564 maFloatTitleFont
= aStdFont
;
565 aStdFont
.SetWeight( WEIGHT_BOLD
);
566 maTitleFont
= aStdFont
;
568 maFaceColor
= Color( COL_LIGHTGRAY
);
569 maCheckedColor
= Color( 0xCC, 0xCC, 0xCC );
570 maLightColor
= Color( COL_WHITE
);
571 maLightBorderColor
= Color( COL_LIGHTGRAY
);
572 maShadowColor
= Color( COL_GRAY
);
573 maDarkShadowColor
= Color( COL_BLACK
);
574 maButtonTextColor
= Color( COL_BLACK
);
575 maButtonRolloverTextColor
= Color( COL_BLACK
);
576 maRadioCheckTextColor
= Color( COL_BLACK
);
577 maGroupTextColor
= Color( COL_BLACK
);
578 maLabelTextColor
= Color( COL_BLACK
);
579 maInfoTextColor
= Color( COL_BLACK
);
580 maWindowColor
= Color( COL_WHITE
);
581 maWindowTextColor
= Color( COL_BLACK
);
582 maDialogColor
= Color( COL_LIGHTGRAY
);
583 maDialogTextColor
= Color( COL_BLACK
);
584 maWorkspaceColor
= Color( COL_GRAY
);
585 maMonoColor
= Color( COL_BLACK
);
586 maFieldColor
= Color( COL_WHITE
);
587 maFieldTextColor
= Color( COL_BLACK
);
588 maFieldRolloverTextColor
= Color( COL_BLACK
);
589 maActiveColor
= Color( COL_BLUE
);
590 maActiveColor2
= Color( COL_BLACK
);
591 maActiveTextColor
= Color( COL_WHITE
);
592 maActiveBorderColor
= Color( COL_LIGHTGRAY
);
593 maDeactiveColor
= Color( COL_GRAY
);
594 maDeactiveColor2
= Color( COL_BLACK
);
595 maDeactiveTextColor
= Color( COL_LIGHTGRAY
);
596 maDeactiveBorderColor
= Color( COL_LIGHTGRAY
);
597 maMenuColor
= Color( COL_LIGHTGRAY
);
598 maMenuBarColor
= Color( COL_LIGHTGRAY
);
599 maMenuBorderColor
= Color( COL_LIGHTGRAY
);
600 maMenuTextColor
= Color( COL_BLACK
);
601 maMenuBarTextColor
= Color( COL_BLACK
);
602 maMenuHighlightColor
= Color( COL_BLUE
);
603 maMenuHighlightTextColor
= Color( COL_WHITE
);
604 maHighlightColor
= Color( COL_BLUE
);
605 maHighlightTextColor
= Color( COL_WHITE
);
606 maActiveTabColor
= Color( COL_WHITE
);
607 maInactiveTabColor
= Color( COL_LIGHTGRAY
);
608 maDisableColor
= Color( COL_GRAY
);
609 maHelpColor
= Color( 0xFF, 0xFF, 0xE0 );
610 maHelpTextColor
= Color( COL_BLACK
);
611 maLinkColor
= Color( COL_BLUE
);
612 maVisitedLinkColor
= Color( 0x00, 0x00, 0xCC );
613 maHighlightLinkColor
= Color( COL_LIGHTBLUE
);
614 maFontColor
= Color( COL_BLACK
);
616 mnRadioButtonStyle
&= ~STYLE_RADIOBUTTON_STYLE
;
617 mnCheckBoxStyle
&= ~STYLE_CHECKBOX_STYLE
;
618 mnPushButtonStyle
&= ~STYLE_PUSHBUTTON_STYLE
;
619 mnTabControlStyle
= 0;
621 mnOptions
&= ~(STYLE_OPTION_SYSTEMSTYLE
| STDSYS_STYLE
);
624 mnFloatTitleHeight
= 13;
625 mnTearOffTitleHeight
= 8;
626 mnMenuBarHeight
= 14;
628 mnUseSystemUIFonts
= 1;
629 mnUseFlatBorders
= 0;
631 mnUseImagesInMenus
= (USHORT
)TRUE
;
632 mnSkipDisabledInMenus
= (USHORT
)FALSE
;
634 Gradient
aGrad( GRADIENT_LINEAR
, DEFAULT_WORKSPACE_GRADIENT_START_COLOR
, DEFAULT_WORKSPACE_GRADIENT_END_COLOR
);
635 maWorkspaceGradient
= Wallpaper( aGrad
);
638 // -----------------------------------------------------------------------
640 StyleSettings::StyleSettings()
642 mpData
= new ImplStyleData();
645 // -----------------------------------------------------------------------
647 StyleSettings::StyleSettings( const StyleSettings
& rSet
)
649 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "StyleSettings: RefCount overflow" );
651 // shared Instance Daten uebernehmen und Referenzcounter erhoehen
652 mpData
= rSet
.mpData
;
653 mpData
->mnRefCount
++;
656 // -----------------------------------------------------------------------
658 StyleSettings::~StyleSettings()
660 // Daten loeschen, wenn letzte Referenz
661 if ( mpData
->mnRefCount
== 1 )
664 mpData
->mnRefCount
--;
667 // -----------------------------------------------------------------------
669 void StyleSettings::Set3DColors( const Color
& rColor
)
672 mpData
->maFaceColor
= rColor
;
673 mpData
->maLightBorderColor
= rColor
;
674 mpData
->maMenuBorderColor
= rColor
;
675 mpData
->maDarkShadowColor
= Color( COL_BLACK
);
676 if ( rColor
!= Color( COL_LIGHTGRAY
) )
678 mpData
->maLightColor
= rColor
;
679 mpData
->maShadowColor
= rColor
;
680 mpData
->maLightColor
.IncreaseLuminance( 64 );
681 mpData
->maShadowColor
.DecreaseLuminance( 64 );
682 ULONG nRed
= mpData
->maLightColor
.GetRed();
683 ULONG nGreen
= mpData
->maLightColor
.GetGreen();
684 ULONG nBlue
= mpData
->maLightColor
.GetBlue();
685 nRed
+= (ULONG
)(mpData
->maShadowColor
.GetRed());
686 nGreen
+= (ULONG
)(mpData
->maShadowColor
.GetGreen());
687 nBlue
+= (ULONG
)(mpData
->maShadowColor
.GetBlue());
688 mpData
->maCheckedColor
= Color( (BYTE
)(nRed
/2), (BYTE
)(nGreen
/2), (BYTE
)(nBlue
/2) );
692 mpData
->maCheckedColor
= Color( 0x99, 0x99, 0x99 );
693 mpData
->maLightColor
= Color( COL_WHITE
);
694 mpData
->maShadowColor
= Color( COL_GRAY
);
698 // -----------------------------------------------------------------------
700 ::rtl::OUString
StyleSettings::ImplSymbolsStyleToName( ULONG nStyle
) const
704 case STYLE_SYMBOLS_DEFAULT
: return ::rtl::OUString::createFromAscii( "default" );
705 case STYLE_SYMBOLS_HICONTRAST
: return ::rtl::OUString::createFromAscii( "hicontrast" );
706 case STYLE_SYMBOLS_INDUSTRIAL
: return ::rtl::OUString::createFromAscii( "industrial" );
707 case STYLE_SYMBOLS_CRYSTAL
: return ::rtl::OUString::createFromAscii( "crystal" );
708 case STYLE_SYMBOLS_TANGO
: return ::rtl::OUString::createFromAscii( "tango" );
709 case STYLE_SYMBOLS_CLASSIC
: return ::rtl::OUString::createFromAscii( "classic" );
710 case STYLE_SYMBOLS_OXYGEN
: return ::rtl::OUString::createFromAscii( "oxygen" );
713 return ::rtl::OUString::createFromAscii( "auto" );
716 // -----------------------------------------------------------------------
718 ULONG
StyleSettings::ImplNameToSymbolsStyle( const ::rtl::OUString
&rName
) const
720 if ( rName
== ::rtl::OUString::createFromAscii( "default" ) )
721 return STYLE_SYMBOLS_DEFAULT
;
722 else if ( rName
== ::rtl::OUString::createFromAscii( "hicontrast" ) )
723 return STYLE_SYMBOLS_HICONTRAST
;
724 else if ( rName
== ::rtl::OUString::createFromAscii( "industrial" ) )
725 return STYLE_SYMBOLS_INDUSTRIAL
;
726 else if ( rName
== ::rtl::OUString::createFromAscii( "crystal" ) )
727 return STYLE_SYMBOLS_CRYSTAL
;
728 else if ( rName
== ::rtl::OUString::createFromAscii( "tango" ) )
729 return STYLE_SYMBOLS_TANGO
;
730 else if ( rName
== ::rtl::OUString::createFromAscii( "classic" ) )
731 return STYLE_SYMBOLS_CLASSIC
;
732 else if ( rName
== ::rtl::OUString::createFromAscii( "oxygen" ) )
733 return STYLE_SYMBOLS_OXYGEN
;
735 return STYLE_SYMBOLS_AUTO
;
738 // -----------------------------------------------------------------------
741 The preferred style name can be read from the desktop setting. We
742 need to find the closest theme name registered in OOo. Therefore
743 we check if any registered style name is a case-insensitive
744 substring of the preferred style name.
746 void StyleSettings::SetPreferredSymbolsStyleName( const ::rtl::OUString
&rName
)
748 if ( rName
.getLength() > 0 )
750 ::rtl::OUString
rNameLowCase( rName
.toAsciiLowerCase() );
752 for( sal_uInt32 n
= 0; n
<= STYLE_SYMBOLS_THEMES_MAX
; n
++ )
753 if ( rNameLowCase
.indexOf( ImplSymbolsStyleToName( n
) ) != -1 )
755 if (n
== STYLE_SYMBOLS_INDUSTRIAL
)
756 // The Industrial OOo icon theme is too old.
757 // The OOo Tango icon theme is closer to the current GNOME Industrial theme rules.
758 SetPreferredSymbolsStyle( STYLE_SYMBOLS_TANGO
);
760 SetPreferredSymbolsStyle( n
);
766 // -----------------------------------------------------------------------
768 ULONG
StyleSettings::GetCurrentSymbolsStyle() const
770 // style selected in Tools -> Options... -> OpenOffice.org -> View
771 ULONG nStyle
= GetSymbolsStyle();
773 if ( nStyle
== STYLE_SYMBOLS_AUTO
)
775 // the preferred style can be read from the desktop setting by the desktop native widgets modules
776 ULONG nPreferredStyle
= GetPreferredSymbolsStyle();
778 if ( nPreferredStyle
== STYLE_SYMBOLS_AUTO
)
781 // use a hardcoded desktop-specific fallback if no preferred style has been detected
782 static bool sbFallbackDesktopChecked
= false;
783 static ULONG snFallbackDesktopStyle
= STYLE_SYMBOLS_DEFAULT
;
785 if ( !sbFallbackDesktopChecked
)
787 snFallbackDesktopStyle
= GetAutoSymbolsStyle();
788 sbFallbackDesktopChecked
= true;
791 nPreferredStyle
= snFallbackDesktopStyle
;
794 nStyle
= GetHighContrastMode()? STYLE_SYMBOLS_HICONTRAST
: nPreferredStyle
;
800 // -----------------------------------------------------------------------
802 ULONG
StyleSettings::GetAutoSymbolsStyle() const
804 const ::rtl::OUString
& rDesktopEnvironment
= Application::GetDesktopEnvironment();
805 ULONG nRet
= STYLE_SYMBOLS_DEFAULT
;
810 const ::com::sun::star::uno::Any
aAny( ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::OPENSOURCECONTEXT
) );
811 sal_Int32
nValue( 0 );
818 catch ( ::com::sun::star::uno::Exception
& )
824 if( rDesktopEnvironment
.equalsIgnoreAsciiCaseAscii( "gnome" ) ||
825 rDesktopEnvironment
.equalsIgnoreAsciiCaseAscii( "windows" ) )
826 nRet
= STYLE_SYMBOLS_TANGO
;
827 else if( rDesktopEnvironment
.equalsIgnoreAsciiCaseAscii( "kde" ) )
828 nRet
= STYLE_SYMBOLS_CRYSTAL
;
829 else if( rDesktopEnvironment
.equalsIgnoreAsciiCaseAscii( "kde4" ) )
830 nRet
= STYLE_SYMBOLS_OXYGEN
;
836 // -----------------------------------------------------------------------
838 void StyleSettings::SetStandardStyles()
841 mpData
->SetStandardStyles();
844 // -----------------------------------------------------------------------
846 void StyleSettings::SetStandardWinStyles()
848 return; // no more style changes since NWF
851 // -----------------------------------------------------------------------
853 void StyleSettings::SetStandardOS2Styles()
855 return; // no more style changes since NWF
858 // -----------------------------------------------------------------------
860 void StyleSettings::SetStandardMacStyles()
862 return; // no more style changes since NWF
865 // -----------------------------------------------------------------------
867 void StyleSettings::SetStandardUnixStyles()
869 return; // no more style changes since NWF
872 // -----------------------------------------------------------------------
874 Color
StyleSettings::GetFaceGradientColor() const
876 // compute a brighter face color that can be used in gradients
877 // for a convex look (eg toolbars)
880 GetFaceColor().RGBtoHSB( h
, s
, b
);
883 return Color( Color::HSBtoRGB( h
, s
, b
) );
886 // -----------------------------------------------------------------------
888 Color
StyleSettings::GetSeparatorColor() const
890 // compute a brighter shadow color for separators (used in toolbars or between menubar and toolbars on Windows XP)
892 GetShadowColor().RGBtoHSB( h
, s
, b
);
895 return Color( Color::HSBtoRGB( h
, s
, b
) );
898 // -----------------------------------------------------------------------
900 const StyleSettings
& StyleSettings::operator =( const StyleSettings
& rSet
)
902 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "StyleSettings: RefCount overflow" );
904 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
905 rSet
.mpData
->mnRefCount
++;
907 // Daten loeschen, wenn letzte Referenz
908 if ( mpData
->mnRefCount
== 1 )
911 mpData
->mnRefCount
--;
913 mpData
= rSet
.mpData
;
918 // -----------------------------------------------------------------------
920 void StyleSettings::CopyData()
922 // Falls noch andere Referenzen bestehen, dann kopieren
923 if ( mpData
->mnRefCount
!= 1 )
925 mpData
->mnRefCount
--;
926 mpData
= new ImplStyleData( *mpData
);
930 // -----------------------------------------------------------------------
932 inline BOOL
ImplIsBackOrWhite( const Color
& rColor
)
934 UINT8 nLuminance
= rColor
.GetLuminance();
935 return ( nLuminance
< 8 ) || ( nLuminance
> 250 );
938 BOOL
StyleSettings::IsHighContrastBlackAndWhite() const
942 // Only use B&W if fully B&W, like on GNOME.
943 // Some colors like CheckedColor and HighlightColor are not B&W in Windows Standard HC Black,
944 // and we don't want to be B&W then, so check these color first, very probably not B&W.
946 // Unfortunately, GNOME uses a very very dark color (0x000033) instead of BLACK (0x000000)
948 if ( !ImplIsBackOrWhite( GetFaceColor() ) )
950 else if ( !ImplIsBackOrWhite( GetHighlightTextColor() ) )
952 else if ( !ImplIsBackOrWhite( GetWindowColor() ) )
954 else if ( !ImplIsBackOrWhite( GetWindowTextColor() ) )
956 else if ( !ImplIsBackOrWhite( GetButtonTextColor() ) )
958 else if ( !ImplIsBackOrWhite( GetButtonTextColor() ) )
960 else if ( !ImplIsBackOrWhite( GetGroupTextColor() ) )
962 else if ( !ImplIsBackOrWhite( GetLabelTextColor() ) )
964 else if ( !ImplIsBackOrWhite( GetDialogColor() ) )
966 else if ( !ImplIsBackOrWhite( GetFieldColor() ) )
968 else if ( !ImplIsBackOrWhite( GetMenuColor() ) )
970 else if ( !ImplIsBackOrWhite( GetMenuBarColor() ) )
972 else if ( !ImplIsBackOrWhite( GetMenuHighlightColor() ) )
978 // -----------------------------------------------------------------------
980 BOOL
StyleSettings::operator ==( const StyleSettings
& rSet
) const
982 if ( mpData
== rSet
.mpData
)
985 if ( (mpData
->mnOptions
== rSet
.mpData
->mnOptions
) &&
986 (mpData
->mnAutoMnemonic
== rSet
.mpData
->mnAutoMnemonic
) &&
987 (mpData
->mnLogoDisplayTime
== rSet
.mpData
->mnLogoDisplayTime
) &&
988 (mpData
->mnDragFullOptions
== rSet
.mpData
->mnDragFullOptions
) &&
989 (mpData
->mnAnimationOptions
== rSet
.mpData
->mnAnimationOptions
) &&
990 (mpData
->mnSelectionOptions
== rSet
.mpData
->mnSelectionOptions
) &&
991 (mpData
->mnDisplayOptions
== rSet
.mpData
->mnDisplayOptions
) &&
992 (mpData
->mnCursorSize
== rSet
.mpData
->mnCursorSize
) &&
993 (mpData
->mnCursorBlinkTime
== rSet
.mpData
->mnCursorBlinkTime
) &&
994 (mpData
->mnBorderSize
== rSet
.mpData
->mnBorderSize
) &&
995 (mpData
->mnTitleHeight
== rSet
.mpData
->mnTitleHeight
) &&
996 (mpData
->mnFloatTitleHeight
== rSet
.mpData
->mnFloatTitleHeight
) &&
997 (mpData
->mnTearOffTitleHeight
== rSet
.mpData
->mnTearOffTitleHeight
) &&
998 (mpData
->mnMenuBarHeight
== rSet
.mpData
->mnMenuBarHeight
) &&
999 (mpData
->mnScrollBarSize
== rSet
.mpData
->mnScrollBarSize
) &&
1000 (mpData
->mnMinThumbSize
== rSet
.mpData
->mnMinThumbSize
) &&
1001 (mpData
->mnSplitSize
== rSet
.mpData
->mnSplitSize
) &&
1002 (mpData
->mnSpinSize
== rSet
.mpData
->mnSpinSize
) &&
1003 (mpData
->mnIconHorzSpace
== rSet
.mpData
->mnIconHorzSpace
) &&
1004 (mpData
->mnIconVertSpace
== rSet
.mpData
->mnIconVertSpace
) &&
1005 (mpData
->mnAntialiasedMin
== rSet
.mpData
->mnAntialiasedMin
) &&
1006 (mpData
->mnScreenZoom
== rSet
.mpData
->mnScreenZoom
) &&
1007 (mpData
->mnScreenFontZoom
== rSet
.mpData
->mnScreenFontZoom
) &&
1008 (mpData
->mnRadioButtonStyle
== rSet
.mpData
->mnRadioButtonStyle
) &&
1009 (mpData
->mnCheckBoxStyle
== rSet
.mpData
->mnCheckBoxStyle
) &&
1010 (mpData
->mnPushButtonStyle
== rSet
.mpData
->mnPushButtonStyle
) &&
1011 (mpData
->mnTabControlStyle
== rSet
.mpData
->mnTabControlStyle
) &&
1012 (mpData
->mnHighContrast
== rSet
.mpData
->mnHighContrast
) &&
1013 (mpData
->mnUseSystemUIFonts
== rSet
.mpData
->mnUseSystemUIFonts
) &&
1014 (mpData
->mnUseFlatBorders
== rSet
.mpData
->mnUseFlatBorders
) &&
1015 (mpData
->mnUseFlatMenues
== rSet
.mpData
->mnUseFlatMenues
) &&
1016 (mpData
->maFaceColor
== rSet
.mpData
->maFaceColor
) &&
1017 (mpData
->maCheckedColor
== rSet
.mpData
->maCheckedColor
) &&
1018 (mpData
->maLightColor
== rSet
.mpData
->maLightColor
) &&
1019 (mpData
->maLightBorderColor
== rSet
.mpData
->maLightBorderColor
) &&
1020 (mpData
->maShadowColor
== rSet
.mpData
->maShadowColor
) &&
1021 (mpData
->maDarkShadowColor
== rSet
.mpData
->maDarkShadowColor
) &&
1022 (mpData
->maButtonTextColor
== rSet
.mpData
->maButtonTextColor
) &&
1023 (mpData
->maRadioCheckTextColor
== rSet
.mpData
->maRadioCheckTextColor
) &&
1024 (mpData
->maGroupTextColor
== rSet
.mpData
->maGroupTextColor
) &&
1025 (mpData
->maLabelTextColor
== rSet
.mpData
->maLabelTextColor
) &&
1026 (mpData
->maInfoTextColor
== rSet
.mpData
->maInfoTextColor
) &&
1027 (mpData
->maWindowColor
== rSet
.mpData
->maWindowColor
) &&
1028 (mpData
->maWindowTextColor
== rSet
.mpData
->maWindowTextColor
) &&
1029 (mpData
->maDialogColor
== rSet
.mpData
->maDialogColor
) &&
1030 (mpData
->maDialogTextColor
== rSet
.mpData
->maDialogTextColor
) &&
1031 (mpData
->maWorkspaceColor
== rSet
.mpData
->maWorkspaceColor
) &&
1032 (mpData
->maMonoColor
== rSet
.mpData
->maMonoColor
) &&
1033 (mpData
->maFieldColor
== rSet
.mpData
->maFieldColor
) &&
1034 (mpData
->maFieldTextColor
== rSet
.mpData
->maFieldTextColor
) &&
1035 (mpData
->maActiveColor
== rSet
.mpData
->maActiveColor
) &&
1036 (mpData
->maActiveColor2
== rSet
.mpData
->maActiveColor2
) &&
1037 (mpData
->maActiveTextColor
== rSet
.mpData
->maActiveTextColor
) &&
1038 (mpData
->maActiveBorderColor
== rSet
.mpData
->maActiveBorderColor
) &&
1039 (mpData
->maDeactiveColor
== rSet
.mpData
->maDeactiveColor
) &&
1040 (mpData
->maDeactiveColor2
== rSet
.mpData
->maDeactiveColor2
) &&
1041 (mpData
->maDeactiveTextColor
== rSet
.mpData
->maDeactiveTextColor
) &&
1042 (mpData
->maDeactiveBorderColor
== rSet
.mpData
->maDeactiveBorderColor
) &&
1043 (mpData
->maMenuColor
== rSet
.mpData
->maMenuColor
) &&
1044 (mpData
->maMenuBarColor
== rSet
.mpData
->maMenuBarColor
) &&
1045 (mpData
->maMenuBorderColor
== rSet
.mpData
->maMenuBorderColor
) &&
1046 (mpData
->maMenuTextColor
== rSet
.mpData
->maMenuTextColor
) &&
1047 (mpData
->maMenuBarTextColor
== rSet
.mpData
->maMenuBarTextColor
) &&
1048 (mpData
->maMenuHighlightColor
== rSet
.mpData
->maMenuHighlightColor
) &&
1049 (mpData
->maMenuHighlightTextColor
== rSet
.mpData
->maMenuHighlightTextColor
) &&
1050 (mpData
->maHighlightColor
== rSet
.mpData
->maHighlightColor
) &&
1051 (mpData
->maHighlightTextColor
== rSet
.mpData
->maHighlightTextColor
) &&
1052 (mpData
->maActiveTabColor
== rSet
.mpData
->maActiveTabColor
) &&
1053 (mpData
->maInactiveTabColor
== rSet
.mpData
->maInactiveTabColor
) &&
1054 (mpData
->maDisableColor
== rSet
.mpData
->maDisableColor
) &&
1055 (mpData
->maHelpColor
== rSet
.mpData
->maHelpColor
) &&
1056 (mpData
->maHelpTextColor
== rSet
.mpData
->maHelpTextColor
) &&
1057 (mpData
->maLinkColor
== rSet
.mpData
->maLinkColor
) &&
1058 (mpData
->maVisitedLinkColor
== rSet
.mpData
->maVisitedLinkColor
) &&
1059 (mpData
->maHighlightLinkColor
== rSet
.mpData
->maHighlightLinkColor
) &&
1060 (mpData
->maAppFont
== rSet
.mpData
->maAppFont
) &&
1061 (mpData
->maHelpFont
== rSet
.mpData
->maHelpFont
) &&
1062 (mpData
->maTitleFont
== rSet
.mpData
->maTitleFont
) &&
1063 (mpData
->maFloatTitleFont
== rSet
.mpData
->maFloatTitleFont
) &&
1064 (mpData
->maMenuFont
== rSet
.mpData
->maMenuFont
) &&
1065 (mpData
->maToolFont
== rSet
.mpData
->maToolFont
) &&
1066 (mpData
->maGroupFont
== rSet
.mpData
->maGroupFont
) &&
1067 (mpData
->maLabelFont
== rSet
.mpData
->maLabelFont
) &&
1068 (mpData
->maInfoFont
== rSet
.mpData
->maInfoFont
) &&
1069 (mpData
->maRadioCheckFont
== rSet
.mpData
->maRadioCheckFont
) &&
1070 (mpData
->maPushButtonFont
== rSet
.mpData
->maPushButtonFont
) &&
1071 (mpData
->maFieldFont
== rSet
.mpData
->maFieldFont
) &&
1072 (mpData
->maIconFont
== rSet
.mpData
->maIconFont
) &&
1073 (mpData
->mnUseImagesInMenus
== rSet
.mpData
->mnUseImagesInMenus
) &&
1074 (mpData
->mnSkipDisabledInMenus
== rSet
.mpData
->mnSkipDisabledInMenus
) &&
1075 (mpData
->maFontColor
== rSet
.mpData
->maFontColor
))
1081 // =======================================================================
1083 ImplMiscData::ImplMiscData()
1086 mnTwoDigitYearStart
= 1930;
1087 mnEnableATT
= sal::static_int_cast
<USHORT
>(~0U);
1088 mnDisablePrinting
= sal::static_int_cast
<USHORT
>(~0U);
1089 static const char* pEnv
= getenv("SAL_DECIMALSEP_ENABLED" ); // set default without UI
1090 mbEnableLocalizedDecimalSep
= (pEnv
!= NULL
) ? TRUE
: FALSE
;
1093 // -----------------------------------------------------------------------
1095 ImplMiscData::ImplMiscData( const ImplMiscData
& rData
)
1098 mnTwoDigitYearStart
= rData
.mnTwoDigitYearStart
;
1099 mnEnableATT
= rData
.mnEnableATT
;
1100 mnDisablePrinting
= rData
.mnDisablePrinting
;
1101 mbEnableLocalizedDecimalSep
= rData
.mbEnableLocalizedDecimalSep
;
1104 // -----------------------------------------------------------------------
1106 MiscSettings::MiscSettings()
1108 mpData
= new ImplMiscData();
1111 // -----------------------------------------------------------------------
1113 MiscSettings::MiscSettings( const MiscSettings
& rSet
)
1115 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "MiscSettings: RefCount overflow" );
1117 // shared Instance Daten uebernehmen und Referenzcounter erhoehen
1118 mpData
= rSet
.mpData
;
1119 mpData
->mnRefCount
++;
1122 // -----------------------------------------------------------------------
1124 MiscSettings::~MiscSettings()
1126 // Daten loeschen, wenn letzte Referenz
1127 if ( mpData
->mnRefCount
== 1 )
1130 mpData
->mnRefCount
--;
1133 // -----------------------------------------------------------------------
1135 const MiscSettings
& MiscSettings::operator =( const MiscSettings
& rSet
)
1137 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "MiscSettings: RefCount overflow" );
1139 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
1140 rSet
.mpData
->mnRefCount
++;
1142 // Daten loeschen, wenn letzte Referenz
1143 if ( mpData
->mnRefCount
== 1 )
1146 mpData
->mnRefCount
--;
1148 mpData
= rSet
.mpData
;
1153 // -----------------------------------------------------------------------
1155 void MiscSettings::CopyData()
1157 // Falls noch andere Referenzen bestehen, dann kopieren
1158 if ( mpData
->mnRefCount
!= 1 )
1160 mpData
->mnRefCount
--;
1161 mpData
= new ImplMiscData( *mpData
);
1165 // -----------------------------------------------------------------------
1167 BOOL
MiscSettings::operator ==( const MiscSettings
& rSet
) const
1169 if ( mpData
== rSet
.mpData
)
1172 if ( (mpData
->mnTwoDigitYearStart
== rSet
.mpData
->mnTwoDigitYearStart
) &&
1173 (mpData
->mnEnableATT
== rSet
.mpData
->mnEnableATT
) &&
1174 (mpData
->mnDisablePrinting
== rSet
.mpData
->mnDisablePrinting
) &&
1175 (mpData
->mbEnableLocalizedDecimalSep
== rSet
.mpData
->mbEnableLocalizedDecimalSep
) )
1181 // -----------------------------------------------------------------------
1183 BOOL
MiscSettings::GetDisablePrinting() const
1185 if( mpData
->mnDisablePrinting
== (USHORT
)~0 )
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;
1194 return (BOOL
)mpData
->mnDisablePrinting
;
1196 // -----------------------------------------------------------------------
1198 BOOL
MiscSettings::GetEnableATToolSupport() const
1202 if( mpData
->mnEnableATT
== (USHORT
)~0 )
1204 // Check in the Windows registry if an AT tool wants Accessibility support to
1208 if( ERROR_SUCCESS
== RegOpenKey(HKEY_CURRENT_USER
,
1209 "Software\\OpenOffice.org\\Accessibility\\AtToolSupport",
1213 WIN_BYTE Data
[6]; // possible values: "true", "false", "1", "0", DWORD
1214 DWORD cbData
= sizeof(Data
);
1216 if( ERROR_SUCCESS
== RegQueryValueEx(hkey
, "SupportAssistiveTechnology",
1217 NULL
, &dwType
, Data
, &cbData
) )
1222 mpData
->mnEnableATT
= ((0 == stricmp((const char *) Data
, "1")) || (0 == stricmp((const char *) Data
, "true")));
1225 mpData
->mnEnableATT
= (USHORT
) (((DWORD
*) Data
)[0]);
1228 // Unsupported registry type
1238 if( mpData
->mnEnableATT
== (USHORT
)~0 )
1240 static const char* pEnv
= getenv("SAL_ACCESSIBILITY_ENABLED" );
1241 if( !pEnv
|| !*pEnv
)
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;
1251 mpData
->mnEnableATT
= 1;
1255 return (BOOL
)mpData
->mnEnableATT
;
1258 // -----------------------------------------------------------------------
1260 void MiscSettings::SetDisablePrinting( BOOL bEnable
)
1262 if ( bEnable
!= mpData
->mnDisablePrinting
)
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;
1272 // -----------------------------------------------------------------------
1274 void MiscSettings::SetEnableATToolSupport( BOOL bEnable
)
1276 if ( bEnable
!= mpData
->mnEnableATT
)
1279 if( bEnable
&& !ImplInitAccessBridge(false, bDummy
) )
1285 // If the accessibility key in the Windows registry exists, change it synchronously
1286 if( ERROR_SUCCESS
== RegOpenKey(HKEY_CURRENT_USER
,
1287 "Software\\OpenOffice.org\\Accessibility\\AtToolSupport",
1291 WIN_BYTE Data
[6]; // possible values: "true", "false", 1, 0
1292 DWORD cbData
= sizeof(Data
);
1294 if( ERROR_SUCCESS
== RegQueryValueEx(hkey
, "SupportAssistiveTechnology",
1295 NULL
, &dwType
, Data
, &cbData
) )
1300 RegSetValueEx(hkey
, "SupportAssistiveTechnology",
1302 bEnable
? (WIN_BYTE
*) "true" : (WIN_BYTE
*) "false",
1303 bEnable
? sizeof("true") : sizeof("false"));
1306 ((DWORD
*) Data
)[0] = bEnable
? 1 : 0;
1307 RegSetValueEx(hkey
, "SupportAssistiveTechnology",
1308 NULL
, dwType
, Data
, sizeof(DWORD
));
1311 // Unsupported registry type
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;
1328 void MiscSettings::SetEnableLocalizedDecimalSep( BOOL bEnable
)
1331 mpData
->mbEnableLocalizedDecimalSep
= bEnable
;
1334 BOOL
MiscSettings::GetEnableLocalizedDecimalSep() const
1336 return mpData
->mbEnableLocalizedDecimalSep
;
1339 // =======================================================================
1341 ImplNotificationData::ImplNotificationData()
1347 // -----------------------------------------------------------------------
1349 ImplNotificationData::ImplNotificationData( const ImplNotificationData
& rData
)
1352 mnOptions
= rData
.mnOptions
;
1355 // -----------------------------------------------------------------------
1357 NotificationSettings::NotificationSettings()
1359 mpData
= new ImplNotificationData();
1362 // -----------------------------------------------------------------------
1364 NotificationSettings::NotificationSettings( const NotificationSettings
& rSet
)
1366 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "NotificationSettings: RefCount overflow" );
1368 // shared Instance Daten uebernehmen und Referenzcounter erhoehen
1369 mpData
= rSet
.mpData
;
1370 mpData
->mnRefCount
++;
1373 // -----------------------------------------------------------------------
1375 NotificationSettings::~NotificationSettings()
1377 // Daten loeschen, wenn letzte Referenz
1378 if ( mpData
->mnRefCount
== 1 )
1381 mpData
->mnRefCount
--;
1384 // -----------------------------------------------------------------------
1386 const NotificationSettings
& NotificationSettings::operator =( const NotificationSettings
& rSet
)
1388 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "NotificationSettings: RefCount overflow" );
1390 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
1391 rSet
.mpData
->mnRefCount
++;
1393 // Daten loeschen, wenn letzte Referenz
1394 if ( mpData
->mnRefCount
== 1 )
1397 mpData
->mnRefCount
--;
1399 mpData
= rSet
.mpData
;
1404 // -----------------------------------------------------------------------
1406 void NotificationSettings::CopyData()
1408 // Falls noch andere Referenzen bestehen, dann kopieren
1409 if ( mpData
->mnRefCount
!= 1 )
1411 mpData
->mnRefCount
--;
1412 mpData
= new ImplNotificationData( *mpData
);
1416 // -----------------------------------------------------------------------
1418 BOOL
NotificationSettings::operator ==( const NotificationSettings
& rSet
) const
1420 if ( mpData
== rSet
.mpData
)
1423 if ( (mpData
->mnOptions
== rSet
.mpData
->mnOptions
) )
1429 // =======================================================================
1431 ImplHelpData::ImplHelpData()
1436 mnTipTimeout
= 3000;
1437 mnBalloonDelay
= 1500;
1440 // -----------------------------------------------------------------------
1442 ImplHelpData::ImplHelpData( const ImplHelpData
& rData
)
1445 mnOptions
= rData
.mnOptions
;
1446 mnTipDelay
= rData
.mnTipDelay
;
1447 mnTipTimeout
= rData
.mnTipTimeout
;
1448 mnBalloonDelay
= rData
.mnBalloonDelay
;
1451 // -----------------------------------------------------------------------
1453 HelpSettings::HelpSettings()
1455 mpData
= new ImplHelpData();
1458 // -----------------------------------------------------------------------
1460 HelpSettings::HelpSettings( const HelpSettings
& rSet
)
1462 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "HelpSettings: RefCount overflow" );
1464 // shared Instance Daten uebernehmen und Referenzcounter erhoehen
1465 mpData
= rSet
.mpData
;
1466 mpData
->mnRefCount
++;
1469 // -----------------------------------------------------------------------
1471 HelpSettings::~HelpSettings()
1473 // Daten loeschen, wenn letzte Referenz
1474 if ( mpData
->mnRefCount
== 1 )
1477 mpData
->mnRefCount
--;
1480 // -----------------------------------------------------------------------
1482 const HelpSettings
& HelpSettings::operator =( const HelpSettings
& rSet
)
1484 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "HelpSettings: RefCount overflow" );
1486 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
1487 rSet
.mpData
->mnRefCount
++;
1489 // Daten loeschen, wenn letzte Referenz
1490 if ( mpData
->mnRefCount
== 1 )
1493 mpData
->mnRefCount
--;
1495 mpData
= rSet
.mpData
;
1500 // -----------------------------------------------------------------------
1502 void HelpSettings::CopyData()
1504 // Falls noch andere Referenzen bestehen, dann kopieren
1505 if ( mpData
->mnRefCount
!= 1 )
1507 mpData
->mnRefCount
--;
1508 mpData
= new ImplHelpData( *mpData
);
1512 // -----------------------------------------------------------------------
1514 BOOL
HelpSettings::operator ==( const HelpSettings
& rSet
) const
1516 if ( mpData
== rSet
.mpData
)
1519 if ( (mpData
->mnOptions
== rSet
.mpData
->mnOptions
) &&
1520 (mpData
->mnTipDelay
== rSet
.mpData
->mnTipDelay
) &&
1521 (mpData
->mnTipTimeout
== rSet
.mpData
->mnTipTimeout
) &&
1522 (mpData
->mnBalloonDelay
== rSet
.mpData
->mnBalloonDelay
) )
1528 // =======================================================================
1530 static BOOL
ImplCompareLocales( const ::com::sun::star::lang::Locale
& L1
, const ::com::sun::star::lang::Locale
& L2
)
1532 return ( ( L1
.Language
== L2
.Language
) &&
1533 ( L1
.Country
== L2
.Country
) &&
1534 ( L1
.Variant
== L2
.Variant
) );
1537 // =======================================================================
1539 ImplAllSettingsData::ImplAllSettingsData()
1542 mnSystemUpdate
= SETTINGS_ALLSETTINGS
;
1543 mnWindowUpdate
= SETTINGS_ALLSETTINGS
;
1544 meLanguage
= LANGUAGE_SYSTEM
;
1545 meUILanguage
= LANGUAGE_SYSTEM
;
1546 mpLocaleDataWrapper
= NULL
;
1547 mpUILocaleDataWrapper
= NULL
;
1548 mpCollatorWrapper
= NULL
;
1549 mpUICollatorWrapper
= NULL
;
1550 mpI18nHelper
= NULL
;
1551 mpUII18nHelper
= NULL
;
1554 // -----------------------------------------------------------------------
1556 ImplAllSettingsData::ImplAllSettingsData( const ImplAllSettingsData
& rData
) :
1557 maMouseSettings( rData
.maMouseSettings
),
1558 maKeyboardSettings( rData
.maKeyboardSettings
),
1559 maStyleSettings( rData
.maStyleSettings
),
1560 maMiscSettings( rData
.maMiscSettings
),
1561 maNotificationSettings( rData
.maNotificationSettings
),
1562 maHelpSettings( rData
.maHelpSettings
),
1563 maLocale( rData
.maLocale
),
1564 maUILocale( rData
.maUILocale
)
1568 mnSystemUpdate
= rData
.mnSystemUpdate
;
1569 mnWindowUpdate
= rData
.mnWindowUpdate
;
1570 meLanguage
= rData
.meLanguage
;
1571 meUILanguage
= rData
.meUILanguage
;
1572 // Pointer couldn't shared and objects haven't a copy ctor
1573 // So we create the cache objects new, if the GetFunction is
1575 mpLocaleDataWrapper
= NULL
;
1576 mpUILocaleDataWrapper
= NULL
;
1577 mpCollatorWrapper
= NULL
;
1578 mpUICollatorWrapper
= NULL
;
1579 mpI18nHelper
= NULL
;
1580 mpUII18nHelper
= NULL
;
1583 // -----------------------------------------------------------------------
1585 ImplAllSettingsData::~ImplAllSettingsData()
1587 if ( mpLocaleDataWrapper
)
1588 delete mpLocaleDataWrapper
;
1589 if ( mpUILocaleDataWrapper
)
1590 delete mpUILocaleDataWrapper
;
1591 if ( mpCollatorWrapper
)
1592 delete mpCollatorWrapper
;
1593 if ( mpUICollatorWrapper
)
1594 delete mpUICollatorWrapper
;
1596 delete mpI18nHelper
;
1597 if ( mpUII18nHelper
)
1598 delete mpUII18nHelper
;
1601 // -----------------------------------------------------------------------
1603 AllSettings::AllSettings()
1605 DBG_CTOR( AllSettings
, NULL
);
1607 mpData
= new ImplAllSettingsData();
1610 // -----------------------------------------------------------------------
1612 AllSettings::AllSettings( const AllSettings
& rSet
)
1614 DBG_CTOR( AllSettings
, NULL
);
1615 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "Settings: RefCount overflow" );
1617 // shared Instance Daten uebernehmen und Referenzcounter erhoehen
1618 mpData
= rSet
.mpData
;
1619 mpData
->mnRefCount
++;
1622 // -----------------------------------------------------------------------
1624 AllSettings::~AllSettings()
1626 DBG_DTOR( AllSettings
, NULL
);
1628 // Daten loeschen, wenn letzte Referenz
1629 if ( mpData
->mnRefCount
== 1 )
1632 mpData
->mnRefCount
--;
1635 // -----------------------------------------------------------------------
1637 const AllSettings
& AllSettings::operator =( const AllSettings
& rSet
)
1639 DBG_ASSERT( rSet
.mpData
->mnRefCount
< 0xFFFFFFFE, "AllSettings: RefCount overflow" );
1640 DBG_CHKTHIS( AllSettings
, NULL
);
1641 DBG_CHKOBJ( &rSet
, AllSettings
, NULL
);
1643 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
1644 rSet
.mpData
->mnRefCount
++;
1646 // Daten loeschen, wenn letzte Referenz
1647 if ( mpData
->mnRefCount
== 1 )
1650 mpData
->mnRefCount
--;
1652 mpData
= rSet
.mpData
;
1657 // -----------------------------------------------------------------------
1659 void AllSettings::CopyData()
1661 DBG_CHKTHIS( AllSettings
, NULL
);
1663 // Falls noch andere Referenzen bestehen, dann kopieren
1664 if ( mpData
->mnRefCount
!= 1 )
1666 mpData
->mnRefCount
--;
1667 mpData
= new ImplAllSettingsData( *mpData
);
1671 // -----------------------------------------------------------------------
1673 ULONG
AllSettings::Update( ULONG nFlags
, const AllSettings
& rSet
)
1675 DBG_CHKTHIS( AllSettings
, NULL
);
1676 DBG_CHKOBJ( &rSet
, AllSettings
, NULL
);
1678 ULONG nChangeFlags
= 0;
1680 if ( nFlags
& SETTINGS_MACHINE
)
1682 if ( mpData
->maMachineSettings
!= rSet
.mpData
->maMachineSettings
)
1685 mpData
->maMachineSettings
= rSet
.mpData
->maMachineSettings
;
1686 nChangeFlags
|= SETTINGS_MACHINE
;
1690 if ( nFlags
& SETTINGS_MOUSE
)
1692 if ( mpData
->maMouseSettings
!= rSet
.mpData
->maMouseSettings
)
1695 mpData
->maMouseSettings
= rSet
.mpData
->maMouseSettings
;
1696 nChangeFlags
|= SETTINGS_MOUSE
;
1700 if ( nFlags
& SETTINGS_KEYBOARD
)
1702 if ( mpData
->maKeyboardSettings
!= rSet
.mpData
->maKeyboardSettings
)
1705 mpData
->maKeyboardSettings
= rSet
.mpData
->maKeyboardSettings
;
1706 nChangeFlags
|= SETTINGS_KEYBOARD
;
1710 if ( nFlags
& SETTINGS_STYLE
)
1712 if ( mpData
->maStyleSettings
!= rSet
.mpData
->maStyleSettings
)
1715 mpData
->maStyleSettings
= rSet
.mpData
->maStyleSettings
;
1716 nChangeFlags
|= SETTINGS_STYLE
;
1720 if ( nFlags
& SETTINGS_MISC
)
1722 if ( mpData
->maMiscSettings
!= rSet
.mpData
->maMiscSettings
)
1725 mpData
->maMiscSettings
= rSet
.mpData
->maMiscSettings
;
1726 nChangeFlags
|= SETTINGS_MISC
;
1730 if ( nFlags
& SETTINGS_NOTIFICATION
)
1732 if ( mpData
->maNotificationSettings
!= rSet
.mpData
->maNotificationSettings
)
1735 mpData
->maNotificationSettings
= rSet
.mpData
->maNotificationSettings
;
1736 nChangeFlags
|= SETTINGS_NOTIFICATION
;
1740 if ( nFlags
& SETTINGS_HELP
)
1742 if ( mpData
->maHelpSettings
!= rSet
.mpData
->maHelpSettings
)
1745 mpData
->maHelpSettings
= rSet
.mpData
->maHelpSettings
;
1746 nChangeFlags
|= SETTINGS_HELP
;
1750 if ( nFlags
& SETTINGS_INTERNATIONAL
)
1752 // Nothing, class International is gone.
1753 DBG_ERRORFILE("AllSettings::Update: who calls with SETTINGS_INTERNATIONAL and why? You're flogging a dead horse.");
1756 if ( nFlags
& SETTINGS_LOCALE
)
1758 if ( mpData
->meLanguage
|| rSet
.mpData
->meLanguage
)
1760 SetLanguage( rSet
.mpData
->meLanguage
);
1761 nChangeFlags
|= SETTINGS_LOCALE
;
1765 if ( nFlags
& SETTINGS_UILOCALE
)
1767 if ( mpData
->meUILanguage
|| rSet
.mpData
->meUILanguage
)
1769 SetUILanguage( rSet
.mpData
->meUILanguage
);
1770 nChangeFlags
|= SETTINGS_UILOCALE
;
1774 return nChangeFlags
;
1777 // -----------------------------------------------------------------------
1779 ULONG
AllSettings::GetChangeFlags( const AllSettings
& rSet
) const
1781 DBG_CHKTHIS( AllSettings
, NULL
);
1782 DBG_CHKOBJ( &rSet
, AllSettings
, NULL
);
1784 ULONG nChangeFlags
= 0;
1786 if ( mpData
->maMachineSettings
!= rSet
.mpData
->maMachineSettings
)
1787 nChangeFlags
|= SETTINGS_MACHINE
;
1789 if ( mpData
->maMouseSettings
!= rSet
.mpData
->maMouseSettings
)
1790 nChangeFlags
|= SETTINGS_MOUSE
;
1792 if ( mpData
->maKeyboardSettings
!= rSet
.mpData
->maKeyboardSettings
)
1793 nChangeFlags
|= SETTINGS_KEYBOARD
;
1795 if ( mpData
->maStyleSettings
!= rSet
.mpData
->maStyleSettings
)
1796 nChangeFlags
|= SETTINGS_STYLE
;
1798 if ( mpData
->maMiscSettings
!= rSet
.mpData
->maMiscSettings
)
1799 nChangeFlags
|= SETTINGS_MISC
;
1801 if ( mpData
->maNotificationSettings
!= rSet
.mpData
->maNotificationSettings
)
1802 nChangeFlags
|= SETTINGS_NOTIFICATION
;
1804 if ( mpData
->maHelpSettings
!= rSet
.mpData
->maHelpSettings
)
1805 nChangeFlags
|= SETTINGS_HELP
;
1807 if ( mpData
->meLanguage
|| rSet
.mpData
->meLanguage
)
1808 nChangeFlags
|= SETTINGS_LOCALE
;
1810 if ( mpData
->meUILanguage
|| rSet
.mpData
->meUILanguage
)
1811 nChangeFlags
|= SETTINGS_UILOCALE
;
1813 return nChangeFlags
;
1816 // -----------------------------------------------------------------------
1818 BOOL
AllSettings::operator ==( const AllSettings
& rSet
) const
1820 DBG_CHKTHIS( AllSettings
, NULL
);
1821 DBG_CHKOBJ( &rSet
, AllSettings
, NULL
);
1823 if ( mpData
== rSet
.mpData
)
1826 if ( (mpData
->maMachineSettings
== rSet
.mpData
->maMachineSettings
) &&
1827 (mpData
->maMouseSettings
== rSet
.mpData
->maMouseSettings
) &&
1828 (mpData
->maKeyboardSettings
== rSet
.mpData
->maKeyboardSettings
) &&
1829 (mpData
->maStyleSettings
== rSet
.mpData
->maStyleSettings
) &&
1830 (mpData
->maMiscSettings
== rSet
.mpData
->maMiscSettings
) &&
1831 (mpData
->maNotificationSettings
== rSet
.mpData
->maNotificationSettings
) &&
1832 (mpData
->maHelpSettings
== rSet
.mpData
->maHelpSettings
) &&
1833 (mpData
->mnSystemUpdate
== rSet
.mpData
->mnSystemUpdate
) &&
1834 (mpData
->mnWindowUpdate
== rSet
.mpData
->mnWindowUpdate
) )
1836 // special treatment for Locale, because maLocale is only
1837 // initialized after first call of GetLocale().
1838 ::com::sun::star::lang::Locale aEmptyLocale
;
1839 if ( ( ImplCompareLocales( mpData
->maLocale
, aEmptyLocale
) && ImplCompareLocales( rSet
.mpData
->maLocale
, aEmptyLocale
) )
1840 || ImplCompareLocales( GetLocale(), rSet
.GetLocale() ) )
1848 // -----------------------------------------------------------------------
1850 void AllSettings::SetLocale( const ::com::sun::star::lang::Locale
& rLocale
)
1854 mpData
->maLocale
= rLocale
;
1856 if ( !rLocale
.Language
.getLength() )
1857 mpData
->meLanguage
= LANGUAGE_SYSTEM
;
1859 mpData
->meLanguage
= MsLangId::convertLocaleToLanguage( rLocale
);
1860 if ( mpData
->mpLocaleDataWrapper
)
1862 delete mpData
->mpLocaleDataWrapper
;
1863 mpData
->mpLocaleDataWrapper
= NULL
;
1865 if ( mpData
->mpI18nHelper
)
1867 delete mpData
->mpI18nHelper
;
1868 mpData
->mpI18nHelper
= NULL
;
1872 // -----------------------------------------------------------------------
1874 void AllSettings::SetUILocale( const ::com::sun::star::lang::Locale
& rLocale
)
1878 mpData
->maUILocale
= rLocale
;
1880 if ( !rLocale
.Language
.getLength() )
1881 mpData
->meUILanguage
= LANGUAGE_SYSTEM
;
1883 mpData
->meUILanguage
= MsLangId::convertLocaleToLanguage( rLocale
);
1884 if ( mpData
->mpUILocaleDataWrapper
)
1886 delete mpData
->mpUILocaleDataWrapper
;
1887 mpData
->mpUILocaleDataWrapper
= NULL
;
1889 if ( mpData
->mpUII18nHelper
)
1891 delete mpData
->mpUII18nHelper
;
1892 mpData
->mpUII18nHelper
= NULL
;
1896 // -----------------------------------------------------------------------
1898 void AllSettings::SetLanguage( LanguageType eLang
)
1902 mpData
->meLanguage
= eLang
;
1904 // Will be calculated in GetLocale()
1905 mpData
->maLocale
= ::com::sun::star::lang::Locale();
1906 if ( mpData
->mpLocaleDataWrapper
)
1908 delete mpData
->mpLocaleDataWrapper
;
1909 mpData
->mpLocaleDataWrapper
= NULL
;
1911 if ( mpData
->mpI18nHelper
)
1913 delete mpData
->mpI18nHelper
;
1914 mpData
->mpI18nHelper
= NULL
;
1918 // -----------------------------------------------------------------------
1920 void AllSettings::SetUILanguage( LanguageType eLang
)
1924 mpData
->meUILanguage
= eLang
;
1926 // Will be calculated in GetUILocale()
1927 mpData
->maUILocale
= ::com::sun::star::lang::Locale();
1928 if ( mpData
->mpUILocaleDataWrapper
)
1930 delete mpData
->mpUILocaleDataWrapper
;
1931 mpData
->mpUILocaleDataWrapper
= NULL
;
1933 if ( mpData
->mpUII18nHelper
)
1935 delete mpData
->mpUII18nHelper
;
1936 mpData
->mpUII18nHelper
= NULL
;
1940 // -----------------------------------------------------------------------
1942 BOOL
AllSettings::GetLayoutRTL() const
1944 static const char* pEnv
= getenv("SAL_RTL_ENABLED" );
1945 static int nUIMirroring
= -1; // -1: undef, 0: auto, 1: on 2: off
1947 // environment always overrides
1953 if( nUIMirroring
== -1 )
1955 nUIMirroring
= 0; // ask configuration only once
1956 utl::OConfigurationNode aNode
= utl::OConfigurationTreeRoot::tryCreateWithServiceFactory(
1957 vcl::unohelper::GetMultiServiceFactory(),
1958 OUString::createFromAscii( "org.openoffice.Office.Common/I18N/CTL" ) ); // note: case sensisitive !
1959 if ( aNode
.isValid() )
1962 ::com::sun::star::uno::Any aValue
= aNode
.getNodeValue( OUString::createFromAscii( "UIMirroring" ) );
1963 if( aValue
>>= bTmp
)
1965 // found true or false; if it was nil, nothing is changed
1966 nUIMirroring
= bTmp
? 1 : 2;
1971 if( nUIMirroring
== 0 ) // no config found (eg, setup) or default (nil) was set: check language
1973 LanguageType aLang
= LANGUAGE_DONTKNOW
;
1974 ImplSVData
* pSVData
= ImplGetSVData();
1975 if ( pSVData
->maAppData
.mpSettings
)
1976 aLang
= pSVData
->maAppData
.mpSettings
->GetUILanguage();
1977 bRTL
= MsLangId::isRightToLeft( aLang
);
1980 bRTL
= (nUIMirroring
== 1);
1985 // -----------------------------------------------------------------------
1987 const ::com::sun::star::lang::Locale
& AllSettings::GetLocale() const
1989 if ( !mpData
->maLocale
.Language
.getLength() )
1990 MsLangId::convertLanguageToLocale( GetLanguage(),
1991 ((AllSettings
*)this)->mpData
->maLocale
);
1993 return mpData
->maLocale
;
1996 // -----------------------------------------------------------------------
1998 const ::com::sun::star::lang::Locale
& AllSettings::GetUILocale() const
2000 if ( !mpData
->maUILocale
.Language
.getLength() )
2001 MsLangId::convertLanguageToLocale( GetUILanguage(),
2002 ((AllSettings
*)this)->mpData
->maUILocale
);
2004 return mpData
->maUILocale
;
2007 // -----------------------------------------------------------------------
2009 LanguageType
AllSettings::GetLanguage() const
2011 if ( mpData
->meLanguage
== LANGUAGE_SYSTEM
)
2012 return MsLangId::getSystemLanguage();
2014 return mpData
->meLanguage
;
2017 // -----------------------------------------------------------------------
2019 LanguageType
AllSettings::GetUILanguage() const
2021 if ( mpData
->meUILanguage
== LANGUAGE_SYSTEM
)
2022 return MsLangId::getSystemUILanguage();
2024 return mpData
->meUILanguage
;
2027 // -----------------------------------------------------------------------
2029 const LocaleDataWrapper
& AllSettings::GetLocaleDataWrapper() const
2031 if ( !mpData
->mpLocaleDataWrapper
)
2032 ((AllSettings
*)this)->mpData
->mpLocaleDataWrapper
= new LocaleDataWrapper( vcl::unohelper::GetMultiServiceFactory(), GetLocale() );
2033 return *mpData
->mpLocaleDataWrapper
;
2036 // -----------------------------------------------------------------------
2038 const LocaleDataWrapper
& AllSettings::GetUILocaleDataWrapper() const
2040 if ( !mpData
->mpUILocaleDataWrapper
)
2041 ((AllSettings
*)this)->mpData
->mpUILocaleDataWrapper
= new LocaleDataWrapper( vcl::unohelper::GetMultiServiceFactory(), GetUILocale() );
2042 return *mpData
->mpUILocaleDataWrapper
;
2045 // -----------------------------------------------------------------------
2047 const vcl::I18nHelper
& AllSettings::GetLocaleI18nHelper() const
2049 if ( !mpData
->mpI18nHelper
) {
2050 ::com::sun::star::uno::Reference
<com::sun::star::lang::XMultiServiceFactory
> aFactory(vcl::unohelper::GetMultiServiceFactory());
2051 ((AllSettings
*)this)->mpData
->mpI18nHelper
= new vcl::I18nHelper( aFactory
, GetLocale() );
2053 return *mpData
->mpI18nHelper
;
2056 // -----------------------------------------------------------------------
2058 const vcl::I18nHelper
& AllSettings::GetUILocaleI18nHelper() const
2060 if ( !mpData
->mpUII18nHelper
) {
2061 ::com::sun::star::uno::Reference
<com::sun::star::lang::XMultiServiceFactory
> aFactory(vcl::unohelper::GetMultiServiceFactory());
2062 ((AllSettings
*)this)->mpData
->mpUII18nHelper
= new vcl::I18nHelper( aFactory
, GetUILocale() );
2064 return *mpData
->mpUII18nHelper
;
2068 // -----------------------------------------------------------------------
2070 const CollatorWrapper& AllSettings::GetCollatorWrapper() const
2072 if ( !mpData->mpCollatorWrapper )
2074 ((AllSettings*)this)->mpData->mpCollatorWrapper = new CollatorWrapper( vcl::unohelper::GetMultiServiceFactory() );
2075 ((AllSettings*)this)->mpData->mpCollatorWrapper->loadDefaultCollator( GetLocale(), 0 );
2077 return *mpData->mpCollatorWrapper;
2080 // -----------------------------------------------------------------------
2082 const CollatorWrapper& AllSettings::GetUICollatorWrapper() const
2084 if ( !mpData->mpUICollatorWrapper )
2086 ((AllSettings*)this)->mpData->mpUICollatorWrapper = new CollatorWrapper( vcl::unohelper::GetMultiServiceFactory() );
2087 ((AllSettings*)this)->mpData->mpUICollatorWrapper->loadDefaultCollator( GetUILocale(), 0 );
2089 return *mpData->mpUICollatorWrapper;