LCOV - code coverage report
Current view: top level - l10ntools/source - helpex.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 51 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 5 0.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 "sal/config.h"
      21             : 
      22             : #include <iostream>
      23             : #include <fstream>
      24             : #include <string>
      25             : #include <cstring>
      26             : 
      27             : #include <stdio.h>
      28             : #include <stdlib.h>
      29             : 
      30             : #include "sal/main.h"
      31             : 
      32             : #include "helpmerge.hxx"
      33             : #include "common.hxx"
      34             : 
      35             : #ifndef TESTDRIVER
      36             : 
      37           0 : void WriteUsage()
      38             : {
      39             :     std::cout
      40             :         << (" Syntax: Helpex -[m]i FileIn -o FileOut [-m DataBase] [-l Lang]\n"
      41             :             " FileIn + i:   Source file (*.xhp)\n"
      42             :             " FileIn + -mi: File including paths of source files"
      43             :             " (only for merge)\n"
      44             :             " FileOut:  Destination file (*.*) or files (in case of -mi)\n"
      45             :             " DataBase: Mergedata (*.po)\n"
      46             :             " Lang: Restrict the handled languages; one element of\n"
      47           0 :             " (de, en-US, ...) or all\n");
      48           0 : }
      49             : 
      50           0 : SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
      51             : 
      52           0 :     bool bMultiMerge = false;
      53           0 :     for (int nIndex = 1; nIndex != argc; ++nIndex)
      54             :     {
      55           0 :         if (std::strcmp(argv[nIndex], "-mi") == 0)
      56             :         {
      57           0 :             argv[nIndex][1] = 'i';
      58           0 :             argv[nIndex][2] = '\0';
      59           0 :             bMultiMerge = true;
      60           0 :             break;
      61             :         }
      62             :     }
      63             : 
      64           0 :     common::HandledArgs aArgs;
      65           0 :     if ( !common::handleArguments( argc, argv, aArgs) )
      66             :     {
      67           0 :         WriteUsage();
      68           0 :         return 1;
      69             :     }
      70           0 :     bool hasNoError = true;
      71             : 
      72           0 :     if ( aArgs.m_bMergeMode )
      73             :     {
      74           0 :         if( bMultiMerge )
      75             :         {
      76           0 :             std::ifstream aInput( aArgs.m_sInputFile.getStr() );
      77           0 :             if( !aInput.is_open() )
      78             :             {
      79           0 :                 std::cerr << "Helpex error: cannot open input file\n";
      80           0 :                 return 1;
      81             :             }
      82           0 :             MergeDataFile* pMergeDataFile = 0;
      83           0 :             if( aArgs.m_sLanguage != "qtz")
      84             :             {
      85           0 :                 pMergeDataFile = new MergeDataFile(aArgs.m_sMergeSrc, OString(), false, false );
      86             :             }
      87           0 :             std::string sTemp;
      88           0 :             aInput >> sTemp;
      89           0 :             while( !aInput.eof() )
      90             :             {
      91             :                 // coverity[tainted_data] - this is a build time tool
      92           0 :                 const OString sXhpFile( sTemp.data(), (sal_Int32)sTemp.length() );
      93           0 :                 HelpParser aParser( sXhpFile );
      94             :                 const OString sOutput(
      95           0 :                     aArgs.m_sOutputFile +
      96           0 :                     sXhpFile.copy( sXhpFile.lastIndexOf('/') ));
      97           0 :                 if( !aParser.Merge( aArgs.m_sMergeSrc, sOutput,
      98           0 :                     aArgs.m_sLanguage, pMergeDataFile ))
      99             :                 {
     100           0 :                     hasNoError = false;
     101             :                 }
     102           0 :                 aInput >> sTemp;
     103           0 :             }
     104           0 :             aInput.close();
     105           0 :             delete pMergeDataFile;
     106             :         }
     107             :         else
     108             :         {
     109           0 :             HelpParser aParser( aArgs.m_sInputFile );
     110           0 :             MergeDataFile* pMergeDataFile = 0;
     111           0 :             if( aArgs.m_sLanguage != "qtz")
     112             :             {
     113           0 :                 pMergeDataFile = new MergeDataFile(aArgs.m_sMergeSrc, aArgs.m_sInputFile, false, false );
     114             :             }
     115             :             hasNoError =
     116             :                 aParser.Merge(
     117             :                     aArgs.m_sMergeSrc, aArgs.m_sOutputFile,
     118           0 :                     aArgs.m_sLanguage, pMergeDataFile );
     119           0 :             delete pMergeDataFile;
     120             :         }
     121             :     }
     122             :     else
     123             :     {
     124           0 :         HelpParser aParser( aArgs.m_sInputFile );
     125             :         hasNoError =
     126             :             HelpParser::CreatePO(
     127             :                 aArgs.m_sOutputFile, aArgs.m_sInputFile,
     128           0 :                 new XMLFile( OString('0') ), "help" );
     129             :     }
     130             : 
     131           0 :     if( hasNoError )
     132           0 :         return 0;
     133             :     else
     134           0 :         return 1;
     135           0 : }
     136             : #endif
     137             : 
     138             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11