Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License or as specified alternatively below. You may obtain a copy of
8 : * the License at http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * Major Contributor(s):
16 : * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
17 : * (initial developer)
18 : *
19 : * All Rights Reserved.
20 : *
21 : * For minor contributions see the git repository.
22 : *
23 : * Alternatively, the contents of this file may be used under the terms of
24 : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
25 : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
26 : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
27 : * instead of those above.
28 : */
29 :
30 : #ifndef HELPINDEXER_HXX
31 : #define HELPINDEXER_HXX
32 :
33 : #include <helpcompiler/dllapi.h>
34 :
35 : #include <rtl/ustring.hxx>
36 : #include <set>
37 :
38 : // I assume that TCHAR is defined as wchar_t throughout
39 :
40 : namespace lucene
41 : {
42 : namespace document
43 : {
44 : class Document;
45 : }
46 : namespace util
47 : {
48 : class Reader;
49 : }
50 : }
51 :
52 9 : class L10N_DLLPUBLIC HelpIndexer {
53 : private:
54 : rtl::OUString d_lang;
55 : rtl::OUString d_module;
56 : rtl::OUString d_captionDir;
57 : rtl::OUString d_contentDir;
58 : rtl::OUString d_indexDir;
59 : rtl::OUString d_error;
60 : std::set<rtl::OUString> d_files;
61 :
62 : public:
63 :
64 : /**
65 : * @param lang Help files language.
66 : * @param module The module of the helpfiles.
67 : * @param srcDir The help directory to index
68 : * @param outDir The directory to write the "module".idxl directory to
69 : */
70 : HelpIndexer(rtl::OUString const &lang, rtl::OUString const &module,
71 : rtl::OUString const &srcDir, rtl::OUString const &outDir);
72 :
73 : /**
74 : * Run the indexer.
75 : * @return true if index successfully generated.
76 : */
77 : bool indexDocuments();
78 :
79 : /**
80 : * Get the error string (empty if no error occurred).
81 : */
82 : rtl::OUString const & getErrorMessage();
83 :
84 : private:
85 :
86 : /**
87 : * Scan the caption & contents directories for help files.
88 : */
89 : bool scanForFiles();
90 :
91 : /**
92 : * Scan for files in the given directory.
93 : */
94 : bool scanForFiles(rtl::OUString const &path);
95 :
96 : /**
97 : * Fill the Document with information on the given help file.
98 : */
99 : bool helpDocument(rtl::OUString const & fileName, lucene::document::Document *doc);
100 :
101 : /**
102 : * Create a reader for the given file, and create an "empty" reader in case the file doesn't exist.
103 : */
104 : lucene::util::Reader *helpFileReader(rtl::OUString const & path);
105 : };
106 :
107 : #endif
108 :
109 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|