1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "precompiled_shell.hxx" 29 #include "sal/config.h" 30 31 #include <string.h> 32 33 #include "com/sun/star/uno/RuntimeException.hpp" 34 #include "osl/file.hxx" 35 #include "osl/security.hxx" 36 #include "osl/thread.h" 37 #include "rtl/strbuf.hxx" 38 #include "rtl/ustrbuf.hxx" 39 40 #include "gconfaccess.hxx" 41 42 #define GCONF_PROXY_MODE_KEY "/system/proxy/mode" 43 #define GCONF_AUTO_SAVE_KEY "/apps/openoffice/auto_save" 44 45 namespace gconfaccess { 46 47 namespace { 48 49 namespace css = com::sun::star ; 50 namespace uno = css::uno ; 51 using namespace rtl; 52 53 GConfClient* getGconfClient() 54 { 55 static GConfClient* mClient= 0; 56 if (mClient == NULL) 57 { 58 /* initialize glib object type library */ 59 g_type_init(); 60 61 GError* aError = NULL; 62 if (!gconf_init(0, NULL, &aError)) 63 { 64 rtl::OUStringBuffer msg; 65 msg.appendAscii("GconfBackend:GconfLayer: Cannot Initialize Gconf connection - " ); 66 msg.appendAscii(aError->message); 67 68 g_error_free(aError); 69 aError = NULL; 70 throw uno::RuntimeException(msg.makeStringAndClear(),NULL); 71 } 72 73 mClient = gconf_client_get_default(); 74 if (!mClient) 75 { 76 throw uno::RuntimeException(rtl::OUString::createFromAscii 77 ("GconfBackend:GconfLayer: Cannot Initialize Gconf connection"),NULL); 78 } 79 80 static const char * const PreloadValuesList[] = 81 { 82 "/desktop/gnome/interface", 83 "/system/proxy", 84 "/system/http_proxy/host", 85 "/desktop/gnome/url-handlers/mailto", 86 #ifdef ENABLE_LOCKDOWN 87 "/apps/openoffice", 88 "/desktop/gnome/lockdown", 89 "/apps/openoffice/lockdown", 90 #endif // ENABLE_LOCKDOWN 91 NULL 92 }; 93 int i = 0; 94 while( PreloadValuesList[i] != NULL ) 95 gconf_client_preload( mClient, PreloadValuesList[i++], GCONF_CLIENT_PRELOAD_ONELEVEL, NULL ); 96 } 97 98 return mClient; 99 } 100 101 static OUString xdg_user_dir_lookup (const char *type) 102 { 103 char *config_home; 104 char *p; 105 int relative; 106 bool bError = false; 107 108 osl::Security aSecurity; 109 oslFileHandle handle; 110 OUString aHomeDirURL; 111 OUString aDocumentsDirURL; 112 OUString aConfigFileURL; 113 OUStringBuffer aUserDirBuf; 114 115 if (!aSecurity.getHomeDir( aHomeDirURL ) ) 116 { 117 osl::FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii("/tmp"), aDocumentsDirURL); 118 return aDocumentsDirURL; 119 } 120 121 config_home = getenv ("XDG_CONFIG_HOME"); 122 if (config_home == NULL || config_home[0] == 0) 123 { 124 aConfigFileURL = OUString(aHomeDirURL); 125 aConfigFileURL += OUString::createFromAscii( "/.config/user-dirs.dirs" ); 126 } 127 else 128 { 129 aConfigFileURL = OUString::createFromAscii(config_home); 130 aConfigFileURL += OUString::createFromAscii( "/user-dirs.dirs" ); 131 } 132 133 if(osl_File_E_None == osl_openFile(aConfigFileURL.pData, &handle, osl_File_OpenFlag_Read)) 134 { 135 rtl::ByteSequence seq; 136 while (osl_File_E_None == osl_readLine(handle , (sal_Sequence **)&seq)) 137 { 138 /* Remove newline at end */ 139 int len = seq.getLength(); 140 if(len>0 && seq[len-1] == '\n') 141 seq[len-1] = 0; 142 143 p = (char *)seq.getArray(); 144 145 while (*p == ' ' || *p == '\t') 146 p++; 147 148 if (strncmp (p, "XDG_", 4) != 0) 149 continue; 150 p += 4; 151 if (strncmp (p, type, strlen (type)) != 0) 152 continue; 153 p += strlen (type); 154 if (strncmp (p, "_DIR", 4) != 0) 155 continue; 156 p += 4; 157 158 while (*p == ' ' || *p == '\t') 159 p++; 160 161 if (*p != '=') 162 continue; 163 p++; 164 165 while (*p == ' ' || *p == '\t') 166 p++; 167 168 if (*p != '"') 169 continue; 170 p++; 171 172 relative = 0; 173 if (strncmp (p, "$HOME/", 6) == 0) 174 { 175 p += 6; 176 relative = 1; 177 } 178 else if (*p != '/') 179 continue; 180 181 if (relative) 182 { 183 aUserDirBuf = OUStringBuffer(aHomeDirURL); 184 aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/" ) ); 185 } 186 else 187 { 188 aUserDirBuf = OUStringBuffer(); 189 } 190 191 while (*p && *p != '"') 192 { 193 if ((*p == '\\') && (*(p+1) != 0)) 194 p++; 195 aUserDirBuf.append((sal_Unicode)*p++); 196 } 197 } 198 osl_closeFile(handle); 199 } 200 else 201 bError = true; 202 203 if (aUserDirBuf.getLength()>0 && !bError) 204 { 205 aDocumentsDirURL = aUserDirBuf.makeStringAndClear(); 206 osl::Directory aDocumentsDir( aDocumentsDirURL ); 207 if( osl::FileBase::E_None == aDocumentsDir.open() ) 208 return aDocumentsDirURL; 209 } 210 211 /* Special case desktop for historical compatibility */ 212 if (strcmp (type, "DESKTOP") == 0) 213 { 214 aUserDirBuf = OUStringBuffer(aHomeDirURL); 215 aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Desktop" ) ); 216 return aUserDirBuf.makeStringAndClear(); 217 } 218 else 219 { 220 aUserDirBuf = OUStringBuffer(aHomeDirURL); 221 aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Documents" ) ); 222 return aUserDirBuf.makeStringAndClear(); 223 } 224 } 225 226 //------------------------------------------------------------------------------ 227 228 uno::Any makeAnyOfGconfValue( GConfValue *aGconfValue ) 229 { 230 switch( aGconfValue->type ) 231 { 232 case GCONF_VALUE_BOOL: 233 return uno::makeAny( (sal_Bool) gconf_value_get_bool( aGconfValue ) ); 234 235 case GCONF_VALUE_INT: 236 return uno::makeAny( (sal_Int32) gconf_value_get_int( aGconfValue ) ); 237 238 case GCONF_VALUE_STRING: 239 return uno::makeAny( OStringToOUString( rtl::OString( 240 gconf_value_get_string(aGconfValue) ), RTL_TEXTENCODING_UTF8 ) ); 241 242 default: 243 fprintf( stderr, "makeAnyOfGconfValue: Type not handled.\n" ); 244 break; 245 } 246 247 return uno::Any(); 248 } 249 250 //------------------------------------------------------------------------------ 251 252 static void splitFontName( GConfValue *aGconfValue, rtl::OUString &rName, sal_Int16 &rHeight) 253 { 254 rtl::OString aFont( gconf_value_get_string( aGconfValue ) ); 255 aFont.trim(); 256 sal_Int32 nIdx = aFont.lastIndexOf( ' ' ); 257 if (nIdx < 1) { // urk 258 rHeight = 12; 259 nIdx = aFont.getLength(); 260 } else { 261 rtl::OString aSize = aFont.copy( nIdx + 1 ); 262 rHeight = static_cast<sal_Int16>( aSize.toInt32() ); 263 } 264 265 rName = rtl::OStringToOUString( aFont.copy( 0, nIdx ), RTL_TEXTENCODING_UTF8 ); 266 } 267 268 //------------------------------------------------------------------------------ 269 270 uno::Any translateToOOo( const ConfigurationValue aValue, GConfValue *aGconfValue ) 271 { 272 273 switch( aValue.nSettingId ) 274 { 275 case SETTING_PROXY_MODE: 276 { 277 rtl::OUString aProxyMode; 278 uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue ); 279 aOriginalValue >>= aProxyMode; 280 281 if( aProxyMode.equals( rtl::OUString::createFromAscii( "manual" ) ) ) 282 return uno::makeAny( (sal_Int32) 1 ); 283 else if( aProxyMode.equals( rtl::OUString::createFromAscii( "none" ) ) ) 284 return uno::makeAny( (sal_Int32) 0 ); 285 } 286 break; 287 288 case SETTING_NO_PROXY_FOR: 289 { 290 rtl::OStringBuffer aBuffer; 291 if( (GCONF_VALUE_LIST == aGconfValue->type) && (GCONF_VALUE_STRING == gconf_value_get_list_type(aGconfValue)) ) 292 { 293 GSList * list = gconf_value_get_list(aGconfValue); 294 for(; list; list = g_slist_next(list)) 295 { 296 aBuffer.append(gconf_value_get_string((GConfValue *) list->data)); 297 aBuffer.append(";"); 298 } 299 // Remove trailing ";" 300 aBuffer.setLength(aBuffer.getLength()-1); 301 return uno::makeAny(rtl::OStringToOUString(aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); 302 } 303 else 304 g_warning( "unexpected type for ignore_hosts" ); 305 } 306 break; 307 308 case SETTING_MAILER_PROGRAM: 309 { 310 rtl::OUString aMailer; 311 uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue ); 312 aOriginalValue >>= aMailer; 313 sal_Int32 nIndex = 0; 314 return uno::makeAny( aMailer.getToken( 0, ' ', nIndex ) ); 315 } 316 317 #ifdef ENABLE_LOCKDOWN 318 // "short" values need to be returned a sal_Int16 319 case SETTING_FONT_ANTI_ALIASING_MIN_PIXEL: 320 case SETTING_SYMBOL_SET: 321 { 322 sal_Int32 nShortValue; 323 uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue ); 324 aOriginalValue >>= nShortValue; 325 return uno::makeAny( (sal_Int16) nShortValue ); 326 } 327 break; 328 #endif // ENABLE_LOCKDOWN 329 330 // "boolean" values that need a string to be returned 331 case SETTING_ENABLE_ACCESSIBILITY: 332 #ifdef ENABLE_LOCKDOWN 333 case SETTING_DISABLE_PRINTING: 334 #endif // ENABLE_LOCKDOWN 335 { 336 sal_Bool bBooleanValue = false; 337 uno::Any aOriginalValue = makeAnyOfGconfValue( aGconfValue ); 338 aOriginalValue >>= bBooleanValue; 339 return uno::makeAny( rtl::OUString::valueOf( (sal_Bool) bBooleanValue ) ); 340 } 341 342 case SETTING_WORK_DIRECTORY: 343 { 344 rtl::OUString aDocumentsDirURL = xdg_user_dir_lookup("DOCUMENTS"); 345 346 return uno::makeAny( aDocumentsDirURL ); 347 } 348 349 case SETTING_USER_GIVENNAME: 350 { 351 rtl::OUString aCompleteName( rtl::OStringToOUString( 352 g_get_real_name(), osl_getThreadTextEncoding() ) ); 353 sal_Int32 nIndex = 0; 354 rtl::OUString aGivenName; 355 do 356 aGivenName = aCompleteName.getToken( 0, ' ', nIndex ); 357 while ( nIndex == 0 ); 358 359 return uno::makeAny( aGivenName ); 360 361 } 362 363 case SETTING_USER_SURNAME: 364 { 365 rtl::OUString aCompleteName( rtl::OStringToOUString( 366 g_get_real_name(), osl_getThreadTextEncoding() ) ); 367 sal_Int32 nIndex = 0; 368 rtl::OUString aSurname; 369 do 370 aSurname = aCompleteName.getToken( 0, ' ', nIndex ); 371 while ( nIndex >= 0 ); 372 373 return uno::makeAny( aSurname ); 374 } 375 376 case SETTING_SOURCEVIEWFONT_NAME: 377 case SETTING_SOURCEVIEWFONT_HEIGHT: 378 { 379 rtl::OUString aName; 380 sal_Int16 nHeight; 381 382 splitFontName (aGconfValue, aName, nHeight); 383 if (aValue.nSettingId == SETTING_SOURCEVIEWFONT_NAME) 384 return uno::makeAny( aName ); 385 else 386 return uno::makeAny( nHeight ); 387 } 388 389 390 default: 391 fprintf( stderr, "Unhandled setting to translate.\n" ); 392 break; 393 } 394 395 return uno::Any(); 396 } 397 398 //------------------------------------------------------------------------------ 399 400 sal_Bool SAL_CALL isDependencySatisfied( GConfClient* aClient, const ConfigurationValue aValue ) 401 { 402 switch( aValue.nDependsOn ) 403 { 404 case SETTING_PROXY_MODE: 405 { 406 GConfValue* aGconfValue = gconf_client_get( aClient, GCONF_PROXY_MODE_KEY, NULL ); 407 408 if ( aGconfValue != NULL ) 409 { 410 bool bOk = g_strcasecmp( "manual", gconf_value_get_string( aGconfValue ) ) == 0; 411 gconf_value_free( aGconfValue ); 412 if (bOk) return sal_True; 413 } 414 } 415 break; 416 417 case SETTING_WORK_DIRECTORY: 418 { 419 rtl::OUString aDocumentsDirURL = xdg_user_dir_lookup("DOCUMENTS"); 420 osl::Directory aDocumentsDir( aDocumentsDirURL ); 421 422 if( osl::FileBase::E_None == aDocumentsDir.open() ) 423 return sal_True; 424 } 425 break; 426 427 case SETTING_USER_GIVENNAME: 428 { 429 rtl::OUString aCompleteName( rtl::OStringToOUString( 430 g_get_real_name(), osl_getThreadTextEncoding() ) ); 431 if( !aCompleteName.equalsAscii( "Unknown" ) ) 432 return sal_True; 433 } 434 break; 435 436 case SETTING_USER_SURNAME: 437 { 438 rtl::OUString aCompleteName( rtl::OStringToOUString( 439 g_get_real_name(), osl_getThreadTextEncoding() ) ); 440 if( !aCompleteName.equalsAscii( "Unknown" ) ) 441 { 442 if( aCompleteName.trim().indexOf(rtl::OUString::createFromAscii(" "), 0) != -1 ) 443 return sal_True; 444 } 445 } 446 break; 447 448 #ifdef ENABLE_LOCKDOWN 449 case SETTING_AUTO_SAVE: 450 { 451 GConfValue* aGconfValue = gconf_client_get( aClient, GCONF_AUTO_SAVE_KEY, NULL ); 452 453 if( ( aGconfValue != NULL ) ) 454 { 455 bool bOk = gconf_value_get_bool( aGconfValue ); 456 gconf_value_free( aGconfValue ); 457 if (bOk) return sal_True; 458 } 459 } 460 break; 461 #endif // ENABLE_LOCKDOWN 462 463 default: 464 fprintf( stderr, "Unhandled setting to check dependency.\n" ); 465 break; 466 } 467 468 return sal_False; 469 } 470 471 } 472 473 ConfigurationValue const ConfigurationValues[] = 474 { 475 { 476 SETTING_ENABLE_ACCESSIBILITY, 477 "/desktop/gnome/interface/accessibility", 478 "EnableATToolSupport", 479 sal_True, 480 SETTINGS_LAST 481 }, 482 483 { 484 SETTING_PROXY_MODE, 485 GCONF_PROXY_MODE_KEY, 486 "ooInetProxyType", 487 sal_True, 488 SETTINGS_LAST 489 }, 490 491 { 492 SETTING_PROXY_HTTP_HOST, 493 "/system/http_proxy/host", 494 "ooInetHTTPProxyName", 495 sal_False, 496 SETTING_PROXY_MODE 497 }, 498 499 { 500 SETTING_PROXY_HTTP_PORT, 501 "/system/http_proxy/port", 502 "ooInetHTTPProxyPort", 503 sal_False, 504 SETTING_PROXY_MODE 505 }, 506 507 { 508 SETTING_PROXY_HTTPS_HOST, 509 "/system/proxy/secure_host", 510 "ooInetHTTPSProxyName", 511 sal_False, 512 SETTING_PROXY_MODE 513 }, 514 515 { 516 SETTING_PROXY_HTTPS_PORT, 517 "/system/proxy/secure_port", 518 "ooInetHTTPSProxyPort", 519 sal_False, 520 SETTING_PROXY_MODE 521 }, 522 523 { 524 SETTING_PROXY_FTP_HOST, 525 "/system/proxy/ftp_host", 526 "ooInetFTPProxyName", 527 sal_False, 528 SETTING_PROXY_MODE 529 }, 530 531 { 532 SETTING_PROXY_FTP_PORT, 533 "/system/proxy/ftp_port", 534 "ooInetFTPProxyPort", 535 sal_False, 536 SETTING_PROXY_MODE 537 }, 538 539 { 540 SETTING_NO_PROXY_FOR, 541 "/system/http_proxy/ignore_hosts", 542 "ooInetNoProxy", 543 sal_True, 544 SETTING_PROXY_MODE 545 }, 546 547 { 548 SETTING_MAILER_PROGRAM, 549 "/desktop/gnome/url-handlers/mailto/command", 550 "ExternalMailer", 551 sal_True, 552 SETTINGS_LAST 553 }, 554 { 555 SETTING_SOURCEVIEWFONT_NAME, 556 "/desktop/gnome/interface/monospace_font_name", 557 "SourceViewFontName", 558 sal_True, 559 SETTINGS_LAST 560 }, 561 { 562 SETTING_SOURCEVIEWFONT_HEIGHT, 563 "/desktop/gnome/interface/monospace_font_name", 564 "SourceViewFontHeight", 565 sal_True, 566 SETTINGS_LAST 567 }, 568 569 { 570 SETTING_WORK_DIRECTORY, 571 "/desktop/gnome/url-handlers/mailto/command", // dummy 572 "WorkPathVariable", 573 sal_True, 574 SETTING_WORK_DIRECTORY, // so that the existence of the dir can be checked 575 }, 576 577 #ifdef ENABLE_LOCKDOWN 578 { 579 SETTING_WRITER_DEFAULT_DOC_FORMAT, 580 "/apps/openoffice/writer_default_document_format", 581 "TextDocumentSetupFactoryDefaultFilter", 582 sal_False, 583 SETTINGS_LAST 584 }, 585 586 { 587 SETTING_IMPRESS_DEFAULT_DOC_FORMAT, 588 "/apps/openoffice/impress_default_document_format", 589 "PresentationDocumentSetupFactoryDefaultFilter", 590 sal_False, 591 SETTINGS_LAST 592 }, 593 594 { 595 SETTING_CALC_DEFAULT_DOC_FORMAT, 596 "/apps/openoffice/calc_default_document_format", 597 "SpreadsheetDocumentSetupFactoryDefaultFilter", 598 sal_False, 599 SETTINGS_LAST 600 }, 601 602 { 603 SETTING_AUTO_SAVE, 604 GCONF_AUTO_SAVE_KEY, 605 "AutoSaveEnabled", 606 sal_False, 607 SETTINGS_LAST 608 }, 609 610 { 611 SETTING_AUTO_SAVE_INTERVAL, 612 "/apps/openoffice/auto_save_interval", 613 "AutoSaveTimeIntervall", 614 sal_False, 615 SETTING_AUTO_SAVE 616 }, 617 618 { 619 SETTING_USER_GIVENNAME, 620 "/desktop/gnome/url-handlers/mailto/command", // dummy 621 "givenname", 622 sal_True, 623 SETTING_USER_GIVENNAME 624 }, 625 626 { 627 SETTING_USER_SURNAME, 628 "/desktop/gnome/url-handlers/mailto/command", // dummy 629 "sn", 630 sal_True, 631 SETTING_USER_SURNAME 632 }, 633 634 { 635 SETTING_DISABLE_PRINTING, 636 "/desktop/gnome/lockdown/disable_printing", 637 "DisablePrinting", 638 sal_True, 639 SETTINGS_LAST 640 }, 641 642 { 643 SETTING_USE_SYSTEM_FILE_DIALOG, 644 "/apps/openoffice/use_system_file_dialog", 645 "UseSystemFileDialog", 646 sal_False, 647 SETTINGS_LAST 648 }, 649 650 { 651 SETTING_PRINTING_MODIFIES_DOCUMENT, 652 "/apps/openoffice/printing_modifies_doc", 653 "PrintingModifiesDocument", 654 sal_False, 655 SETTINGS_LAST 656 }, 657 658 { 659 SETTING_SHOW_ICONS_IN_MENUS, 660 "/apps/openoffice/show_menu_icons", 661 "ShowIconsInMenues", 662 sal_False, 663 SETTINGS_LAST 664 }, 665 666 { 667 SETTING_SHOW_INACTIVE_MENUITEMS, 668 "/apps/openoffice/show_menu_inactive_items", 669 "DontHideDisabledEntry", 670 sal_False, 671 SETTINGS_LAST 672 }, 673 674 { 675 SETTING_SHOW_FONT_PREVIEW, 676 "/apps/openoffice/show_font_preview", 677 "ShowFontBoxWYSIWYG", 678 sal_False, 679 SETTINGS_LAST 680 }, 681 682 { 683 SETTING_SHOW_FONT_HISTORY, 684 "/apps/openoffice/show_font_history", 685 "FontViewHistory", 686 sal_False, 687 SETTINGS_LAST 688 }, 689 690 { 691 SETTING_ENABLE_OPENGL, 692 "/apps/openoffice/use_opengl", 693 "OpenGL", 694 sal_False, 695 SETTINGS_LAST 696 }, 697 698 { 699 SETTING_OPTIMIZE_OPENGL, 700 "/apps/openoffice/optimize_opengl", 701 "OpenGL_Faster", 702 sal_False, 703 SETTINGS_LAST 704 }, 705 706 { 707 SETTING_USE_SYSTEM_FONT, 708 "/apps/openoffice/use_system_font", 709 "AccessibilityIsSystemFont", 710 sal_False, 711 SETTINGS_LAST 712 }, 713 714 { 715 SETTING_USE_FONT_ANTI_ALIASING, 716 "/apps/openoffice/use_font_anti_aliasing", 717 "FontAntiAliasingEnabled", 718 sal_False, 719 SETTINGS_LAST 720 }, 721 722 { 723 SETTING_FONT_ANTI_ALIASING_MIN_PIXEL, 724 "/apps/openoffice/font_anti_aliasing_min_pixel", 725 "FontAntiAliasingMinPixelHeight", 726 sal_True, 727 SETTINGS_LAST 728 }, 729 730 { 731 SETTING_WARN_CREATE_PDF, 732 "/apps/openoffice/lockdown/warn_info_create_pdf", 733 "WarnCreatePDF", 734 sal_False, 735 SETTINGS_LAST 736 }, 737 738 { 739 SETTING_WARN_PRINT_DOC, 740 "/apps/openoffice/lockdown/warn_info_printing", 741 "WarnPrintDoc", 742 sal_False, 743 SETTINGS_LAST 744 }, 745 746 { 747 SETTING_WARN_SAVEORSEND_DOC, 748 "/apps/openoffice/lockdown/warn_info_saving", 749 "WarnSaveOrSendDoc", 750 sal_False, 751 SETTINGS_LAST 752 }, 753 754 { 755 SETTING_WARN_SIGN_DOC, 756 "/apps/openoffice/lockdown/warn_info_signing", 757 "WarnSignDoc", 758 sal_False, 759 SETTINGS_LAST 760 }, 761 762 { 763 SETTING_REMOVE_PERSONAL_INFO, 764 "/apps/openoffice/lockdown/remove_personal_info_on_save", 765 "Scripting/RemovePersonalInfoOnSaving", 766 sal_False, 767 SETTINGS_LAST 768 }, 769 770 { 771 SETTING_RECOMMEND_PASSWORD, 772 "/apps/openoffice/lockdown/recommend_password_on_save", 773 "RecommendPasswordProtection", 774 sal_False, 775 SETTINGS_LAST 776 }, 777 778 { 779 SETTING_UNDO_STEPS, 780 "/apps/openoffice/undo_steps", 781 "UndoSteps", 782 sal_False, 783 SETTINGS_LAST 784 }, 785 786 { 787 SETTING_SYMBOL_SET, 788 "/apps/openoffice/icon_size", 789 "SymbolSet", 790 sal_True, 791 SETTINGS_LAST 792 }, 793 794 { 795 SETTING_MACRO_SECURITY_LEVEL, 796 "/apps/openoffice/lockdown/macro_security_level", 797 "MacroSecurityLevel", 798 sal_False, 799 SETTINGS_LAST 800 }, 801 802 { 803 SETTING_CREATE_BACKUP, 804 "/apps/openoffice/create_backup", 805 "CreateBackup", 806 sal_False, 807 SETTINGS_LAST 808 }, 809 810 { 811 SETTING_WARN_ALIEN_FORMAT, 812 "/apps/openoffice/warn_alien_format", 813 "WarnAlienFormat", 814 sal_False, 815 SETTINGS_LAST 816 }, 817 818 #endif // ENABLE_LOCKDOWN 819 }; 820 821 std::size_t const nConfigurationValues = 822 sizeof ConfigurationValues / sizeof ConfigurationValues[0]; 823 824 css::beans::Optional< css::uno::Any > getValue(ConfigurationValue const & data) 825 { 826 GConfClient* aClient = getGconfClient(); 827 GConfValue* aGconfValue; 828 if( ( data.nDependsOn == SETTINGS_LAST ) || isDependencySatisfied( aClient, data ) ) 829 { 830 aGconfValue = gconf_client_get( aClient, data.GconfItem, NULL ); 831 832 if( aGconfValue != NULL ) 833 { 834 css::uno::Any value; 835 if( data.bNeedsTranslation ) 836 value = translateToOOo( data, aGconfValue ); 837 else 838 value = makeAnyOfGconfValue( aGconfValue ); 839 840 gconf_value_free( aGconfValue ); 841 842 return css::beans::Optional< css::uno::Any >(true, value); 843 } 844 } 845 return css::beans::Optional< css::uno::Any >(); 846 } 847 848 } 849