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