1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 #include "sal/config.h"
35 #include "lngmerge.hxx"
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
50 // set of global variables
51 rtl::OString sInputFile
;
52 sal_Bool bEnableExport
;
56 sal_Bool bULF
; // ULF = Unicode Language File
58 rtl::OString sPrjRoot
;
59 rtl::OString sOutputFile
;
60 rtl::OString sMergeSrc
;
62 /*****************************************************************************/
63 sal_Bool
ParseCommandLine( int argc
, char* argv
[])
64 /*****************************************************************************/
66 bEnableExport
= sal_False
;
67 bMergeMode
= sal_False
;
73 Export::sLanguages
= "";
75 sal_uInt16 nState
= STATE_NON
;
76 sal_Bool bInput
= sal_False
;
79 for( int i
= 1; i
< argc
; i
++ ) {
80 rtl::OString sSwitch
= rtl::OString(argv
[i
]).toAsciiUpperCase();
81 if (sSwitch
.equalsL(RTL_CONSTASCII_STRINGPARAM("-I")))
82 nState
= STATE_INPUT
; // next tokens specifies source files
83 else if (sSwitch
.equalsL(RTL_CONSTASCII_STRINGPARAM("-O")))
84 nState
= STATE_OUTPUT
; // next token specifies the dest file
85 else if (sSwitch
.equalsL(RTL_CONSTASCII_STRINGPARAM("-P")))
86 nState
= STATE_PRJ
; // next token specifies the cur. project
87 else if (sSwitch
.equalsL(RTL_CONSTASCII_STRINGPARAM("-R")))
88 nState
= STATE_ROOT
; // next token specifies path to project root
89 else if (sSwitch
.equalsL(RTL_CONSTASCII_STRINGPARAM("-M")))
90 nState
= STATE_MERGESRC
; // next token specifies the merge database
91 else if (sSwitch
.equalsL(RTL_CONSTASCII_STRINGPARAM("-E")))
93 nState
= STATE_ERRORLOG
;
94 bErrorLog
= sal_False
;
96 else if (sSwitch
.equalsL(RTL_CONSTASCII_STRINGPARAM("-L")))
97 nState
= STATE_LANGUAGES
;
102 return sal_False
; // no valid command line
106 sInputFile
= argv
[ i
];
107 bInput
= sal_True
; // source file found
111 sOutputFile
= argv
[ i
]; // the dest. file
119 sPrjRoot
= argv
[ i
]; // path to project root
122 case STATE_MERGESRC
: {
123 sMergeSrc
= argv
[ i
];
124 bMergeMode
= sal_True
; // activate merge mode, cause merge database found
127 case STATE_LANGUAGES
: {
128 Export::sLanguages
= argv
[ i
];
136 // command line is valid
138 bEnableExport
= sal_True
;
142 // command line is not valid
147 /*****************************************************************************/
149 /*****************************************************************************/
151 fprintf( stdout
, "Syntax:ULFEX[-p Prj][-r PrjRoot]-i FileIn -o FileOut[-m DataBase][-L l1,l2,...]\n" );
152 fprintf( stdout
, " Prj: Project\n" );
153 fprintf( stdout
, " PrjRoot: Path to project root (..\\.. etc.)\n" );
154 fprintf( stdout
, " FileIn: Source file (*.lng)\n" );
155 fprintf( stdout
, " FileOut: Destination file (*.*)\n" );
156 fprintf( stdout
, " DataBase: Mergedata (*.sdf)\n" );
157 fprintf( stdout
, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
160 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc
, argv
) {
161 if ( !ParseCommandLine( argc
, argv
))
167 if (!sOutputFile
.isEmpty())
169 LngParser
aParser( sInputFile
, bUTF8
, bULF
);
171 aParser
.Merge(sMergeSrc
, sOutputFile
);
173 aParser
.CreateSDF( sOutputFile
, sPrj
, sPrjRoot
);
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */