curl: upgrade to 8.11.1
[LibreOffice.git] / unotools / source / config / docinfohelper.cxx
blob2d106002b8d5155d27b51395462a65c6484d34cb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <rtl/ustrbuf.hxx>
21 #include <unotools/configmgr.hxx>
22 #include <unotools/bootstrap.hxx>
23 #include <unotools/docinfohelper.hxx>
24 #include <rtl/bootstrap.hxx>
25 #include <officecfg/Office/Common.hxx>
27 using namespace ::com::sun::star;
29 namespace utl
32 OUString DocInfoHelper::GetGeneratorString()
34 static const OUString sGenerator = []()
36 OUString aResultOverride = officecfg::Office::Common::Save::Document::GeneratorOverride::get();
37 if( !aResultOverride.isEmpty())
38 return aResultOverride;
40 OUStringBuffer aResult(128);
42 // First product: branded name + version
43 // version is <product_versions>_<product_extension>$<platform>
45 // plain product name
46 OUString aValue( utl::ConfigManager::getProductName() );
47 if ( !aValue.isEmpty() )
49 aResult.append( aValue.replace( ' ', '_' ) + "/" );
51 aValue = utl::ConfigManager::getProductVersion();
52 if ( !aValue.isEmpty() )
54 aResult.append( aValue.replace( ' ', '_' ) );
56 aValue = utl::ConfigManager::getProductExtension();
57 if ( !aValue.isEmpty() )
59 aResult.append( aValue.replace( ' ', '_' ) );
63 OUString os( u"$_OS"_ustr );
64 OUString arch( u"$_ARCH"_ustr );
65 ::rtl::Bootstrap::expandMacros(os);
66 ::rtl::Bootstrap::expandMacros(arch);
67 aResult.append( "$" + os + "_" + arch + " " );
70 // second product: LibreOffice_project/<build_information>
71 // build_information has '(' and '[' encoded as '$', ')' and ']' ignored
72 // and ':' replaced by '-'
74 aResult.append( "LibreOffice_project/" );
75 OUString aBuildId( Bootstrap::getBuildIdData( OUString() ) );
76 for( sal_Int32 i=0; i < aBuildId.getLength(); i++ )
78 sal_Unicode c = aBuildId[i];
79 switch( c )
81 case '(':
82 case '[':
83 aResult.append( '$' );
84 break;
85 case ')':
86 case ']':
87 break;
88 case ':':
89 aResult.append( '-' );
90 break;
91 default:
92 aResult.append( c );
93 break;
98 return aResult.makeStringAndClear();
99 }();
100 return sGenerator;
103 } // end of namespace utl
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */