File: opendocparse.cc

package info (click to toggle)
xapian-omega 1.2.19-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,040 kB
  • ctags: 1,126
  • sloc: sh: 11,071; cpp: 10,383; makefile: 286; perl: 160
file content (66 lines) | stat: -rw-r--r-- 1,722 bytes parent folder | download | duplicates (5)
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
/** @file opendocparse.cc
 * @brief Extract text from XML from an OpenDocument document.
 */
/* Copyright (C) 2012 Olly Betts
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

#include <config.h>

#include "opendocparse.h"

using namespace std;

bool
OpenDocParser::opening_tag(const string &tag)
{
    if (tag == "office:body") {
	indexing = true;
    } else if (tag == "style:style") {
	(void)get_parameter("style:master-page-name", master_page_name);
    } else if (tag == "style:master-page") {
	string n;
	if (get_parameter("style:name", n) && n == master_page_name)
	    indexing = true;
    }
    return true;
}

bool
OpenDocParser::closing_tag(const string &tag)
{
    if (!indexing)
	return true;

    if (tag == "text:p") {
	pending_space = true;
    } else if (tag == "office:body" || tag == "style:style") {
	indexing = false;
    }
    return true;
}

void
OpenDocParser::process_text(const string &text)
{
    if (indexing && !text.empty()) {
	if (pending_space) {
	    pending_space = false;
	    dump += ' ';
	}
	dump += text;
    }
}