LCOV - code coverage report
Current view: top level - l10ntools/source - lngex.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 73 0.0 %
Date: 2012-08-25 Functions: 0 6 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "sal/config.h"
      30                 :            : 
      31                 :            : #include <stdio.h>
      32                 :            : 
      33                 :            : #include "sal/main.h"
      34                 :            : 
      35                 :            : #include "lngmerge.hxx"
      36                 :            : 
      37                 :            : // defines to parse command line
      38                 :            : #define STATE_NON       0x0001
      39                 :            : #define STATE_INPUT     0x0002
      40                 :            : #define STATE_OUTPUT    0x0003
      41                 :            : #define STATE_PRJ       0x0004
      42                 :            : #define STATE_ROOT      0x0005
      43                 :            : #define STATE_MERGESRC  0x0006
      44                 :            : #define STATE_ERRORLOG  0x0007
      45                 :            : #define STATE_BREAKHELP 0x0008
      46                 :            : #define STATE_UNMERGE   0x0009
      47                 :            : #define STATE_ULF       0x000A
      48                 :            : #define STATE_LANGUAGES 0x000B
      49                 :            : 
      50                 :            : // set of global variables
      51                 :          0 : rtl::OString sInputFile;
      52                 :            : sal_Bool bEnableExport;
      53                 :            : sal_Bool bMergeMode;
      54                 :            : sal_Bool bUTF8;
      55                 :            : sal_Bool bULF; // ULF = Unicode Language File
      56                 :          0 : rtl::OString sPrj;
      57                 :          0 : rtl::OString sPrjRoot;
      58                 :          0 : rtl::OString sOutputFile;
      59                 :          0 : rtl::OString sMergeSrc;
      60                 :            : 
      61                 :            : /*****************************************************************************/
      62                 :          0 : sal_Bool ParseCommandLine( int argc, char* argv[])
      63                 :            : /*****************************************************************************/
      64                 :            : {
      65                 :          0 :     bEnableExport = sal_False;
      66                 :          0 :     bMergeMode = sal_False;
      67                 :          0 :     bUTF8 = sal_True;
      68                 :          0 :     bULF = sal_False;
      69                 :          0 :     sPrj = "";
      70                 :          0 :     sPrjRoot = "";
      71                 :          0 :     Export::sLanguages = "";
      72                 :            : 
      73                 :          0 :     sal_uInt16 nState = STATE_NON;
      74                 :          0 :     sal_Bool bInput = sal_False;
      75                 :            : 
      76                 :            :     // parse command line
      77                 :          0 :     for( int i = 1; i < argc; i++ ) {
      78                 :          0 :         rtl::OString sSwitch = rtl::OString(argv[i]).toAsciiUpperCase();
      79                 :          0 :         if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-I")))
      80                 :          0 :             nState = STATE_INPUT; // next tokens specifies source files
      81                 :          0 :         else if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-O")))
      82                 :          0 :             nState = STATE_OUTPUT; // next token specifies the dest file
      83                 :          0 :         else if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-P")))
      84                 :          0 :             nState = STATE_PRJ; // next token specifies the cur. project
      85                 :          0 :         else if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-R")))
      86                 :          0 :             nState = STATE_ROOT; // next token specifies path to project root
      87                 :          0 :         else if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-M")))
      88                 :          0 :             nState = STATE_MERGESRC; // next token specifies the merge database
      89                 :          0 :         else if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-E")))
      90                 :            :         {
      91                 :          0 :             nState = STATE_ERRORLOG;
      92                 :            :         }
      93                 :          0 :         else if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-L")))
      94                 :          0 :             nState = STATE_LANGUAGES;
      95                 :            :         else
      96                 :            :         {
      97                 :          0 :             switch ( nState ) {
      98                 :            :                 case STATE_NON: {
      99                 :          0 :                     return sal_False;   // no valid command line
     100                 :            :                 }
     101                 :            :                 //break;
     102                 :            :                 case STATE_INPUT: {
     103                 :          0 :                     sInputFile = argv[ i ];
     104                 :          0 :                     bInput = sal_True; // source file found
     105                 :            :                 }
     106                 :          0 :                 break;
     107                 :            :                 case STATE_OUTPUT: {
     108                 :          0 :                     sOutputFile = argv[ i ]; // the dest. file
     109                 :            :                 }
     110                 :          0 :                 break;
     111                 :            :                 case STATE_PRJ: {
     112                 :          0 :                     sPrj = argv[ i ];
     113                 :            :                 }
     114                 :          0 :                 break;
     115                 :            :                 case STATE_ROOT: {
     116                 :          0 :                     sPrjRoot = argv[ i ]; // path to project root
     117                 :            :                 }
     118                 :          0 :                 break;
     119                 :            :                 case STATE_MERGESRC: {
     120                 :          0 :                     sMergeSrc = argv[ i ];
     121                 :          0 :                     bMergeMode = sal_True; // activate merge mode, cause merge database found
     122                 :            :                 }
     123                 :          0 :                 break;
     124                 :            :                 case STATE_LANGUAGES: {
     125                 :          0 :                     Export::sLanguages = argv[ i ];
     126                 :            :                 }
     127                 :          0 :                 break;
     128                 :            :             }
     129                 :            :         }
     130                 :          0 :     }
     131                 :            : 
     132                 :          0 :     if ( bInput ) {
     133                 :            :         // command line is valid
     134                 :          0 :         bULF = sal_True;
     135                 :          0 :         bEnableExport = sal_True;
     136                 :          0 :         return sal_True;
     137                 :            :     }
     138                 :            : 
     139                 :            :     // command line is not valid
     140                 :          0 :     return sal_False;
     141                 :            : }
     142                 :            : 
     143                 :            : 
     144                 :            : /*****************************************************************************/
     145                 :          0 : void Help()
     146                 :            : /*****************************************************************************/
     147                 :            : {
     148                 :          0 :     fprintf( stdout, "Syntax:ULFEX[-p Prj][-r PrjRoot]-i FileIn -o FileOut[-m DataBase][-L l1,l2,...]\n" );
     149                 :          0 :     fprintf( stdout, " Prj:      Project\n" );
     150                 :          0 :     fprintf( stdout, " PrjRoot:  Path to project root (..\\.. etc.)\n" );
     151                 :          0 :     fprintf( stdout, " FileIn:   Source file (*.lng)\n" );
     152                 :          0 :     fprintf( stdout, " FileOut:  Destination file (*.*)\n" );
     153                 :          0 :     fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
     154                 :          0 :     fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
     155                 :          0 : }
     156                 :            : 
     157                 :          0 : SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
     158                 :          0 :     if ( !ParseCommandLine( argc, argv ))
     159                 :            :     {
     160                 :          0 :         Help();
     161                 :          0 :         return 1;
     162                 :            :     }
     163                 :            : 
     164                 :          0 :     if (!sOutputFile.isEmpty())
     165                 :            :     {
     166                 :          0 :         LngParser aParser( sInputFile, bULF );
     167                 :          0 :         if ( bMergeMode )
     168                 :          0 :             aParser.Merge(sMergeSrc, sOutputFile);
     169                 :            :         else
     170                 :          0 :             aParser.CreateSDF( sOutputFile, sPrj, sPrjRoot );
     171                 :            :     }
     172                 :            : 
     173                 :          0 :     return 0;
     174                 :          0 : }
     175                 :            : 
     176                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10