Bump for 4.0-15
[LibreOffice.git] / l10ntools / source / helpex.cxx
blob21a8b9d3e1b75173a6276162036760df455d3cab
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "sal/config.h"
22 #include <iostream>
23 #include <fstream>
24 #include <string>
25 #include <cstring>
27 #include <stdio.h>
28 #include <stdlib.h>
30 #include "sal/main.h"
32 #include "helpmerge.hxx"
34 #ifndef TESTDRIVER
36 void WriteUsage()
38 std::cout
39 << "Syntax: Helpex [-p Prj] [-r Root] -[m]i FileIn -o FileOut"
40 << " [-m DataBase] [-l l1,l2,...]\n"
41 << " Prj: Project\n"
42 << " Root: Path to project root (../.. etc.)\n"
43 << " FileIn + i: Source file (*.xhp)\n"
44 << " FileIn + -mi: File including pathes of source files"
45 << " (only for merge)"
46 << " FileOut: Destination file (*.*) or files (in case of -mi)\n"
47 << " DataBase: Mergedata (*.po)\n"
48 << " -l: Restrict the handled languages; l1, l2, ... are elements of"
49 << " (de, en-US, ...)\n";
52 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
54 bool bMultiMerge = false;
55 for (int nIndex = 1; nIndex != argc; ++nIndex)
57 if (std::strcmp(argv[nIndex], "-mi") == 0)
59 argv[nIndex][1] = 'i';
60 argv[nIndex][2] = '\0';
61 bMultiMerge = true;
62 break;
66 HandledArgs aArgs;
67 if ( !Export::handleArguments( argc, argv, aArgs) )
69 WriteUsage();
70 return 1;
72 bool hasNoError = true;
74 if ( aArgs.m_bMergeMode )
76 if( bMultiMerge )
78 std::ifstream aInput( aArgs.m_sInputFile.getStr() );
79 if( !aInput.is_open() )
81 std::cerr << "Helpex error: cannot open input file\n";
82 return 1;
84 MergeDataFile aMergeDataFile(
85 aArgs.m_sMergeSrc, OString(), false, false );
86 std::string sTemp;
87 aInput >> sTemp;
88 while( !aInput.eof() )
90 const OString sXhpFile( sTemp.data(), sTemp.length() );
91 HelpParser aParser( sXhpFile );
92 const OString sOutput(
93 aArgs.m_sOutputFile +
94 sXhpFile.copy( sXhpFile.lastIndexOf("/") ));
95 if( !aParser.Merge( aArgs.m_sMergeSrc, sOutput,
96 Export::sLanguages, aMergeDataFile ))
98 hasNoError = false;
100 aInput >> sTemp;
102 aInput.close();
104 else
106 HelpParser aParser( aArgs.m_sInputFile );
107 MergeDataFile aMergeDataFile(
108 aArgs.m_sMergeSrc, aArgs.m_sInputFile, false, false );
109 hasNoError =
110 aParser.Merge(
111 aArgs.m_sMergeSrc, aArgs.m_sOutputFile,
112 Export::sLanguages , aMergeDataFile );
115 else
117 HelpParser aParser( aArgs.m_sInputFile );
118 hasNoError =
119 aParser.CreateSDF(
120 aArgs.m_sOutputFile, aArgs.m_sPrj, aArgs.m_sPrjRoot,
121 aArgs.m_sInputFile, new XMLFile( OUString('0') ), "help" );
124 if( hasNoError )
125 return 0;
126 else
127 return 1;
129 #endif
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */