LibreOffice Module l10ntools (master) 1
treex.cxx
Go to the documentation of this file.
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
10#include <iostream>
11#include <cstring>
12#include <sal/main.h>
13
14#include <common.hxx>
15#include <treemerge.hxx>
16
17static void WriteUsage()
18{
19 std::cout
20 << ("Syntax: Treex [-r Root] -i FileIn -o FileOut"
21 " [-m DataBase] [-l Lang]\n"
22 " Root: Path to root of localized xhp files\n"
23 " FileIn: Source files (*.tree)\n"
24 " FileOut: Destination file (*.*)\n"
25 " DataBase: Mergedata (*.po)\n"
26 " Lang: Restrict the handled languages; one element of\n"
27 " (de, en-US, ...) or all\n");
28}
29
30
32{
33 OString sXHPRoot;
34 for (int nIndex = 1; nIndex != argc; ++nIndex)
35 {
36 if (std::strcmp(argv[nIndex], "-r") == 0)
37 {
38 sXHPRoot = OString( argv[nIndex + 1] );
39 for( int nIndex2 = nIndex+3; nIndex2 < argc; nIndex2 = nIndex2 + 2 )
40 {
41 argv[nIndex-3] = argv[nIndex-1];
42 argv[nIndex-2] = argv[nIndex];
43 }
44 argc = argc - 2;
45 break;
46 }
47 }
49 if( !common::handleArguments(argc, argv, aArgs) )
50 {
51 WriteUsage();
52 return 1;
53 }
54
55 TreeParser aParser(aArgs.m_sInputFile, aArgs.m_sLanguage );
56 if( !aParser.isInitialized() )
57 {
58 return 1;
59 }
60
61 if( aArgs.m_bMergeMode || !sXHPRoot.isEmpty() )
62 {
63 aParser.Merge( aArgs.m_sMergeSrc, aArgs.m_sOutputFile, sXHPRoot );
64 }
65 else
66 {
67 aParser.Extract( aArgs.m_sOutputFile );
68 }
69 return 0;
70}
71
72/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Class for localization of *.tree files.
Definition: treemerge.hxx:24
void Extract(const OString &rPOFile)
Export strings.
Definition: treemerge.cxx:227
bool isInitialized() const
Definition: treemerge.hxx:35
void Merge(const OString &rMergeSrc, const OString &rDestinationFile, const OString &rXhpRoot)
Merge strings to tree file and update reference to help files(xhp)
Definition: treemerge.cxx:250
sal_Int32 nIndex
bool handleArguments(int argc, char *argv[], HandledArgs &o_aHandledArgs)
Handle command line parameters.
Definition: common.cxx:25
Result type of handleArguments()
Definition: common.hxx:26
OString m_sMergeSrc
Definition: common.hxx:29
OString m_sOutputFile
Definition: common.hxx:28
OString m_sLanguage
Definition: common.hxx:30
OString m_sInputFile
Definition: common.hxx:27
static void WriteUsage()
Definition: treex.cxx:17
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
Definition: treex.cxx:31