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_CRYSTAL: return ::rtl::OUString::createFromAscii( "crystal" ); 699 case STYLE_SYMBOLS_TANGO: return ::rtl::OUString::createFromAscii( "tango" ); 700 case STYLE_SYMBOLS_CLASSIC: return ::rtl::OUString::createFromAscii( "classic" ); 701 } 702 703 return ::rtl::OUString::createFromAscii( "auto" ); 704 } 705 706 // ----------------------------------------------------------------------- 707 708 sal_uLong StyleSettings::ImplNameToSymbolsStyle( const ::rtl::OUString &rName ) const 709 { 710 if ( rName == ::rtl::OUString::createFromAscii( "default" ) ) 711 return STYLE_SYMBOLS_DEFAULT; 712 else if ( rName == ::rtl::OUString::createFromAscii( "hicontrast" ) ) 713 return STYLE_SYMBOLS_HICONTRAST; 714 else if ( rName == ::rtl::OUString::createFromAscii( "industrial" ) ) 715 return STYLE_SYMBOLS_INDUSTRIAL; 716 else if ( rName == ::rtl::OUString::createFromAscii( "crystal" ) ) 717 return STYLE_SYMBOLS_CRYSTAL; 718 else if ( rName == ::rtl::OUString::createFromAscii( "tango" ) ) 719 return STYLE_SYMBOLS_TANGO; 720 else if ( rName == ::rtl::OUString::createFromAscii( "classic" ) ) 721 return STYLE_SYMBOLS_CLASSIC; 722 723 return STYLE_SYMBOLS_AUTO; 724 } 725 726 // ----------------------------------------------------------------------- 727 728 /** 729 The preferred style name can be read from the desktop setting. We 730 need to find the closest theme name registered in OOo. Therefore 731 we check if any registered style name is a case-insensitive 732 substring of the preferred style name. 733 */ 734 void StyleSettings::SetPreferredSymbolsStyleName( const ::rtl::OUString &rName ) 735 { 736 if ( rName.getLength() > 0 ) 737 { 738 ::rtl::OUString rNameLowCase( rName.toAsciiLowerCase() ); 739 740 for( sal_uInt32 n = 0; n <= STYLE_SYMBOLS_THEMES_MAX; n++ ) 741 if ( rNameLowCase.indexOf( ImplSymbolsStyleToName( n ) ) != -1 ) 742 SetPreferredSymbolsStyle( n ); 743 } 744 } 745 746 // ----------------------------------------------------------------------- 747 748 sal_uLong StyleSettings::GetCurrentSymbolsStyle() const 749 { 750 // style selected in Tools -> Options... -> OpenOffice.org -> View 751 sal_uLong nStyle = GetSymbolsStyle(); 752 753 if ( nStyle == STYLE_SYMBOLS_AUTO || ( !CheckSymbolStyle (nStyle) ) ) 754 { 755 // the preferred style can be read from the desktop setting by the desktop native widgets modules 756 sal_uLong nPreferredStyle = GetPreferredSymbolsStyle(); 757 758 if ( nPreferredStyle == STYLE_SYMBOLS_AUTO || ( !CheckSymbolStyle (nPreferredStyle) ) ) 759 { 760 761 // use a hardcoded desktop-specific fallback if no preferred style has been detected 762 static bool sbFallbackDesktopChecked = false; 763 static sal_uLong snFallbackDesktopStyle = STYLE_SYMBOLS_DEFAULT; 764 765 if ( !sbFallbackDesktopChecked ) 766 { 767 snFallbackDesktopStyle = GetAutoSymbolsStyle(); 768 sbFallbackDesktopChecked = true; 769 } 770 771 nPreferredStyle = snFallbackDesktopStyle; 772 } 773 774 if (GetHighContrastMode() && CheckSymbolStyle (STYLE_SYMBOLS_HICONTRAST) ) 775 nStyle = STYLE_SYMBOLS_HICONTRAST; 776 else 777 nStyle = nPreferredStyle; 778 } 779 780 return nStyle; 781 } 782 783 // ----------------------------------------------------------------------- 784 785 sal_uLong StyleSettings::GetAutoSymbolsStyle() const 786 { 787 const ::rtl::OUString& rDesktopEnvironment = Application::GetDesktopEnvironment(); 788 sal_uLong nRet = STYLE_SYMBOLS_DEFAULT; 789 bool bCont = true; 790 791 try 792 { 793 const ::com::sun::star::uno::Any aAny( ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::OPENSOURCECONTEXT ) ); 794 sal_Int32 nValue( 0 ); 795 796 aAny >>= nValue; 797 798 if( 0 == nValue ) 799 bCont = false; 800 } 801 catch ( ::com::sun::star::uno::Exception& ) 802 { 803 } 804 805 if( bCont ) 806 { 807 if( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "gnome" ) ) 808 nRet = STYLE_SYMBOLS_TANGO; 809 else if( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "kde" ) ) 810 nRet = STYLE_SYMBOLS_CRYSTAL; 811 } 812 813 // falback to any existing style 814 if ( ! CheckSymbolStyle (nRet) ) 815 { 816 for ( sal_uLong n = 0 ; n <= STYLE_SYMBOLS_THEMES_MAX ; n++ ) 817 { 818 sal_uLong nStyleToCheck = n; 819 820 // auto is not a real theme => can't be fallback 821 if ( nStyleToCheck == STYLE_SYMBOLS_AUTO ) 822 continue; 823 824 // will check hicontrast in the end 825 if ( nStyleToCheck == STYLE_SYMBOLS_HICONTRAST ) 826 continue; 827 if ( nStyleToCheck == STYLE_SYMBOLS_THEMES_MAX ) 828 nStyleToCheck = STYLE_SYMBOLS_HICONTRAST; 829 830 if ( CheckSymbolStyle ( nStyleToCheck ) ) 831 { 832 nRet = nStyleToCheck; 833 n = STYLE_SYMBOLS_THEMES_MAX; 834 } 835 } 836 } 837 838 return nRet; 839 } 840 841 // ----------------------------------------------------------------------- 842 843 bool StyleSettings::CheckSymbolStyle( sal_uLong nStyle ) const 844 { 845 static ImplImageTreeSingletonRef aImageTree; 846 return aImageTree->checkStyle( ImplSymbolsStyleToName( nStyle ) ); 847 } 848 849 // ----------------------------------------------------------------------- 850 851 void StyleSettings::SetStandardStyles() 852 { 853 CopyData(); 854 mpData->SetStandardStyles(); 855 } 856 857 // ----------------------------------------------------------------------- 858 859 Color StyleSettings::GetFaceGradientColor() const 860 { 861 // compute a brighter face color that can be used in gradients 862 // for a convex look (eg toolbars) 863 864 sal_uInt16 h, s, b; 865 GetFaceColor().RGBtoHSB( h, s, b ); 866 if( s > 1) s=1; 867 if( b < 98) b=98; 868 return Color( Color::HSBtoRGB( h, s, b ) ); 869 } 870 871 // ----------------------------------------------------------------------- 872 873 Color StyleSettings::GetSeparatorColor() const 874 { 875 // compute a brighter shadow color for separators (used in toolbars or between menubar and toolbars on Windows XP) 876 sal_uInt16 h, s, b; 877 GetShadowColor().RGBtoHSB( h, s, b ); 878 b += b/4; 879 s -= s/4; 880 return Color( Color::HSBtoRGB( h, s, b ) ); 881 } 882 883 // ----------------------------------------------------------------------- 884 885 const StyleSettings& StyleSettings::operator =( const StyleSettings& rSet ) 886 { 887 DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "StyleSettings: RefCount overflow" ); 888 889 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann 890 rSet.mpData->mnRefCount++; 891 892 // Daten loeschen, wenn letzte Referenz 893 if ( mpData->mnRefCount == 1 ) 894 delete mpData; 895 else 896 mpData->mnRefCount--; 897 898 mpData = rSet.mpData; 899 900 return *this; 901 } 902 903 // ----------------------------------------------------------------------- 904 905 void StyleSettings::CopyData() 906 { 907 // Falls noch andere Referenzen bestehen, dann kopieren 908 if ( mpData->mnRefCount != 1 ) 909 { 910 mpData->mnRefCount--; 911 mpData = new ImplStyleData( *mpData ); 912 } 913 } 914 915 // ----------------------------------------------------------------------- 916 917 inline sal_Bool ImplIsBackOrWhite( const Color& rColor ) 918 { 919 sal_uInt8 nLuminance = rColor.GetLuminance(); 920 return ( nLuminance < 8 ) || ( nLuminance > 250 ); 921 } 922 923 sal_Bool StyleSettings::IsHighContrastBlackAndWhite() const 924 { 925 sal_Bool bBWOnly = sal_True; 926 927 // Only use B&W if fully B&W, like on GNOME. 928 // Some colors like CheckedColor and HighlightColor are not B&W in Windows Standard HC Black, 929 // and we don't want to be B&W then, so check these color first, very probably not B&W. 930 931 // Unfortunately, GNOME uses a very very dark color (0x000033) instead of BLACK (0x000000) 932 933 if ( !ImplIsBackOrWhite( GetFaceColor() ) ) 934 bBWOnly = sal_False; 935 else if ( !ImplIsBackOrWhite( GetHighlightTextColor() ) ) 936 bBWOnly = sal_False; 937 else if ( !ImplIsBackOrWhite( GetWindowColor() ) ) 938 bBWOnly = sal_False; 939 else if ( !ImplIsBackOrWhite( GetWindowTextColor() ) ) 940 bBWOnly = sal_False; 941 else if ( !ImplIsBackOrWhite( GetButtonTextColor() ) ) 942 bBWOnly = sal_False; 943 else if ( !ImplIsBackOrWhite( GetButtonTextColor() ) ) 944 bBWOnly = sal_False; 945 else if ( !ImplIsBackOrWhite( GetGroupTextColor() ) ) 946 bBWOnly = sal_False; 947 else if ( !ImplIsBackOrWhite( GetLabelTextColor() ) ) 948 bBWOnly = sal_False; 949 else if ( !ImplIsBackOrWhite( GetDialogColor() ) ) 950 bBWOnly = sal_False; 951 else if ( !ImplIsBackOrWhite( GetFieldColor() ) ) 952 bBWOnly = sal_False; 953 else if ( !ImplIsBackOrWhite( GetMenuColor() ) ) 954 bBWOnly = sal_False; 955 else if ( !ImplIsBackOrWhite( GetMenuBarColor() ) ) 956 bBWOnly = sal_False; 957 else if ( !ImplIsBackOrWhite( GetMenuHighlightColor() ) ) 958 bBWOnly = sal_False; 959 960 return bBWOnly; 961 } 962 963 // ----------------------------------------------------------------------- 964 965 sal_Bool StyleSettings::operator ==( const StyleSettings& rSet ) const 966 { 967 if ( mpData == rSet.mpData ) 968 return sal_True; 969 970 if ( (mpData->mnOptions == rSet.mpData->mnOptions) && 971 (mpData->mnAutoMnemonic == rSet.mpData->mnAutoMnemonic) && 972 (mpData->mnLogoDisplayTime == rSet.mpData->mnLogoDisplayTime) && 973 (mpData->mnDragFullOptions == rSet.mpData->mnDragFullOptions) && 974 (mpData->mnAnimationOptions == rSet.mpData->mnAnimationOptions) && 975 (mpData->mnSelectionOptions == rSet.mpData->mnSelectionOptions) && 976 (mpData->mnDisplayOptions == rSet.mpData->mnDisplayOptions) && 977 (mpData->mnCursorSize == rSet.mpData->mnCursorSize) && 978 (mpData->mnCursorBlinkTime == rSet.mpData->mnCursorBlinkTime) && 979 (mpData->mnBorderSize == rSet.mpData->mnBorderSize) && 980 (mpData->mnTitleHeight == rSet.mpData->mnTitleHeight) && 981 (mpData->mnFloatTitleHeight == rSet.mpData->mnFloatTitleHeight) && 982 (mpData->mnTearOffTitleHeight == rSet.mpData->mnTearOffTitleHeight) && 983 (mpData->mnMenuBarHeight == rSet.mpData->mnMenuBarHeight) && 984 (mpData->mnScrollBarSize == rSet.mpData->mnScrollBarSize) && 985 (mpData->mnMinThumbSize == rSet.mpData->mnMinThumbSize) && 986 (mpData->mnSplitSize == rSet.mpData->mnSplitSize) && 987 (mpData->mnSpinSize == rSet.mpData->mnSpinSize) && 988 (mpData->mnIconHorzSpace == rSet.mpData->mnIconHorzSpace) && 989 (mpData->mnIconVertSpace == rSet.mpData->mnIconVertSpace) && 990 (mpData->mnAntialiasedMin == rSet.mpData->mnAntialiasedMin) && 991 (mpData->mnScreenZoom == rSet.mpData->mnScreenZoom) && 992 (mpData->mnScreenFontZoom == rSet.mpData->mnScreenFontZoom) && 993 (mpData->mnHighContrast == rSet.mpData->mnHighContrast) && 994 (mpData->mnUseSystemUIFonts == rSet.mpData->mnUseSystemUIFonts) && 995 (mpData->mnUseFlatBorders == rSet.mpData->mnUseFlatBorders) && 996 (mpData->mnUseFlatMenues == rSet.mpData->mnUseFlatMenues) && 997 (mpData->mnSymbolsStyle == rSet.mpData->mnSymbolsStyle) && 998 (mpData->mnPreferredSymbolsStyle == rSet.mpData->mnPreferredSymbolsStyle) && 999 (mpData->maFaceColor == rSet.mpData->maFaceColor) && 1000 (mpData->maCheckedColor == rSet.mpData->maCheckedColor) && 1001 (mpData->maLightColor == rSet.mpData->maLightColor) && 1002 (mpData->maLightBorderColor == rSet.mpData->maLightBorderColor) && 1003 (mpData->maShadowColor == rSet.mpData->maShadowColor) && 1004 (mpData->maDarkShadowColor == rSet.mpData->maDarkShadowColor) && 1005 (mpData->maButtonTextColor == rSet.mpData->maButtonTextColor) && 1006 (mpData->maRadioCheckTextColor == rSet.mpData->maRadioCheckTextColor) && 1007 (mpData->maGroupTextColor == rSet.mpData->maGroupTextColor) && 1008 (mpData->maLabelTextColor == rSet.mpData->maLabelTextColor) && 1009 (mpData->maInfoTextColor == rSet.mpData->maInfoTextColor) && 1010 (mpData->maWindowColor == rSet.mpData->maWindowColor) && 1011 (mpData->maWindowTextColor == rSet.mpData->maWindowTextColor) && 1012 (mpData->maDialogColor == rSet.mpData->maDialogColor) && 1013 (mpData->maDialogTextColor == rSet.mpData->maDialogTextColor) && 1014 (mpData->maWorkspaceColor == rSet.mpData->maWorkspaceColor) && 1015 (mpData->maMonoColor == rSet.mpData->maMonoColor) && 1016 (mpData->maFieldColor == rSet.mpData->maFieldColor) && 1017 (mpData->maFieldTextColor == rSet.mpData->maFieldTextColor) && 1018 (mpData->maActiveColor == rSet.mpData->maActiveColor) && 1019 (mpData->maActiveColor2 == rSet.mpData->maActiveColor2) && 1020 (mpData->maActiveTextColor == rSet.mpData->maActiveTextColor) && 1021 (mpData->maActiveBorderColor == rSet.mpData->maActiveBorderColor) && 1022 (mpData->maDeactiveColor == rSet.mpData->maDeactiveColor) && 1023 (mpData->maDeactiveColor2 == rSet.mpData->maDeactiveColor2) && 1024 (mpData->maDeactiveTextColor == rSet.mpData->maDeactiveTextColor) && 1025 (mpData->maDeactiveBorderColor == rSet.mpData->maDeactiveBorderColor) && 1026 (mpData->maMenuColor == rSet.mpData->maMenuColor) && 1027 (mpData->maMenuBarColor == rSet.mpData->maMenuBarColor) && 1028 (mpData->maMenuBorderColor == rSet.mpData->maMenuBorderColor) && 1029 (mpData->maMenuTextColor == rSet.mpData->maMenuTextColor) && 1030 (mpData->maMenuBarTextColor == rSet.mpData->maMenuBarTextColor) && 1031 (mpData->maMenuHighlightColor == rSet.mpData->maMenuHighlightColor) && 1032 (mpData->maMenuHighlightTextColor == rSet.mpData->maMenuHighlightTextColor) && 1033 (mpData->maHighlightColor == rSet.mpData->maHighlightColor) && 1034 (mpData->maHighlightTextColor == rSet.mpData->maHighlightTextColor) && 1035 (mpData->maActiveTabColor == rSet.mpData->maActiveTabColor) && 1036 (mpData->maInactiveTabColor == rSet.mpData->maInactiveTabColor) && 1037 (mpData->maDisableColor == rSet.mpData->maDisableColor) && 1038 (mpData->maHelpColor == rSet.mpData->maHelpColor) && 1039 (mpData->maHelpTextColor == rSet.mpData->maHelpTextColor) && 1040 (mpData->maLinkColor == rSet.mpData->maLinkColor) && 1041 (mpData->maVisitedLinkColor == rSet.mpData->maVisitedLinkColor) && 1042 (mpData->maHighlightLinkColor == rSet.mpData->maHighlightLinkColor) && 1043 (mpData->maAppFont == rSet.mpData->maAppFont) && 1044 (mpData->maHelpFont == rSet.mpData->maHelpFont) && 1045 (mpData->maTitleFont == rSet.mpData->maTitleFont) && 1046 (mpData->maFloatTitleFont == rSet.mpData->maFloatTitleFont) && 1047 (mpData->maMenuFont == rSet.mpData->maMenuFont) && 1048 (mpData->maToolFont == rSet.mpData->maToolFont) && 1049 (mpData->maGroupFont == rSet.mpData->maGroupFont) && 1050 (mpData->maLabelFont == rSet.mpData->maLabelFont) && 1051 (mpData->maInfoFont == rSet.mpData->maInfoFont) && 1052 (mpData->maRadioCheckFont == rSet.mpData->maRadioCheckFont) && 1053 (mpData->maPushButtonFont == rSet.mpData->maPushButtonFont) && 1054 (mpData->maFieldFont == rSet.mpData->maFieldFont) && 1055 (mpData->maIconFont == rSet.mpData->maIconFont) && 1056 (mpData->mnUseImagesInMenus == rSet.mpData->mnUseImagesInMenus) && 1057 (mpData->mnSkipDisabledInMenus == rSet.mpData->mnSkipDisabledInMenus) && 1058 (mpData->maFontColor == rSet.mpData->maFontColor )) 1059 return sal_True; 1060 else 1061 return sal_False; 1062 } 1063 1064 // ======================================================================= 1065 1066 ImplMiscData::ImplMiscData() 1067 { 1068 mnRefCount = 1; 1069 mnEnableATT = sal::static_int_cast<sal_uInt16>(~0U); 1070 mnDisablePrinting = sal::static_int_cast<sal_uInt16>(~0U); 1071 static const char* pEnv = getenv("SAL_DECIMALSEP_ENABLED" ); // set default without UI 1072 mbEnableLocalizedDecimalSep = (pEnv != NULL) ? sal_True : sal_False; 1073 } 1074 1075 // ----------------------------------------------------------------------- 1076 1077 ImplMiscData::ImplMiscData( const ImplMiscData& rData ) 1078 { 1079 mnRefCount = 1; 1080 mnEnableATT = rData.mnEnableATT; 1081 mnDisablePrinting = rData.mnDisablePrinting; 1082 mbEnableLocalizedDecimalSep = rData.mbEnableLocalizedDecimalSep; 1083 } 1084 1085 // ----------------------------------------------------------------------- 1086 1087 MiscSettings::MiscSettings() 1088 { 1089 mpData = new ImplMiscData(); 1090 } 1091 1092 // ----------------------------------------------------------------------- 1093 1094 MiscSettings::MiscSettings( const MiscSettings& rSet ) 1095 { 1096 DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "MiscSettings: RefCount overflow" ); 1097 1098 // shared Instance Daten uebernehmen und Referenzcounter erhoehen 1099 mpData = rSet.mpData; 1100 mpData->mnRefCount++; 1101 } 1102 1103 // ----------------------------------------------------------------------- 1104 1105 MiscSettings::~MiscSettings() 1106 { 1107 // Daten loeschen, wenn letzte Referenz 1108 if ( mpData->mnRefCount == 1 ) 1109 delete mpData; 1110 else 1111 mpData->mnRefCount--; 1112 } 1113 1114 // ----------------------------------------------------------------------- 1115 1116 const MiscSettings& MiscSettings::operator =( const MiscSettings& rSet ) 1117 { 1118 DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "MiscSettings: RefCount overflow" ); 1119 1120 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann 1121 rSet.mpData->mnRefCount++; 1122 1123 // Daten loeschen, wenn letzte Referenz 1124 if ( mpData->mnRefCount == 1 ) 1125 delete mpData; 1126 else 1127 mpData->mnRefCount--; 1128 1129 mpData = rSet.mpData; 1130 1131 return *this; 1132 } 1133 1134 // ----------------------------------------------------------------------- 1135 1136 void MiscSettings::CopyData() 1137 { 1138 // Falls noch andere Referenzen bestehen, dann kopieren 1139 if ( mpData->mnRefCount != 1 ) 1140 { 1141 mpData->mnRefCount--; 1142 mpData = new ImplMiscData( *mpData ); 1143 } 1144 } 1145 1146 // ----------------------------------------------------------------------- 1147 1148 sal_Bool MiscSettings::operator ==( const MiscSettings& rSet ) const 1149 { 1150 if ( mpData == rSet.mpData ) 1151 return sal_True; 1152 1153 if ( (mpData->mnEnableATT == rSet.mpData->mnEnableATT ) && 1154 (mpData->mnDisablePrinting == rSet.mpData->mnDisablePrinting ) && 1155 (mpData->mbEnableLocalizedDecimalSep == rSet.mpData->mbEnableLocalizedDecimalSep ) ) 1156 return sal_True; 1157 else 1158 return sal_False; 1159 } 1160 1161 // ----------------------------------------------------------------------- 1162 1163 sal_Bool MiscSettings::GetDisablePrinting() const 1164 { 1165 if( mpData->mnDisablePrinting == (sal_uInt16)~0 ) 1166 { 1167 rtl::OUString aEnable = 1168 vcl::SettingsConfigItem::get()-> 1169 getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DesktopManagement" ) ), 1170 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisablePrinting" ) ) ); 1171 mpData->mnDisablePrinting = aEnable.equalsIgnoreAsciiCaseAscii( "true" ) ? 1 : 0; 1172 } 1173 1174 return (sal_Bool)mpData->mnDisablePrinting; 1175 } 1176 // ----------------------------------------------------------------------- 1177 1178 sal_Bool MiscSettings::GetEnableATToolSupport() const 1179 { 1180 1181 #ifdef WNT 1182 if( mpData->mnEnableATT == (sal_uInt16)~0 ) 1183 { 1184 // Check in the Windows registry if an AT tool wants Accessibility support to 1185 // be activated .. 1186 HKEY hkey; 1187 1188 if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER, 1189 "Software\\OpenOffice.org\\Accessibility\\AtToolSupport", 1190 &hkey) ) 1191 { 1192 DWORD dwType; 1193 sal_uInt8 Data[6]; // possible values: "true", "false", "1", "0", DWORD 1194 DWORD cbData = sizeof(Data); 1195 1196 if( ERROR_SUCCESS == RegQueryValueEx(hkey, "SupportAssistiveTechnology", 1197 NULL, &dwType, Data, &cbData) ) 1198 { 1199 switch (dwType) 1200 { 1201 case REG_SZ: 1202 mpData->mnEnableATT = ((0 == stricmp((const char *) Data, "1")) || (0 == stricmp((const char *) Data, "true"))); 1203 break; 1204 case REG_DWORD: 1205 mpData->mnEnableATT = (sal_uInt16) (((DWORD *) Data)[0]); 1206 break; 1207 default: 1208 // Unsupported registry type 1209 break; 1210 } 1211 } 1212 1213 RegCloseKey(hkey); 1214 } 1215 } 1216 #endif 1217 1218 if( mpData->mnEnableATT == (sal_uInt16)~0 ) 1219 { 1220 static const char* pEnv = getenv("SAL_ACCESSIBILITY_ENABLED" ); 1221 if( !pEnv || !*pEnv ) 1222 { 1223 rtl::OUString aEnable = 1224 vcl::SettingsConfigItem::get()-> 1225 getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Accessibility" ) ), 1226 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableATToolSupport" ) ) ); 1227 mpData->mnEnableATT = aEnable.equalsIgnoreAsciiCaseAscii( "true" ) ? 1 : 0; 1228 } 1229 else 1230 { 1231 mpData->mnEnableATT = 1; 1232 } 1233 } 1234 1235 return (sal_Bool)mpData->mnEnableATT; 1236 } 1237 1238 // ----------------------------------------------------------------------- 1239 1240 void MiscSettings::SetDisablePrinting( sal_Bool bEnable ) 1241 { 1242 if ( bEnable != mpData->mnDisablePrinting ) 1243 { 1244 vcl::SettingsConfigItem::get()-> 1245 setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DesktopManagement" ) ), 1246 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisablePrinting" ) ), 1247 rtl::OUString::createFromAscii( bEnable ? "true" : "false" ) ); 1248 mpData->mnDisablePrinting = bEnable ? 1 : 0; 1249 } 1250 } 1251 1252 // ----------------------------------------------------------------------- 1253 1254 void MiscSettings::SetEnableATToolSupport( sal_Bool bEnable ) 1255 { 1256 if ( bEnable != mpData->mnEnableATT ) 1257 { 1258 sal_Bool bDummy; 1259 if( bEnable && !ImplInitAccessBridge(false, bDummy) ) 1260 return; 1261 1262 #ifdef WNT 1263 HKEY hkey; 1264 1265 // If the accessibility key in the Windows registry exists, change it synchronously 1266 if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER, 1267 "Software\\OpenOffice.org\\Accessibility\\AtToolSupport", 1268 &hkey) ) 1269 { 1270 DWORD dwType; 1271 sal_uInt8 Data[6]; // possible values: "true", "false", 1, 0 1272 DWORD cbData = sizeof(Data); 1273 1274 if( ERROR_SUCCESS == RegQueryValueEx(hkey, "SupportAssistiveTechnology", 1275 NULL, &dwType, Data, &cbData) ) 1276 { 1277 switch (dwType) 1278 { 1279 case REG_SZ: 1280 RegSetValueEx(hkey, "SupportAssistiveTechnology", 1281 NULL, dwType, 1282 bEnable ? (sal_uInt8 *) "true" : (sal_uInt8 *) "false", 1283 bEnable ? sizeof("true") : sizeof("false")); 1284 break; 1285 case REG_DWORD: 1286 ((DWORD *) Data)[0] = bEnable ? 1 : 0; 1287 RegSetValueEx(hkey, "SupportAssistiveTechnology", 1288 NULL, dwType, Data, sizeof(DWORD)); 1289 break; 1290 default: 1291 // Unsupported registry type 1292 break; 1293 } 1294 } 1295 1296 RegCloseKey(hkey); 1297 } 1298 1299 #endif 1300 vcl::SettingsConfigItem::get()-> 1301 setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Accessibility" ) ), 1302 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableATToolSupport" ) ), 1303 rtl::OUString::createFromAscii( bEnable ? "true" : "false" ) ); 1304 mpData->mnEnableATT = bEnable ? 1 : 0; 1305 } 1306 } 1307 1308 void MiscSettings::SetEnableLocalizedDecimalSep( sal_Bool bEnable ) 1309 { 1310 CopyData(); 1311 mpData->mbEnableLocalizedDecimalSep = bEnable; 1312 } 1313 1314 sal_Bool MiscSettings::GetEnableLocalizedDecimalSep() const 1315 { 1316 return mpData->mbEnableLocalizedDecimalSep; 1317 } 1318 1319 // ======================================================================= 1320 1321 ImplNotificationData::ImplNotificationData() 1322 { 1323 mnRefCount = 1; 1324 mnOptions = 0; 1325 } 1326 1327 // ----------------------------------------------------------------------- 1328 1329 ImplNotificationData::ImplNotificationData( const ImplNotificationData& rData ) 1330 { 1331 mnRefCount = 1; 1332 mnOptions = rData.mnOptions; 1333 } 1334 1335 // ----------------------------------------------------------------------- 1336 1337 NotificationSettings::NotificationSettings() 1338 { 1339 mpData = new ImplNotificationData(); 1340 } 1341 1342 // ----------------------------------------------------------------------- 1343 1344 NotificationSettings::NotificationSettings( const NotificationSettings& rSet ) 1345 { 1346 DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "NotificationSettings: RefCount overflow" ); 1347 1348 // shared Instance Daten uebernehmen und Referenzcounter erhoehen 1349 mpData = rSet.mpData; 1350 mpData->mnRefCount++; 1351 } 1352 1353 // ----------------------------------------------------------------------- 1354 1355 NotificationSettings::~NotificationSettings() 1356 { 1357 // Daten loeschen, wenn letzte Referenz 1358 if ( mpData->mnRefCount == 1 ) 1359 delete mpData; 1360 else 1361 mpData->mnRefCount--; 1362 } 1363 1364 // ----------------------------------------------------------------------- 1365 1366 const NotificationSettings& NotificationSettings::operator =( const NotificationSettings& rSet ) 1367 { 1368 DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "NotificationSettings: RefCount overflow" ); 1369 1370 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann 1371 rSet.mpData->mnRefCount++; 1372 1373 // Daten loeschen, wenn letzte Referenz 1374 if ( mpData->mnRefCount == 1 ) 1375 delete mpData; 1376 else 1377 mpData->mnRefCount--; 1378 1379 mpData = rSet.mpData; 1380 1381 return *this; 1382 } 1383 1384 // ----------------------------------------------------------------------- 1385 1386 void NotificationSettings::CopyData() 1387 { 1388 // Falls noch andere Referenzen bestehen, dann kopieren 1389 if ( mpData->mnRefCount != 1 ) 1390 { 1391 mpData->mnRefCount--; 1392 mpData = new ImplNotificationData( *mpData ); 1393 } 1394 } 1395 1396 // ----------------------------------------------------------------------- 1397 1398 sal_Bool NotificationSettings::operator ==( const NotificationSettings& rSet ) const 1399 { 1400 if ( mpData == rSet.mpData ) 1401 return sal_True; 1402 1403 if ( (mpData->mnOptions == rSet.mpData->mnOptions) ) 1404 return sal_True; 1405 else 1406 return sal_False; 1407 } 1408 1409 // ======================================================================= 1410 1411 ImplHelpData::ImplHelpData() 1412 { 1413 mnRefCount = 1; 1414 mnOptions = 0; 1415 mnTipDelay = 500; 1416 mnTipTimeout = 3000; 1417 mnBalloonDelay = 1500; 1418 } 1419 1420 // ----------------------------------------------------------------------- 1421 1422 ImplHelpData::ImplHelpData( const ImplHelpData& rData ) 1423 { 1424 mnRefCount = 1; 1425 mnOptions = rData.mnOptions; 1426 mnTipDelay = rData.mnTipDelay; 1427 mnTipTimeout = rData.mnTipTimeout; 1428 mnBalloonDelay = rData.mnBalloonDelay; 1429 } 1430 1431 // ----------------------------------------------------------------------- 1432 1433 HelpSettings::HelpSettings() 1434 { 1435 mpData = new ImplHelpData(); 1436 } 1437 1438 // ----------------------------------------------------------------------- 1439 1440 HelpSettings::HelpSettings( const HelpSettings& rSet ) 1441 { 1442 DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "HelpSettings: RefCount overflow" ); 1443 1444 // shared Instance Daten uebernehmen und Referenzcounter erhoehen 1445 mpData = rSet.mpData; 1446 mpData->mnRefCount++; 1447 } 1448 1449 // ----------------------------------------------------------------------- 1450 1451 HelpSettings::~HelpSettings() 1452 { 1453 // Daten loeschen, wenn letzte Referenz 1454 if ( mpData->mnRefCount == 1 ) 1455 delete mpData; 1456 else 1457 mpData->mnRefCount--; 1458 } 1459 1460 // ----------------------------------------------------------------------- 1461 1462 const HelpSettings& HelpSettings::operator =( const HelpSettings& rSet ) 1463 { 1464 DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "HelpSettings: RefCount overflow" ); 1465 1466 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann 1467 rSet.mpData->mnRefCount++; 1468 1469 // Daten loeschen, wenn letzte Referenz 1470 if ( mpData->mnRefCount == 1 ) 1471 delete mpData; 1472 else 1473 mpData->mnRefCount--; 1474 1475 mpData = rSet.mpData; 1476 1477 return *this; 1478 } 1479 1480 // ----------------------------------------------------------------------- 1481 1482 void HelpSettings::CopyData() 1483 { 1484 // Falls noch andere Referenzen bestehen, dann kopieren 1485 if ( mpData->mnRefCount != 1 ) 1486 { 1487 mpData->mnRefCount--; 1488 mpData = new ImplHelpData( *mpData ); 1489 } 1490 } 1491 1492 // ----------------------------------------------------------------------- 1493 1494 sal_Bool HelpSettings::operator ==( const HelpSettings& rSet ) const 1495 { 1496 if ( mpData == rSet.mpData ) 1497 return sal_True; 1498 1499 if ( (mpData->mnOptions == rSet.mpData->mnOptions ) && 1500 (mpData->mnTipDelay == rSet.mpData->mnTipDelay ) && 1501 (mpData->mnTipTimeout == rSet.mpData->mnTipTimeout ) && 1502 (mpData->mnBalloonDelay == rSet.mpData->mnBalloonDelay ) ) 1503 return sal_True; 1504 else 1505 return sal_False; 1506 } 1507 1508 // ======================================================================= 1509 1510 ImplAllSettingsData::ImplAllSettingsData() 1511 { 1512 mnRefCount = 1; 1513 mnSystemUpdate = SETTINGS_ALLSETTINGS; 1514 mnWindowUpdate = SETTINGS_ALLSETTINGS; 1515 meLanguage = LANGUAGE_SYSTEM; 1516 meUILanguage = LANGUAGE_SYSTEM; 1517 mpLocaleDataWrapper = NULL; 1518 mpUILocaleDataWrapper = NULL; 1519 mpCollatorWrapper = NULL; 1520 mpUICollatorWrapper = NULL; 1521 mpI18nHelper = NULL; 1522 mpUII18nHelper = NULL; 1523 maMiscSettings.SetEnableLocalizedDecimalSep( maSysLocale.GetOptions().IsDecimalSeparatorAsLocale() ); 1524 } 1525 1526 // ----------------------------------------------------------------------- 1527 1528 ImplAllSettingsData::ImplAllSettingsData( const ImplAllSettingsData& rData ) : 1529 maMouseSettings( rData.maMouseSettings ), 1530 maKeyboardSettings( rData.maKeyboardSettings ), 1531 maStyleSettings( rData.maStyleSettings ), 1532 maMiscSettings( rData.maMiscSettings ), 1533 maNotificationSettings( rData.maNotificationSettings ), 1534 maHelpSettings( rData.maHelpSettings ), 1535 maLocale( rData.maLocale ) 1536 { 1537 mnRefCount = 1; 1538 mnSystemUpdate = rData.mnSystemUpdate; 1539 mnWindowUpdate = rData.mnWindowUpdate; 1540 meLanguage = rData.meLanguage; 1541 // Pointer couldn't shared and objects haven't a copy ctor 1542 // So we create the cache objects new, if the GetFunction is 1543 // called 1544 mpLocaleDataWrapper = NULL; 1545 mpUILocaleDataWrapper = NULL; 1546 mpCollatorWrapper = NULL; 1547 mpUICollatorWrapper = NULL; 1548 mpI18nHelper = NULL; 1549 mpUII18nHelper = NULL; 1550 } 1551 1552 // ----------------------------------------------------------------------- 1553 1554 ImplAllSettingsData::~ImplAllSettingsData() 1555 { 1556 if ( mpLocaleDataWrapper ) 1557 delete mpLocaleDataWrapper; 1558 if ( mpUILocaleDataWrapper ) 1559 delete mpUILocaleDataWrapper; 1560 if ( mpCollatorWrapper ) 1561 delete mpCollatorWrapper; 1562 if ( mpUICollatorWrapper ) 1563 delete mpUICollatorWrapper; 1564 if ( mpI18nHelper ) 1565 delete mpI18nHelper; 1566 if ( mpUII18nHelper ) 1567 delete mpUII18nHelper; 1568 } 1569 1570 // ----------------------------------------------------------------------- 1571 1572 AllSettings::AllSettings() 1573 { 1574 DBG_CTOR( AllSettings, NULL ); 1575 1576 mpData = new ImplAllSettingsData(); 1577 } 1578 1579 // ----------------------------------------------------------------------- 1580 1581 AllSettings::AllSettings( const AllSettings& rSet ) 1582 { 1583 DBG_CTOR( AllSettings, NULL ); 1584 DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "Settings: RefCount overflow" ); 1585 1586 // shared Instance Daten uebernehmen und Referenzcounter erhoehen 1587 mpData = rSet.mpData; 1588 mpData->mnRefCount++; 1589 } 1590 1591 // ----------------------------------------------------------------------- 1592 1593 AllSettings::~AllSettings() 1594 { 1595 DBG_DTOR( AllSettings, NULL ); 1596 1597 // Daten loeschen, wenn letzte Referenz 1598 if ( mpData->mnRefCount == 1 ) 1599 delete mpData; 1600 else 1601 mpData->mnRefCount--; 1602 } 1603 1604 // ----------------------------------------------------------------------- 1605 1606 const AllSettings& AllSettings::operator =( const AllSettings& rSet ) 1607 { 1608 DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "AllSettings: RefCount overflow" ); 1609 DBG_CHKTHIS( AllSettings, NULL ); 1610 DBG_CHKOBJ( &rSet, AllSettings, NULL ); 1611 1612 // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann 1613 rSet.mpData->mnRefCount++; 1614 1615 // Daten loeschen, wenn letzte Referenz 1616 if ( mpData->mnRefCount == 1 ) 1617 delete mpData; 1618 else 1619 mpData->mnRefCount--; 1620 1621 mpData = rSet.mpData; 1622 1623 return *this; 1624 } 1625 1626 // ----------------------------------------------------------------------- 1627 1628 void AllSettings::CopyData() 1629 { 1630 DBG_CHKTHIS( AllSettings, NULL ); 1631 1632 // Falls noch andere Referenzen bestehen, dann kopieren 1633 if ( mpData->mnRefCount != 1 ) 1634 { 1635 mpData->mnRefCount--; 1636 mpData = new ImplAllSettingsData( *mpData ); 1637 } 1638 } 1639 1640 // ----------------------------------------------------------------------- 1641 1642 sal_uLong AllSettings::Update( sal_uLong nFlags, const AllSettings& rSet ) 1643 { 1644 DBG_CHKTHIS( AllSettings, NULL ); 1645 DBG_CHKOBJ( &rSet, AllSettings, NULL ); 1646 1647 sal_uLong nChangeFlags = 0; 1648 1649 if ( nFlags & SETTINGS_MACHINE ) 1650 { 1651 if ( mpData->maMachineSettings != rSet.mpData->maMachineSettings ) 1652 { 1653 CopyData(); 1654 mpData->maMachineSettings = rSet.mpData->maMachineSettings; 1655 nChangeFlags |= SETTINGS_MACHINE; 1656 } 1657 } 1658 1659 if ( nFlags & SETTINGS_MOUSE ) 1660 { 1661 if ( mpData->maMouseSettings != rSet.mpData->maMouseSettings ) 1662 { 1663 CopyData(); 1664 mpData->maMouseSettings = rSet.mpData->maMouseSettings; 1665 nChangeFlags |= SETTINGS_MOUSE; 1666 } 1667 } 1668 1669 if ( nFlags & SETTINGS_KEYBOARD ) 1670 { 1671 if ( mpData->maKeyboardSettings != rSet.mpData->maKeyboardSettings ) 1672 { 1673 CopyData(); 1674 mpData->maKeyboardSettings = rSet.mpData->maKeyboardSettings; 1675 nChangeFlags |= SETTINGS_KEYBOARD; 1676 } 1677 } 1678 1679 if ( nFlags & SETTINGS_STYLE ) 1680 { 1681 if ( mpData->maStyleSettings != rSet.mpData->maStyleSettings ) 1682 { 1683 CopyData(); 1684 mpData->maStyleSettings = rSet.mpData->maStyleSettings; 1685 nChangeFlags |= SETTINGS_STYLE; 1686 } 1687 } 1688 1689 if ( nFlags & SETTINGS_MISC ) 1690 { 1691 if ( mpData->maMiscSettings != rSet.mpData->maMiscSettings ) 1692 { 1693 CopyData(); 1694 mpData->maMiscSettings = rSet.mpData->maMiscSettings; 1695 nChangeFlags |= SETTINGS_MISC; 1696 } 1697 } 1698 1699 if ( nFlags & SETTINGS_NOTIFICATION ) 1700 { 1701 if ( mpData->maNotificationSettings != rSet.mpData->maNotificationSettings ) 1702 { 1703 CopyData(); 1704 mpData->maNotificationSettings = rSet.mpData->maNotificationSettings; 1705 nChangeFlags |= SETTINGS_NOTIFICATION; 1706 } 1707 } 1708 1709 if ( nFlags & SETTINGS_HELP ) 1710 { 1711 if ( mpData->maHelpSettings != rSet.mpData->maHelpSettings ) 1712 { 1713 CopyData(); 1714 mpData->maHelpSettings = rSet.mpData->maHelpSettings; 1715 nChangeFlags |= SETTINGS_HELP; 1716 } 1717 } 1718 1719 if ( nFlags & SETTINGS_INTERNATIONAL ) 1720 { 1721 // Nothing, class International is gone. 1722 DBG_ERRORFILE("AllSettings::Update: who calls with SETTINGS_INTERNATIONAL and why? You're flogging a dead horse."); 1723 } 1724 1725 if ( nFlags & SETTINGS_LOCALE ) 1726 { 1727 if ( mpData->meLanguage || rSet.mpData->meLanguage ) 1728 { 1729 SetLanguage( rSet.mpData->meLanguage ); 1730 nChangeFlags |= SETTINGS_LOCALE; 1731 } 1732 } 1733 1734 if ( nFlags & SETTINGS_UILOCALE ) 1735 { 1736 // UILocale can't be changed 1737 } 1738 1739 return nChangeFlags; 1740 } 1741 1742 // ----------------------------------------------------------------------- 1743 1744 sal_uLong AllSettings::GetChangeFlags( const AllSettings& rSet ) const 1745 { 1746 DBG_CHKTHIS( AllSettings, NULL ); 1747 DBG_CHKOBJ( &rSet, AllSettings, NULL ); 1748 1749 sal_uLong nChangeFlags = 0; 1750 1751 if ( mpData->maMachineSettings != rSet.mpData->maMachineSettings ) 1752 nChangeFlags |= SETTINGS_MACHINE; 1753 1754 if ( mpData->maMouseSettings != rSet.mpData->maMouseSettings ) 1755 nChangeFlags |= SETTINGS_MOUSE; 1756 1757 if ( mpData->maKeyboardSettings != rSet.mpData->maKeyboardSettings ) 1758 nChangeFlags |= SETTINGS_KEYBOARD; 1759 1760 if ( mpData->maStyleSettings != rSet.mpData->maStyleSettings ) 1761 nChangeFlags |= SETTINGS_STYLE; 1762 1763 if ( mpData->maMiscSettings != rSet.mpData->maMiscSettings ) 1764 nChangeFlags |= SETTINGS_MISC; 1765 1766 if ( mpData->maNotificationSettings != rSet.mpData->maNotificationSettings ) 1767 nChangeFlags |= SETTINGS_NOTIFICATION; 1768 1769 if ( mpData->maHelpSettings != rSet.mpData->maHelpSettings ) 1770 nChangeFlags |= SETTINGS_HELP; 1771 1772 if ( mpData->meLanguage || rSet.mpData->meLanguage ) 1773 nChangeFlags |= SETTINGS_LOCALE; 1774 1775 return nChangeFlags; 1776 } 1777 1778 // ----------------------------------------------------------------------- 1779 1780 sal_Bool AllSettings::operator ==( const AllSettings& rSet ) const 1781 { 1782 DBG_CHKTHIS( AllSettings, NULL ); 1783 DBG_CHKOBJ( &rSet, AllSettings, NULL ); 1784 1785 if ( mpData == rSet.mpData ) 1786 return sal_True; 1787 1788 if ( (mpData->maMachineSettings == rSet.mpData->maMachineSettings) && 1789 (mpData->maMouseSettings == rSet.mpData->maMouseSettings) && 1790 (mpData->maKeyboardSettings == rSet.mpData->maKeyboardSettings) && 1791 (mpData->maStyleSettings == rSet.mpData->maStyleSettings) && 1792 (mpData->maMiscSettings == rSet.mpData->maMiscSettings) && 1793 (mpData->maNotificationSettings == rSet.mpData->maNotificationSettings) && 1794 (mpData->maHelpSettings == rSet.mpData->maHelpSettings) && 1795 (mpData->mnSystemUpdate == rSet.mpData->mnSystemUpdate) && 1796 (mpData->maLocale == rSet.mpData->maLocale) && 1797 (mpData->mnWindowUpdate == rSet.mpData->mnWindowUpdate) ) 1798 { 1799 return sal_True; 1800 } 1801 else 1802 return sal_False; 1803 } 1804 1805 // ----------------------------------------------------------------------- 1806 1807 void AllSettings::SetLocale( const ::com::sun::star::lang::Locale& rLocale ) 1808 { 1809 CopyData(); 1810 1811 mpData->maLocale = rLocale; 1812 1813 if ( !rLocale.Language.getLength() ) 1814 mpData->meLanguage = LANGUAGE_SYSTEM; 1815 else 1816 mpData->meLanguage = MsLangId::convertLocaleToLanguage( rLocale ); 1817 if ( mpData->mpLocaleDataWrapper ) 1818 { 1819 delete mpData->mpLocaleDataWrapper; 1820 mpData->mpLocaleDataWrapper = NULL; 1821 } 1822 if ( mpData->mpI18nHelper ) 1823 { 1824 delete mpData->mpI18nHelper; 1825 mpData->mpI18nHelper = NULL; 1826 } 1827 } 1828 1829 // ----------------------------------------------------------------------- 1830 1831 void AllSettings::SetUILocale( const ::com::sun::star::lang::Locale& ) 1832 { 1833 // there is only one UILocale per process 1834 } 1835 1836 // ----------------------------------------------------------------------- 1837 1838 void AllSettings::SetLanguage( LanguageType eLang ) 1839 { 1840 if ( eLang != mpData->meLanguage ) 1841 { 1842 CopyData(); 1843 1844 mpData->meLanguage = eLang; 1845 MsLangId::convertLanguageToLocale( GetLanguage(), ((AllSettings*)this)->mpData->maLocale ); 1846 if ( mpData->mpLocaleDataWrapper ) 1847 { 1848 delete mpData->mpLocaleDataWrapper; 1849 mpData->mpLocaleDataWrapper = NULL; 1850 } 1851 if ( mpData->mpI18nHelper ) 1852 { 1853 delete mpData->mpI18nHelper; 1854 mpData->mpI18nHelper = NULL; 1855 } 1856 } 1857 } 1858 1859 // ----------------------------------------------------------------------- 1860 1861 void AllSettings::SetUILanguage( LanguageType ) 1862 { 1863 // there is only one UILanguage per process 1864 } 1865 1866 // ----------------------------------------------------------------------- 1867 1868 sal_Bool AllSettings::GetLayoutRTL() const 1869 { 1870 static const char* pEnv = getenv("SAL_RTL_ENABLED" ); 1871 static int nUIMirroring = -1; // -1: undef, 0: auto, 1: on 2: off 1872 1873 // environment always overrides 1874 if( pEnv ) 1875 return true; 1876 1877 sal_Bool bRTL = sal_False; 1878 1879 if( nUIMirroring == -1 ) 1880 { 1881 nUIMirroring = 0; // ask configuration only once 1882 utl::OConfigurationNode aNode = utl::OConfigurationTreeRoot::tryCreateWithServiceFactory( 1883 vcl::unohelper::GetMultiServiceFactory(), 1884 OUString::createFromAscii( "org.openoffice.Office.Common/I18N/CTL" ) ); // note: case sensisitive ! 1885 if ( aNode.isValid() ) 1886 { 1887 sal_Bool bTmp = sal_Bool(); 1888 ::com::sun::star::uno::Any aValue = aNode.getNodeValue( OUString::createFromAscii( "UIMirroring" ) ); 1889 if( aValue >>= bTmp ) 1890 { 1891 // found true or false; if it was nil, nothing is changed 1892 nUIMirroring = bTmp ? 1 : 2; 1893 } 1894 } 1895 } 1896 1897 if( nUIMirroring == 0 ) // no config found (eg, setup) or default (nil) was set: check language 1898 { 1899 LanguageType aLang = LANGUAGE_DONTKNOW; 1900 ImplSVData* pSVData = ImplGetSVData(); 1901 if ( pSVData->maAppData.mpSettings ) 1902 aLang = pSVData->maAppData.mpSettings->GetUILanguage(); 1903 bRTL = MsLangId::isRightToLeft( aLang ); 1904 } 1905 else 1906 bRTL = (nUIMirroring == 1); 1907 1908 return bRTL; 1909 } 1910 1911 // ----------------------------------------------------------------------- 1912 1913 const ::com::sun::star::lang::Locale& AllSettings::GetLocale() const 1914 { 1915 if ( !mpData->maLocale.Language.getLength() ) 1916 mpData->maLocale = mpData->maSysLocale.GetLocale(); 1917 1918 return mpData->maLocale; 1919 } 1920 1921 // ----------------------------------------------------------------------- 1922 1923 const ::com::sun::star::lang::Locale& AllSettings::GetUILocale() const 1924 { 1925 // the UILocale is never changed 1926 if ( !mpData->maUILocale.Language.getLength() ) 1927 mpData->maUILocale = mpData->maSysLocale.GetUILocale(); 1928 1929 return mpData->maUILocale; 1930 } 1931 1932 // ----------------------------------------------------------------------- 1933 1934 LanguageType AllSettings::GetLanguage() const 1935 { 1936 // meLanguage == LANGUAGE_SYSTEM means: use settings from SvtSysLocale 1937 if ( mpData->meLanguage == LANGUAGE_SYSTEM ) 1938 return mpData->maSysLocale.GetLanguage(); 1939 1940 return mpData->meLanguage; 1941 } 1942 1943 // ----------------------------------------------------------------------- 1944 1945 LanguageType AllSettings::GetUILanguage() const 1946 { 1947 // the UILanguage is never changed 1948 return mpData->maSysLocale.GetUILanguage(); 1949 } 1950 1951 // ----------------------------------------------------------------------- 1952 1953 const LocaleDataWrapper& AllSettings::GetLocaleDataWrapper() const 1954 { 1955 if ( !mpData->mpLocaleDataWrapper ) 1956 ((AllSettings*)this)->mpData->mpLocaleDataWrapper = new LocaleDataWrapper( vcl::unohelper::GetMultiServiceFactory(), GetLocale() ); 1957 return *mpData->mpLocaleDataWrapper; 1958 } 1959 1960 // ----------------------------------------------------------------------- 1961 1962 const LocaleDataWrapper& AllSettings::GetUILocaleDataWrapper() const 1963 { 1964 if ( !mpData->mpUILocaleDataWrapper ) 1965 ((AllSettings*)this)->mpData->mpUILocaleDataWrapper = new LocaleDataWrapper( vcl::unohelper::GetMultiServiceFactory(), GetUILocale() ); 1966 return *mpData->mpUILocaleDataWrapper; 1967 } 1968 1969 // ----------------------------------------------------------------------- 1970 1971 const vcl::I18nHelper& AllSettings::GetLocaleI18nHelper() const 1972 { 1973 if ( !mpData->mpI18nHelper ) { 1974 ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> aFactory(vcl::unohelper::GetMultiServiceFactory()); 1975 ((AllSettings*)this)->mpData->mpI18nHelper = new vcl::I18nHelper( aFactory, GetLocale() ); 1976 } 1977 return *mpData->mpI18nHelper; 1978 } 1979 1980 // ----------------------------------------------------------------------- 1981 1982 const vcl::I18nHelper& AllSettings::GetUILocaleI18nHelper() const 1983 { 1984 if ( !mpData->mpUII18nHelper ) { 1985 ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> aFactory(vcl::unohelper::GetMultiServiceFactory()); 1986 ((AllSettings*)this)->mpData->mpUII18nHelper = new vcl::I18nHelper( aFactory, GetUILocale() ); 1987 } 1988 return *mpData->mpUII18nHelper; 1989 } 1990 1991 1992 // ----------------------------------------------------------------------- 1993 /* 1994 const CollatorWrapper& AllSettings::GetCollatorWrapper() const 1995 { 1996 if ( !mpData->mpCollatorWrapper ) 1997 { 1998 ((AllSettings*)this)->mpData->mpCollatorWrapper = new CollatorWrapper( vcl::unohelper::GetMultiServiceFactory() ); 1999 ((AllSettings*)this)->mpData->mpCollatorWrapper->loadDefaultCollator( GetLocale(), 0 ); 2000 } 2001 return *mpData->mpCollatorWrapper; 2002 } 2003 */ 2004 // ----------------------------------------------------------------------- 2005 /* 2006 const CollatorWrapper& AllSettings::GetUICollatorWrapper() const 2007 { 2008 if ( !mpData->mpUICollatorWrapper ) 2009 { 2010 ((AllSettings*)this)->mpData->mpUICollatorWrapper = new CollatorWrapper( vcl::unohelper::GetMultiServiceFactory() ); 2011 ((AllSettings*)this)->mpData->mpUICollatorWrapper->loadDefaultCollator( GetUILocale(), 0 ); 2012 } 2013 return *mpData->mpUICollatorWrapper; 2014 } 2015 */ 2016 2017 void AllSettings::LocaleSettingsChanged( sal_uInt32 nHint ) 2018 { 2019 AllSettings aAllSettings( Application::GetSettings() ); 2020 if ( nHint & SYSLOCALEOPTIONS_HINT_DECSEP ) 2021 { 2022 MiscSettings aMiscSettings = aAllSettings.GetMiscSettings(); 2023 sal_Bool bIsDecSepAsLocale = aAllSettings.mpData->maSysLocale.GetOptions().IsDecimalSeparatorAsLocale(); 2024 if ( aMiscSettings.GetEnableLocalizedDecimalSep() != bIsDecSepAsLocale ) 2025 { 2026 aMiscSettings.SetEnableLocalizedDecimalSep( bIsDecSepAsLocale ); 2027 aAllSettings.SetMiscSettings( aMiscSettings ); 2028 } 2029 } 2030 2031 if ( (nHint & SYSLOCALEOPTIONS_HINT_LOCALE) ) 2032 aAllSettings.SetLocale( aAllSettings.mpData->maSysLocale.GetOptions().GetLocale() ); 2033 2034 Application::SetSettings( aAllSettings ); 2035 } 2036