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