1*b5088357SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*b5088357SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*b5088357SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*b5088357SAndrew Rist * distributed with this work for additional information
6*b5088357SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*b5088357SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*b5088357SAndrew Rist * "License"); you may not use this file except in compliance
9*b5088357SAndrew Rist * with the License. You may obtain a copy of the License at
10*b5088357SAndrew Rist *
11*b5088357SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*b5088357SAndrew Rist *
13*b5088357SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*b5088357SAndrew Rist * software distributed under the License is distributed on an
15*b5088357SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b5088357SAndrew Rist * KIND, either express or implied. See the License for the
17*b5088357SAndrew Rist * specific language governing permissions and limitations
18*b5088357SAndrew Rist * under the License.
19*b5088357SAndrew Rist *
20*b5088357SAndrew Rist *************************************************************/
21*b5088357SAndrew Rist
22*b5088357SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_unotools.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
28cdf0e10cSrcweir #include <tools/inetdef.hxx>
29cdf0e10cSrcweir #include <unotools/configmgr.hxx>
30cdf0e10cSrcweir #include <unotools/bootstrap.hxx>
31cdf0e10cSrcweir #include <unotools/docinfohelper.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir using namespace ::com::sun::star;
34cdf0e10cSrcweir
35cdf0e10cSrcweir namespace utl
36cdf0e10cSrcweir {
37cdf0e10cSrcweir
GetGeneratorString()38cdf0e10cSrcweir ::rtl::OUString DocInfoHelper::GetGeneratorString()
39cdf0e10cSrcweir {
40cdf0e10cSrcweir rtl::OUStringBuffer aResult;
41cdf0e10cSrcweir
42cdf0e10cSrcweir // First product: branded name + version
43cdf0e10cSrcweir // version is <product_versions>_<product_extension>$<platform>
44cdf0e10cSrcweir utl::ConfigManager* pMgr = utl::ConfigManager::GetConfigManager();
45cdf0e10cSrcweir if ( pMgr )
46cdf0e10cSrcweir {
47cdf0e10cSrcweir // plain product name
48cdf0e10cSrcweir rtl::OUString aValue;
49cdf0e10cSrcweir uno::Any aAny = pMgr->GetDirectConfigProperty(
50cdf0e10cSrcweir utl::ConfigManager::PRODUCTNAME);
51cdf0e10cSrcweir if ( (aAny >>= aValue) && aValue.getLength() )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir aResult.append( aValue.replace( ' ', '_' ) );
54cdf0e10cSrcweir aResult.append( (sal_Unicode)'/' );
55cdf0e10cSrcweir
56cdf0e10cSrcweir aAny = pMgr->GetDirectConfigProperty(
57cdf0e10cSrcweir utl::ConfigManager::PRODUCTVERSION);
58cdf0e10cSrcweir if ( (aAny >>= aValue) && aValue.getLength() )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir aResult.append( aValue.replace( ' ', '_' ) );
61cdf0e10cSrcweir
62cdf0e10cSrcweir aAny = pMgr->GetDirectConfigProperty(
63cdf0e10cSrcweir utl::ConfigManager::PRODUCTEXTENSION);
64cdf0e10cSrcweir if ( (aAny >>= aValue) && aValue.getLength() )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir aResult.append( (sal_Unicode)'_' );
67cdf0e10cSrcweir aResult.append( aValue.replace( ' ', '_' ) );
68cdf0e10cSrcweir }
69cdf0e10cSrcweir }
70cdf0e10cSrcweir
71cdf0e10cSrcweir aResult.append( (sal_Unicode)'$' );
72cdf0e10cSrcweir aResult.append( ::rtl::OUString::createFromAscii(
73cdf0e10cSrcweir TOOLS_INETDEF_OS ).replace( ' ', '_' ) );
74cdf0e10cSrcweir
75cdf0e10cSrcweir aResult.append( (sal_Unicode)' ' );
76cdf0e10cSrcweir }
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
79cdf0e10cSrcweir // second product: OpenOffice.org_project/<build_information>
80cdf0e10cSrcweir // build_information has '(' and '[' encoded as '$', ')' and ']' ignored
81cdf0e10cSrcweir // and ':' replaced by '-'
82cdf0e10cSrcweir {
83cdf0e10cSrcweir aResult.appendAscii( "OpenOffice.org_project/" );
84cdf0e10cSrcweir ::rtl::OUString aDefault;
85cdf0e10cSrcweir ::rtl::OUString aBuildId( Bootstrap::getBuildIdData( aDefault ) );
86cdf0e10cSrcweir for( sal_Int32 i=0; i < aBuildId.getLength(); i++ )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir sal_Unicode c = aBuildId[i];
89cdf0e10cSrcweir switch( c )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir case '(':
92cdf0e10cSrcweir case '[':
93cdf0e10cSrcweir aResult.append( (sal_Unicode)'$' );
94cdf0e10cSrcweir break;
95cdf0e10cSrcweir case ')':
96cdf0e10cSrcweir case ']':
97cdf0e10cSrcweir break;
98cdf0e10cSrcweir case ':':
99cdf0e10cSrcweir aResult.append( (sal_Unicode)'-' );
100cdf0e10cSrcweir break;
101cdf0e10cSrcweir default:
102cdf0e10cSrcweir aResult.append( c );
103cdf0e10cSrcweir break;
104cdf0e10cSrcweir }
105cdf0e10cSrcweir }
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
108cdf0e10cSrcweir return aResult.makeStringAndClear();
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir } // end of namespace utl
112cdf0e10cSrcweir
113