LibreOffice Module unotools (master) 1
docinfohelper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <rtl/ustrbuf.hxx>
24#include <rtl/bootstrap.hxx>
25#include <officecfg/Office/Common.hxx>
26
27using namespace ::com::sun::star;
28
29namespace utl
30{
31
33{
34 static const OUString sGenerator = []()
35 {
37 if( !aResultOverride.isEmpty())
38 return aResultOverride;
39
40 OUStringBuffer aResult(128);
41
42 // First product: branded name + version
43 // version is <product_versions>_<product_extension>$<platform>
44
45 // plain product name
46 OUString aValue( utl::ConfigManager::getProductName() );
47 if ( !aValue.isEmpty() )
48 {
49 aResult.append( aValue.replace( ' ', '_' ) + "/" );
50
52 if ( !aValue.isEmpty() )
53 {
54 aResult.append( aValue.replace( ' ', '_' ) );
55
57 if ( !aValue.isEmpty() )
58 {
59 aResult.append( aValue.replace( ' ', '_' ) );
60 }
61 }
62
63 OUString os( "$_OS" );
64 OUString arch( "$_ARCH" );
65 ::rtl::Bootstrap::expandMacros(os);
66 ::rtl::Bootstrap::expandMacros(arch);
67 aResult.append( "$" + os + "_" + arch + " " );
68 }
69
70 // second product: LibreOffice_project/<build_information>
71 // build_information has '(' and '[' encoded as '$', ')' and ']' ignored
72 // and ':' replaced by '-'
73 {
74 aResult.append( "LibreOffice_project/" );
75 OUString aBuildId( Bootstrap::getBuildIdData( OUString() ) );
76 for( sal_Int32 i=0; i < aBuildId.getLength(); i++ )
77 {
78 sal_Unicode c = aBuildId[i];
79 switch( c )
80 {
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;
94 }
95 }
96 }
97
98 return aResult.makeStringAndClear();
99 }();
100 return sGenerator;
101}
102
103} // end of namespace utl
104
105/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static OUString getBuildIdData(OUString const &_sDefault)
retrieve the BUILDID information item; uses the given default, if not found
Definition: bootstrap.cxx:548
static OUString getProductVersion()
Definition: configmgr.cxx:99
static OUString getProductExtension()
Definition: configmgr.cxx:91
static OUString getProductName()
Definition: configmgr.cxx:95
static OUString GetGeneratorString()
OUString get(TranslateId sContextAndId, const std::locale &loc)
Definition: resmgr.cxx:211
int i
sal_uInt16 sal_Unicode