diff options
Diffstat (limited to 'src/backend/filters')
-rw-r--r-- | src/backend/filters/bt_gbfhtml.cpp | 12 | ||||
-rw-r--r-- | src/backend/filters/bt_gbfhtml.h | 8 | ||||
-rw-r--r-- | src/backend/filters/bt_osishtml.cpp | 37 | ||||
-rw-r--r-- | src/backend/filters/bt_osishtml.h | 4 | ||||
-rw-r--r-- | src/backend/filters/bt_plainhtml.cpp | 11 | ||||
-rw-r--r-- | src/backend/filters/bt_plainhtml.h | 5 | ||||
-rw-r--r-- | src/backend/filters/bt_teihtml.cpp | 143 | ||||
-rw-r--r-- | src/backend/filters/bt_teihtml.h | 34 | ||||
-rw-r--r-- | src/backend/filters/bt_thmlhtml.cpp | 46 | ||||
-rw-r--r-- | src/backend/filters/bt_thmlhtml.h | 3 | ||||
-rw-r--r-- | src/backend/filters/bt_thmlplain.cpp | 3 | ||||
-rw-r--r-- | src/backend/filters/bt_thmlplain.h | 2 | ||||
-rw-r--r-- | src/backend/filters/osismorphsegmentation.cpp | 8 | ||||
-rw-r--r-- | src/backend/filters/osismorphsegmentation.h | 2 |
14 files changed, 246 insertions, 72 deletions
diff --git a/src/backend/filters/bt_gbfhtml.cpp b/src/backend/filters/bt_gbfhtml.cpp index 6580bcd..8d6a36a 100644 --- a/src/backend/filters/bt_gbfhtml.cpp +++ b/src/backend/filters/bt_gbfhtml.cpp @@ -7,21 +7,17 @@ * **********/ +#include "backend/filters/bt_gbfhtml.h" - -//BibleTime includes -#include "bt_gbfhtml.h" - +#include <QRegExp> +#include <QString> #include "backend/drivers/cswordmoduleinfo.h" #include "backend/managers/cswordbackend.h" #include "util/cpointers.h" -//Sword includes +// Sword includes: #include <utilxml.h> -//Qt includes -#include <QRegExp> -#include <QString> Filters::BT_GBFHTML::BT_GBFHTML() : sword::GBFHTML() { diff --git a/src/backend/filters/bt_gbfhtml.h b/src/backend/filters/bt_gbfhtml.h index ad23653..45e7e59 100644 --- a/src/backend/filters/bt_gbfhtml.h +++ b/src/backend/filters/bt_gbfhtml.h @@ -7,17 +7,13 @@ * **********/ - - -/* $Header: /cvsroot/bibletime/bibletime/bibletime/backend/filters/bt_gbfhtml.h,v 1.24 2006/02/25 11:38:15 joachim Exp $ */ -/* $Revision: 1.24 $ */ - #ifndef BT_GBFHTML_H #define BT_GBFHTML_H -//Sword includes +// Sword includes: #include <gbfhtml.h> + namespace Filters { /** GBF to HTML filter, diff --git a/src/backend/filters/bt_osishtml.cpp b/src/backend/filters/bt_osishtml.cpp index 9026a94..7525aca 100644 --- a/src/backend/filters/bt_osishtml.cpp +++ b/src/backend/filters/bt_osishtml.cpp @@ -7,25 +7,20 @@ * **********/ -//BibleTime includes -#include "bt_osishtml.h" -#include "backend/managers/clanguagemgr.h" -#include "backend/managers/creferencemanager.h" -#include "backend/drivers/cswordmoduleinfo.h" +#include "backend/filters/bt_osishtml.h" +#include <QString> #include "backend/config/cbtconfig.h" +#include "backend/drivers/cswordmoduleinfo.h" +#include "backend/managers/clanguagemgr.h" +#include "backend/managers/referencemanager.h" #include "util/cpointers.h" -//Sword -#include <swmodule.h> +// Sword includes: #include <swbuf.h> +#include <swmodule.h> #include <utilxml.h> -//Qt -#include <QString> - -//KDE - Filters::BT_OSISHTML::BT_OSISHTML() : sword::OSISHTMLHREF() { setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes @@ -39,7 +34,7 @@ Filters::BT_OSISHTML::BT_OSISHTML() : sword::OSISHTMLHREF() { // addTokenSubstitute("divineName", "<span class=\"name\"><span class=\"divine\">"); // addTokenSubstitute("/divineName", "</span></span>"); - //TODO Move that down to the real tag handling, segs without the type morph would generate incorrect markup, as the end span is always inserted + /// \todo Move that down to the real tag handling, segs without the type morph would generate incorrect markup, as the end span is always inserted // addTokenSubstitute("seg type=\"morph\"", "<span class=\"morphSegmentation\">"); // addTokenSubstitute("/seg", "</span>"); @@ -112,11 +107,11 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo if ((attrib = tag.getAttribute("lemma"))) { char splitChar = '|'; const int countSplit1 = tag.getAttributePartCount("lemma", '|'); - const int countSplit2 = tag.getAttributePartCount("lemma", ' '); //TODO: not allowed, remove soon + const int countSplit2 = tag.getAttributePartCount("lemma", ' '); /// \todo not allowed, remove soon int count = 0; if (countSplit1 > countSplit2) { //| split char - splitChar = '|'; //TODO: not allowed, remove soon + splitChar = '|'; /// \todo not allowed, remove soon count = countSplit1; } else { @@ -153,7 +148,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo if ((attrib = tag.getAttribute("morph"))) { char splitChar = '|'; const int countSplit1 = tag.getAttributePartCount("morph", '|'); - const int countSplit2 = tag.getAttributePartCount("morph", ' '); //TODO: not allowed, remove soon + const int countSplit2 = tag.getAttributePartCount("morph", ' '); /// \todo not allowed, remove soon int count = 0; if (countSplit1 > countSplit2) { //| split char @@ -574,7 +569,7 @@ void Filters::BT_OSISHTML::renderReference(const char *osisRef, sword::SWBuf &bu } if (mod) { - CReferenceManager::ParseOptions options; + ReferenceManager::ParseOptions options; options.refBase = QString::fromUtf8(myUserData->key->getText()); options.refDestinationModule = QString(mod->name()); options.sourceLanguage = QString(myModule->Lang()); @@ -582,14 +577,14 @@ void Filters::BT_OSISHTML::renderReference(const char *osisRef, sword::SWBuf &bu buf.append("<a href=\""); buf.append( //create the hyperlink with key and mod - CReferenceManager::encodeHyperlink( + ReferenceManager::encodeHyperlink( mod->name(), - CReferenceManager::parseVerseReference(hrefRef, options), - CReferenceManager::typeFromModule(mod->type()) + ReferenceManager::parseVerseReference(hrefRef, options), + ReferenceManager::typeFromModule(mod->type()) ).toUtf8().constData() ); buf.append("\" crossrefs=\""); - buf.append((const char*)CReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any + buf.append((const char*)ReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any buf.append("\">"); } // should we add something if there were no referenced module available? diff --git a/src/backend/filters/bt_osishtml.h b/src/backend/filters/bt_osishtml.h index 04b68ec..83bf0a9 100644 --- a/src/backend/filters/bt_osishtml.h +++ b/src/backend/filters/bt_osishtml.h @@ -10,10 +10,10 @@ #ifndef BT_OSISHTML_H #define BT_OSISHTML_H -//Sword includes +// Sword includes: +#include <osishtmlhref.h> #include <swbuf.h> #include <swmodule.h> -#include <osishtmlhref.h> namespace Filters { diff --git a/src/backend/filters/bt_plainhtml.cpp b/src/backend/filters/bt_plainhtml.cpp index d26d8ed..c70db79 100644 --- a/src/backend/filters/bt_plainhtml.cpp +++ b/src/backend/filters/bt_plainhtml.cpp @@ -7,7 +7,8 @@ * **********/ -#include "bt_plainhtml.h" +#include "backend/filters/bt_plainhtml.h" + Filters::BT_PLAINHTML::BT_PLAINHTML() : sword::SWFilter() { } @@ -32,7 +33,7 @@ char Filters::BT_PLAINHTML::processText(sword::SWBuf& text, const sword::SWKey* continue; } else if ((*from == '\n')) { // only one new line - text += "<BR>"; + text += "<br/>"; continue; } else if (*from == '<') { @@ -48,15 +49,15 @@ char Filters::BT_PLAINHTML::processText(sword::SWBuf& text, const sword::SWKey* continue; } else if (*from == '{') { //footnote start - text += "<FONT COLOR=\"#800000\"><SMALL> ("; /// \bug Possible color conflict + text += "<font color=\"#800000\"><small> ("; /// \bug Possible color conflict continue; } else if (*from == '}') { //footnote end - text += ") </SMALL></FONT>"; + text += ") </small></font>"; continue; } else if ((*from == ' ') && (count > 5000)) { - text += "<WBR>"; + text += "<wbr/>"; count = 0; continue; } diff --git a/src/backend/filters/bt_plainhtml.h b/src/backend/filters/bt_plainhtml.h index 0430e51..c228660 100644 --- a/src/backend/filters/bt_plainhtml.h +++ b/src/backend/filters/bt_plainhtml.h @@ -10,9 +10,10 @@ #ifndef BT_PLAINHTML_H #define BT_PLAINHTML_H -//Sword includes -#include <swfilter.h> +// Sword includes: #include <swbuf.h> +#include <swfilter.h> + class SWKey; class SWModule; diff --git a/src/backend/filters/bt_teihtml.cpp b/src/backend/filters/bt_teihtml.cpp new file mode 100644 index 0000000..340e8af --- /dev/null +++ b/src/backend/filters/bt_teihtml.cpp @@ -0,0 +1,143 @@ +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2008 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ + +#include "backend/filters/bt_teihtml.h" + +#include <QString> +#include "backend/config/cbtconfig.h" +#include "backend/drivers/cswordmoduleinfo.h" +#include "backend/managers/clanguagemgr.h" +#include "backend/managers/referencemanager.h" +#include "util/cpointers.h" + +// Sword includes: +#include <swbuf.h> +#include <swmodule.h> +#include <utilxml.h> + + + +Filters::BT_TEIHTML::BT_TEIHTML() : sword::TEIHTMLHREF() { + setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes +} + +bool Filters::BT_TEIHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) { + // manually process if it wasn't a simple substitution + + if (!substituteToken(buf, token)) { + + sword::XMLTag tag(token); + + if (0) { + + } + else if (!strcmp(tag.getName(), "ref")) { + + if (!tag.isEndTag() && !tag.isEmpty()) { + + renderReference(tag.getAttribute("osisRef"), buf, userData); + + } + else if (tag.isEndTag()) { + buf.append("</a>"); + } + else { // empty reference marker + // -- what should we do? nothing for now. + } + } + // <hi> highlighted text + else if (!strcmp(tag.getName(), "hi")) { + const sword::SWBuf type = tag.getAttribute("rend"); + + if ((!tag.isEndTag()) && (!tag.isEmpty())) { + if (type == "bold") { + buf.append("<span class=\"bold\">"); + } + else if (type == "illuminated") { + buf.append("<span class=\"illuminated\">"); + } + else if (type == "italic") { + buf.append("<span class=\"italic\">"); + } + else if (type == "line-through") { + buf.append("<span class=\"line-through\">"); + } + else if (type == "normal") { + buf.append("<span class=\"normal\">"); + } + else if (type == "small-caps") { + buf.append("<span class=\"small-caps\">"); + } + else if (type == "underline") { + buf.append("<span class=\"underline\">"); + } + else { + buf.append("<span>"); //don't break markup, </span> is inserted later + } + } + else if (tag.isEndTag()) { //all hi replacements are html spans + buf.append("</span>"); + } + } + else { //all tokens handled by OSISHTMLHref will run through the filter now + return sword::TEIHTMLHREF::handleToken(buf, token, userData); + } + } + + return false; +} + +void Filters::BT_TEIHTML::renderReference(const char *osisRef, sword::SWBuf &buf, sword::BasicFilterUserData *myUserData) { + QString ref( osisRef ); + QString hrefRef( ref ); + + if (!ref.isEmpty()) { + //find out the mod, using the current module makes sense if it's a bible or commentary because the refs link into a bible by default. + //If the osisRef is something like "ModuleID:key comes here" then the + // modulename is given, so we'll use that one + + CSwordModuleInfo* mod = CBTConfig::get( CBTConfig::standardBible ); + + // Q_ASSERT(mod); There's no necessarily a module or standard Bible + + //if the osisRef like "GerLut:key" contains a module, use that + int pos = ref.indexOf(":"); + + if ((pos >= 0) && ref.at(pos - 1).isLetter() && ref.at(pos + 1).isLetter()) { + QString newModuleName = ref.left(pos); + hrefRef = ref.mid(pos + 1); + + if (CPointers::backend()->findModuleByName(newModuleName)) { + mod = CPointers::backend()->findModuleByName(newModuleName); + } + } + + if (mod) { + ReferenceManager::ParseOptions options; + options.refBase = QString::fromUtf8(myUserData->key->getText()); + options.refDestinationModule = QString(mod->name()); + options.sourceLanguage = QString(mod->module()->Lang()); + options.destinationLanguage = QString("en"); + + buf.append("<a href=\""); + buf.append( //create the hyperlink with key and mod + ReferenceManager::encodeHyperlink( + mod->name(), + ReferenceManager::parseVerseReference(hrefRef, options), + ReferenceManager::typeFromModule(mod->type()) + ).toUtf8().constData() + ); + buf.append("\" crossrefs=\""); + buf.append((const char*)ReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any + buf.append("\">"); + } + // should we add something if there were no referenced module available? + } +} + diff --git a/src/backend/filters/bt_teihtml.h b/src/backend/filters/bt_teihtml.h new file mode 100644 index 0000000..2160349 --- /dev/null +++ b/src/backend/filters/bt_teihtml.h @@ -0,0 +1,34 @@ +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2008 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ + +#ifndef BT_TEIHTML_H +#define BT_TEIHTML_H + +// Sword includes: +#include <teihtmlhref.h> +#include <swbuf.h> + +namespace Filters { + +/** BibleTime's TEI to HTMl filter. +* This filter works on TEI tags and outputs HTML in the structure supported by BibleTime. +*/ + +class BT_TEIHTML : public sword::TEIHTMLHREF { + + public: + BT_TEIHTML(); + virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData); + private: + void renderReference(const char *osisRef, sword::SWBuf &buf, sword::BasicFilterUserData *myUserData); +}; + +} //end of Filters namespace + +#endif diff --git a/src/backend/filters/bt_thmlhtml.cpp b/src/backend/filters/bt_thmlhtml.cpp index 4ee333d..478339c 100644 --- a/src/backend/filters/bt_thmlhtml.cpp +++ b/src/backend/filters/bt_thmlhtml.cpp @@ -7,25 +7,24 @@ * **********/ -//BibleTime includes -#include "bt_thmlhtml.h" -#include "backend/managers/clanguagemgr.h" -#include "backend/drivers/cswordmoduleinfo.h" -#include "backend/managers/creferencemanager.h" +#include "backend/filters/bt_thmlhtml.h" +#include <QString> +#include <QRegExp> +#include <QUrl> +#include <QTextCodec> #include "backend/config/cbtconfig.h" +#include "backend/drivers/cswordmoduleinfo.h" +#include "backend/managers/clanguagemgr.h" +#include "backend/managers/referencemanager.h" #include "util/cpointers.h" -#include <boost/scoped_ptr.hpp> -//Sword includes +// Sword includes: #include <swmodule.h> +#include <utilstr.h> #include <utilxml.h> #include <versekey.h> -#include <utilstr.h> -//Qt includes -#include <QString> -#include <QRegExp> Filters::BT_ThMLHTML::BT_ThMLHTML() { setEscapeStringCaseSensitive(true); @@ -258,7 +257,7 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible); //Q_ASSERT(mod); tested later if (mod) { - CReferenceManager::ParseOptions options; + ReferenceManager::ParseOptions options; options.refBase = QString::fromUtf8(myUserData->key->getText()); //current module key options.refDestinationModule = QString(mod->name()); options.sourceLanguage = QString(myModule->Lang()); @@ -274,7 +273,7 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo if (! oldRef.isEmpty() ) { options.refBase = oldRef; //use the last ref as a base, e.g. Rom 1,2-3, when the next ref is only 3:3-10 } - const QString completeRef( CReferenceManager::parseVerseReference((*it), options) ); + const QString completeRef( ReferenceManager::parseVerseReference((*it), options) ); oldRef = completeRef; //use the parsed result as the base for the next ref. @@ -284,10 +283,10 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo buf.append("<a href=\""); buf.append( - CReferenceManager::encodeHyperlink( + ReferenceManager::encodeHyperlink( mod->name(), completeRef, - CReferenceManager::typeFromModule(mod->type()) + ReferenceManager::typeFromModule(mod->type()) ).toUtf8().constData() ); @@ -317,23 +316,23 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible); //Q_ASSERT(mod); tested later - CReferenceManager::ParseOptions options; + ReferenceManager::ParseOptions options; options.refBase = QString::fromUtf8(myUserData->key->getText()); options.sourceLanguage = myModule->Lang(); options.destinationLanguage = QString("en"); - const QString completeRef = CReferenceManager::parseVerseReference(QString::fromUtf8(ref), options); + const QString completeRef = ReferenceManager::parseVerseReference(QString::fromUtf8(ref), options); if (mod) { options.refDestinationModule = QString(mod->name()); buf.append("<span class=\"crossreference\">"); buf.append("<a href=\""); buf.append( - CReferenceManager::encodeHyperlink( + ReferenceManager::encodeHyperlink( mod->name(), completeRef, - CReferenceManager::typeFromModule(mod->type()) + ReferenceManager::typeFromModule(mod->type()) ).toUtf8().constData() ); buf.append("\" crossrefs=\""); @@ -370,10 +369,11 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo value++; //strip the first / } - buf.append("<img src=\"file:"); - buf.append(myUserData->module->getConfigEntry("AbsoluteDataPath")); - buf.append('/'); - buf.append(value); + buf.append("<img src=\""); + QString absPath(QTextCodec::codecForLocale()->toUnicode(myUserData->module->getConfigEntry("AbsoluteDataPath"))); + QString relPath(QString::fromUtf8(value)); + QString url(QUrl::fromLocalFile(absPath.append('/').append(relPath)).toString()); + buf.append(url.toUtf8().data()); buf.append("\" />"); } else { // let unknown token pass thru diff --git a/src/backend/filters/bt_thmlhtml.h b/src/backend/filters/bt_thmlhtml.h index 25b168c..6a220b6 100644 --- a/src/backend/filters/bt_thmlhtml.h +++ b/src/backend/filters/bt_thmlhtml.h @@ -10,10 +10,11 @@ #ifndef BT_THMLHTML_H #define BT_THMLHTML_H -//Sword +// Sword includes: #include <swbuf.h> #include <thmlhtml.h> + namespace Filters { /** ThML to HTML filter. diff --git a/src/backend/filters/bt_thmlplain.cpp b/src/backend/filters/bt_thmlplain.cpp index 2cd3cf9..ecd7bbd 100644 --- a/src/backend/filters/bt_thmlplain.cpp +++ b/src/backend/filters/bt_thmlplain.cpp @@ -13,7 +13,8 @@ * ASCII rendered symbols. */ -#include "bt_thmlplain.h" +#include "backend/filters/bt_thmlplain.h" + Filters::BT_ThMLPlain::BT_ThMLPlain() { } diff --git a/src/backend/filters/bt_thmlplain.h b/src/backend/filters/bt_thmlplain.h index 7ef82d6..92c2c33 100644 --- a/src/backend/filters/bt_thmlplain.h +++ b/src/backend/filters/bt_thmlplain.h @@ -10,9 +10,11 @@ #ifndef BT_THMLPLAIN_H #define BT_THMLPLAIN_H +// Sword includes: #include <swbuf.h> #include <swfilter.h> + namespace Filters { /** This filter converts ThML text to plain text diff --git a/src/backend/filters/osismorphsegmentation.cpp b/src/backend/filters/osismorphsegmentation.cpp index 26e7470..512fe2e 100644 --- a/src/backend/filters/osismorphsegmentation.cpp +++ b/src/backend/filters/osismorphsegmentation.cpp @@ -6,11 +6,13 @@ * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ -#include "osismorphsegmentation.h" -//Sword +#include "backend/filters/osismorphsegmentation.h" + +// Sword includes: #include <utilxml.h> + const char Filters::OSISMorphSegmentation::oName[] = "Morph segmentation"; const char Filters::OSISMorphSegmentation::oTip[] = "Toggles morph segmentation On and Off if they exist"; @@ -24,7 +26,7 @@ Filters::OSISMorphSegmentation::OSISMorphSegmentation() : sword::SWOptionFilter( Filters::OSISMorphSegmentation::~OSISMorphSegmentation() {} -char Filters::OSISMorphSegmentation::processText(sword::SWBuf &text, const sword::SWKey */*key*/, const sword::SWModule */*module*/) { +char Filters::OSISMorphSegmentation::processText(sword::SWBuf &text, const sword::SWKey * /*key*/, const sword::SWModule * /*module*/) { sword::SWBuf token; bool intoken = false; bool hide = false; diff --git a/src/backend/filters/osismorphsegmentation.h b/src/backend/filters/osismorphsegmentation.h index bc405f5..c5bbb18 100644 --- a/src/backend/filters/osismorphsegmentation.h +++ b/src/backend/filters/osismorphsegmentation.h @@ -10,9 +10,11 @@ #ifndef OSISMORPHSEGMENTATION_H #define OSISMORPHSEGMENTATION_H +// Sword includes: #include <swbuf.h> #include <swoptfilter.h> + namespace Filters { /** This Filter shows/hides headings in a OSIS text. |