bump product version to 4.1.6.2
[LibreOffice.git] / l10ntools / source / helpex.cxx
blob5c6156f95c86e5d14201ff72baaa391b80c7f32b
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"
33 #include "common.hxx"
35 #ifndef TESTDRIVER
37 void WriteUsage()
39 std::cout
40 << " Syntax: Helpex -[m]i FileIn -o FileOut [-m DataBase] [-l Lang]\n"
41 << " FileIn + i: Source file (*.xhp)\n"
42 << " FileIn + -mi: File including paths of source files"
43 << " (only for merge)\n"
44 << " FileOut: Destination file (*.*) or files (in case of -mi)\n"
45 << " DataBase: Mergedata (*.po)\n"
46 << " Lang: Restrict the handled languages; one element of\n"
47 << " (de, en-US, ...) or all\n";
50 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
52 bool bMultiMerge = false;
53 for (int nIndex = 1; nIndex != argc; ++nIndex)
55 if (std::strcmp(argv[nIndex], "-mi") == 0)
57 argv[nIndex][1] = 'i';
58 argv[nIndex][2] = '\0';
59 bMultiMerge = true;
60 break;
64 common::HandledArgs aArgs;
65 if ( !common::handleArguments( argc, argv, aArgs) )
67 WriteUsage();
68 return 1;
70 bool hasNoError = true;
72 if ( aArgs.m_bMergeMode )
74 if( bMultiMerge )
76 std::ifstream aInput( aArgs.m_sInputFile.getStr() );
77 if( !aInput.is_open() )
79 std::cerr << "Helpex error: cannot open input file\n";
80 return 1;
82 MergeDataFile* pMergeDataFile = 0;
83 if( aArgs.m_sLanguage != "qtz")
85 pMergeDataFile = new MergeDataFile(aArgs.m_sMergeSrc, OString(), false, false );
87 std::string sTemp;
88 aInput >> sTemp;
89 while( !aInput.eof() )
91 const OString sXhpFile( sTemp.data(), sTemp.length() );
92 HelpParser aParser( sXhpFile );
93 const OString sOutput(
94 aArgs.m_sOutputFile +
95 sXhpFile.copy( sXhpFile.lastIndexOf("/") ));
96 if( !aParser.Merge( aArgs.m_sMergeSrc, sOutput,
97 aArgs.m_sLanguage, pMergeDataFile ))
99 hasNoError = false;
101 aInput >> sTemp;
103 aInput.close();
104 delete pMergeDataFile;
106 else
108 HelpParser aParser( aArgs.m_sInputFile );
109 MergeDataFile* pMergeDataFile = 0;
110 if( aArgs.m_sLanguage != "qtz")
112 pMergeDataFile = new MergeDataFile(aArgs.m_sMergeSrc, aArgs.m_sInputFile, false, false );
114 hasNoError =
115 aParser.Merge(
116 aArgs.m_sMergeSrc, aArgs.m_sOutputFile,
117 aArgs.m_sLanguage, pMergeDataFile );
118 delete pMergeDataFile;
121 else
123 HelpParser aParser( aArgs.m_sInputFile );
124 hasNoError =
125 aParser.CreatePO(
126 aArgs.m_sOutputFile, aArgs.m_sInputFile,
127 new XMLFile( OUString('0') ), "help" );
130 if( hasNoError )
131 return 0;
132 else
133 return 1;
135 #endif
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */