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