1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
26 using namespace ::com::sun::star
;
31 OUString
DocInfoHelper::GetGeneratorString()
33 OUStringBuffer
aResult(128);
35 // First product: branded name + version
36 // version is <product_versions>_<product_extension>$<platform>
39 OUString
aValue( utl::ConfigManager::getProductName() );
40 if ( !aValue
.isEmpty() )
42 aResult
.append( aValue
.replace( ' ', '_' ) );
43 aResult
.append( '/' );
45 aValue
= utl::ConfigManager::getProductVersion();
46 if ( !aValue
.isEmpty() )
48 aResult
.append( aValue
.replace( ' ', '_' ) );
50 aValue
= utl::ConfigManager::getProductExtension();
51 if ( !aValue
.isEmpty() )
53 aResult
.append( aValue
.replace( ' ', '_' ) );
57 OUString
os( "$_OS" );
58 OUString
arch( "$_ARCH" );
59 ::rtl::Bootstrap::expandMacros(os
);
60 ::rtl::Bootstrap::expandMacros(arch
);
61 aResult
.append( '$' );
63 aResult
.append( '_' );
64 aResult
.append( arch
);
65 aResult
.append( ' ' );
68 // second product: LibreOffice_project/<build_information>
69 // build_information has '(' and '[' encoded as '$', ')' and ']' ignored
70 // and ':' replaced by '-'
72 aResult
.append( "LibreOffice_project/" );
73 OUString
aBuildId( Bootstrap::getBuildIdData( OUString() ) );
74 for( sal_Int32 i
=0; i
< aBuildId
.getLength(); i
++ )
76 sal_Unicode c
= aBuildId
[i
];
81 aResult
.append( '$' );
87 aResult
.append( '-' );
96 return aResult
.makeStringAndClear();
99 } // end of namespace utl
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */