1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_unotools.hxx" 30 31 #include <rtl/ustrbuf.hxx> 32 #include <tools/inetdef.hxx> 33 #include <unotools/configmgr.hxx> 34 #include <unotools/bootstrap.hxx> 35 #include <unotools/docinfohelper.hxx> 36 37 using namespace ::com::sun::star; 38 39 namespace utl 40 { 41 42 ::rtl::OUString DocInfoHelper::GetGeneratorString() 43 { 44 rtl::OUStringBuffer aResult; 45 46 // First product: branded name + version 47 // version is <product_versions>_<product_extension>$<platform> 48 utl::ConfigManager* pMgr = utl::ConfigManager::GetConfigManager(); 49 if ( pMgr ) 50 { 51 // plain product name 52 rtl::OUString aValue; 53 uno::Any aAny = pMgr->GetDirectConfigProperty( 54 utl::ConfigManager::PRODUCTNAME); 55 if ( (aAny >>= aValue) && aValue.getLength() ) 56 { 57 aResult.append( aValue.replace( ' ', '_' ) ); 58 aResult.append( (sal_Unicode)'/' ); 59 60 aAny = pMgr->GetDirectConfigProperty( 61 utl::ConfigManager::PRODUCTVERSION); 62 if ( (aAny >>= aValue) && aValue.getLength() ) 63 { 64 aResult.append( aValue.replace( ' ', '_' ) ); 65 66 aAny = pMgr->GetDirectConfigProperty( 67 utl::ConfigManager::PRODUCTEXTENSION); 68 if ( (aAny >>= aValue) && aValue.getLength() ) 69 { 70 aResult.append( (sal_Unicode)'_' ); 71 aResult.append( aValue.replace( ' ', '_' ) ); 72 } 73 } 74 75 aResult.append( (sal_Unicode)'$' ); 76 aResult.append( ::rtl::OUString::createFromAscii( 77 TOOLS_INETDEF_OS ).replace( ' ', '_' ) ); 78 79 aResult.append( (sal_Unicode)' ' ); 80 } 81 } 82 83 // second product: OpenOffice.org_project/<build_information> 84 // build_information has '(' and '[' encoded as '$', ')' and ']' ignored 85 // and ':' replaced by '-' 86 { 87 aResult.appendAscii( "OpenOffice.org_project/" ); 88 ::rtl::OUString aDefault; 89 ::rtl::OUString aBuildId( Bootstrap::getBuildIdData( aDefault ) ); 90 for( sal_Int32 i=0; i < aBuildId.getLength(); i++ ) 91 { 92 sal_Unicode c = aBuildId[i]; 93 switch( c ) 94 { 95 case '(': 96 case '[': 97 aResult.append( (sal_Unicode)'$' ); 98 break; 99 case ')': 100 case ']': 101 break; 102 case ':': 103 aResult.append( (sal_Unicode)'-' ); 104 break; 105 default: 106 aResult.append( c ); 107 break; 108 } 109 } 110 } 111 112 return aResult.makeStringAndClear(); 113 } 114 115 } // end of namespace utl 116 117