1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docinfohelper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_unotools.hxx"
34 #include <rtl/ustrbuf.hxx>
35 #include <tools/inetdef.hxx>
36 #include <unotools/configmgr.hxx>
37 #include <unotools/bootstrap.hxx>
38 #include <unotools/docinfohelper.hxx>
40 using namespace ::com::sun::star
;
45 ::rtl::OUString
DocInfoHelper::GetGeneratorString()
47 rtl::OUStringBuffer aResult
;
49 // First product: branded name + version
50 // version is <product_versions>_<product_extension>$<platform>
51 utl::ConfigManager
* pMgr
= utl::ConfigManager::GetConfigManager();
56 uno::Any aAny
= pMgr
->GetDirectConfigProperty(
57 utl::ConfigManager::PRODUCTNAME
);
58 if ( (aAny
>>= aValue
) && aValue
.getLength() )
60 aResult
.append( aValue
.replace( ' ', '_' ) );
61 aResult
.append( (sal_Unicode
)'/' );
63 aAny
= pMgr
->GetDirectConfigProperty(
64 utl::ConfigManager::PRODUCTVERSION
);
65 if ( (aAny
>>= aValue
) && aValue
.getLength() )
67 aResult
.append( aValue
.replace( ' ', '_' ) );
69 aAny
= pMgr
->GetDirectConfigProperty(
70 utl::ConfigManager::PRODUCTEXTENSION
);
71 if ( (aAny
>>= aValue
) && aValue
.getLength() )
73 aResult
.append( (sal_Unicode
)'_' );
74 aResult
.append( aValue
.replace( ' ', '_' ) );
78 aResult
.append( (sal_Unicode
)'$' );
79 aResult
.append( ::rtl::OUString::createFromAscii(
80 TOOLS_INETDEF_OS
).replace( ' ', '_' ) );
82 aResult
.append( (sal_Unicode
)' ' );
86 // second product: OpenOffice.org_project/<build_information>
87 // build_information has '(' and '[' encoded as '$', ')' and ']' ignored
88 // and ':' replaced by '-'
90 aResult
.appendAscii( "OpenOffice.org_project/" );
91 ::rtl::OUString aDefault
;
92 ::rtl::OUString
aBuildId( Bootstrap::getBuildIdData( aDefault
) );
93 for( sal_Int32 i
=0; i
< aBuildId
.getLength(); i
++ )
95 sal_Unicode c
= aBuildId
[i
];
100 aResult
.append( (sal_Unicode
)'$' );
106 aResult
.append( (sal_Unicode
)'-' );
115 return aResult
.makeStringAndClear();
118 } // end of namespace utl