LCOV - code coverage report
Current view: top level - unotools/source/config - docinfohelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 31 36 86.1 %
Date: 2015-06-13 12:38:46 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11