"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "opendocparse.cc" between
xapian-omega-1.4.19.tar.xz and xapian-omega-1.4.20.tar.xz

About: Xapian Omega is an application built on Xapian, consisting of indexers and a CGI search frontend.

opendocparse.cc  (xapian-omega-1.4.19.tar.xz):opendocparse.cc  (xapian-omega-1.4.20.tar.xz)
/** @file /** @file
* @brief Extract text from OpenDocument XML. * @brief Extract text from OpenDocument XML.
*/ */
/* Copyright (C) 2012 Olly Betts /* Copyright (C) 2012-2022 Olly Betts
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <config.h> #include <config.h>
#include "opendocparse.h" #include "opendocparse.h"
#include <cstring>
#include "stringutils.h"
using namespace std; using namespace std;
bool bool
OpenDocParser::opening_tag(const string &tag) OpenDocParser::opening_tag(const string &tag)
{ {
if (tag == "office:body") { if (startswith(tag, "text:")) {
const char* tail = tag.c_str() + 5;
if (strcmp(tail, "p") == 0 ||
strcmp(tail, "h") == 0 ||
strcmp(tail, "line-break") == 0 ||
strcmp(tail, "tab") == 0) {
pending_space = true;
}
} else if (tag == "office:body") {
indexing = true; indexing = true;
} else if (tag == "style:style") { } else if (tag == "style:style") {
(void)get_parameter("style:master-page-name", master_page_name); (void)get_parameter("style:master-page-name", master_page_name);
} else if (tag == "style:master-page") { } else if (tag == "style:master-page") {
string n; string n;
if (get_parameter("style:name", n) && n == master_page_name) if (get_parameter("style:name", n) && n == master_page_name)
indexing = true; indexing = true;
} }
return true; return true;
} }
bool bool
OpenDocParser::closing_tag(const string &tag) OpenDocParser::closing_tag(const string &tag)
{ {
if (!indexing) if (!indexing)
return true; return true;
if (tag == "text:p") { if (tag == "text:p" || tag == "text:h") {
pending_space = true; pending_space = true;
} else if (tag == "office:body" || tag == "style:style") { } else if (tag == "office:body" || tag == "style:style") {
indexing = false; indexing = false;
} }
return true; return true;
} }
void void
OpenDocParser::process_text(const string &text) OpenDocParser::process_text(const string &text)
{ {
if (indexing && !text.empty()) { if (indexing && !text.empty()) {
if (pending_space) { if (pending_space) {
pending_space = false; pending_space = false;
dump += ' '; if (!text.empty()) dump += ' ';
} }
dump += text; dump += text;
} }
} }
 End of changes. 5 change blocks. 
4 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)