Make sure EOF is defined
[xapian.git] / xapian-applications / omega / opendocparse.cc
bloba31c3298fd9fb825bf4cab1e9a0bd8957f07fe2e
1 /** @file opendocparse.cc
2 * @brief Extract text from XML from an OpenDocument document.
3 */
4 /* Copyright (C) 2012 Olly Betts
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <config.h>
23 #include "opendocparse.h"
25 using namespace std;
27 bool
28 OpenDocParser::opening_tag(const string &tag)
30 if (tag == "office:body") {
31 indexing = true;
32 } else if (tag == "style:style") {
33 (void)get_parameter("style:master-page-name", master_page_name);
34 } else if (tag == "style:master-page") {
35 string n;
36 if (get_parameter("style:name", n) && n == master_page_name)
37 indexing = true;
39 return true;
42 bool
43 OpenDocParser::closing_tag(const string &tag)
45 if (!indexing)
46 return true;
48 if (tag == "text:p") {
49 pending_space = true;
50 } else if (tag == "office:body" || tag == "style:style") {
51 indexing = false;
53 return true;
56 void
57 OpenDocParser::process_text(const string &text)
59 if (indexing && !text.empty()) {
60 if (pending_space) {
61 pending_space = false;
62 dump += ' ';
64 dump += text;