Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <officecfg/Office/Common.hxx>
21 :
22 : #include <svsys.h>
23 : #include "comphelper/processfactory.hxx"
24 : #include <rtl/bootstrap.hxx>
25 : #include "tools/debug.hxx"
26 : #include <vcl/graphicfilter.hxx>
27 :
28 : #include "i18nlangtag/mslangid.hxx"
29 : #include "i18nlangtag/languagetag.hxx"
30 :
31 : #include "vcl/svapp.hxx"
32 : #include "vcl/event.hxx"
33 : #include "vcl/settings.hxx"
34 : #include "vcl/i18nhelp.hxx"
35 : #include "vcl/configsettings.hxx"
36 : #include "vcl/gradient.hxx"
37 : #include "vcl/outdev.hxx"
38 :
39 : #include "unotools/fontcfg.hxx"
40 : #include "unotools/localedatawrapper.hxx"
41 : #include "unotools/collatorwrapper.hxx"
42 : #include "unotools/confignode.hxx"
43 : #include "unotools/syslocaleoptions.hxx"
44 :
45 : using namespace ::com::sun::star;
46 :
47 : #include "svdata.hxx"
48 : #include "impimagetree.hxx"
49 : // =======================================================================
50 :
51 : DBG_NAME( AllSettings )
52 :
53 : // =======================================================================
54 :
55 144 : ImplMouseData::ImplMouseData()
56 : {
57 144 : mnRefCount = 1;
58 144 : mnOptions = 0;
59 144 : mnDoubleClkTime = 500;
60 144 : mnDoubleClkWidth = 2;
61 144 : mnDoubleClkHeight = 2;
62 144 : mnStartDragWidth = 2;
63 144 : mnStartDragHeight = 2;
64 144 : mnStartDragCode = MOUSE_LEFT;
65 144 : mnDragMoveCode = 0;
66 144 : mnDragCopyCode = KEY_MOD1;
67 144 : mnDragLinkCode = KEY_SHIFT | KEY_MOD1;
68 144 : mnContextMenuCode = MOUSE_RIGHT;
69 144 : mnContextMenuClicks = 1;
70 144 : mbContextMenuDown = sal_True;
71 144 : mnMiddleButtonAction = MOUSE_MIDDLE_AUTOSCROLL;
72 144 : mnScrollRepeat = 100;
73 144 : mnButtonStartRepeat = 370;
74 144 : mnButtonRepeat = 90;
75 144 : mnActionDelay = 250;
76 144 : mnMenuDelay = 150;
77 144 : mnFollow = MOUSE_FOLLOW_MENU | MOUSE_FOLLOW_DDLIST;
78 144 : mnWheelBehavior = MOUSE_WHEEL_ALWAYS;
79 144 : }
80 :
81 : // -----------------------------------------------------------------------
82 :
83 1186 : ImplMouseData::ImplMouseData( const ImplMouseData& rData )
84 : {
85 1186 : mnRefCount = 1;
86 1186 : mnOptions = rData.mnOptions;
87 1186 : mnDoubleClkTime = rData.mnDoubleClkTime;
88 1186 : mnDoubleClkWidth = rData.mnDoubleClkWidth;
89 1186 : mnDoubleClkHeight = rData.mnDoubleClkHeight;
90 1186 : mnStartDragWidth = rData.mnStartDragWidth;
91 1186 : mnStartDragHeight = rData.mnStartDragHeight;
92 1186 : mnStartDragCode = rData.mnStartDragCode;
93 1186 : mnDragMoveCode = rData.mnDragMoveCode;
94 1186 : mnDragCopyCode = rData.mnDragCopyCode;
95 1186 : mnDragLinkCode = rData.mnDragLinkCode;
96 1186 : mnContextMenuCode = rData.mnContextMenuCode;
97 1186 : mnContextMenuClicks = rData.mnContextMenuClicks;
98 1186 : mbContextMenuDown = rData.mbContextMenuDown;
99 1186 : mnMiddleButtonAction = rData.mnMiddleButtonAction;
100 1186 : mnScrollRepeat = rData.mnScrollRepeat;
101 1186 : mnButtonStartRepeat = rData.mnButtonStartRepeat;
102 1186 : mnButtonRepeat = rData.mnButtonRepeat;
103 1186 : mnActionDelay = rData.mnActionDelay;
104 1186 : mnMenuDelay = rData.mnMenuDelay;
105 1186 : mnFollow = rData.mnFollow;
106 1186 : mnWheelBehavior = rData.mnWheelBehavior;
107 1186 : }
108 :
109 : // -----------------------------------------------------------------------
110 :
111 144 : MouseSettings::MouseSettings()
112 : {
113 144 : mpData = new ImplMouseData();
114 144 : }
115 :
116 : // -----------------------------------------------------------------------
117 :
118 21740 : MouseSettings::MouseSettings( const MouseSettings& rSet )
119 : {
120 : DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "MouseSettings: RefCount overflow" );
121 :
122 : // copy shared instance data and increment reference counter
123 21740 : mpData = rSet.mpData;
124 21740 : mpData->mnRefCount++;
125 21740 : }
126 :
127 : // -----------------------------------------------------------------------
128 :
129 21810 : MouseSettings::~MouseSettings()
130 : {
131 : // delete data if last reference
132 21810 : if ( mpData->mnRefCount == 1 )
133 1274 : delete mpData;
134 : else
135 20536 : mpData->mnRefCount--;
136 21810 : }
137 :
138 : // -----------------------------------------------------------------------
139 :
140 1360 : const MouseSettings& MouseSettings::operator =( const MouseSettings& rSet )
141 : {
142 : DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "MouseSettings: RefCount overflow" );
143 :
144 : // increment reference counter first, to be able to assign oneself
145 1360 : rSet.mpData->mnRefCount++;
146 :
147 : // delete data if last reference
148 1360 : if ( mpData->mnRefCount == 1 )
149 0 : delete mpData;
150 : else
151 1360 : mpData->mnRefCount--;
152 :
153 1360 : mpData = rSet.mpData;
154 :
155 1360 : return *this;
156 : }
157 :
158 : // -----------------------------------------------------------------------
159 :
160 1352 : void MouseSettings::CopyData()
161 : {
162 : // copy if another references exist
163 1352 : if ( mpData->mnRefCount != 1 )
164 : {
165 1186 : mpData->mnRefCount--;
166 1186 : mpData = new ImplMouseData( *mpData );
167 : }
168 1352 : }
169 :
170 : // -----------------------------------------------------------------------
171 :
172 22746 : sal_Bool MouseSettings::operator ==( const MouseSettings& rSet ) const
173 : {
174 22746 : if ( mpData == rSet.mpData )
175 20891 : return sal_True;
176 :
177 3710 : if ( (mpData->mnOptions == rSet.mpData->mnOptions) &&
178 3710 : (mpData->mnDoubleClkTime == rSet.mpData->mnDoubleClkTime) &&
179 3710 : (mpData->mnDoubleClkWidth == rSet.mpData->mnDoubleClkWidth) &&
180 3710 : (mpData->mnDoubleClkHeight == rSet.mpData->mnDoubleClkHeight) &&
181 3710 : (mpData->mnStartDragWidth == rSet.mpData->mnStartDragWidth) &&
182 3710 : (mpData->mnStartDragHeight == rSet.mpData->mnStartDragHeight) &&
183 3710 : (mpData->mnStartDragCode == rSet.mpData->mnStartDragCode) &&
184 3710 : (mpData->mnDragMoveCode == rSet.mpData->mnDragMoveCode) &&
185 3710 : (mpData->mnDragCopyCode == rSet.mpData->mnDragCopyCode) &&
186 3710 : (mpData->mnDragLinkCode == rSet.mpData->mnDragLinkCode) &&
187 3710 : (mpData->mnContextMenuCode == rSet.mpData->mnContextMenuCode) &&
188 3710 : (mpData->mnContextMenuClicks == rSet.mpData->mnContextMenuClicks) &&
189 3710 : (mpData->mbContextMenuDown == rSet.mpData->mbContextMenuDown) &&
190 3461 : (mpData->mnMiddleButtonAction == rSet.mpData->mnMiddleButtonAction) &&
191 3212 : (mpData->mnScrollRepeat == rSet.mpData->mnScrollRepeat) &&
192 3212 : (mpData->mnButtonStartRepeat == rSet.mpData->mnButtonStartRepeat) &&
193 2470 : (mpData->mnButtonRepeat == rSet.mpData->mnButtonRepeat) &&
194 1728 : (mpData->mnActionDelay == rSet.mpData->mnActionDelay) &&
195 1712 : (mpData->mnMenuDelay == rSet.mpData->mnMenuDelay) &&
196 1696 : (mpData->mnFollow == rSet.mpData->mnFollow) &&
197 848 : (mpData->mnWheelBehavior == rSet.mpData->mnWheelBehavior ) )
198 342 : return sal_True;
199 : else
200 1513 : return sal_False;
201 : }
202 :
203 : // =======================================================================
204 :
205 144 : ImplStyleData::ImplStyleData() :
206 : maPersonaHeaderFooter(),
207 : maPersonaHeaderBitmap(),
208 144 : maPersonaFooterBitmap()
209 : {
210 144 : mnRefCount = 1;
211 144 : mnScrollBarSize = 16;
212 144 : mnMinThumbSize = 16;
213 144 : mnSplitSize = 3;
214 144 : mnSpinSize = 16;
215 144 : mnIconHorzSpace = 50;
216 144 : mnIconVertSpace = 40;
217 144 : mnAntialiasedMin = 0;
218 144 : mnCursorSize = 2;
219 144 : mnCursorBlinkTime = STYLE_CURSOR_NOBLINKTIME;
220 144 : mnScreenZoom = 100;
221 144 : mnScreenFontZoom = 100;
222 144 : mnLogoDisplayTime = LOGO_DISPLAYTIME_STARTTIME;
223 : mnDragFullOptions = DRAGFULL_OPTION_WINDOWMOVE | DRAGFULL_OPTION_WINDOWSIZE |
224 : DRAGFULL_OPTION_OBJECTMOVE | DRAGFULL_OPTION_OBJECTSIZE |
225 : DRAGFULL_OPTION_DOCKING | DRAGFULL_OPTION_SPLIT |
226 144 : DRAGFULL_OPTION_SCROLL;
227 144 : mnAnimationOptions = 0;
228 144 : mnSelectionOptions = 0;
229 144 : mnDisplayOptions = 0;
230 144 : mnOptions = 0;
231 144 : mnAutoMnemonic = 1;
232 144 : mnToolbarIconSize = STYLE_TOOLBAR_ICONSIZE_UNKNOWN;
233 144 : mnSymbolsStyle = STYLE_SYMBOLS_AUTO;
234 144 : mnUseImagesInMenus = STYLE_MENUIMAGES_AUTO;
235 144 : mnPreferredSymbolsStyle = STYLE_SYMBOLS_AUTO;
236 144 : mpFontOptions = NULL;
237 144 : mnEdgeBlending = 35;
238 144 : maEdgeBlendingTopLeftColor = RGB_COLORDATA(0xC0, 0xC0, 0xC0);
239 144 : maEdgeBlendingBottomRightColor = RGB_COLORDATA(0x40, 0x40, 0x40);
240 144 : mnListBoxMaximumLineCount = 25;
241 144 : mnColorValueSetColumnCount = 12;
242 144 : mnColorValueSetMaximumRowCount = 40;
243 144 : maListBoxPreviewDefaultLogicSize = Size(15, 7);
244 144 : maListBoxPreviewDefaultPixelSize = Size(0, 0); // on-demand calculated in GetListBoxPreviewDefaultPixelSize()
245 144 : mnListBoxPreviewDefaultLineWidth = 1;
246 144 : mbPreviewUsesCheckeredBackground = true;
247 :
248 144 : SetStandardStyles();
249 144 : }
250 :
251 : // -----------------------------------------------------------------------
252 :
253 20292 : ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
254 : maActiveBorderColor( rData.maActiveBorderColor ),
255 : maActiveColor( rData.maActiveColor ),
256 : maActiveColor2( rData.maActiveColor2 ),
257 : maActiveTextColor( rData.maActiveTextColor ),
258 : maButtonTextColor( rData.maButtonTextColor ),
259 : maButtonRolloverTextColor( rData.maButtonRolloverTextColor ),
260 : maCheckedColor( rData.maCheckedColor ),
261 : maDarkShadowColor( rData.maDarkShadowColor ),
262 : maDeactiveBorderColor( rData.maDeactiveBorderColor ),
263 : maDeactiveColor( rData.maDeactiveColor ),
264 : maDeactiveColor2( rData.maDeactiveColor2 ),
265 : maDeactiveTextColor( rData.maDeactiveTextColor ),
266 : maDialogColor( rData.maDialogColor ),
267 : maDialogTextColor( rData.maDialogTextColor ),
268 : maDisableColor( rData.maDisableColor ),
269 : maFaceColor( rData.maFaceColor ),
270 : maFieldColor( rData.maFieldColor ),
271 : maFieldTextColor( rData.maFieldTextColor ),
272 : maFieldRolloverTextColor( rData.maFieldRolloverTextColor ),
273 : maFontColor( rData.maFontColor ),
274 : maGroupTextColor( rData.maGroupTextColor ),
275 : maHelpColor( rData.maHelpColor ),
276 : maHelpTextColor( rData.maHelpTextColor ),
277 : maHighlightColor( rData.maHighlightColor ),
278 : maHighlightLinkColor( rData.maHighlightLinkColor ),
279 : maHighlightTextColor( rData.maHighlightTextColor ),
280 : maInfoTextColor( rData.maInfoTextColor ),
281 : maLabelTextColor( rData.maLabelTextColor ),
282 : maLightBorderColor( rData.maLightBorderColor ),
283 : maLightColor( rData.maLightColor ),
284 : maLinkColor( rData.maLinkColor ),
285 : maMenuBarColor( rData.maMenuBarColor ),
286 : maMenuBarRolloverColor( rData.maMenuBarRolloverColor ),
287 : maMenuBorderColor( rData.maMenuBorderColor ),
288 : maMenuColor( rData.maMenuColor ),
289 : maMenuHighlightColor( rData.maMenuHighlightColor ),
290 : maMenuHighlightTextColor( rData.maMenuHighlightTextColor ),
291 : maMenuTextColor( rData.maMenuTextColor ),
292 : maMenuBarTextColor( rData.maMenuBarTextColor ),
293 : maMenuBarRolloverTextColor( rData.maMenuBarRolloverTextColor ),
294 : maMonoColor( rData.maMonoColor ),
295 : maRadioCheckTextColor( rData.maRadioCheckTextColor ),
296 : maShadowColor( rData.maShadowColor ),
297 : maVisitedLinkColor( rData.maVisitedLinkColor ),
298 : maWindowColor( rData.maWindowColor ),
299 : maWindowTextColor( rData.maWindowTextColor ),
300 : maWorkspaceColor( rData.maWorkspaceColor ),
301 : maActiveTabColor( rData.maActiveTabColor ),
302 : maInactiveTabColor( rData.maInactiveTabColor ),
303 : maAppFont( rData.maAppFont ),
304 : maHelpFont( rData.maAppFont ),
305 : maTitleFont( rData.maTitleFont ),
306 : maFloatTitleFont( rData.maFloatTitleFont ),
307 : maMenuFont( rData.maMenuFont ),
308 : maToolFont( rData.maToolFont ),
309 : maLabelFont( rData.maLabelFont ),
310 : maInfoFont( rData.maInfoFont ),
311 : maRadioCheckFont( rData.maRadioCheckFont ),
312 : maPushButtonFont( rData.maPushButtonFont ),
313 : maFieldFont( rData.maFieldFont ),
314 : maIconFont( rData.maIconFont ),
315 : maGroupFont( rData.maGroupFont ),
316 : maWorkspaceGradient( rData.maWorkspaceGradient ),
317 : maDialogStyle( rData.maDialogStyle ),
318 : maFrameStyle( rData.maFrameStyle ),
319 : maPersonaHeaderFooter( rData.maPersonaHeaderFooter ),
320 : maPersonaHeaderBitmap( rData.maPersonaHeaderBitmap ),
321 20292 : maPersonaFooterBitmap( rData.maPersonaFooterBitmap )
322 : {
323 20292 : mnRefCount = 1;
324 20292 : mnBorderSize = rData.mnBorderSize;
325 20292 : mnTitleHeight = rData.mnTitleHeight;
326 20292 : mnFloatTitleHeight = rData.mnFloatTitleHeight;
327 20292 : mnTearOffTitleHeight = rData.mnTearOffTitleHeight;
328 20292 : mnMenuBarHeight = rData.mnMenuBarHeight;
329 20292 : mnScrollBarSize = rData.mnScrollBarSize;
330 20292 : mnMinThumbSize = rData.mnMinThumbSize;
331 20292 : mnSplitSize = rData.mnSplitSize;
332 20292 : mnSpinSize = rData.mnSpinSize;
333 20292 : mnIconHorzSpace = rData.mnIconHorzSpace;
334 20292 : mnIconVertSpace = rData.mnIconVertSpace;
335 20292 : mnAntialiasedMin = rData.mnAntialiasedMin;
336 20292 : mnCursorSize = rData.mnCursorSize;
337 20292 : mnCursorBlinkTime = rData.mnCursorBlinkTime;
338 20292 : mnScreenZoom = rData.mnScreenZoom;
339 20292 : mnScreenFontZoom = rData.mnScreenFontZoom;
340 20292 : mnLogoDisplayTime = rData.mnLogoDisplayTime;
341 20292 : mnDragFullOptions = rData.mnDragFullOptions;
342 20292 : mnAnimationOptions = rData.mnAnimationOptions;
343 20292 : mnSelectionOptions = rData.mnSelectionOptions;
344 20292 : mnDisplayOptions = rData.mnDisplayOptions;
345 20292 : mnOptions = rData.mnOptions;
346 20292 : mnHighContrast = rData.mnHighContrast;
347 20292 : mnUseSystemUIFonts = rData.mnUseSystemUIFonts;
348 20292 : mnUseFlatBorders = rData.mnUseFlatBorders;
349 20292 : mnUseFlatMenus = rData.mnUseFlatMenus;
350 20292 : mnAutoMnemonic = rData.mnAutoMnemonic;
351 20292 : mnUseImagesInMenus = rData.mnUseImagesInMenus;
352 20292 : mbPreferredUseImagesInMenus = rData.mbPreferredUseImagesInMenus;
353 20292 : mnSkipDisabledInMenus = rData.mnSkipDisabledInMenus;
354 20292 : mbHideDisabledMenuItems = rData.mbHideDisabledMenuItems;
355 20292 : mbAcceleratorsInContextMenus = rData.mbAcceleratorsInContextMenus;
356 20292 : mbPrimaryButtonWarpsSlider = rData.mbPrimaryButtonWarpsSlider;
357 20292 : mnToolbarIconSize = rData.mnToolbarIconSize;
358 20292 : mnSymbolsStyle = rData.mnSymbolsStyle;
359 20292 : mnPreferredSymbolsStyle = rData.mnPreferredSymbolsStyle;
360 20292 : mpFontOptions = rData.mpFontOptions;
361 20292 : mnEdgeBlending = rData.mnEdgeBlending;
362 20292 : maEdgeBlendingTopLeftColor = rData.maEdgeBlendingTopLeftColor;
363 20292 : maEdgeBlendingBottomRightColor = rData.maEdgeBlendingBottomRightColor;
364 20292 : mnListBoxMaximumLineCount = rData.mnListBoxMaximumLineCount;
365 20292 : mnColorValueSetColumnCount = rData.mnColorValueSetColumnCount;
366 20292 : mnColorValueSetMaximumRowCount = rData.mnColorValueSetMaximumRowCount;
367 20292 : maListBoxPreviewDefaultLogicSize = rData.maListBoxPreviewDefaultLogicSize;
368 20292 : maListBoxPreviewDefaultPixelSize = rData.maListBoxPreviewDefaultPixelSize;
369 20292 : mnListBoxPreviewDefaultLineWidth = rData.mnListBoxPreviewDefaultLineWidth;
370 20292 : mbPreviewUsesCheckeredBackground = rData.mbPreviewUsesCheckeredBackground;
371 20292 : }
372 :
373 : // -----------------------------------------------------------------------
374 :
375 227 : void ImplStyleData::SetStandardStyles()
376 : {
377 227 : Font aStdFont( FAMILY_SWISS, Size( 0, 8 ) );
378 227 : aStdFont.SetCharSet( osl_getThreadTextEncoding() );
379 227 : aStdFont.SetWeight( WEIGHT_NORMAL );
380 227 : aStdFont.SetName( utl::DefaultFontConfiguration::get().getUserInterfaceFont(com::sun::star::lang::Locale( OUString( "en" ), OUString(), OUString() ) ) );
381 227 : maAppFont = aStdFont;
382 227 : maHelpFont = aStdFont;
383 227 : maMenuFont = aStdFont;
384 227 : maToolFont = aStdFont;
385 227 : maGroupFont = aStdFont;
386 227 : maLabelFont = aStdFont;
387 227 : maInfoFont = aStdFont;
388 227 : maRadioCheckFont = aStdFont;
389 227 : maPushButtonFont = aStdFont;
390 227 : maFieldFont = aStdFont;
391 227 : maIconFont = aStdFont;
392 227 : aStdFont.SetWeight( WEIGHT_BOLD );
393 227 : maFloatTitleFont = aStdFont;
394 227 : maTitleFont = aStdFont;
395 :
396 227 : maFaceColor = Color( COL_LIGHTGRAY );
397 227 : maCheckedColor = Color( 0xCC, 0xCC, 0xCC );
398 227 : maLightColor = Color( COL_WHITE );
399 227 : maLightBorderColor = Color( COL_LIGHTGRAY );
400 227 : maShadowColor = Color( COL_GRAY );
401 227 : maDarkShadowColor = Color( COL_BLACK );
402 227 : maButtonTextColor = Color( COL_BLACK );
403 227 : maButtonRolloverTextColor = Color( COL_BLACK );
404 227 : maRadioCheckTextColor = Color( COL_BLACK );
405 227 : maGroupTextColor = Color( COL_BLACK );
406 227 : maLabelTextColor = Color( COL_BLACK );
407 227 : maInfoTextColor = Color( COL_BLACK );
408 227 : maWindowColor = Color( COL_WHITE );
409 227 : maWindowTextColor = Color( COL_BLACK );
410 227 : maDialogColor = Color( COL_LIGHTGRAY );
411 227 : maDialogTextColor = Color( COL_BLACK );
412 227 : maWorkspaceColor = Color( 0xF0, 0xF0, 0xF0 );
413 227 : maMonoColor = Color( COL_BLACK );
414 227 : maFieldColor = Color( COL_WHITE );
415 227 : maFieldTextColor = Color( COL_BLACK );
416 227 : maFieldRolloverTextColor = Color( COL_BLACK );
417 227 : maActiveColor = Color( COL_BLUE );
418 227 : maActiveColor2 = Color( COL_BLACK );
419 227 : maActiveTextColor = Color( COL_WHITE );
420 227 : maActiveBorderColor = Color( COL_LIGHTGRAY );
421 227 : maDeactiveColor = Color( COL_GRAY );
422 227 : maDeactiveColor2 = Color( COL_BLACK );
423 227 : maDeactiveTextColor = Color( COL_LIGHTGRAY );
424 227 : maDeactiveBorderColor = Color( COL_LIGHTGRAY );
425 227 : maMenuColor = Color( COL_LIGHTGRAY );
426 227 : maMenuBarColor = Color( COL_LIGHTGRAY );
427 227 : maMenuBarRolloverColor = Color( COL_BLUE );
428 227 : maMenuBorderColor = Color( COL_LIGHTGRAY );
429 227 : maMenuTextColor = Color( COL_BLACK );
430 227 : maMenuBarTextColor = Color( COL_BLACK );
431 227 : maMenuBarRolloverTextColor = Color( COL_WHITE );
432 227 : maMenuHighlightColor = Color( COL_BLUE );
433 227 : maMenuHighlightTextColor = Color( COL_WHITE );
434 227 : maHighlightColor = Color( COL_BLUE );
435 227 : maHighlightTextColor = Color( COL_WHITE );
436 227 : maActiveTabColor = Color( COL_WHITE );
437 227 : maInactiveTabColor = Color( COL_LIGHTGRAY );
438 227 : maDisableColor = Color( COL_GRAY );
439 227 : maHelpColor = Color( 0xFF, 0xFF, 0xE0 );
440 227 : maHelpTextColor = Color( COL_BLACK );
441 227 : maLinkColor = Color( COL_BLUE );
442 227 : maVisitedLinkColor = Color( 0x00, 0x00, 0xCC );
443 227 : maHighlightLinkColor = Color( COL_LIGHTBLUE );
444 227 : maFontColor = Color( COL_BLACK );
445 :
446 227 : mnBorderSize = 1;
447 227 : mnTitleHeight = 18;
448 227 : mnFloatTitleHeight = 13;
449 227 : mnTearOffTitleHeight = 8;
450 227 : mnMenuBarHeight = 14;
451 227 : mnHighContrast = 0;
452 227 : mnUseSystemUIFonts = 1;
453 227 : mnUseFlatBorders = 0;
454 227 : mnUseFlatMenus = 0;
455 227 : mbPreferredUseImagesInMenus = sal_True;
456 227 : mnSkipDisabledInMenus = (sal_uInt16)sal_False;
457 227 : mbHideDisabledMenuItems = sal_False;
458 227 : mbAcceleratorsInContextMenus = sal_True;
459 227 : mbPrimaryButtonWarpsSlider = sal_False;
460 :
461 454 : Gradient aGrad( GradientStyle_LINEAR, DEFAULT_WORKSPACE_GRADIENT_START_COLOR, DEFAULT_WORKSPACE_GRADIENT_END_COLOR );
462 454 : maWorkspaceGradient = Wallpaper( aGrad );
463 227 : }
464 :
465 : // -----------------------------------------------------------------------
466 :
467 144 : StyleSettings::StyleSettings()
468 : {
469 144 : mpData = new ImplStyleData();
470 144 : }
471 :
472 : // -----------------------------------------------------------------------
473 :
474 42591 : StyleSettings::StyleSettings( const StyleSettings& rSet )
475 : {
476 : DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "StyleSettings: RefCount overflow" );
477 :
478 : // copy shared instance data and increment reference counter
479 42591 : mpData = rSet.mpData;
480 42591 : mpData->mnRefCount++;
481 42591 : }
482 :
483 : // -----------------------------------------------------------------------
484 :
485 42661 : StyleSettings::~StyleSettings()
486 : {
487 : // if last reference then delete data
488 42661 : if ( mpData->mnRefCount == 1 )
489 20281 : delete mpData;
490 : else
491 22380 : mpData->mnRefCount--;
492 42661 : }
493 :
494 860 : const Size& StyleSettings::GetListBoxPreviewDefaultPixelSize() const
495 : {
496 860 : if(0 == mpData->maListBoxPreviewDefaultPixelSize.Width() || 0 == mpData->maListBoxPreviewDefaultPixelSize.Height())
497 : {
498 : const_cast< StyleSettings* >(this)->mpData->maListBoxPreviewDefaultPixelSize =
499 8 : Application::GetDefaultDevice()->LogicToPixel(mpData->maListBoxPreviewDefaultLogicSize, MAP_APPFONT);
500 : }
501 :
502 860 : return mpData->maListBoxPreviewDefaultPixelSize;
503 : }
504 :
505 : // -----------------------------------------------------------------------
506 :
507 118 : void StyleSettings::Set3DColors( const Color& rColor )
508 : {
509 118 : CopyData();
510 118 : mpData->maFaceColor = rColor;
511 118 : mpData->maLightBorderColor = rColor;
512 118 : mpData->maMenuBorderColor = rColor;
513 118 : mpData->maDarkShadowColor = Color( COL_BLACK );
514 118 : if ( rColor != Color( COL_LIGHTGRAY ) )
515 : {
516 118 : mpData->maLightColor = rColor;
517 118 : mpData->maShadowColor = rColor;
518 118 : mpData->maDarkShadowColor=rColor;
519 118 : mpData->maLightColor.IncreaseLuminance( 64 );
520 118 : mpData->maShadowColor.DecreaseLuminance( 64 );
521 118 : mpData->maDarkShadowColor.DecreaseLuminance( 100 );
522 118 : sal_uLong nRed = mpData->maLightColor.GetRed();
523 118 : sal_uLong nGreen = mpData->maLightColor.GetGreen();
524 118 : sal_uLong nBlue = mpData->maLightColor.GetBlue();
525 118 : nRed += (sal_uLong)(mpData->maShadowColor.GetRed());
526 118 : nGreen += (sal_uLong)(mpData->maShadowColor.GetGreen());
527 118 : nBlue += (sal_uLong)(mpData->maShadowColor.GetBlue());
528 118 : mpData->maCheckedColor = Color( (sal_uInt8)(nRed/2), (sal_uInt8)(nGreen/2), (sal_uInt8)(nBlue/2) );
529 : }
530 : else
531 : {
532 0 : mpData->maCheckedColor = Color( 0x99, 0x99, 0x99 );
533 0 : mpData->maLightColor = Color( COL_WHITE );
534 0 : mpData->maShadowColor = Color( COL_GRAY );
535 : }
536 118 : }
537 :
538 : // -----------------------------------------------------------------------
539 :
540 22961 : OUString StyleSettings::ImplSymbolsStyleToName( sal_uLong nStyle ) const
541 : {
542 22961 : switch ( nStyle )
543 : {
544 29 : case STYLE_SYMBOLS_DEFAULT: return OUString("default");
545 29 : case STYLE_SYMBOLS_HICONTRAST: return OUString("hicontrast");
546 0 : case STYLE_SYMBOLS_INDUSTRIAL: return OUString("tango"); // industrial is dead
547 29 : case STYLE_SYMBOLS_CRYSTAL: return OUString("crystal");
548 22341 : case STYLE_SYMBOLS_TANGO: return OUString("tango");
549 29 : case STYLE_SYMBOLS_OXYGEN: return OUString("oxygen");
550 29 : case STYLE_SYMBOLS_CLASSIC: return OUString("classic");
551 29 : case STYLE_SYMBOLS_HUMAN: return OUString("human");
552 29 : case STYLE_SYMBOLS_SIFR: return OUString("sifr");
553 29 : case STYLE_SYMBOLS_TANGO_TESTING: return OUString("tango_testing");
554 : }
555 :
556 388 : return OUString("auto");
557 : }
558 :
559 : // -----------------------------------------------------------------------
560 :
561 0 : sal_uLong StyleSettings::ImplNameToSymbolsStyle( const OUString &rName ) const
562 : {
563 0 : if ( rName == OUString("default") )
564 0 : return STYLE_SYMBOLS_DEFAULT;
565 0 : else if ( rName == OUString("hicontrast") )
566 0 : return STYLE_SYMBOLS_HICONTRAST;
567 0 : else if ( rName == OUString("industrial") )
568 0 : return STYLE_SYMBOLS_TANGO; // industrial is dead
569 0 : else if ( rName == OUString("crystal") )
570 0 : return STYLE_SYMBOLS_CRYSTAL;
571 0 : else if ( rName == OUString("tango") )
572 0 : return STYLE_SYMBOLS_TANGO;
573 0 : else if ( rName == OUString("oxygen") )
574 0 : return STYLE_SYMBOLS_OXYGEN;
575 0 : else if ( rName == OUString("classic") )
576 0 : return STYLE_SYMBOLS_CLASSIC;
577 0 : else if ( rName == OUString("human") )
578 0 : return STYLE_SYMBOLS_HUMAN;
579 0 : else if ( rName == OUString("sifr") )
580 0 : return STYLE_SYMBOLS_SIFR;
581 0 : else if ( rName == OUString("tango_testing") )
582 0 : return STYLE_SYMBOLS_TANGO_TESTING;
583 :
584 0 : return STYLE_SYMBOLS_AUTO;
585 : }
586 :
587 : // -----------------------------------------------------------------------
588 :
589 : /**
590 : The preferred style name can be read from the desktop setting. We
591 : need to find the closest theme name registered in OOo. Therefore
592 : we check if any registered style name is a case-insensitive
593 : substring of the preferred style name.
594 : */
595 0 : void StyleSettings::SetPreferredSymbolsStyleName( const OUString &rName )
596 : {
597 0 : if ( !rName.isEmpty() )
598 : {
599 0 : OUString rNameLowCase( rName.toAsciiLowerCase() );
600 :
601 0 : for( sal_uInt32 n = 0; n <= STYLE_SYMBOLS_THEMES_MAX; n++ )
602 0 : if ( rNameLowCase.indexOf( ImplSymbolsStyleToName( n ) ) != -1 )
603 0 : SetPreferredSymbolsStyle( n );
604 : }
605 0 : }
606 :
607 0 : void StyleSettings::SetCheckedColorSpecialCase( )
608 : {
609 0 : CopyData();
610 : // Light gray checked color special case
611 0 : if ( GetFaceColor() == COL_LIGHTGRAY )
612 0 : mpData->maCheckedColor = Color( 0xCC, 0xCC, 0xCC );
613 : else
614 : {
615 0 : sal_uInt8 nRed = (sal_uInt8)(((sal_uInt16)mpData->maFaceColor.GetRed() + (sal_uInt16)mpData->maLightColor.GetRed())/2);
616 0 : sal_uInt8 nGreen = (sal_uInt8)(((sal_uInt16)mpData->maFaceColor.GetGreen() + (sal_uInt16)mpData->maLightColor.GetGreen())/2);
617 0 : sal_uInt8 nBlue = (sal_uInt8)(((sal_uInt16)mpData->maFaceColor.GetBlue() + (sal_uInt16)mpData->maLightColor.GetBlue())/2);
618 0 : mpData->maCheckedColor = Color( nRed, nGreen, nBlue );
619 : }
620 0 : }
621 :
622 : // -----------------------------------------------------------------------
623 :
624 102495 : sal_uLong StyleSettings::GetCurrentSymbolsStyle() const
625 : {
626 : // style selected in Tools -> Options... -> OpenOffice.org -> View
627 102495 : sal_uLong nStyle = GetSymbolsStyle();
628 :
629 102495 : if ( nStyle == STYLE_SYMBOLS_AUTO || ( !CheckSymbolStyle (nStyle) ) )
630 : {
631 : // the preferred style can be read from the desktop setting by the desktop native widgets modules
632 102495 : sal_uLong nPreferredStyle = GetPreferredSymbolsStyle();
633 :
634 102495 : if ( nPreferredStyle == STYLE_SYMBOLS_AUTO || ( !CheckSymbolStyle (nPreferredStyle) ) )
635 : {
636 :
637 : // use a hardcoded desktop-specific fallback if no preferred style has been detected
638 : static bool sbFallbackDesktopChecked = false;
639 : static sal_uLong snFallbackDesktopStyle = STYLE_SYMBOLS_DEFAULT;
640 :
641 102495 : if ( !sbFallbackDesktopChecked )
642 : {
643 61 : snFallbackDesktopStyle = GetAutoSymbolsStyle();
644 61 : sbFallbackDesktopChecked = true;
645 : }
646 :
647 102495 : nPreferredStyle = snFallbackDesktopStyle;
648 : }
649 :
650 102495 : if (GetHighContrastMode() && CheckSymbolStyle (STYLE_SYMBOLS_HICONTRAST) )
651 0 : nStyle = STYLE_SYMBOLS_HICONTRAST;
652 : else
653 102495 : nStyle = nPreferredStyle;
654 : }
655 :
656 102495 : return nStyle;
657 : }
658 :
659 : // -----------------------------------------------------------------------
660 :
661 61 : sal_uLong StyleSettings::GetAutoSymbolsStyle() const
662 : {
663 61 : OUString const & env = Application::GetDesktopEnvironment();
664 :
665 : sal_uLong nRet;
666 122 : if ( env.equalsIgnoreAsciiCase("tde") ||
667 61 : env.equalsIgnoreAsciiCase("kde") )
668 0 : nRet = STYLE_SYMBOLS_CRYSTAL;
669 61 : else if ( env.equalsIgnoreAsciiCase("kde4") )
670 0 : nRet = STYLE_SYMBOLS_OXYGEN;
671 : else
672 61 : nRet = STYLE_SYMBOLS_TANGO;
673 :
674 : // falback to any existing style
675 61 : if ( ! CheckSymbolStyle (nRet) )
676 : {
677 377 : for ( sal_uLong n = 0 ; n <= STYLE_SYMBOLS_THEMES_MAX ; n++ )
678 : {
679 348 : sal_uLong nStyleToCheck = n;
680 :
681 : // auto is not a real theme => can't be fallback
682 348 : if ( nStyleToCheck == STYLE_SYMBOLS_AUTO )
683 29 : continue;
684 :
685 : // will check hicontrast in the end
686 319 : if ( nStyleToCheck == STYLE_SYMBOLS_HICONTRAST )
687 29 : continue;
688 290 : if ( nStyleToCheck == STYLE_SYMBOLS_THEMES_MAX )
689 29 : nStyleToCheck = STYLE_SYMBOLS_HICONTRAST;
690 :
691 290 : if ( CheckSymbolStyle ( nStyleToCheck ) )
692 : {
693 0 : nRet = nStyleToCheck;
694 0 : n = STYLE_SYMBOLS_THEMES_MAX;
695 : }
696 : }
697 : }
698 :
699 61 : return nRet;
700 : }
701 :
702 : // -----------------------------------------------------------------------
703 :
704 351 : bool StyleSettings::CheckSymbolStyle( sal_uLong nStyle ) const
705 : {
706 351 : if ( nStyle == STYLE_SYMBOLS_INDUSTRIAL )
707 29 : return false; // industrial is dead
708 :
709 322 : static ImplImageTreeSingletonRef aImageTree;
710 322 : return aImageTree->checkStyle( ImplSymbolsStyleToName( nStyle ) );
711 : }
712 :
713 : // -----------------------------------------------------------------------
714 :
715 26423 : sal_Bool StyleSettings::GetUseImagesInMenus() const
716 : {
717 : // icon mode selected in Tools -> Options... -> OpenOffice.org -> View
718 26423 : sal_uInt16 nStyle = mpData->mnUseImagesInMenus;
719 :
720 26423 : if ( nStyle == STYLE_MENUIMAGES_AUTO )
721 26423 : return GetPreferredUseImagesInMenus();
722 :
723 0 : return (sal_Bool)nStyle;
724 : }
725 :
726 : // -----------------------------------------------------------------------
727 :
728 61 : static BitmapEx readBitmapEx( const OUString& rPath )
729 : {
730 61 : OUString aPath( rPath );
731 61 : rtl::Bootstrap::expandMacros( aPath );
732 :
733 : // import the image
734 122 : Graphic aGraphic;
735 61 : if ( GraphicFilter::LoadGraphic( aPath, String(), aGraphic ) != GRFILTER_OK )
736 61 : return BitmapEx();
737 :
738 61 : return aGraphic.GetBitmapEx();
739 : }
740 :
741 : enum WhichPersona { PERSONA_HEADER, PERSONA_FOOTER };
742 :
743 : /** Update the setting of the Persona header / footer in ImplStyleData */
744 104011 : static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFooter, BitmapEx& rHeaderFooterBitmap, Color& maMenuBarTextColor )
745 : {
746 104011 : uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
747 104011 : if ( !xContext.is() )
748 0 : return;
749 :
750 : // read from the configuration
751 104072 : OUString aPersona( officecfg::Office::Common::Misc::Persona::get( xContext ) );
752 104072 : OUString aPersonaSettings( officecfg::Office::Common::Misc::PersonaSettings::get( xContext ) );
753 :
754 : // have the settings changed?
755 104072 : OUString aOldValue( aPersona + ";" + aPersonaSettings );
756 104011 : if ( rHeaderFooter == aOldValue )
757 103950 : return;
758 :
759 61 : rHeaderFooter = aOldValue;
760 61 : rHeaderFooterBitmap = BitmapEx();
761 :
762 : // now read the new values and setup bitmaps
763 122 : OUString aHeader, aFooter;
764 61 : if ( aPersona == "own" )
765 : {
766 0 : sal_Int32 nIndex = 0;
767 0 : aHeader = aPersonaSettings.getToken( 0, ';', nIndex );
768 0 : if ( nIndex > 0 )
769 0 : aFooter = aPersonaSettings.getToken( 0, ';', nIndex );
770 :
771 : // change menu text color, advance nIndex to skip the '#'
772 0 : if ( nIndex > 0 )
773 : {
774 0 : OUString aColor = aPersonaSettings.getToken( 0, ';', ++nIndex );
775 0 : maMenuBarTextColor = Color( aColor.toUInt64( 16 ) );
776 : }
777 : }
778 61 : else if ( aPersona == "default" )
779 : {
780 61 : aHeader = "header.jpg";
781 61 : aFooter = "footer.jpg";
782 : }
783 :
784 122 : OUString aName;
785 61 : switch ( eWhich ) {
786 61 : case PERSONA_HEADER: aName = aHeader; break;
787 0 : case PERSONA_FOOTER: aName = aFooter; break;
788 : }
789 :
790 61 : if ( !aName.isEmpty() )
791 : {
792 : // try the gallery first, then the program path:
793 61 : OUString gallery = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
794 61 : rtl::Bootstrap::expandMacros( gallery );
795 61 : gallery += "/user/gallery/personas/";
796 :
797 61 : if ( aPersona == "own" )
798 0 : rHeaderFooterBitmap = readBitmapEx( gallery + aName );
799 :
800 61 : if ( rHeaderFooterBitmap.IsEmpty() )
801 61 : rHeaderFooterBitmap = readBitmapEx( "$BRAND_BASE_DIR/program/" + aName );
802 61 : }
803 : }
804 :
805 104011 : const BitmapEx StyleSettings::GetPersonaHeader() const
806 : {
807 104011 : setupPersonaHeaderFooter( PERSONA_HEADER, mpData->maPersonaHeaderFooter, mpData->maPersonaHeaderBitmap, mpData->maMenuBarTextColor );
808 104011 : return mpData->maPersonaHeaderBitmap;
809 : }
810 :
811 : // -----------------------------------------------------------------------
812 :
813 83 : void StyleSettings::SetStandardStyles()
814 : {
815 83 : CopyData();
816 83 : mpData->SetStandardStyles();
817 83 : }
818 :
819 : // -----------------------------------------------------------------------
820 :
821 106298 : Color StyleSettings::GetFaceGradientColor() const
822 : {
823 : // compute a brighter face color that can be used in gradients
824 : // for a convex look (eg toolbars)
825 :
826 : sal_uInt16 h, s, b;
827 106298 : GetFaceColor().RGBtoHSB( h, s, b );
828 106298 : if( s > 1) s=1;
829 106298 : if( b < 98) b=98;
830 106298 : return Color( Color::HSBtoRGB( h, s, b ) );
831 : }
832 :
833 : // -----------------------------------------------------------------------
834 :
835 16513 : Color StyleSettings::GetSeparatorColor() const
836 : {
837 : // compute a brighter shadow color for separators (used in toolbars or between menubar and toolbars on Windows XP)
838 : sal_uInt16 h, s, b;
839 16513 : GetShadowColor().RGBtoHSB( h, s, b );
840 16513 : b += b/4;
841 16513 : s -= s/4;
842 16513 : return Color( Color::HSBtoRGB( h, s, b ) );
843 : }
844 :
845 : // -----------------------------------------------------------------------
846 :
847 20565 : const StyleSettings& StyleSettings::operator =( const StyleSettings& rSet )
848 : {
849 : DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "StyleSettings: RefCount overflow" );
850 :
851 : // increase reference counter first, to be able to assign oneself
852 20565 : rSet.mpData->mnRefCount++;
853 :
854 : // if last reference then delete data
855 20565 : if ( mpData->mnRefCount == 1 )
856 83 : delete mpData;
857 : else
858 20482 : mpData->mnRefCount--;
859 :
860 20565 : mpData = rSet.mpData;
861 :
862 20565 : return *this;
863 : }
864 :
865 : // -----------------------------------------------------------------------
866 :
867 24075 : void StyleSettings::CopyData()
868 : {
869 : // copy if other references exist
870 24075 : if ( mpData->mnRefCount != 1 )
871 : {
872 20292 : mpData->mnRefCount--;
873 20292 : mpData = new ImplStyleData( *mpData );
874 : }
875 24075 : }
876 :
877 : // -----------------------------------------------------------------------
878 :
879 22746 : sal_Bool StyleSettings::operator ==( const StyleSettings& rSet ) const
880 : {
881 22746 : if ( mpData == rSet.mpData )
882 2072 : return sal_True;
883 :
884 61984 : if ( (mpData->mnOptions == rSet.mpData->mnOptions) &&
885 41272 : (mpData->mnAutoMnemonic == rSet.mpData->mnAutoMnemonic) &&
886 41272 : (mpData->mnLogoDisplayTime == rSet.mpData->mnLogoDisplayTime) &&
887 41270 : (mpData->mnDragFullOptions == rSet.mpData->mnDragFullOptions) &&
888 41268 : (mpData->mnAnimationOptions == rSet.mpData->mnAnimationOptions) &&
889 41237 : (mpData->mnSelectionOptions == rSet.mpData->mnSelectionOptions) &&
890 41206 : (mpData->mnDisplayOptions == rSet.mpData->mnDisplayOptions) &&
891 41206 : (mpData->mnCursorSize == rSet.mpData->mnCursorSize) &&
892 41206 : (mpData->mnCursorBlinkTime == rSet.mpData->mnCursorBlinkTime) &&
893 41206 : (mpData->mnBorderSize == rSet.mpData->mnBorderSize) &&
894 41206 : (mpData->mnTitleHeight == rSet.mpData->mnTitleHeight) &&
895 41206 : (mpData->mnFloatTitleHeight == rSet.mpData->mnFloatTitleHeight) &&
896 41206 : (mpData->mnTearOffTitleHeight == rSet.mpData->mnTearOffTitleHeight) &&
897 41206 : (mpData->mnMenuBarHeight == rSet.mpData->mnMenuBarHeight) &&
898 41206 : (mpData->mnScrollBarSize == rSet.mpData->mnScrollBarSize) &&
899 41206 : (mpData->mnMinThumbSize == rSet.mpData->mnMinThumbSize) &&
900 41206 : (mpData->mnSplitSize == rSet.mpData->mnSplitSize) &&
901 41206 : (mpData->mnSpinSize == rSet.mpData->mnSpinSize) &&
902 41206 : (mpData->mnIconHorzSpace == rSet.mpData->mnIconHorzSpace) &&
903 41206 : (mpData->mnIconVertSpace == rSet.mpData->mnIconVertSpace) &&
904 40957 : (mpData->mnAntialiasedMin == rSet.mpData->mnAntialiasedMin) &&
905 40708 : (mpData->mnScreenZoom == rSet.mpData->mnScreenZoom) &&
906 40708 : (mpData->mnScreenFontZoom == rSet.mpData->mnScreenFontZoom) &&
907 40708 : (mpData->mnHighContrast == rSet.mpData->mnHighContrast) &&
908 40708 : (mpData->mnUseSystemUIFonts == rSet.mpData->mnUseSystemUIFonts) &&
909 40708 : (mpData->mnUseFlatBorders == rSet.mpData->mnUseFlatBorders) &&
910 40708 : (mpData->mnUseFlatMenus == rSet.mpData->mnUseFlatMenus) &&
911 40708 : (mpData->mnSymbolsStyle == rSet.mpData->mnSymbolsStyle) &&
912 40708 : (mpData->mnPreferredSymbolsStyle == rSet.mpData->mnPreferredSymbolsStyle) &&
913 40699 : (mpData->maFaceColor == rSet.mpData->maFaceColor) &&
914 40690 : (mpData->maCheckedColor == rSet.mpData->maCheckedColor) &&
915 40690 : (mpData->maLightColor == rSet.mpData->maLightColor) &&
916 40690 : (mpData->maLightBorderColor == rSet.mpData->maLightBorderColor) &&
917 40690 : (mpData->maShadowColor == rSet.mpData->maShadowColor) &&
918 40690 : (mpData->maDarkShadowColor == rSet.mpData->maDarkShadowColor) &&
919 40690 : (mpData->maButtonTextColor == rSet.mpData->maButtonTextColor) &&
920 40690 : (mpData->maRadioCheckTextColor == rSet.mpData->maRadioCheckTextColor) &&
921 40690 : (mpData->maGroupTextColor == rSet.mpData->maGroupTextColor) &&
922 40690 : (mpData->maLabelTextColor == rSet.mpData->maLabelTextColor) &&
923 40690 : (mpData->maInfoTextColor == rSet.mpData->maInfoTextColor) &&
924 40690 : (mpData->maWindowColor == rSet.mpData->maWindowColor) &&
925 40690 : (mpData->maWindowTextColor == rSet.mpData->maWindowTextColor) &&
926 40690 : (mpData->maDialogColor == rSet.mpData->maDialogColor) &&
927 40690 : (mpData->maDialogTextColor == rSet.mpData->maDialogTextColor) &&
928 40690 : (mpData->maWorkspaceColor == rSet.mpData->maWorkspaceColor) &&
929 40690 : (mpData->maMonoColor == rSet.mpData->maMonoColor) &&
930 40690 : (mpData->maFieldColor == rSet.mpData->maFieldColor) &&
931 40672 : (mpData->maFieldTextColor == rSet.mpData->maFieldTextColor) &&
932 40654 : (mpData->maActiveColor == rSet.mpData->maActiveColor) &&
933 40654 : (mpData->maActiveColor2 == rSet.mpData->maActiveColor2) &&
934 40654 : (mpData->maActiveTextColor == rSet.mpData->maActiveTextColor) &&
935 40654 : (mpData->maActiveBorderColor == rSet.mpData->maActiveBorderColor) &&
936 40654 : (mpData->maDeactiveColor == rSet.mpData->maDeactiveColor) &&
937 40654 : (mpData->maDeactiveColor2 == rSet.mpData->maDeactiveColor2) &&
938 40654 : (mpData->maDeactiveTextColor == rSet.mpData->maDeactiveTextColor) &&
939 40654 : (mpData->maDeactiveBorderColor == rSet.mpData->maDeactiveBorderColor) &&
940 40654 : (mpData->maMenuColor == rSet.mpData->maMenuColor) &&
941 40654 : (mpData->maMenuBarColor == rSet.mpData->maMenuBarColor) &&
942 40654 : (mpData->maMenuBarRolloverColor == rSet.mpData->maMenuBarRolloverColor) &&
943 40654 : (mpData->maMenuBorderColor == rSet.mpData->maMenuBorderColor) &&
944 40654 : (mpData->maMenuTextColor == rSet.mpData->maMenuTextColor) &&
945 40654 : (mpData->maMenuBarTextColor == rSet.mpData->maMenuBarTextColor) &&
946 40654 : (mpData->maMenuBarRolloverTextColor == rSet.mpData->maMenuBarRolloverTextColor) &&
947 40654 : (mpData->maMenuHighlightColor == rSet.mpData->maMenuHighlightColor) &&
948 40654 : (mpData->maMenuHighlightTextColor == rSet.mpData->maMenuHighlightTextColor) &&
949 40654 : (mpData->maHighlightColor == rSet.mpData->maHighlightColor) &&
950 40654 : (mpData->maHighlightTextColor == rSet.mpData->maHighlightTextColor) &&
951 40654 : (mpData->maActiveTabColor == rSet.mpData->maActiveTabColor) &&
952 40654 : (mpData->maInactiveTabColor == rSet.mpData->maInactiveTabColor) &&
953 40654 : (mpData->maDisableColor == rSet.mpData->maDisableColor) &&
954 40654 : (mpData->maHelpColor == rSet.mpData->maHelpColor) &&
955 40654 : (mpData->maHelpTextColor == rSet.mpData->maHelpTextColor) &&
956 40654 : (mpData->maLinkColor == rSet.mpData->maLinkColor) &&
957 40654 : (mpData->maVisitedLinkColor == rSet.mpData->maVisitedLinkColor) &&
958 40654 : (mpData->maHighlightLinkColor == rSet.mpData->maHighlightLinkColor) &&
959 40654 : (mpData->maAppFont == rSet.mpData->maAppFont) &&
960 40654 : (mpData->maHelpFont == rSet.mpData->maHelpFont) &&
961 40654 : (mpData->maTitleFont == rSet.mpData->maTitleFont) &&
962 40654 : (mpData->maFloatTitleFont == rSet.mpData->maFloatTitleFont) &&
963 40654 : (mpData->maMenuFont == rSet.mpData->maMenuFont) &&
964 40654 : (mpData->maToolFont == rSet.mpData->maToolFont) &&
965 40654 : (mpData->maGroupFont == rSet.mpData->maGroupFont) &&
966 40654 : (mpData->maLabelFont == rSet.mpData->maLabelFont) &&
967 40654 : (mpData->maInfoFont == rSet.mpData->maInfoFont) &&
968 40654 : (mpData->maRadioCheckFont == rSet.mpData->maRadioCheckFont) &&
969 40654 : (mpData->maPushButtonFont == rSet.mpData->maPushButtonFont) &&
970 40654 : (mpData->maFieldFont == rSet.mpData->maFieldFont) &&
971 40654 : (mpData->maIconFont == rSet.mpData->maIconFont) &&
972 40654 : (mpData->mnUseImagesInMenus == rSet.mpData->mnUseImagesInMenus) &&
973 40654 : (mpData->mbPreferredUseImagesInMenus == rSet.mpData->mbPreferredUseImagesInMenus) &&
974 40654 : (mpData->mnSkipDisabledInMenus == rSet.mpData->mnSkipDisabledInMenus) &&
975 40654 : (mpData->mbHideDisabledMenuItems == rSet.mpData->mbHideDisabledMenuItems) &&
976 40654 : (mpData->mbAcceleratorsInContextMenus == rSet.mpData->mbAcceleratorsInContextMenus)&&
977 40654 : (mpData->mbPrimaryButtonWarpsSlider == rSet.mpData->mbPrimaryButtonWarpsSlider) &&
978 40654 : (mpData->maFontColor == rSet.mpData->maFontColor) &&
979 40654 : (mpData->mnEdgeBlending == rSet.mpData->mnEdgeBlending) &&
980 40654 : (mpData->maEdgeBlendingTopLeftColor == rSet.mpData->maEdgeBlendingTopLeftColor) &&
981 40654 : (mpData->maEdgeBlendingBottomRightColor == rSet.mpData->maEdgeBlendingBottomRightColor) &&
982 40654 : (mpData->mnListBoxMaximumLineCount == rSet.mpData->mnListBoxMaximumLineCount) &&
983 40405 : (mpData->mnColorValueSetColumnCount == rSet.mpData->mnColorValueSetColumnCount) &&
984 40156 : (mpData->mnColorValueSetMaximumRowCount == rSet.mpData->mnColorValueSetMaximumRowCount) &&
985 40156 : (mpData->maListBoxPreviewDefaultLogicSize == rSet.mpData->maListBoxPreviewDefaultLogicSize) &&
986 40156 : (mpData->maListBoxPreviewDefaultPixelSize == rSet.mpData->maListBoxPreviewDefaultPixelSize) &&
987 60830 : (mpData->mnListBoxPreviewDefaultLineWidth == rSet.mpData->mnListBoxPreviewDefaultLineWidth) &&
988 20078 : (mpData->mbPreviewUsesCheckeredBackground == rSet.mpData->mbPreviewUsesCheckeredBackground))
989 20078 : return sal_True;
990 : else
991 596 : return sal_False;
992 : }
993 :
994 : // =======================================================================
995 :
996 144 : ImplMiscData::ImplMiscData()
997 : {
998 144 : mnRefCount = 1;
999 144 : mnEnableATT = sal::static_int_cast<sal_uInt16>(~0U);
1000 144 : mnDisablePrinting = sal::static_int_cast<sal_uInt16>(~0U);
1001 144 : static const char* pEnv = getenv("SAL_DECIMALSEP_ENABLED" ); // set default without UI
1002 144 : mbEnableLocalizedDecimalSep = (pEnv != NULL) ? sal_True : sal_False;
1003 144 : }
1004 :
1005 : // -----------------------------------------------------------------------
1006 :
1007 0 : ImplMiscData::ImplMiscData( const ImplMiscData& rData )
1008 : {
1009 0 : mnRefCount = 1;
1010 0 : mnEnableATT = rData.mnEnableATT;
1011 0 : mnDisablePrinting = rData.mnDisablePrinting;
1012 0 : mbEnableLocalizedDecimalSep = rData.mbEnableLocalizedDecimalSep;
1013 0 : }
1014 :
1015 : // -----------------------------------------------------------------------
1016 :
1017 144 : MiscSettings::MiscSettings()
1018 : {
1019 144 : mpData = new ImplMiscData();
1020 144 : }
1021 :
1022 : // -----------------------------------------------------------------------
1023 :
1024 20562 : MiscSettings::MiscSettings( const MiscSettings& rSet )
1025 : {
1026 : DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "MiscSettings: RefCount overflow" );
1027 :
1028 : // copy shared instance data and increment reference counter
1029 20562 : mpData = rSet.mpData;
1030 20562 : mpData->mnRefCount++;
1031 20562 : }
1032 :
1033 : // -----------------------------------------------------------------------
1034 :
1035 20632 : MiscSettings::~MiscSettings()
1036 : {
1037 : // if last reference then delete data
1038 20632 : if ( mpData->mnRefCount == 1 )
1039 90 : delete mpData;
1040 : else
1041 20542 : mpData->mnRefCount--;
1042 20632 : }
1043 :
1044 : // -----------------------------------------------------------------------
1045 :
1046 0 : const MiscSettings& MiscSettings::operator =( const MiscSettings& rSet )
1047 : {
1048 : DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "MiscSettings: RefCount overflow" );
1049 :
1050 : // increase reference counter first, to be able to assign oneself
1051 0 : rSet.mpData->mnRefCount++;
1052 :
1053 : // if last reference then delete data
1054 0 : if ( mpData->mnRefCount == 1 )
1055 0 : delete mpData;
1056 : else
1057 0 : mpData->mnRefCount--;
1058 :
1059 0 : mpData = rSet.mpData;
1060 :
1061 0 : return *this;
1062 : }
1063 :
1064 : // -----------------------------------------------------------------------
1065 :
1066 144 : void MiscSettings::CopyData()
1067 : {
1068 : // copy if other references exist
1069 144 : if ( mpData->mnRefCount != 1 )
1070 : {
1071 0 : mpData->mnRefCount--;
1072 0 : mpData = new ImplMiscData( *mpData );
1073 : }
1074 144 : }
1075 :
1076 : // -----------------------------------------------------------------------
1077 :
1078 22746 : sal_Bool MiscSettings::operator ==( const MiscSettings& rSet ) const
1079 : {
1080 22746 : if ( mpData == rSet.mpData )
1081 22746 : return sal_True;
1082 :
1083 0 : if ( (mpData->mnEnableATT == rSet.mpData->mnEnableATT ) &&
1084 0 : (mpData->mnDisablePrinting == rSet.mpData->mnDisablePrinting ) &&
1085 0 : (mpData->mbEnableLocalizedDecimalSep == rSet.mpData->mbEnableLocalizedDecimalSep ) )
1086 0 : return sal_True;
1087 : else
1088 0 : return sal_False;
1089 : }
1090 :
1091 : // -----------------------------------------------------------------------
1092 :
1093 1533 : sal_Bool MiscSettings::GetDisablePrinting() const
1094 : {
1095 1533 : if( mpData->mnDisablePrinting == (sal_uInt16)~0 )
1096 : {
1097 : OUString aEnable =
1098 : vcl::SettingsConfigItem::get()->
1099 : getValue( OUString( "DesktopManagement" ),
1100 30 : OUString( "DisablePrinting" ) );
1101 30 : mpData->mnDisablePrinting = aEnable.equalsIgnoreAsciiCase("true") ? 1 : 0;
1102 : }
1103 :
1104 1533 : return (sal_Bool)mpData->mnDisablePrinting;
1105 : }
1106 : // -----------------------------------------------------------------------
1107 :
1108 23953 : sal_Bool MiscSettings::GetEnableATToolSupport() const
1109 : {
1110 :
1111 : #ifdef WNT
1112 : if( mpData->mnEnableATT == (sal_uInt16)~0 )
1113 : {
1114 : // Check in the Windows registry if an AT tool wants Accessibility support to
1115 : // be activated ..
1116 : HKEY hkey;
1117 :
1118 : if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,
1119 : "Software\\LibreOffice\\Accessibility\\AtToolSupport",
1120 : &hkey) )
1121 : {
1122 : DWORD dwType;
1123 : sal_uInt8 Data[6]; // possible values: "true", "false", "1", "0", DWORD
1124 : DWORD cbData = sizeof(Data);
1125 :
1126 : if( ERROR_SUCCESS == RegQueryValueEx(hkey, "SupportAssistiveTechnology",
1127 : NULL, &dwType, Data, &cbData) )
1128 : {
1129 : switch (dwType)
1130 : {
1131 : case REG_SZ:
1132 : mpData->mnEnableATT = ((0 == stricmp((const char *) Data, "1")) || (0 == stricmp((const char *) Data, "true")));
1133 : break;
1134 : case REG_DWORD:
1135 : mpData->mnEnableATT = (sal_uInt16) (((DWORD *) Data)[0]);
1136 : break;
1137 : default:
1138 : // Unsupported registry type
1139 : break;
1140 : }
1141 : }
1142 :
1143 : RegCloseKey(hkey);
1144 : }
1145 : }
1146 : #endif
1147 :
1148 23953 : if( mpData->mnEnableATT == (sal_uInt16)~0 )
1149 : {
1150 110 : static const char* pEnv = getenv("SAL_ACCESSIBILITY_ENABLED" );
1151 110 : if( !pEnv || !*pEnv )
1152 : {
1153 : OUString aEnable =
1154 : vcl::SettingsConfigItem::get()->
1155 : getValue( OUString( "Accessibility" ),
1156 110 : OUString( "EnableATToolSupport" ) );
1157 110 : mpData->mnEnableATT = aEnable.equalsIgnoreAsciiCase("true") ? 1 : 0;
1158 : }
1159 : else
1160 : {
1161 0 : mpData->mnEnableATT = 1;
1162 : }
1163 : }
1164 :
1165 23953 : return (sal_Bool)mpData->mnEnableATT;
1166 : }
1167 :
1168 : #ifdef WNT
1169 : void MiscSettings::SetEnableATToolSupport( sal_Bool bEnable )
1170 : {
1171 : if ( bEnable != mpData->mnEnableATT )
1172 : {
1173 : bool bDummy;
1174 : if( bEnable && !ImplInitAccessBridge(false, bDummy) )
1175 : return;
1176 :
1177 : HKEY hkey;
1178 :
1179 : // If the accessibility key in the Windows registry exists, change it synchronously
1180 : if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,
1181 : "Software\\LibreOffice\\Accessibility\\AtToolSupport",
1182 : &hkey) )
1183 : {
1184 : DWORD dwType;
1185 : sal_uInt8 Data[6]; // possible values: "true", "false", 1, 0
1186 : DWORD cbData = sizeof(Data);
1187 :
1188 : if( ERROR_SUCCESS == RegQueryValueEx(hkey, "SupportAssistiveTechnology",
1189 : NULL, &dwType, Data, &cbData) )
1190 : {
1191 : switch (dwType)
1192 : {
1193 : case REG_SZ:
1194 : RegSetValueEx(hkey, "SupportAssistiveTechnology",
1195 : 0, dwType,
1196 : bEnable ? (sal_uInt8 *) "true" : (sal_uInt8 *) "false",
1197 : bEnable ? sizeof("true") : sizeof("false"));
1198 : break;
1199 : case REG_DWORD:
1200 : ((DWORD *) Data)[0] = bEnable ? 1 : 0;
1201 : RegSetValueEx(hkey, "SupportAssistiveTechnology",
1202 : 0, dwType, Data, sizeof(DWORD));
1203 : break;
1204 : default:
1205 : // Unsupported registry type
1206 : break;
1207 : }
1208 : }
1209 :
1210 : RegCloseKey(hkey);
1211 : }
1212 :
1213 : vcl::SettingsConfigItem::get()->
1214 : setValue( OUString( "Accessibility" ),
1215 : OUString( "EnableATToolSupport" ),
1216 : bEnable ? OUString("true") : OUString("false" ) );
1217 : mpData->mnEnableATT = bEnable ? 1 : 0;
1218 : }
1219 : }
1220 : #endif
1221 :
1222 144 : void MiscSettings::SetEnableLocalizedDecimalSep( sal_Bool bEnable )
1223 : {
1224 144 : CopyData();
1225 144 : mpData->mbEnableLocalizedDecimalSep = bEnable;
1226 144 : }
1227 :
1228 0 : sal_Bool MiscSettings::GetEnableLocalizedDecimalSep() const
1229 : {
1230 0 : return mpData->mbEnableLocalizedDecimalSep;
1231 : }
1232 :
1233 : // =======================================================================
1234 :
1235 144 : ImplHelpData::ImplHelpData()
1236 : {
1237 144 : mnRefCount = 1;
1238 144 : mnOptions = 0;
1239 144 : mnTipDelay = 500;
1240 144 : mnTipTimeout = 3000;
1241 144 : mnBalloonDelay = 1500;
1242 144 : }
1243 :
1244 : // -----------------------------------------------------------------------
1245 :
1246 83 : ImplHelpData::ImplHelpData( const ImplHelpData& rData )
1247 : {
1248 83 : mnRefCount = 1;
1249 83 : mnOptions = rData.mnOptions;
1250 83 : mnTipDelay = rData.mnTipDelay;
1251 83 : mnTipTimeout = rData.mnTipTimeout;
1252 83 : mnBalloonDelay = rData.mnBalloonDelay;
1253 83 : }
1254 :
1255 : // -----------------------------------------------------------------------
1256 :
1257 144 : HelpSettings::HelpSettings()
1258 : {
1259 144 : mpData = new ImplHelpData();
1260 144 : }
1261 :
1262 : // -----------------------------------------------------------------------
1263 :
1264 20645 : HelpSettings::HelpSettings( const HelpSettings& rSet )
1265 : {
1266 : DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "HelpSettings: RefCount overflow" );
1267 :
1268 : // copy shared instance data and increment reference counter
1269 20645 : mpData = rSet.mpData;
1270 20645 : mpData->mnRefCount++;
1271 20645 : }
1272 :
1273 : // -----------------------------------------------------------------------
1274 :
1275 20715 : HelpSettings::~HelpSettings()
1276 : {
1277 : // if last reference then delete data
1278 20715 : if ( mpData->mnRefCount == 1 )
1279 173 : delete mpData;
1280 : else
1281 20542 : mpData->mnRefCount--;
1282 20715 : }
1283 :
1284 : // -----------------------------------------------------------------------
1285 :
1286 249 : const HelpSettings& HelpSettings::operator =( const HelpSettings& rSet )
1287 : {
1288 : DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "HelpSettings: RefCount overflow" );
1289 :
1290 : // increase reference counter first, to be able to assign oneself
1291 249 : rSet.mpData->mnRefCount++;
1292 :
1293 : // delete data if last reference
1294 249 : if ( mpData->mnRefCount == 1 )
1295 0 : delete mpData;
1296 : else
1297 249 : mpData->mnRefCount--;
1298 :
1299 249 : mpData = rSet.mpData;
1300 :
1301 249 : return *this;
1302 : }
1303 :
1304 : // -----------------------------------------------------------------------
1305 :
1306 83 : void HelpSettings::CopyData()
1307 : {
1308 : // copy of other references exist
1309 83 : if ( mpData->mnRefCount != 1 )
1310 : {
1311 83 : mpData->mnRefCount--;
1312 83 : mpData = new ImplHelpData( *mpData );
1313 : }
1314 83 : }
1315 :
1316 : // -----------------------------------------------------------------------
1317 :
1318 22746 : sal_Bool HelpSettings::operator ==( const HelpSettings& rSet ) const
1319 : {
1320 22746 : if ( mpData == rSet.mpData )
1321 22497 : return sal_True;
1322 :
1323 498 : if ( (mpData->mnOptions == rSet.mpData->mnOptions ) &&
1324 498 : (mpData->mnTipDelay == rSet.mpData->mnTipDelay ) &&
1325 249 : (mpData->mnTipTimeout == rSet.mpData->mnTipTimeout ) &&
1326 0 : (mpData->mnBalloonDelay == rSet.mpData->mnBalloonDelay ) )
1327 0 : return sal_True;
1328 : else
1329 249 : return sal_False;
1330 : }
1331 :
1332 : // =======================================================================
1333 :
1334 144 : ImplAllSettingsData::ImplAllSettingsData()
1335 : :
1336 : maLocale( LANGUAGE_SYSTEM ),
1337 144 : maUILocale( LANGUAGE_SYSTEM )
1338 : {
1339 144 : mnRefCount = 1;
1340 144 : mnSystemUpdate = SETTINGS_ALLSETTINGS;
1341 144 : mnWindowUpdate = SETTINGS_ALLSETTINGS;
1342 144 : mpLocaleDataWrapper = NULL;
1343 144 : mpUILocaleDataWrapper = NULL;
1344 144 : mpI18nHelper = NULL;
1345 144 : mpUII18nHelper = NULL;
1346 144 : maMiscSettings.SetEnableLocalizedDecimalSep( maSysLocale.GetOptions().IsDecimalSeparatorAsLocale() );
1347 144 : }
1348 :
1349 : // -----------------------------------------------------------------------
1350 :
1351 20562 : ImplAllSettingsData::ImplAllSettingsData( const ImplAllSettingsData& rData ) :
1352 : maMouseSettings( rData.maMouseSettings ),
1353 : maStyleSettings( rData.maStyleSettings ),
1354 : maMiscSettings( rData.maMiscSettings ),
1355 : maHelpSettings( rData.maHelpSettings ),
1356 : maLocale( rData.maLocale ),
1357 20562 : maUILocale( rData.maUILocale )
1358 : {
1359 20562 : mnRefCount = 1;
1360 20562 : mnSystemUpdate = rData.mnSystemUpdate;
1361 20562 : mnWindowUpdate = rData.mnWindowUpdate;
1362 : // Pointer couldn't shared and objects haven't a copy ctor
1363 : // So we create the cache objects new, if the GetFunction is
1364 : // called
1365 20562 : mpLocaleDataWrapper = NULL;
1366 20562 : mpUILocaleDataWrapper = NULL;
1367 20562 : mpI18nHelper = NULL;
1368 20562 : mpUII18nHelper = NULL;
1369 20562 : }
1370 :
1371 : // -----------------------------------------------------------------------
1372 :
1373 41264 : ImplAllSettingsData::~ImplAllSettingsData()
1374 : {
1375 20632 : delete mpLocaleDataWrapper;
1376 20632 : delete mpUILocaleDataWrapper;
1377 20632 : if ( mpI18nHelper )
1378 46 : delete mpI18nHelper;
1379 20632 : if ( mpUII18nHelper )
1380 0 : delete mpUII18nHelper;
1381 20632 : }
1382 :
1383 : // -----------------------------------------------------------------------
1384 :
1385 144 : AllSettings::AllSettings()
1386 : {
1387 : DBG_CTOR( AllSettings, NULL );
1388 :
1389 144 : mpData = new ImplAllSettingsData();
1390 144 : }
1391 :
1392 : // -----------------------------------------------------------------------
1393 :
1394 186349 : AllSettings::AllSettings( const AllSettings& rSet )
1395 : {
1396 : DBG_CTOR( AllSettings, NULL );
1397 : DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "Settings: RefCount overflow" );
1398 :
1399 : // copy shared instance data and increse reference counter
1400 186349 : mpData = rSet.mpData;
1401 186349 : mpData->mnRefCount++;
1402 186349 : }
1403 :
1404 : // -----------------------------------------------------------------------
1405 :
1406 185995 : AllSettings::~AllSettings()
1407 : {
1408 : DBG_DTOR( AllSettings, NULL );
1409 :
1410 : // if last reference then delete data
1411 185995 : if ( mpData->mnRefCount == 1 )
1412 17324 : delete mpData;
1413 : else
1414 168671 : mpData->mnRefCount--;
1415 185995 : }
1416 :
1417 : // -----------------------------------------------------------------------
1418 :
1419 113213 : const AllSettings& AllSettings::operator =( const AllSettings& rSet )
1420 : {
1421 : DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "AllSettings: RefCount overflow" );
1422 : DBG_CHKTHIS( AllSettings, NULL );
1423 : DBG_CHKOBJ( &rSet, AllSettings, NULL );
1424 :
1425 : // increase reference counter first, to be able to assign oneself
1426 113213 : rSet.mpData->mnRefCount++;
1427 :
1428 : // if last reference then delete data
1429 113213 : if ( mpData->mnRefCount == 1 )
1430 3308 : delete mpData;
1431 : else
1432 109905 : mpData->mnRefCount--;
1433 :
1434 113213 : mpData = rSet.mpData;
1435 :
1436 113213 : return *this;
1437 : }
1438 :
1439 : // -----------------------------------------------------------------------
1440 :
1441 22330 : void AllSettings::CopyData()
1442 : {
1443 : DBG_CHKTHIS( AllSettings, NULL );
1444 :
1445 : // copy if other references exist
1446 22330 : if ( mpData->mnRefCount != 1 )
1447 : {
1448 20562 : mpData->mnRefCount--;
1449 20562 : mpData = new ImplAllSettingsData( *mpData );
1450 : }
1451 22330 : }
1452 :
1453 : // -----------------------------------------------------------------------
1454 :
1455 500 : sal_uLong AllSettings::Update( sal_uLong nFlags, const AllSettings& rSet )
1456 : {
1457 : DBG_CHKTHIS( AllSettings, NULL );
1458 : DBG_CHKOBJ( &rSet, AllSettings, NULL );
1459 :
1460 500 : sal_uLong nChangeFlags = 0;
1461 :
1462 500 : if ( nFlags & SETTINGS_MOUSE )
1463 : {
1464 500 : if ( mpData->maMouseSettings != rSet.mpData->maMouseSettings )
1465 : {
1466 166 : CopyData();
1467 166 : mpData->maMouseSettings = rSet.mpData->maMouseSettings;
1468 166 : nChangeFlags |= SETTINGS_MOUSE;
1469 : }
1470 : }
1471 :
1472 500 : if ( nFlags & SETTINGS_STYLE )
1473 : {
1474 500 : if ( mpData->maStyleSettings != rSet.mpData->maStyleSettings )
1475 : {
1476 332 : CopyData();
1477 332 : mpData->maStyleSettings = rSet.mpData->maStyleSettings;
1478 332 : nChangeFlags |= SETTINGS_STYLE;
1479 : }
1480 : }
1481 :
1482 500 : if ( nFlags & SETTINGS_MISC )
1483 : {
1484 500 : if ( mpData->maMiscSettings != rSet.mpData->maMiscSettings )
1485 : {
1486 0 : CopyData();
1487 0 : mpData->maMiscSettings = rSet.mpData->maMiscSettings;
1488 0 : nChangeFlags |= SETTINGS_MISC;
1489 : }
1490 : }
1491 :
1492 500 : if ( nFlags & SETTINGS_HELP )
1493 : {
1494 500 : if ( mpData->maHelpSettings != rSet.mpData->maHelpSettings )
1495 : {
1496 166 : CopyData();
1497 166 : mpData->maHelpSettings = rSet.mpData->maHelpSettings;
1498 166 : nChangeFlags |= SETTINGS_HELP;
1499 : }
1500 : }
1501 :
1502 500 : if ( nFlags & SETTINGS_LOCALE )
1503 : {
1504 500 : if ( mpData->maLocale != rSet.mpData->maLocale )
1505 : {
1506 160 : SetLanguageTag( rSet.mpData->maLocale );
1507 160 : nChangeFlags |= SETTINGS_LOCALE;
1508 : }
1509 : }
1510 :
1511 500 : if ( nFlags & SETTINGS_UILOCALE )
1512 : {
1513 : // UILocale can't be changed
1514 : }
1515 :
1516 500 : return nChangeFlags;
1517 : }
1518 :
1519 : // -----------------------------------------------------------------------
1520 :
1521 22246 : sal_uLong AllSettings::GetChangeFlags( const AllSettings& rSet ) const
1522 : {
1523 : DBG_CHKTHIS( AllSettings, NULL );
1524 : DBG_CHKOBJ( &rSet, AllSettings, NULL );
1525 :
1526 22246 : sal_uLong nChangeFlags = 0;
1527 :
1528 22246 : if ( mpData->maMouseSettings != rSet.mpData->maMouseSettings )
1529 1347 : nChangeFlags |= SETTINGS_MOUSE;
1530 :
1531 22246 : if ( mpData->maStyleSettings != rSet.mpData->maStyleSettings )
1532 264 : nChangeFlags |= SETTINGS_STYLE;
1533 :
1534 22246 : if ( mpData->maMiscSettings != rSet.mpData->maMiscSettings )
1535 0 : nChangeFlags |= SETTINGS_MISC;
1536 :
1537 22246 : if ( mpData->maHelpSettings != rSet.mpData->maHelpSettings )
1538 83 : nChangeFlags |= SETTINGS_HELP;
1539 :
1540 22246 : if ( mpData->maLocale != rSet.mpData->maLocale )
1541 6 : nChangeFlags |= SETTINGS_LOCALE;
1542 :
1543 22246 : return nChangeFlags;
1544 : }
1545 :
1546 : // -----------------------------------------------------------------------
1547 :
1548 0 : sal_Bool AllSettings::operator ==( const AllSettings& rSet ) const
1549 : {
1550 : DBG_CHKTHIS( AllSettings, NULL );
1551 : DBG_CHKOBJ( &rSet, AllSettings, NULL );
1552 :
1553 0 : if ( mpData == rSet.mpData )
1554 0 : return sal_True;
1555 :
1556 0 : if ( (mpData->maMouseSettings == rSet.mpData->maMouseSettings) &&
1557 0 : (mpData->maStyleSettings == rSet.mpData->maStyleSettings) &&
1558 0 : (mpData->maMiscSettings == rSet.mpData->maMiscSettings) &&
1559 0 : (mpData->maHelpSettings == rSet.mpData->maHelpSettings) &&
1560 0 : (mpData->mnSystemUpdate == rSet.mpData->mnSystemUpdate) &&
1561 0 : (mpData->maLocale == rSet.mpData->maLocale) &&
1562 0 : (mpData->mnWindowUpdate == rSet.mpData->mnWindowUpdate) )
1563 : {
1564 0 : return sal_True;
1565 : }
1566 : else
1567 0 : return sal_False;
1568 : }
1569 :
1570 : // -----------------------------------------------------------------------
1571 :
1572 164 : void AllSettings::SetLanguageTag( const LanguageTag& rLanguageTag )
1573 : {
1574 164 : if (mpData->maLocale != rLanguageTag)
1575 : {
1576 164 : CopyData();
1577 :
1578 164 : mpData->maLocale = rLanguageTag;
1579 :
1580 164 : if ( mpData->mpLocaleDataWrapper )
1581 : {
1582 0 : delete mpData->mpLocaleDataWrapper;
1583 0 : mpData->mpLocaleDataWrapper = NULL;
1584 : }
1585 164 : if ( mpData->mpI18nHelper )
1586 : {
1587 0 : delete mpData->mpI18nHelper;
1588 0 : mpData->mpI18nHelper = NULL;
1589 : }
1590 : }
1591 164 : }
1592 :
1593 : // -----------------------------------------------------------------------
1594 :
1595 0 : void AllSettings::SetUILanguageTag( const LanguageTag& )
1596 : {
1597 : // there is only one UILocale per process
1598 0 : }
1599 :
1600 : // -----------------------------------------------------------------------
1601 :
1602 451663 : bool AllSettings::GetLayoutRTL() const
1603 : {
1604 451663 : static const char* pEnv = getenv("SAL_RTL_ENABLED" );
1605 : static int nUIMirroring = -1; // -1: undef, 0: auto, 1: on 2: off
1606 :
1607 : // environment always overrides
1608 451663 : if( pEnv )
1609 0 : return true;
1610 :
1611 451663 : bool bRTL = false;
1612 :
1613 451663 : if( nUIMirroring == -1 )
1614 : {
1615 132 : nUIMirroring = 0; // ask configuration only once
1616 : utl::OConfigurationNode aNode = utl::OConfigurationTreeRoot::tryCreateWithComponentContext(
1617 : comphelper::getProcessComponentContext(),
1618 132 : OUString("org.openoffice.Office.Common/I18N/CTL") ); // note: case sensitive !
1619 132 : if ( aNode.isValid() )
1620 : {
1621 132 : sal_Bool bTmp = sal_Bool();
1622 132 : ::com::sun::star::uno::Any aValue = aNode.getNodeValue( OUString("UIMirroring") );
1623 132 : if( aValue >>= bTmp )
1624 : {
1625 : // found true or false; if it was nil, nothing is changed
1626 0 : nUIMirroring = bTmp ? 1 : 2;
1627 132 : }
1628 132 : }
1629 : }
1630 :
1631 451663 : if( nUIMirroring == 0 ) // no config found (eg, setup) or default (nil) was set: check language
1632 : {
1633 451663 : LanguageType aLang = LANGUAGE_DONTKNOW;
1634 451663 : ImplSVData* pSVData = ImplGetSVData();
1635 451663 : if ( pSVData->maAppData.mpSettings )
1636 451663 : aLang = pSVData->maAppData.mpSettings->GetUILanguageTag().getLanguageType();
1637 451663 : bRTL = MsLangId::isRightToLeft( aLang );
1638 : }
1639 : else
1640 0 : bRTL = (nUIMirroring == 1);
1641 :
1642 451663 : return bRTL;
1643 : }
1644 :
1645 : // -----------------------------------------------------------------------
1646 :
1647 1065582 : const LanguageTag& AllSettings::GetLanguageTag() const
1648 : {
1649 : // SYSTEM locale means: use settings from SvtSysLocale that is resolved
1650 1065582 : if ( mpData->maLocale.isSystemLocale() )
1651 72 : mpData->maLocale = mpData->maSysLocale.GetLanguageTag();
1652 :
1653 1065582 : return mpData->maLocale;
1654 : }
1655 :
1656 : // -----------------------------------------------------------------------
1657 :
1658 489986 : const LanguageTag& AllSettings::GetUILanguageTag() const
1659 : {
1660 : // the UILocale is never changed
1661 489986 : if ( mpData->maUILocale.isSystemLocale() )
1662 144 : mpData->maUILocale = mpData->maSysLocale.GetUILanguageTag();
1663 :
1664 489986 : return mpData->maUILocale;
1665 : }
1666 :
1667 : // -----------------------------------------------------------------------
1668 :
1669 1942 : const LocaleDataWrapper& AllSettings::GetLocaleDataWrapper() const
1670 : {
1671 1942 : if ( !mpData->mpLocaleDataWrapper )
1672 : ((AllSettings*)this)->mpData->mpLocaleDataWrapper = new LocaleDataWrapper(
1673 11 : comphelper::getProcessComponentContext(), GetLanguageTag() );
1674 1942 : return *mpData->mpLocaleDataWrapper;
1675 : }
1676 :
1677 : // -----------------------------------------------------------------------
1678 :
1679 0 : const LocaleDataWrapper& AllSettings::GetUILocaleDataWrapper() const
1680 : {
1681 0 : if ( !mpData->mpUILocaleDataWrapper )
1682 : ((AllSettings*)this)->mpData->mpUILocaleDataWrapper = new LocaleDataWrapper(
1683 0 : comphelper::getProcessComponentContext(), GetUILanguageTag() );
1684 0 : return *mpData->mpUILocaleDataWrapper;
1685 : }
1686 :
1687 : // -----------------------------------------------------------------------
1688 :
1689 5372 : const vcl::I18nHelper& AllSettings::GetLocaleI18nHelper() const
1690 : {
1691 5372 : if ( !mpData->mpI18nHelper ) {
1692 : ((AllSettings*)this)->mpData->mpI18nHelper = new vcl::I18nHelper(
1693 66 : comphelper::getProcessComponentContext(), GetLanguageTag() );
1694 : }
1695 5372 : return *mpData->mpI18nHelper;
1696 : }
1697 :
1698 : // -----------------------------------------------------------------------
1699 :
1700 0 : const vcl::I18nHelper& AllSettings::GetUILocaleI18nHelper() const
1701 : {
1702 0 : if ( !mpData->mpUII18nHelper ) {
1703 : ((AllSettings*)this)->mpData->mpUII18nHelper = new vcl::I18nHelper(
1704 0 : comphelper::getProcessComponentContext(), GetUILanguageTag() );
1705 : }
1706 0 : return *mpData->mpUII18nHelper;
1707 : }
1708 :
1709 1 : void AllSettings::LocaleSettingsChanged( sal_uInt32 nHint )
1710 : {
1711 1 : AllSettings aAllSettings( Application::GetSettings() );
1712 1 : if ( nHint & SYSLOCALEOPTIONS_HINT_DECSEP )
1713 : {
1714 0 : MiscSettings aMiscSettings = aAllSettings.GetMiscSettings();
1715 0 : sal_Bool bIsDecSepAsLocale = aAllSettings.mpData->maSysLocale.GetOptions().IsDecimalSeparatorAsLocale();
1716 0 : if ( aMiscSettings.GetEnableLocalizedDecimalSep() != bIsDecSepAsLocale )
1717 : {
1718 0 : aMiscSettings.SetEnableLocalizedDecimalSep( bIsDecSepAsLocale );
1719 0 : aAllSettings.SetMiscSettings( aMiscSettings );
1720 0 : }
1721 : }
1722 :
1723 1 : if ( (nHint & SYSLOCALEOPTIONS_HINT_LOCALE) )
1724 1 : aAllSettings.SetLanguageTag( aAllSettings.mpData->maSysLocale.GetOptions().GetLanguageTag() );
1725 :
1726 1 : Application::SetSettings( aAllSettings );
1727 466 : }
1728 :
1729 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|