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