summaryrefslogtreecommitdiff
path: root/l10ntools/source/treex.cxx
blob: 4e8fe0b2641488249774a85be8245fb3165e204c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <iostream>
#include <cstring>
#include <sal/main.h>

#include <common.hxx>
#include <treemerge.hxx>

static void WriteUsage()
{
    std::cout
        << ("Syntax: Treex [-r Root] -i FileIn -o FileOut"
            " [-m DataBase] [-l Lang]\n"
            " Root:  Path to root of localized xhp files\n"
            " FileIn:   Source files (*.tree)\n"
            " FileOut:  Destination file (*.*)\n"
            " DataBase: Mergedata (*.po)\n"
            " Lang: Restrict the handled languages; one element of\n"
            " (de, en-US, ...) or all\n");
}


SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
{
    OString sXHPRoot;
    for (int nIndex = 1; nIndex != argc; ++nIndex)
    {
        if (std::strcmp(argv[nIndex], "-r") == 0)
        {
            sXHPRoot = OString( argv[nIndex + 1] );
            for( int nIndex2 = nIndex+3; nIndex2 < argc; nIndex2 = nIndex2 + 2 )
            {
                argv[nIndex-3] = argv[nIndex-1];
                argv[nIndex-2] = argv[nIndex];
            }
            argc = argc - 2;
            break;
        }
    }
    common::HandledArgs aArgs;
    if( !common::handleArguments(argc, argv, aArgs) )
    {
        WriteUsage();
        return 1;
    }

    TreeParser aParser(aArgs.m_sInputFile, aArgs.m_sLanguage );
    if( !aParser.isInitialized() )
    {
        return 1;
    }

    if( aArgs.m_bMergeMode || !sXHPRoot.isEmpty() )
    {
        aParser.Merge( aArgs.m_sMergeSrc, aArgs.m_sOutputFile, sXHPRoot );
    }
    else
    {
        aParser.Extract( aArgs.m_sOutputFile );
    }
    return 0;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */