LCOV - code coverage report
Current view: top level - libreoffice/l10ntools/source - helpex.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 54 0.0 %
Date: 2012-12-27 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             : 
      34             : #ifndef TESTDRIVER
      35             : 
      36           0 : void WriteUsage()
      37             : {
      38             :     std::cout
      39           0 :         << "Syntax: Helpex [-p Prj] [-r Root] -[m]i FileIn -o FileOut"
      40           0 :         << " [-m DataBase] [-l l1,l2,...]\n"
      41           0 :         << " Prj: Project\n"
      42           0 :         << " Root: Path to project root (../.. etc.)\n"
      43           0 :         << " FileIn + i:   Source file (*.xhp)\n"
      44           0 :         << " FileIn + -mi: File including pathes of source files"
      45           0 :         << " (only for merge)"
      46           0 :         << " FileOut:  Destination file (*.*) or files (in case of -mi)\n"
      47           0 :         << " DataBase: Mergedata (*.po)\n"
      48           0 :         << " -l: Restrict the handled languages; l1, l2, ... are elements of"
      49           0 :         << " (de, en-US, ...)\n";
      50           0 : }
      51             : 
      52           0 : SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
      53             : 
      54           0 :     bool bMultiMerge = false;
      55           0 :     for (int nIndex = 1; nIndex != argc; ++nIndex)
      56             :     {
      57           0 :         if (std::strcmp(argv[nIndex], "-mi") == 0)
      58             :         {
      59           0 :             argv[nIndex][1] = 'i';
      60           0 :             argv[nIndex][2] = '\0';
      61           0 :             bMultiMerge = true;
      62           0 :             break;
      63             :         }
      64             :     }
      65             : 
      66           0 :     HandledArgs aArgs;
      67           0 :     if ( !Export::handleArguments( argc, argv, aArgs) )
      68             :     {
      69           0 :         WriteUsage();
      70           0 :         return 1;
      71             :     }
      72           0 :     bool hasNoError = true;
      73             : 
      74           0 :     if ( aArgs.m_bMergeMode )
      75             :     {
      76           0 :         if( bMultiMerge )
      77             :         {
      78           0 :             std::ifstream aInput( aArgs.m_sInputFile.getStr() );
      79           0 :             if( !aInput.is_open() )
      80             :             {
      81           0 :                 std::cerr << "Helpex error: cannot open input file\n";
      82           0 :                 return 1;
      83             :             }
      84             :             MergeDataFile aMergeDataFile(
      85           0 :                 aArgs.m_sMergeSrc, OString(), false, false );
      86           0 :             std::string sTemp;
      87           0 :             aInput >> sTemp;
      88           0 :             while( !aInput.eof() )
      89             :             {
      90           0 :                 const OString sXhpFile( sTemp.data(), sTemp.length() );
      91           0 :                 HelpParser aParser( sXhpFile );
      92             :                 const OString sOutput(
      93             :                     aArgs.m_sOutputFile +
      94           0 :                     sXhpFile.copy( sXhpFile.lastIndexOf("/") ));
      95           0 :                 if( !aParser.Merge( aArgs.m_sMergeSrc, sOutput,
      96           0 :                     Export::sLanguages, aMergeDataFile ))
      97             :                 {
      98           0 :                     hasNoError = false;
      99             :                 }
     100           0 :                 aInput >> sTemp;
     101           0 :             }
     102           0 :             aInput.close();
     103             :         }
     104             :         else
     105             :         {
     106           0 :             HelpParser aParser( aArgs.m_sInputFile );
     107             :             MergeDataFile aMergeDataFile(
     108           0 :                 aArgs.m_sMergeSrc, aArgs.m_sInputFile, false, false );
     109             :             hasNoError =
     110             :                 aParser.Merge(
     111             :                     aArgs.m_sMergeSrc, aArgs.m_sOutputFile,
     112           0 :                     Export::sLanguages , aMergeDataFile );
     113             :         }
     114             :     }
     115             :     else
     116             :     {
     117           0 :         HelpParser aParser( aArgs.m_sInputFile );
     118             :         hasNoError =
     119             :             aParser.CreateSDF(
     120             :                 aArgs.m_sOutputFile, aArgs.m_sPrj, aArgs.m_sPrjRoot,
     121           0 :                 aArgs.m_sInputFile, new XMLFile( OUString('0') ), "help" );
     122             :     }
     123             : 
     124           0 :     if( hasNoError )
     125           0 :         return 0;
     126             :     else
     127           0 :         return 1;
     128           0 : }
     129             : #endif
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10