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