Branch data Line data Source code
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>
21 : : #include <unotools/configmgr.hxx>
22 : : #include <unotools/bootstrap.hxx>
23 : : #include <unotools/docinfohelper.hxx>
24 : : #include <rtl/bootstrap.hxx>
25 : :
26 : : using namespace ::com::sun::star;
27 : :
28 : : namespace utl
29 : : {
30 : :
31 : 1174 : ::rtl::OUString DocInfoHelper::GetGeneratorString()
32 : : {
33 : 1174 : rtl::OUStringBuffer aResult;
34 : :
35 : : // First product: branded name + version
36 : : // version is <product_versions>_<product_extension>$<platform>
37 : :
38 : : // plain product name
39 [ + - ]: 1174 : rtl::OUString aValue( utl::ConfigManager::getProductName() );
40 [ + - ]: 1174 : if ( !aValue.isEmpty() )
41 : : {
42 [ + - ]: 1174 : aResult.append( aValue.replace( ' ', '_' ) );
43 [ + - ]: 1174 : aResult.append( (sal_Unicode)'/' );
44 : :
45 [ + - ]: 1174 : aValue = utl::ConfigManager::getProductVersion();
46 [ + - ]: 1174 : if ( !aValue.isEmpty() )
47 : : {
48 [ + - ]: 1174 : aResult.append( aValue.replace( ' ', '_' ) );
49 : :
50 [ + - ]: 1174 : aValue = utl::ConfigManager::getProductExtension();
51 [ + + ]: 1174 : if ( !aValue.isEmpty() )
52 : : {
53 [ + - ]: 1107 : aResult.append( (sal_Unicode)'_' );
54 [ + - ]: 1107 : aResult.append( aValue.replace( ' ', '_' ) );
55 : : }
56 : : }
57 : :
58 : 1174 : ::rtl::OUString os( "$_OS" );
59 : 1174 : ::rtl::OUString arch( "$_ARCH" );
60 : 1174 : ::rtl::Bootstrap::expandMacros(os);
61 : 1174 : ::rtl::Bootstrap::expandMacros(arch);
62 [ + - ]: 1174 : aResult.append( (sal_Unicode)'$' );
63 [ + - ]: 1174 : aResult.append( os );
64 [ + - ]: 1174 : aResult.append( (sal_Unicode)'_' );
65 [ + - ]: 1174 : aResult.append( arch );
66 [ + - ]: 1174 : aResult.append( (sal_Unicode)' ' );
67 : : }
68 : :
69 : : // second product: LibreOffice_project/<build_information>
70 : : // build_information has '(' and '[' encoded as '$', ')' and ']' ignored
71 : : // and ':' replaced by '-'
72 : : {
73 [ + - ]: 1174 : aResult.appendAscii( "LibreOffice_project/" );
74 : 1174 : ::rtl::OUString aDefault;
75 [ + - ]: 1174 : ::rtl::OUString aBuildId( Bootstrap::getBuildIdData( aDefault ) );
76 [ + + ]: 2648 : for( sal_Int32 i=0; i < aBuildId.getLength(); i++ )
77 : : {
78 : 1474 : sal_Unicode c = aBuildId[i];
79 [ - - - + ]: 1474 : switch( c )
80 : : {
81 : : case '(':
82 : : case '[':
83 [ # # ]: 0 : aResult.append( (sal_Unicode)'$' );
84 : 0 : break;
85 : : case ')':
86 : : case ']':
87 : 0 : break;
88 : : case ':':
89 [ # # ]: 0 : aResult.append( (sal_Unicode)'-' );
90 : 0 : break;
91 : : default:
92 [ + - ]: 1474 : aResult.append( c );
93 : 1474 : break;
94 : : }
95 : 1174 : }
96 : : }
97 : :
98 [ + - ]: 1174 : return aResult.makeStringAndClear();
99 : : }
100 : :
101 : : } // end of namespace utl
102 : :
103 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|