1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
12 //flags for handleArguments()
13 #define STATE_NON 0x0001
14 #define STATE_INPUT 0x0002
15 #define STATE_OUTPUT 0x0003
16 #define STATE_MERGESRC 0x0005
17 #define STATE_LANGUAGES 0x0006
22 int argc
, char * argv
[], HandledArgs
& o_aHandledArgs
)
24 o_aHandledArgs
= HandledArgs();
25 sal_uInt16 nState
= STATE_NON
;
27 for( int i
= 1; i
< argc
; i
++ )
29 if ( OString( argv
[ i
] ).toAsciiUpperCase() == "-I" )
31 nState
= STATE_INPUT
; // next token specifies source file
33 else if ( OString( argv
[ i
] ).toAsciiUpperCase() == "-O" )
35 nState
= STATE_OUTPUT
; // next token specifies the dest file
37 else if ( OString( argv
[ i
] ).toAsciiUpperCase() == "-M" )
39 nState
= STATE_MERGESRC
; // next token specifies the merge database
40 o_aHandledArgs
.m_bMergeMode
= true;
42 else if ( OString( argv
[ i
] ).toAsciiUpperCase() == "-L" )
44 nState
= STATE_LANGUAGES
;
52 return false; // no valid command line
56 o_aHandledArgs
.m_sInputFile
= OString( argv
[i
] );
61 o_aHandledArgs
.m_sOutputFile
= OString( argv
[i
] );
66 o_aHandledArgs
.m_sMergeSrc
= OString( argv
[i
] );
71 o_aHandledArgs
.m_sLanguage
= OString( argv
[i
] );
77 if( !o_aHandledArgs
.m_sInputFile
.isEmpty() &&
78 !o_aHandledArgs
.m_sOutputFile
.isEmpty() )
84 o_aHandledArgs
= HandledArgs();
89 void writeUsage(const OString
& rName
, const OString
& rFileType
)
92 << " Syntax: " << rName
.getStr()
93 << " -i FileIn -o FileOut [-m DataBase] [-l Lang]\n"
94 << " FileIn: Source files (" << rFileType
.getStr() << ")\n"
95 << " FileOut: Destination file (*.*)\n"
96 << " DataBase: Mergedata (*.po)\n"
97 << " Lang: Restrict the handled language; one element of\n"
98 << " (de, en-US, ...) or all\n";
102 const OString
& rExecutable
, PoOfstream
& rPoStream
, const OString
& rSourceFile
,
103 const OString
& rResType
, const OString
& rGroupId
, const OString
& rLocalId
,
104 const OString
& rHelpText
, const OString
& rText
, const PoEntry::TYPE eType
)
108 PoEntry
aPO(rSourceFile
, rResType
, rGroupId
, rLocalId
, rHelpText
, rText
, eType
);
109 rPoStream
.writeEntry( aPO
);
111 catch( PoEntry::Exception
& aException
)
113 if(aException
== PoEntry::NOSOURCFILE
)
115 std::cerr
<< rExecutable
<< " warning: no sourcefile specified for po entry\n";
119 std::cerr
<< rExecutable
<< " warning: invalid po attributes extracted from " << rSourceFile
<< "\n";
120 if(aException
== PoEntry::NOGROUPID
)
122 std::cerr
<< "No groupID specified!\n";
123 std::cerr
<< "String: " << rText
<< "\n";
125 else if (aException
== PoEntry::NOSTRING
)
127 std::cerr
<< "No string specified!\n";
128 std::cerr
<< "GroupID: " << rGroupId
<< "\n";
129 if( !rLocalId
.isEmpty() ) std::cerr
<< "LocalID: " << rLocalId
<< "\n";
133 if (aException
== PoEntry::NORESTYPE
)
135 std::cerr
<< "No resource type specified!\n";
137 else if (aException
== PoEntry::WRONGHELPTEXT
)
139 std::cerr
<< "x-comment length is 5 characters:" << rHelpText
<< "\n";
142 std::cerr
<< "GroupID: " << rGroupId
<< "\n";
143 if( !rLocalId
.isEmpty() ) std::cerr
<< "LocalID: " << rLocalId
<< "\n";
144 std::cerr
<< "String: " << rText
<< "\n";
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */